Licence agreement

NO LITIGATION
CODE-GENIE IS PROVIDED ON AN "AS IS" BASIS: THE AUTHOR WILL NOT BE LIABLE FOR DATA LOSS, DAMAGES, LOSS OF PROFITS OR ANY OTHER KIND OF LOSS WHILE USING OR MISUSING THIS SOFTWARE.

It doesn't mean that we don't trust in our product, it only means that we cannot afford to litigate. This way our customers (and maybe you) do not have to pay extra for supporting lawyers.

Warranty
If you found a bug in the program you can report it to us. We will fix it ASAP, and you can download the fixed version from our site. You don't have to be a registered customer for this.

Using the program
Code-Genie is a pay-ware program. You can download the trial-version from our site. The trial-version has limitations: Undo/Redo commands are disabled and the program is optimized for exe-size, not speed.

Distribution
You cannot distribute the program in any form without asking us first. But you can place a link to the program (http://www.code-genie.com/cgenie.zip) on your site, and we encourage you to do this if you like it.

By using the program you accept the conditions of the licence above.


Overview of Code-Genie

Code-Genie is an editor designed for programmers and web-developers, but non-programmers can also use it as a replacement of Notepad. It contains a text and a binary editor.

See also:
Text Editor
Binary Editor


Command-line

Usage:
cgenie.exe [[OPTION] [FILE]]...

Here the tags between[ and ] are optional. Options are:
-r | open FILE as read-only
-lN | go to the Nth line of the FILE. For binary files N means byte position.
-b | start with a new blank text document.

Notes:
As you can see OPTION precedes FILE. There is no space between the line-number switch and the line number. You can specify more files at the command line. If the filename contains space you should enclose it in double quotes.

Examples:

# open the file tips.txt
cgenie tips.txt

# open tips.txt at line #14, then open file_id.diz as read-only at line #3.
cgenie -l14 tips.txt -l3 -r file_id.diz

# open a file whose name contains spaces
cgenie "c:\Program Files\filename.ext"

# launch CG with and empty document
cgenie -b


Commands of the config file

Config File

A text file?
Exactly. Code-Genie doesn't use dialogs for user-configuration. Instead it uses a simple plain text file for storing your configuration information. So whenever you choose Settings from the View menu a file named cgenie.conf will be loaded.

Why?
Because you don't waste your time looking up the location of a given option in the myriad of configuration-pages. If you don't know where a given command is defined simply Search for it in the text file. The second reason is that we don't have to resize a given dialog-box each time we have to add a new configuration option. Third because this makes Code-Genie smaller in size. And finally this is a text editor after all.

How?
The cgenie.conf file is a plain text file with a very simple syntax. After you made the modification you wanted, simply save the file back to disk, and the changes will be applied automatically. If you don't know the syntax of a given command or you are not sure what a given command is for simply press F1 over the word: Code-Genie will look it up in its help file.

The following commands are defined:

StartWithLastEdited
Load in the last edited files upon startup if the program is launched without command-line arguments.

ResolveLinkFiles
Deprecated, don't use it. Redundant, since CG will always dereference link files to the file they point to except in the case when you directly ask it not to do so: In the OpenDialog select the link file and choose Open As: Binary. In this case the link file will be opened.

MinimizeToAppBar
Minimizes Code-Genie beside the clock on the AppBar when you click on the Minimize icon.

LockEditedFiles
Automatically lock the files opened in Code-Genie. This way others can see the file you just editing, but they cannot overwrite it. To remove the lock on a file, go to the File menu and click on Lock. Finally CG will try to create a lock file beside the locked file. The lock-file name will be filename.ext.lock. This lock file gives others some information on who locks a given file.

NotifyFileChanges
If enabled Code-Genie will monitor the opened files for changes. Whenever someone overwrites one of the opened files Code-Genie will ask you whether to reload the changed file or not.

ShowTipOfTheDay
Specifies whether to show tip of the day messages at startup.

AutosaveInterval
Specifies the autosave interval in minutes. If set to zero, autosave will be disabled. Autosave means that Code-Genie will periodically save the changes you made in a back-up file (autosave.dat file in the directory of Code-Genie). This way you don't loose all of your unsaved work after a program/system crash or power failure.

BgColor
Specifies the background color of the editor. If commented out the system default color will be used. The color format is #RRGGBB.

FgColor
Specifies the foreground color of the editor. If commented out the system default color will be used. The color format is #RRGGBB.

SelectedBgColor
Specifies the background color of the selected text. If commented out the system default color will be used. The color format is #RRGGBB.

SelectedFgColor
Specifies the foreground color of the selected text. If commented out the system default color will be used. The color format is #RRGGBB.

ActiveLine
Specifies the background color of the active line. This applies to the binary editor only. If commented out there will be no background-coloring. The color format is #RRGGBB.

Gutter
Specifies the color of the gutter (the small vertical stripe on the left of the window). The color format is #RRGGBB.

Whitespace
Specifies the color of whitespace characters (like space, new-line and tabulator). The color format is #RRGGBB.

The following settings apply to the Text Editor only:

SelectorAllowDocking
Specifies whether to allow docking of the two selector-bars or not. If enabled the selectors can be docked to the left or right side of Code-Genie.

TabSize
Specifies how many space characters a tabulator will occupy at most.

ReplaceTabsWithSpaces
Specifies whether to automatically replace tabulator characters with spaces as you hit tab. This option doesn't affect the tabulator characters that are already in the file, only the newly entered tabulators.

EnableVirtualSpace
If enabled you can move the cursor beyond the end of the line. If WordWrap is turned on this option is disabled.

KeepTextFilesTidy
If enabled it removes trailing spaces at line-ends, and terminates the last line with a new-line character upon saving the file back to disk. Default value is false.

ColorizeHyperlinks
Specifies whether to colorize internet hyperlinks and email-addresses. If set to true these hyperlinks will be colored as blue and will be underlined. Right click on these links to follow them.

LineNumbering
Switches on/off line numbering in the text editor depending on its state: true or false. Line numbers displayed left to the text. Only the last 3 digits of the line numbers are displayed to avoid shifting of text at lines 10, 100, 1000, etc. The exact line numbers can be determined from the Statusbar.

DefaultLineSeparator
Specifies the file format of newly created text files. It may have 3 values: dos, unix or mac. It affects the new-line format of the file after you saved it back to disk. To view/change the current format of the file choose View | Properties.

DefaultSyntax
Here you can assign default syntax files to certain file-extensions. This way whenever you open up a file in Code-Genie, the program will look up this list for the extension of the file to be opened. If there is a default syntax associated to that extension, that syntax will be applied automatically. Format:
DefaultSyntax syntax-file [file-extensions separated by comas]

syntax-file represents the title of the syntax file (i.e. without its .cgsyn extension. The argument in brackets are optional. If you omit the extensions it means that the specified syntax-file will be applied on newly created text files.

The following settings apply to the Binary Editor only:

BytesPerRow
Specifies how many bytes will be displayed in one row.

MotorolaByteOrder
Specifies the current byte-order. By default Intel byte-order is used. If set to true Motorola byte-order will be used. This option is applied when you select 2, 4 or 8 consecutive bytes and right click on them. The values for INT 4, UINT 4 and such will depend on this byte-order.

HighLightActiveLine
Specifies whether to highlight the active line in the binary editor with a different color or not. ActiveLine specifies the color of the line.

Accessing Code-Genie from Windows:

AddCGToStartMenu
Adds Code-Genie to the Start Menu of Windows if set to true.

AddCGToProgramsMenu
Adds Code-Genie to the Programs Menu of Windows if set to true.

AddCGToDesktop
Places an icon to Code-Genie on the Desktop if set to true.

AddCGToQuickLaunchBar
Adds Code-Genie to the Quick Launch Bar of Windows if set to true. Note here that IE 5.0 or above should be installed for this to work.

AddCGToEditWithMenu
Adds Code-Genie to the Edit With of Explorer if set to true.

AddCGToSendToMenu
Adds Code-Genie to the Send To Menu of Explorer if set to true.

AddCGToIExplorerEditWithMenu
Adds Code-Genie to the Edit With Menu of Internet Explorer if set to true. See also: notepad.exe

Printer settings

PrintHeader
Specifies the format of the header of each printed page. Wildcards can also be specified.

PrintFooter
Specifies the format of the footer of each printed page. Wildcards can also be specified.

PrintMarginLeft
Specifies the width of the left margin on the page. The width here is expressed in inches.

PrintMarginRight
Specifies the width of the right margin on the page. The width here is expressed in inches.

PrintMarginTop
Specifies the height of the top margin on the page. The height here is expressed in inches.

PrintMarginBottom
Specifies the height of the bottom margin on the page. The height here is expressed in inches.

PrintInColor
Specifies whether to print the text in color or in B&W. Of course it applies to color printers only.

User tools

AddUserTool
You can run programs from within Code-Genie. This is the command that lets you specify these tools. The format of the command is:
AddUserTool MenuName Command [Arguments] [Options] [InintialDir]

Arguments listed in brackets are optional. Their meaning are:

  • MenuName is the text that will appear in the Tools menu.
  • Command is the command to be executed
  • Arguments are the arguments for the command. Wildcards can also be specified.
  • Options: Two options are defined: CaptureOutput for capturing the output of console programs and displaying it on the Output Window and PromptForArguments for prompting for arguments just before runnig the tool. Both of these can be specified by OR-ing them. (e.g.: CaptureOutput|PromptForArguments ).
  • InitialDir will be the initial directory of the program. Some programs may require this to set correctly prior running.
In some cases you may want to leave an argument empty, but want to specify the next argument. In this case use the \0 escape-sequence. This is a null character, it indicates that the argument is empty.

Shortcut
Assign a to a macro or a Code Fragment. Format is:
Shortcut macro_file function_name shortcut

macro_file is the name of the macro/cfl file the function_name macro/CF is in. The macro/CF file must be in the macros/cfl subdirectories of the program respectively. The macro_file is relative to this directory. Finally shortcut is your preferred hot-key to the macro/CF. Example:

Shortcut  VBS\sExamples.vbs  vbGreetings  C - G

See also:
File structure of the config file


Selectors

Selector is basically a list box that you can see beside the edited documents. It is dockable bar so you can dock it to any side of the editor for fast access. Or even better: you can hide it while you are editing, and bring it up with the Alt+F1 or Alt+F2 key-combinations when you need it. This way it doesn't occupy any space on the screen.

You can toggle the docking-state of the selector with the SelectorAllowDocking config parameter.

The selector looks like a virtual file-system: you can move into and move up in the directories. Here is a quick list on the items you can find here:
Code Fragments
Recent files
Current directory listing
Clipboard history
VBScript macro-file
JScript macro-file


Comparing Files

The comparing feature Code-Genie provides is intentionally simple, hence easy to use.

You can compare two of the currently opened files by selecting View |Compare.... On this dialog you can select the two files to be compared. It is practical to tile the two files side by side or one above the other before starting comparing.

Pressing OK doesn’t start comparing immediately because the starting positions inside the files are not yet specified. Therefore place the cursor at the desired starting points in each file. Now comparing can start. By pressing F4 Code-Genie starts comparing the two files character by character, and stops at the very first difference found. Later on you can position the cursors at different starting positions, and compare will continue from that location by pressing F4 again.

There is no difference between comparing text and binary files. So it works for two binary files as well. Or even for a text and a binary file.

Alternatively if you need a more sophisticated compare you can launch 3rd-party tools (like diff) from within CG and get its output redirected.


Color-selector

You can reach it from the View menu or from the Toolbar Color selector.

It has 4 sliders: The top three is for selecting the Red, Green and Blue components of the color, while the bottom is called Luminosity: If you set a color with the 3 sliders above, you can change its shade from black to white.

Meanwhile it displays the hex-value of the RGB components beside the sliders. If you hit Enter, that color-value will be inserted into the document in the format of RRGGBB.

Similarly if you select 6 numbers in the document before opening this dialog, that color will be displayed. This may be useful for editing color-codes in HTML/CSS documents.


Backing Up Files

The command can be reached from the File menu. It applies for both text and binary files.

This command doesn’t create a backup file with .BAK extension as other editors do. Instead it renames the file associated to the currently edited document to filename00.ext, where 00 is a number ranging from 00 to 99. The benefits of this behaviour:

  • Preserves the file-extension, so html,php etc. files will be executed correctly even after they are backed up.
  • An earlier backup of the file will not be overwritten accidentally.
  • Up to 100 different backups can be stored. The latest backup has the highest number.

Note: To avoid accidental multiple backups the command will not create a copy of the file found on the disk, but it will rename that file instead. So filename.ext will be renamed to filename00.ext, and therefore filename.ext will disappear. So you have to save the currently edited file later.


Replacing Notepad

Code-Genie comes with a notepad.exe file. This can be used to effectively replace Notepad with Code-Genie in one step. All you have to do is backup the old notepad.exe file found in your Windows directory, and replace it with this new file.

Some versions of Windows have multiple instances of the Notepad.exe file (like in system32 and in system32/dllcache). In this case you have to replace all of them.

Later on, if you changed your mind, you can replace the new file with the original one you backed up earlier.


Projects

Code-Genie comes with an -intentionally- very simple project manager. Its only purpose is to allow you to organize your selected files into one unit and to allow opening them in one step.

Project files:
Project files are simple text files in the projects subdirectory of Code-Genie with the file extension prj. Their format is pretty simple: empty lines and lines starting with # will be treated as comments and will be ignored. Each remaining line specify a filename (full pathname!), one in each line. There are no characters with special meaning, so no escaping needed.

Creating:
You can create it with your hands, or you can let CG do it for you: open all the files you want to add to the project, choose Window | Windows..., select the files to be added to the project and click on the Create Project button. A text file will be created for you. The only thing you have to do is to save that file in the projects dir of CG with the extension prj. And you are ready.

Modifying:
Right click on the selector over its name, choose Edit. The text file will be loaded where you can add new or delete exising files. To add a new file you have to manually type in its full pathname. Or a better way: open that file in CG, choose View | Properties and copy-paste its full path name from that dialog.

Deleting:
Right-click on its name on the Selector and choose Delete. Or remove manually that file.


Checksums

The Checksum Generator can be reached from the View menu. It calculates checksums for the entire file or for the selection only. The following checksums are supported:

CheckSum-8 | 8 bit count, adds all the bytes, initial value = 0x00
CheckSum-16 | 16 bit count, adds all the bytes, initial value = 0x00
CRC-32 | 32 bit CRC, polynomial = 0x04C11DB7, initial value = 0xFFFFFFFF
MD5 | uses the official MD5 message-digest algorithm

The result values will be in hexadecimal format, so they will be prefixed with 0x except for the MD5 hash algorithm where this prefix is omitted due to practical reasons.

Note:
In Code-Genie files opened as text are stored internally in unix-format. The results of the above checksums will be based on this internal data. So be aware this 'feature' when calculating multi-line checksums. If you need checksums for files with DOS/MAC or other formats go and open it as binary and make the calculation there. This guarantees correct results.


Text Editor | Shortcuts

Shortcuts

Below is a list of shortcuts defined for the text editor. The following abbreviations are used:

  • C - x means Ctrl+X
  • C - X means Ctrl+Shift+X
  • M - x means Meta+X or Alt+X
  • S - Del means Shift+Del

Shortcut | Description
M + Enter | Properties (language, size, date etc.)
C - Space | Autocomplete
C - m | Find the pair of the current bracket or HTML tag.
Tab | Increase indent ( works for multi-line selection )
S - Tab | Decrease indent ( works for multi-line selection )
C - Tab | Go to the next window
F3 | Find next
C - F3 | Find the next occurence of the word the cursor is currently over
S - F3 | Find previous
C - S - F3 | Find previous occurrence of the word the cursor is currently over
C - i | Incremental Search
C - f | Find
C - h | Replace
C - F | Find in Files
C - H | Replace in Files
S - <a cursor key> S - <PgUp/PgDn> | Selects text
C - Right C - Left | Moves to next / previous word
C - C | Append text to Clipboard
C - V | Paste text found on the Clipboard as if it was a CF (Code Fragment). Ex.: if <b>^!</b> is on the Clipboard, then you can make the selected text bold with one command
C - x S - Del | Cut
C - c C - Ins | Copy
C - v S - Ins | Paste
F5 | Switches between the bin and hex mode in the binary editor.
M - F1 | Set the focus to Selector1
M - F2 | Set the focus to Selector2
C - m | Find the pair of the current bracket or HTML tag.
C - x | (where X is a number from 0 to 10) Run macro number X
C - a | Selects the entire file
C - b | Back-up file
C - g | Goto
C - n | File new
C - o | File open
C - p | Print
C - s | File Save
C - S | File Save As
C - u | Decrease indent
C - v | Paste
C - w | Window-list
C - z M - Back | Undo
Caps Lock | Toggle case on the selected text
C - F2 | Insert bookmark
F2 | Jump to the next bookmark
F4 | Compare next
F5 | Switch between bin/hex mode in the binary editor


The Text Editor

The text editor works just like a general purpose text editor, but has some interesting features to mention:

  • Syntax-highlighting
  • Built in macro support
  • Color printing
  • Code fragment library (CFL)
  • Auto-save
  • Auto-complete
  • Block and chart operations
  • File-comparisons
  • Text justification
  • Context-sensitive help support
  • Automatic back-up file creation


Text Editor | File-format and encoding

File-format

Text files come in different file-formats based on the line-terminating charachter(s) used: carriege-return (\r), line-feed (\n) and their combination.

  • Windows uses \r\n
  • Unix/Linux uses \n
  • while Mac uses \r
to indicate the end of a line.

Internally Code-Genie converts each file to Unix format upon loading. This simplifies handling, searching, and fixes erroneous text files generated by some programs. So internally you always work with Unix files. Upon saving the file will gets converted into and stored in its original format. For newly created files the DefaultLineSeparator specifies the desired output format.

Encoding

There are different encoding in use for text files:

  • Text (or ANSI)
  • UTF-8
  • Unicode
Internally Code-Genie stores each character on one byte (Single-Byte Character Sets or SBCS for short). Multi-Byte Character Sets (MBCS) used by some far-Eastern languages are not supported (even though it is stored in Unicode encoding).

You can view and set the file-format and encoding of a given file on the View | Properties dialog.


Text Editor | Printing

Printing

You can print the source code by choosing Print from the File menu. You can set the name and the size of the printing font in the View |Fonts | Printer menu. By default it uses Courier New with 10 point size.

If you want to print your code as one part of a Word document, you can export the text in RTF format, so the coloring and formatting informations will be preserved. You can either choose Export from the File menu or Copy As RTF from the Edit menu. In the previous case you can create a separate Rich Text file, while in the second case you can copy the selected text onto the clipboard in Rich Text format.

As you can see in the Edit menu you can copy the source in HTML format, too. This format is Microsoft©-specific: the actual Clipboard-format is text, but with html tags inserted. This way you can easily publish your source code on the Internet.


Text Editor | Regular Expressions

Regular Expressions

The Regular Expression library is a relevant feature of Code-Genie (You can find them in the Find/Replace dialogs). Code-Genie uses a perl-compatible RegExp library called PCRE. This library is used in the preg_* branch of PHP functions. Below is a quick reference to the library.

RegExp notation
^
\A 		Matches the beginning of a string/line. (see the multiline modifier below)
$
\z 		Matches the end of a string/line. (see the multiline modifier below)
* Repeats the previous expression 0 or more times.
+ Repeats the previous expression 1 or more times.
? Repeats the previous expression 0 or 1 time.
{n} | Repeats the previous expression exactly n-times.
{n,m} | Repeats the previous expression at least n, but at most m times.
{n, } | Repeats the previous expression at least n-times.
. Matches every character except new line [^\n]
(see the dot-all modifier below)
(x) | Subpattern (also known as grouping). Used for grouping expressions. See back-references below.
(?: shy-grouping: this subpattern will not be available as a back-reference.
\0
\1
\2
...
\9 		Back-reference (the portion of the string matched by the subpattern). \0 means the entire string matched, \1 means the portion of string matched by the first subpattern, \2 means the second and so on. They can be handy in replace operations. Up to 10 back-references are recognized by CG. The "Perl-ish" $1 .. $9 notation is not supported.
x|y | Matches x or y. So e.g. apple|orange will match either apple or orange
[abc] | Matches all characters enumerated between the square brackets.E.g. [0-9a-zA-Z] matches all alphanumeric characters.
[^abc] | Matches none of the enumerated characters.
\d | A decimal character. Equivalent to [0-9]
\D | Every character that is not decimal (Equivalent to [^0-9] )
\n | New line character
\s | Space character. Equivalent to [ \f\n\r\t\v].
\S | Everything that is not treated as a space.
\t | Tabulator character
\w | Characters found in variables [0-9a-zA-Z_].
\W | Opposite of \w
\b | Marks a word boundary. If inside a class (and only then) it is treated as a backspace.
\ddd | character specified with its octal code ddd.
\xhh | character specified with its hexadecimal code hh.
(?=
(?! 		Zero-width positive / negative lookahead assertions
(?<=
(?<! 		Zero-width positive / negative lookbehind assertions
*?
+?
{m,n}? 		general non-greedy closures. Similar to the ungreedy modifier. The method used here is called backtracking
(?< Atomic-grouping. Prevents further backtracking behind the matched part of this subpattern if matched already.

This listing is not intended to be a whole reference of RegExp. You can find tutorials, further examples and more detailed references on the Internet.

Modifiers:

Regular expressions may have one or more modifiers. To apply modifiers you have to enclose your regexp in forward-slashes, then append the modifiers to it. E.g.: /your_regexp/modifiers. The following modifiers are defined:

  • m is the multiline modifier. Without this ^ and $ matches only the beginning of the file and end of the file respectively. By applying this modifier they will match the beginning and end of each line too.
  • i is the case-insensitive switch. Use it for case-insensitive matches.
  • s is the dot-all switch. By default . (dot) matches everything except newlines. By applying this switch . will match newlines too.
  • U is the ungreedy switch. By default the regexp pattern matching algorithm is greedy. i.e. it will match the longest possible match first. This option will override this behaviour. The general non-greedy closures (*?, +? and {m,n}? ) are also supported.

The above syntax is well-known for PHP coders, but the original Perl-format also works: (?modifiers)regexp

And some basic examples:

a whole word ending in a semicolon:

\w+;

a whole word ending in a semicolon, but the semicolon itself is not part of the match:

\w+(?=;)

to select the text foo or for you would write

fo(o|r) instead of
foo|r

lines starting with #:

/^#.*$/m

trim left:

replace /^\s+/m with an empty string

select an html-tag:

/<.*>/mU or
/<.*?>/m

Note here the important ungreedy switches in both solutions! The multiline modifier is for html tags broken into multiple lines.

Same as above, but now using the perl-ish notation:

(?mU)<.*> or
(?m)<.*?>

replace bold-text with italic:

replace /<b>(.*)<\/b>/miUs with <i>\1</i>

make the text Code-Genie bold in the document:

replace Code-Genie with <b>\0<\/b>

Remove all html tags other than table, tr and td

replace <(?>\/?)(?!table|tr|td).*?> with an empty string

Here you can see how atomic-grouping and negative-lookahead assertion work together. Try to figure out why atomic-grouping is a must-have in this pattern!

There are characters with special meaning in regexp (like the / in the example above). To use them you must escape them with C-style backslashes. So to select text enclosed in parentheseses you would write:

\(.*\) instead of (.*)

Similarly if you use regexp in a program-code you may have to escape the special characters of that language as well. This renders your regexp rather cryptic.

Remove the beginning of the string till the first occurance of the word 'apple', but not the word itself:

replace /\A.*?(?=apple)/s with nothing

Finally we suggest you to get used to Regular Expressions since this is the most powerful tool of all text processings. The learning curve may be a little long but it worths the efforts!


Text Editor | AutoComplete

AutoComplete

Code-Genie will help you finalize a word or statement if you press C - Space in the text editor. Code-Genie will suggest words and statements in the following manners:
By searching backward in the current text from the current cursor location.
By looking up keywords of the current syntax.
By looking for a similar file or directory name in the directory of the current document.


Text Editor | Code-fragments

Code-fragments

One key of fast editing is code-reuse. Code-Genie has a built in support for it. Code-Fragment (CF) is nothing more than a fragment of text. Any kind of text. When you execute the CF, that text will be inserted into the document at the current cursor position. You can reach these CFs from the Selectors. Double-click on a CF to execute it.

CFs are organized into libraries. One library-file may contain many CFs. These files are plain text files in the cfl subdirectory of the program with cfl extension.

Inside the library to separate one CF from the other you should insert a separator-line in-between the two CFs. A separator-line starts with the character #. Example:

#Script
<script language="JavaScript">
<!--

^!

//-->
</script>
#Image
<img src="^!" alt="">
#

Above you can see two CFs. It is practical to identify a longer CF by a short, descriptive name. Such names can be defined in the separator-line after the # character. In our example the display name of the first CF is Script, while the name of the second is Image.

^! represents the cursor location: After inserting this CF into the text, the cursor will blink at that location. If you select some text before, then that text will be inserted at this location. So e.g. if you select 'text', and choose <b>^!</b> from the list ,then <b>text</b> will be inserted, and the cursor will blink just before the </b> element.

Q: What if (one of the lines of) my CF starts with #.
A: The answer is simple: prefix it with a ^ such as ^# .
so e.g. if your CF looks like this

#include "^!"
,then you should write
^#include "^!"

You can have any number of CFL files and any number of CF in each library. But it is practical to organize them well so that the most frequently used ones are always at hand, or else you will just waste your time looking up the one you need.

See also:
CFLs in binary files


Text Editor | Word-Wrap

Word-Wrap

Wraps long lines that don't fit in the visible width of the window. The command can be reached from the toolbar and from the View menu. For your confort each line that is a wrapped part of the previous line will be marked with a small grey ball on the left in the gutter.

CG uses soft-wrapping i.e. it doesn't inject new-line characters in the text where the line should be wrapped. So wrapping is for your confort only, it will not affect the file to be saved. Similarly the wrapping-boundary is automatically adjusted to the actual width of the window.

If you need hard-wrapping you can do it with a regexp-replace, with a macro or with the justify command.


Text Editor | Text Justification

Text Justification

To justify some text select a few lines first, then choose the Justify command from Selection menu. This command will reformat the selection by making each line of the selected text equal in length. Please don't mix it with the word-wrap feature, because the latter doesn't remove the new line characters from the text!

How it looks like?
Before:

To justify some text select a few lines first,
then choose the Justify command from Edit->Format Selection.
This command will reformat the selection by making each line
of the selected text equal in length. Please don't mix it
with the word-wrap feature, because the latter doesn't remove the new
line characters from the text!

After:

To justify some text  select a few lines  first, then choose
the  Justify  command  from  Edit->Format   Selection.  This
command will reformat  the selection by  making each line of
the selected text equal in  length. Please don't mix it with
the word-wrap feature, because the latter doesn't remove the
new line characters from the text!
Why is it good?
Because -unlike in word-wrap- the justified format of the text will be preserved after you saved the document.

When to use it?
For formatting the text of e-mails before sending them, or for creating plain text documentations. But justifying a Java, C or Pascal source file is usually not the best choice.

You can justify one paragraph of text at a time, or you can select the entire file, too. In the latter case Code-Genie will split the selected text into paragraphs for justify. An empty line separates each paragraph. If the paragraph has a title, then an empty line should separate that title from the paragraph. In this case the title will be one paragraph, and the text below will be an other paragraph, and they will not merged by Justify.

Note:
Justified text looks cool only with proportional fonts (where the size of each character is equal).

See also:
Word-Wrap


Text Editor | Indentation

Indentation

Indentation describes how Code-Genie should behave when you press ENTER at the end of the line. It has 3 states:

  • None
    means no indentation: the cursor will blink at the very beginning of the next line
  • Auto
    means the cursor will blink just below the first visible character of the previous line
  • Smart
    is the same as Auto except, plus if the previous line ends with { or , or : or begin then it will indent the next line. Similarly if the previous line ends with }, it will unindent the previous line. So it is useful for C/C++/Java/JavaScript/PHP/Python and such languages.


Text Editor | Monitor Clipboard

Monitor Clipboard

This command monitors the Clipboard for changes. Whenever it changes, it will paste the new text into the document. This command can be reached from the Edit | Special | Monitor Clipboard menu. A check mark appears next to the menu item if this option is active.

Each pasted text will be separated from the others by a separator. The default separator is the new line character (\n). To use a different separator select some text prior activating this command: that text will be used as the separator. So if e.g. you select a comma (','), then the pasted texts will be separated by commas.


Text Editor | Macro | Macros support

Macros support

You can automate Code-Genie by creating macros. Code-Genie uses the ScriptContol from Microsoft©, which is freely available for download from www.activex.com, www.microsoft.com, or directly from code-genie.com/sc.exe. The language of the macros can be VBScript or JScript. You can choose the one you like.

The macro procedures are stored in the *.vbs (for VBScript) and in the *.js (for JScript) files in the macros subdir of the program. You can easily create new procedures, or modify existing macros by editing these files or creating new ones.

The methods defined by Code-Genie can be reached under the Doc. scope. So e.g. to move the cursor to the end of the document you would type Doc.SSE=Doc.GetSize.

Macro recording

You can record macros by pressing the 'record' button on the toolbar. Its depressed state indicates that macro recording is on. Whenever you press this button again CG will ask you where to save the newly recorded macro. Here you can choose the file and choose whether to save it in JScript or VBScript in one step. After you have chosen the file for the new macro, CG will open it and place the new macro at the end of the file. Since macro recordings have inherent limitations against macro writing you should fine-tune your macro by editing it. By saving the file your new macro is ready to serve. Double click on its in the selector to launch it.

See also:
Macro interface


Text Editor | Macro | Macro interface

Macro interface

Properties:

  • SS
  • SE
  • SSE
  • SelText
  • Clipboard

Basic Methods
Note: arguments in square brackets [] are optional.

  • FilePath
  • FileDir [file_path]
  • FileExt [file_path]
  • FileName [file_path]
  • FileTitle [file_path]
  • GetSize
  • LineCount
  • PosToLine nPos
  • LineToPos nLine
  • GetChar nPos
  • AuxMove nPosFrom, cgMode
  • Find szFindWhat [, cgMode]
  • Replace szReplWhat, szReplTo [, cgMode [,szWhere]]
  • MReplace szReplWhat, szReplTo [,szWhere [,szSeparator]]]

Special methods
Note: arguments in square brackets [] are optional.

  • Prompt szPrompt
  • MsgBox szMsg
  • Confirm szMsg
  • Save szFileName
  • ChangeCase cgMode
  • TrimLeft [szWhat]
  • TrimRight [szWhat]
  • Indent
  • Unindent
  • Tabify
  • Untabify
  • CopyColumn Separator
  • DelColumn Separator

Constants

  • cgDocStart
  • cgDocEnd
  • cgLineStart
  • cgLineEnd
  • cgWordLeft
  • cgWordRight
  • cgFindUp
  • cgFindCase
  • cgFindWholeWord
  • cgFindRegExp
  • cgLowerCase
  • cgUpperCase
  • cgCapitalize

See also:
JScript Intro
VBScript Intro


Text Editor | Context-sensitive help support

Keyword-lookup

Keyword-lookup means that when you press F1 during editing, the currently edited word will be looked up in the help file.

Multiple help files:
CG supports multiple help files as well. You can select the active help file from the list of available ones below the Help | Active Help submenu. The currently active help file will be marked with a dot in front of its name. Similarly when you select Contents from the Help menu, this file will be loaded.

Managing help files:
The help files listed here are from the helps subdirectory of the program. You can place help files here by copying the files into this directory. Code-Genie supports hlp files (WinHelp) and chm files (HTMLHelp). Additionally you can place lnk files (Windows Shortcut) here that point to such help files found in other directories. The references will be resolved by CG at run-time.

Getting such files:
You can find such help files on our website. If the help file you need is not in the list, you can try to find it on the Internet.

Creating such files:
This topic is out of scope of this manual, but one important note: keyword-lookup works only for words listed in the Index section of the help file.


Text Editor | Block and column operations

Block and column operations

These two operations are very similar so we discuss them on one page. You can find them in the Selection menu. The first thing in common is that these operations work for multi-line selection only.

Block operations

First take a look at the following picture.

Block operations applies not to the selected text, but to the characters inside the selection-rectangle (that we enclosed with a red rectangle for clarity). These operations are Copy, Delete and Paste for copying, deleting and inserting from the Clipboard respectively.

Column operations

Copy operations are similar to Block operations, but here the selection-rectangle is different. Here you treat the text file as a tab-delimited text file where each new record is separated with a new line and the cells are separated with tabulator characters. You can make such text files simply by saving a spreadsheet of data as a tab-delimited text file in Excel. The same operations are available here: Copy, Delete and Paste.

Your next question can be: what if I want to separate my cells with a character other than tabulator (e.g. , (coma)). The only solution is by using the macro functions. Or for more sophisticated operations simply copy-paste the selected text to Excel, do the operations you want there, then copy-paste the result back into CG.


The Binary Editor

Code-Genie has a built in full-featured binary editor. At first glance it may seem strange since it is not too similar to today's popular hex-editors. But I can assure that it can do all the tasks these editors can do. Here is how to use it:

You can see the bytes of the file side by side, no hexadecimal display is available. This is because the hex-display would take two-third of your window. This way you can see a much bigger portion of the edited file at once. But the hexadecimal representation of bytes is also important. So, as you can see, the topmost row of the binary editor is reserved for this purpose: You can see here the hex representation of the byte the cursor is on and its four neighbours to the left and four to the right. The central byte is represented with inverted colors indicating that it is the currently edited byte.

So far so good. But what if I want to edit that byte as a hex number? You can switch to Hex Editing mode at any time by pressing F5. This way only the first half of the byte will be inverted in color indicating that you are editing in Hex mode. That simple.

For further reading check out some of the followings:

  • Edit/View bytes as integers, floats.
  • Intel/Motorola byte-order
  • Code-Fragments in binary files
  • Copy as text
  • File comparisons
  • Checksum, CRC and MD5 calculations
  • BackUp file creation


Binary Editor | Code Fragments in binary files

Code-fragments in the Binary Editor

Code-fragments (CF) can be used for binary files, too. For a working example on how to use it see the asm_x86.cfl file.

When you double click on a CF in one of the selectors, first Code-Genie will try to interpet its associated text as a series of bytes in hexa format. If it can convert it to bytes, Code-Genie will insert that bytes into the binary file at the current cursor position instead of the text.

Example:
In a binary CF you can say e.g. 'Hello' in two ways:

by typing the text 'Hello',
or by typing the text 48 65 6C 6C 6F

A binary CF can consist a lot of bytes, that are hard to write in one line. Therefore you can create multi-line CFs:

Example:

#Exe-header
4D 5A 90 00 03 00 00 00 04 00 00 00 FF FF 00 00
B8 00 00 00 00 00 00 00 40 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 E8 00 00 00
0E 1F BA 0E 00 B4 09 CD 21 B8 01 4C CD 21 54 68
#end

By using the Copy as text item of the Edit menu of the Binary editor, you can create such binary CFs as easy as a copy-paste operation.


Binary Editor | Copy as Hex

Copy as Hex

Converts the selected binary data to hexadecimal format and places it onto the Clipboard as plain text. The command can be reached from the Edit menu.

You can use this command for creating binary code-fragments or to export binary data from the binary editor to the text editor.

This command is the inverse pair of the Paste Hex command.


Binary Editor | Paste Hex

Paste Hex

This command can be reached from the Edit menu. It treats the text found on the Clipboard as a hexadecimal representation of some binary data: it will convert it to binary and then insert it into the document.

The format of the text on the Clipboard must be in hexadecimal format (like FF D4 61 00). Whitespaces (space, tabulator, new-line) are allowed in the text since these will be removed automatically prior conversion. Similarly the command is case-insensitive, so e.g. FF005E means the same as ff005e.

This command is the inverse of the Copy As Hex command and works similar to the binary Code-Fragments.


Binary Editor | Motorola byte-order

Motorola byte-order

The Intel and the Motorola processors uses different byte-orders.
Example: a number (such as 4) represented as a 2-byte long integer looks
04 00 on the Motorola, and
00 04 on the Intel-processors.

You can switch between them by checking/unchecking the Motorola byte-order item of the View menu.

See also:
Edit/View bytes as integers/floats


Syntax-HighLighting

What is it all about:
The text editor can highlight a text file according to the specification of a given programming language. By default Code-Genie can syntax-highlight a wide range of syntaxes from C++ to CSS. To change the default syntax of a given document choose a different language from View | Properties.

The basic concept:
Code-Genie knows nothing about languages such a C++, HTML, PHP and such. It retrieves all of the information needed for highlighting a given programming language from syntax files. These files are plain text files with cgsyn extension in the syn subdirectory of Code-Genie.

Creating a new syntax file:
Create a new text file, define the rules of syntax highlighting, and finally save the file to the syn subdirectory of the program with cgsyn extension.

Modifying an existing syntax file:
The file is in the syn subdirectory of the program. Open it in the editor and edit it. Finally save the file back to disk. Your changes will be applied immediately. If you made some syntax errors in the file, an error message will pop up in the output window indicating the cause and position of the error.

Removing a syntax file:
To remove a syntax simply move/delete the file associated with it.

See also:
Syntax commands
Examples
DefaultSyntax directive


Text Editor | Syntax | Syntax-HighLighting Terminology

Syntax-HighLighting Terminology

When Code-Genie loads a text file from disk, it stores each character internally on one byte. The characters are classified as follows:

  • alphanumeric: letters from the English-alphabet ('a-zA-Z'), numbers ('0-9'), the underline character ('_') and (possibly) the hyphen ('-')
  • locale-specific: letters from the non-English alphabet (like 'áéöí')
  • space (' \t\n\r\v')
  • null-character ('\0'). Not valid in a text file.
  • stop-character: all other characters (like '{}[]();?><$&*')

Keyword
A keyword can contain up to 30 alphanumeric characters.

KeywordGroup
A keyword group can contain one or more keywords.

KeywordPrefix
Prefix is a one-character long identifier. All words starting with this identifier will be treated as a keyword and will be colored as you defined. It must be a stop-character.

KeywordSuffix
Suffix is a one-character long identifier. All words ending with this identifier will be treated as a keyword and will be colored as you defined. It must be a stop-character.

Number
Is a fix or floating point number. It may be a decimal one or a hexadecimal with 0x prefix.

Operator
Is a one-character long identifier. It must be a stop-character.

Delimiter
Delimiter is a sequence of one or more stop-characters (up to 30 characters).

Block
A block is a block of text. It has one starting delimiter, has at least one ending delimiter and may have one or more not-ending delimiters. Not-ending means that if the delimiter specified here is encountered, then the block will continue after this. See the examples on how to use it in practice.

Nesting
The syntax-file contains syntax-elements organized in a tree structure. The Nest command is used for describing the hierarchy among these syntax-elements. The Nest command defines the parent of a given syntax-element. The type of the parent must be a Block. The syntax-element mounted this way is visible only inside that block.

See also:
Syntax commands
Structure of syntax files
Examples
DefaultSyntax directive


Text Editor | Syntax | Structure of Syntax/config files

Structure of syntax/config files

The config file (cgenie.conf) and syntax files (*.cgsyn files in the syn subdirectory of the program) are plain text files that follow the same structure. The structure is as follows:

Comments:
Empty lines and lines starting with # will be treated as comment and will be skipped till the end of the line. Note here that the comment must start at the beginning of the line or else it will not be treated as comment. Example:

# comment till the end of the line
command        # but this is not a comment!!

All the remaining lines will be parsed by Code-Genie. The parser is line-based i.e. one command must fit in one line. Some commands may accept variable number of arguments and/or can grow rather large. To ovecome this problem logical lines were introduced:

Logical lines:
All commands must start at the beginning of the line. To continue the line in the next line all you have to do is to indent the next line with one or more space or tabulator characters. Each consecutive indented line will belong to the same logical line and will be parsed as if it was one physical line. Example:

Logical line starts here
   continues in this line
   and in this line
But this is the next logical line

Space is the separator:
The commands and their arguments are space-separated. It means that you have to separate each command or argument from the others by one or more space or tabulator characters. Example:

Command1  argument1 argument2
   argument3
   argument4
Command2
   argument1

Escaping:
Since some special characters are reserved they must have some special notation. So the following wildcard characters were introduced:

\s | for space
\t | for tabulator
\n | for new-line
\0 | for the null character
\\ | for a single backslash (\)

\s wildchar must be used if an argument contains a space character. \0 can be useful if you want to set an argument empty while the argument(s) after this are not empty. Example:

Command
   argument1
   \0
   argument3\swith\sspaces
   \n

Types of arguments
An argument may have the following types:

  • Boolean: yes,y,true,no,n,false
  • Numbers (integers and floats)
  • Strings

See also:
Terminology
Syntax commands
Examples
DefaultSyntax directive


Text Editor | Syntax | Commands of syntax files

Commands of syntax files

The following commands are defined for syntax files:

CaseInsensitive
Specifies whether the syntax is case-sensitive or not. Syntax is:
CaseInsensitive [bool]

By default case-sensitive is assumed. Use this command to override. Can accept an optional bool argument.

KeywordGroup
With this command you can define a group of keywords. Syntax is:
KeywordGroup group_name [keyword1] [keyword2] ...

As you can see this command can have variable number of arguments depending on the number of keywords you want to specify. Note here that some languages (such as Java, Perl, PHP) may have more than 300 functions you can enumerate here. As you increase the number of keywords in a syntax file the parser engine gets slower an slower (especially on slower machines). One solution to this problem would be to partition these words into smaller keyword-groups and Nest only the groups you actually use.
Final note: the length of a keyword should not exceed 30 characters. Longer keywords will not be highlighted correctly.

KeywordPrefix
Specifies a given character to be used as a prefix for keywords. All words beginning with this prefix will be treated as keyword and will be colored and formatted as you specified. Syntax is:
KeywordPrefix prefix_name prefix

Example:

KeywordPrefix  php_variables  $

KeywordSuffix
Specifies a given character to be used as a suffix for keywords. All words ending with this suffix will be treated as keyword and will be colored and formatted as you specified. Syntax is:
KeywordSuffix suffix_name suffix

BlockStart
Defines the start of a block. Syntax is:
BlockStart block_name start_string

BlockEnd
Defines the end(s) of a block. Syntax is:
BlockEnd block_name end_string1 [end_string2] ...

BlockNotEnd
Defines the not-end delimiter(s) of the block. Syntax is:
BlockNotEnd block_name notend_string1 [notend_string2] ...

Number
Specifyies the name of a number-node. Its format and coloring are specified separately by using the Format, FgColor and BgColor commands. Syntax is:
Number number_node_name

Operator
Specifies an operator-node: its name and the operators enumerated side by side. Syntax is:
Operator node_name operators

Example:

Operator  my_operators  +-;[]{}|:,
Its format and coloring are specified separately by the Format, FgColor and BgColor commands.

Nest
Used for describing the tree-hierarchy among the blocks and other elements. Usage:
Nest child_name [parent_name]

If parent is omitted the child will be mounted as a global element. Note here that parent MUST be a block-name. So you cannot nest a syntax-element under e.g. a keyword-group since it would have no meaning.

Formatting and coloring commands:

Format
Specifies the format attributes of syntax-elements. Usage:
Format node-name format_attributes

Format-attributes are b for bold, i for italic and u for underlined. Example (we want bold and underlined keywords):

Format  my_keywords  bu

FgColor
Specifyies the foreground color of syntax-elements. Usage:
FgColor node-name #RRGGBB

The color must be specified in red-green-blue triplets. Example (we want red keywords):

FgColor my_keywords  #FF0000

BgColor
Specifyies the background color of syntax-elements. Usage:
BgColor node-name #RRGGBB

The color must be specified in red-green-blue triplets. Example (we want our keywords highlighted with light-blue background):

BgColor my_keywords  #9090FF

See also:
Syntax highligting overview
Terminology
Structure of syntax files
Examples
DefaultSyntax directive


Text Editor | Syntax | Syntax highligting examples

Syntax highligting examples

Here you can find some simple copy-paste examples for syntax-highlighting just to get you started. All you have to do is to copy-paste the code-snippet into a text file and save the file with cgsyn extension into the syn subdirectory of the program.

Example 1:
We want to syntax highlight all the 'code' and 'genie' words in documents with blue color and bold formatting. Solution:

KeywordGroup  my_keywords  code  genie
FgColor       my_keywords  #0000ff
Format        my_keywords  b

Nest          my_keywords

Example 2:
We want to color C-style single-line comments with a green color. In this case the comment block starts with // and ends at the end of the line. But if the last character of that line ends with a backslash (\), it will continue in the next line. Solution:

BlockStart   comment  //
BlockEnd     comment  \n
BlockNotEnd  comment  \\\n
# note here the \\\n=== \\ + \n
# \\ is a single \ and \n is a new line
FgColor      comment  #00FF00
Nest         comment

Example 3: We want to color/format html, body, script and other keywords with blue/bold+underlined but only inside html tags. Solution:

KeywordGroup  tag_kwds
   html  body  script
   pre  p  b i title head
FgColor       tag_kwds  #0000FF
Format        tag_kwds  bu

BlockStart   tag   <
BlockEnd     tag   >

Nest tag_kwds tag
Nest tag

For more advanced examples see the syntax files shipped with Code-Genie.

See also:
Syntax highligting overview
Commands
Terminology
Structure of syntax files
DefaultSyntax directive


Tips and Tricks

General

The Tip of the day feature in the Help menu can give you some very useful hints. By default it pops up every time you launch the program. Your next task is to figure out where to turn it off.

To move Code-Genie to a different directory: Simply move all the files of Code-Genie into the destination directory, Code-Genie will continue to work. For multi-user setups click here

Uninstalling is just as simple: Chose Help | Uninstall.... Code-Genie doesn't spoil you system: it neither copies any DLLs anywhere in your system, nor use your system's Registry except when you especially ask it to do so.

Double-click on a file name in the Output Window, and CG will load it. This is perfect for redirected compiler-outputs. When there is a line-number displayed beside the filename, the cursor will be positioned there.

Double-clicking on the gray background that is behind the documents opens up the FileOpenDialog.

To jump between the currently opened documents, press C - Tab or C - S - Tab. Similary you can use the two side-buttons of MS. IntelliMouse ®, too.

Use the simple project manager to organize your documents.

Text Editor:

You can reach the selectors with a shortcut, too: M - F1 ,M - F2

You can append text to the Clipboard by holding down the Shift key while you press C - c.

You can paste text from the Clipboard as CF by pressing C - V.

To save your source in HTML or RTF format, select Export... from the File menu. To copy the selected text in HTML or RTF format choose Copy As HTML or Copy As RTF from the Edit menu. This way you can copy/paste your code into e.g. Word with syntax-coloring preserved.

To find a pair of a bracket press C - M. You can even use it for matching html-tags pairs.

To indent more than one line, select them first, and press TAB. To unindent lines, select them and press Shift+Tab.

Quick open: You can open a file in the editor by right clicking on it, and selecting Open from the drop-down menu. So e.g. if you type "readme.txt", then you right click on it, you can select Open from the drop-down menu if the "readme.txt" file can be found in the directory of the currently edited file.

Quick help: By pressing F1 while editing, the currently edited word will be looked up in the active help file. You can change the active help file from the help menu. See keyword-lookup for more.

AutoComplete: If you press C - Space during editing, Code-Genie will try to help you finish the currently edited word. If it can, it will finish. If there were more possible solutions, Code-Genie will enumerate all the possibilities in a list from where you can choose the most appropriate.

To remove all of the occurrences of a word, press C - h . Specify the word, and leave the Replace With box empty. Now press Replace All. Similarly you can make all of the occurrences of a word capitalized.

To search for a pattern instead of a string use regular expressions.

To change the current syntax highlighting, press M - Enter, and choose a different language.

You can see two parts of a file at the same time by dragging the small rectangle over the up-arrow of the vertical scroll bar. To remove the split-screen effect, double click on the line separating the two views.

To see more of your file you can use the View | Full Screen mode.

To insert a bookmark press C - F2, to remove it, press it again. To jump between the bookmarks press F2.

Double-click selects a word, triple-click selects the entire line.

Binary Editor:

To open a text file as binary, select Binary in the Open As combo of the File Open dialog. Similarly you can open a syntax file as binary as well.

To switch between binary and hexa editing mode press F5.

Beside searching for hex or text pattern, you can even search for text that is encoded in unicode.


Frequently Asked Questions

General

What are those numbers in the Version?
The build date of the program. So if the version number is V3.11.12 it means that the program you have was built on 12th of November, 2003.

What big files can CG handle?
Big enough! Well theoretically 2GB is the upper limit, but practically a few hundreds of megabytes. Of course the file should fit into the available memory (both physical and virtual), too. Of course the bigger the file the more time it takes to load. And yes, Code-Genie tries to load the whole file into memory, not just one portion of it.

The settings are in a text file?
Exactly. After a while we got tired resizing the dialogs, rearranging their controls to make some more room for a new one. So we chose this way. At first it may be unconfortable for click-and-go users, but for people with some *nix background it may be the missing link.

Text Editor

Line numbering continues with 000 after 999
This is intentional. Only the last 3 digits of line numbers are displayed. This is to avoid the one character right-shifting of text at 1000, 10000 etc. The exact line number can be seen from the statusbar.

What is smart indenting?
When you press Enter at the end of a line basic editors start the next line at the beginning of the row. When auto-indenting is on CG will start the next line below the beginning of the previous line. One step further is smart indenting. Here CG will try to guess how to indent the next line. For more info on it click here.

Can I save my file in xxx format?
Code-Genie (CG for short) can save your document in DOS/Unix/Mac format in plain text/Unicode/UTF-8 encoding. See View | Properties for more details on this.

What is paste as html?
When you copy some text in Internet Explorer and try to paste it in a CG-document, CG can choose between pasting the plain text and pasting the html code that implements it. If you choose paste as HTML, then the html content will be inserted into the document instead of the plain text. Unfortunately this works for IE only, Netscape doesn't support it yet ( yet == version 4.77).

What is Complete Word in the Edit menu for?
By pressing C-Space, CG tries to complete the word you just started typing. If CG has more hints it will display them in a popup listbox from which you can select the desired word. See this for more info.

Unicode-support means support for Far-Eastern languages?
Unfortunately not (yet). At this time CG stores each character on one byte (SBCS).

Does CG provide some document-templates?
Use Code-Fragments to create the template you need.

Code Fragment Libraries

What is it for?
As its name implies it stores fragments of text that you use frequently. These fragments are groupped together and stored in one file. This file is a Code Fragment Library ( files with cfl extension in the cfl subdir of Code-Genie).

How can I use them?
Double click on the name of the CF, and Code-Genie will insert its associated text into the document at the current cursor location.

Can I modify a code-fragment?
Yes. Open the cfl-file file, modify it, and save it back to disk.

Can I create new libraries?
Yes. Create a new text document, write some fragments and save it with cfl extension in the cfl/ subdirectory od Code-Genie. Similarly you can delete a library at any time by deleting its associated cfl file.

How many CFs can I place in one CFL?
No limit. But a practical advice would be to store only the CFs you use frequently. This way you don't waste your time looking up the given CF in the selectors.

Can CFs be used for binary files?
Yes. See the cfl/asm_x86.cfl for more details on this.

Can I assign a shortcut to a CF?
Yes: See the Shortcut command in the config file.

Macro-support

What is it for?
For automating your tedious editing tasks.

Why should I install the ScriptControl?
The ScriptControl is a 3rd-party component that interprets your scripts. It is actually an OCX component with a well-defined interface to the outer-world. Code-Genie communicates with the control via this interface. This way this control executes the script you wrote, but the result will be displayed on the active document of Code-Genie.

Can I assign a shortcut to a macro?
Yes. See the Shortcut command in the config file.

Keyword-lookup

What is it for?
When you press F1 during editing, the currently edited word will be automatically looked up in the active help file.

How can I add help files to the list of Active helps?
Copy the help file to the helps subdirectory of Code-Genie.

So I have to copy all the help files to this subdirectory?
You should, but you don't have to: create a shortcut to the help file (a file with .lnk extension) and place this link file to the helps subdir of CG. The shortcut will be resolved at run time.

What kind of help files can CG use?
Currently Code-Genie supports hlp and chm files. But not all help files support keyword-lookup. Keyword lookup will work only for words that are listed in the Index-field of the help file. Listing is not case-sensitive, but the given word must present there exactly. This means that if you want to lookup e.g. 'strstr', then 'strstr' (or StrStr') must be present in the index-field. But if 'strstr-searching in string' is present only, keyword-lookup will fail.

Where can I find such help files?
Everywhere on the Internet. But take a look a www.code-genie.com/ufiles.html first.

Syntax files

What is it for?
Code-Genie is not an HTML, or a C++ editor. Actually it never intended to be. CG is a text editor that tries to help its users editing more easily by syntax-highlighting the document.

Does CG support xxx-syntax?
Code-Genie does know nothing about the syntax of C++, Java, PHP, HTML, JavaScript and such. But you can teach it how to colorize such files. All the information required for colorizing a file is stored in syntax files ( files with .cgsyn extension in the syn subdirectory of the program). This is why CG is so modular: you can add a new syntax-file to the menu, or remove a not-needed one at any time by adding or deleting its associated .cgsyn file.

How to teach CG a syntax?
See the tutorial. But before diving into deep waters take a look at www.code-genie.com/ufiles.html first. Perhaps you will find the syntax file you need there.

Syntax-definition doesn't allow...
We tried to implement a syntax definition that is as flexible as possible, but the proliferation of programming languages makes it very hard to cover all languages entirely. Therefore the syntax-definition has its own limitations. So e.g. CG will never cover the C/C++ 100% precisely, but you can achive 99.9% accurancy. This accurancy changes for different languages of course.


Change Log

Editor's note: The Change Log can grow rather large. So for easy navigation we suggest you search for a (key)word on this page.

2004-02-03
This build contains bug-fizes only. None of them are serious, but worth upgrading.

2004-01-26
A new build with enhancements and bug fixes. These are:

  • Hitting ESC now stops FindInFiles, ReplaceInFiles and running tools.
  • Clicking on the gutter selects the whole line.
  • Unix-style shortcut notation was introduced in the menus.
  • C-S now works as Save As...
  • Left and Right alignment commands were added.
  • KeepTextFilesTidy config command was added.
  • A bug in Unicode-search of the binary editor was fixed.

2004-01-02
A serious bug was fixed in the binary editor (crash upon saving locked files); A harmless bug was fixed in file-locking (some '*.lock' files were not deleted); From now on extra spaces at the end of the lines get removed when EnableVirtualSpace is turned on; Some corrections were made in the help file and a more detailed help page for Regular Expressions with more working examples is added. And by the way: We wish you a happy new year!

2003-11-25
Licence change: Due to the virulent cracker-underworld, the trial-version of Code-Genie is no longer fully-functional: Undo/Redo commands are disabled and the program is optimized for file-size instead of speed.

2003-11-12
Bug fix: Replace in files had a problem with searching strings containing escaped characters.

2003-11-07
Bug fix: Leading/trailing whitespace characters of rows of code-fragments were trimmed prior inserting.

2003-11-03
Three smaller bugs were fixed: one in project-management, one in command-prompt-handling and an other one in converting old short (8.3) pathnames to long.

2003-10-28
Enhancement: From now on Code-Genie doesn't ship with the cgenie.conf file. Instead it uses a cgenie.conf.default file. Upon starting the program for the very first time the default file will be automatically renamed to cgenie.conf. This way the next time you update your program, your custom settings in your cgenie.conf file will not be accidentally overwritten.

2003-10-20
Bug fix: The default file extension in Find In Files was '*.*', which skipped files with no extension. Now it is replaced with '*', which covers all files. The same applies for Replace In Files.

2003-10-06
Bug fix: The LED and the motor of the floppy drive was active during editing a file residing on a removable disk.

2003-08-15
Bug fix: Two smaller flaws were fixed: Code-fragments inserted via a keyboard-shortcut inserted an extra new-line character at the end; the multimedia-keys of multimedia keyboards were not functioning if CG was in focus.

2003-07-31
Bug fix: The new buid fixes a bug in the UTF8-save, one in FindInFiles and a typo in a warning message.

2003-07-28
The new build fixes a smaller flaw and adds Recent-Dirs combo to the Save As and Export dialogs.

2003-07-17
The new buid fixes one bug in AutoSave and one in the Reload command of the binary editor; adds locale-support for dates/times displayed in different parts of CG; and preserves WordWrap settings across sessions.

2003-07-04
Bug fix: Two smaller flaws were fixed in Code-Genie: one in Find In Files and the other in the Export as HTML commands.

2003-06-11
New build fixes a smaller bug in color printing, adds a -b command-line switch to replace the (sometimes irritating) new-empty document at startup, and makes the documentation of Regular-expressions more thorough.

2003-05-31
Bug fix: Regexp replace didn't handled backslashes correctly in the replace string. This bug affects all earlier versions.
Discovered by: Doug B.

2003-05-19
Bug fix: ReplaceAll may hang CG if Whole words only was turned on.
Discovered by: Steve M.

2003-05-14
A maintenance-release of Code-Genie was released. It fixes two bugs and adds a few enhancements to the program.

2003-04-28
The new build of Code-Genie fixes some bugs and adds a new command (Paste Hex) to the binary editor.

2003-04-20
Bug fix: Two bugs in AutoComlete were fixed. One of which was a serious one (caused program crash), the other was only annoying. The bugs affect all versions of the program to date.
Discovered by: Richard H. and daFunky

2003-04-10
New build: The new-build is avilable for download. Changes:

  • Project-management support
  • Redesigned helpfile to look more Windows-like.
  • From now on the Word-wrap button applies not only to the active document, but to all of the text documents.
  • MReplace method was added to the macro interface.
  • Tons of smaller changes, bug fixes that affect almost all part of CG.

2003-03-03
New build: New build with new features. List of changes/enhancements:

  • Several bug-fixes of the beta version.
  • The Search and Replace commands in the binary editor have changed.
  • Find in Files command became a lot faster.
  • You can use Regular Expressions in Find in Files (though it is a lot slower than a regular search)
  • You can specify complex file patterns for Find in Files and Replace in Files (e.g. match any php file starting with the letter 'F': f*.php)
  • AutoIndent for Code-Fragments.
  • Explorer right click handles multiple files (replace the ShellExt.dll with the new one)
  • Command-line enhancements (see the help for more info on it)
  • Lots of smaller changes.

2003-02-03
Enhancement: We added support for the left and right side-buttons of the MS. IntelliEye Mouse: you can tab between the opened documents with these buttons just like pressing Ctrl+Tab or Ctrl+Shift+Tab. But this feature is experimental since MS doesn't provide official info on this subject. So if it doesn't work for you we kindly ask you to report it to us.

2003-01-20
Bug fix: The header and the footer of the page to be printed get corrupted if the file path contained a $ sign.
Discovered by: Doug Baer

2003-01-16
Bug fixes: The new build fixes a file-locking bug that may lead to crashes and a typo in the RegExp menu of the Find dialog.

2003-01-15
Bug fix: CG crashed when you wanted to overwrite a locked file with the Save As... command. So e.g. CG will crash if you had file1.ext open and want to save it as file2.ext, where file2.ext is kept locked (by CG or by an other application).

2002-12-05
The new build fixes some smaller bugs and adds some enhancements.

2002-11-25
Enhancement: From now on Code-Genie doesn't ask you whether to save the content of the Output window or not. It will not get saved by default. Furtheremore the newly introduced hot-key (Alt+F3) will jump you to the Output window.

2002-11-18
Bug fix: The Sort command "eated" the very last item of the selected text if it was not followed by a terminating separator.
Discovered by: Marcin Kita

2002-11-15
The new build fixes some smaller bugs and adds some enhancements to the Find, Replace, FindInFiles, ReplaceInFiles dialogs and to the OutputWindow. And there are some corrections in the help file, too.

2002-11-10
Bug fix: A bug that resulted in a crash was discovered by Chris (aka. Crazee). It would be rather hard to describe the conditions needed to reproduce it, but the bug was sure there. An other typo was also discovered by Derek Parnell: the Output Window was abbreviated to only 'Ouput'.

2002-10-29
Enhancements: Replace, FileExt, FileName, FileTitle, FileDir functions got some extensions while they are still backward compatible.

2002-10-29
Bug fix: Executing a tool opened a blank OutputWindow even if CaptureOutput was not specified.
Discovered by: Derek Parnell

2002-10-23
Bug fix: Closing the Output Window and then running a command that writes to it (e.g. Find in Files) resulted in a program crash. It applied to the latest version (3.10.16) only.
Discovered by: Antoine

2002-10-23
Bug fix: Code-Genie didn't start on NT 4.0 where IE4.0 was not installed also. Here I mean IE4.0 and not above because this is the only version that updates the shell32.dll file. Discovered by: Frank Shumacher and Kevin Wu

2002-10-23
Enhancements: Thew new build introduces some smaller enhancements (like removing the ResolveLinkFiles config command and adding an Insert File Names... command (Edit->Selection->Insert File Names)) and some smaller bug fixes.

2002-10-16
Enhancements: Thew new build introduces some enhancements:
The first one is that from now on you can reach the two selectors by keyboard shortcuts (Alt+F1 and Alt+F2 respectively). Here is what happens when you press this hotkey: if the selector is not visible, it will be shown and will receive the focus; if it is visible, but not focused, it will be focused; if it is visible and focused, it will be hidden. Finally ESC will remove the focus from the selector back to the document.
The other enhancement is that the OutputBar was removed from the program. This was mainly because of the limitations of its embedded edit control (64k limit, copy-paste problems etc.). So from now on the OutputBar is an Output window.
Finally the Tools menu was redesigned a little bit to make it easier to reach the tools by shortcuts and navigate in the menu.

2002-09-26
Bug fix: notepad.exe replacement only displayed the directory of Code-Genie instead of executing the program. This bug was introduced a few days earlier, so earlier versions are not affected. The bug was not in notepad.exe, but in cgenie.exe
Discovered by: Eugene Elder

2002-09-26
Enhancement: Multi-user support was added.

2002-09-26
Enhancement: Triple-clicking is implemented: Double-clicking in the text editor selects a word, triple-clicking selects the entire line.

2002-09-25
Bug fix: RegExp-replace problem: In some special circumstances when the pattern to be matched contained the beginning of a line (^) character the Replace All function didn't work as expected.
Discovered by: Thanh Ngan Dang

2002-09-24
Smaller enhancement: Double-clicking on the dark-gray background of the program (behind the opened documents) now pops up the FileOpenDialog.

2002-09-24
Licence change: Code-Genie is not freeware any more. This is because the possibility of voluntarily donations was not incentive enough for you to support the program. So this was a neccessary step to keep the product alive.

2002-09-10
Bug fixes: The new build fixes several smaller bugs in the program, and in the tips.txt file.

2002-09-04
Bug fixed: UnIndent didn't unindent the last line of the selection if the last line was the last line of the document.
Discovered by: Nous

2002-09-02
Program update: Lot of smaller bug fixes, enhancements, corrections and modifications took place in the program and its accompanying files.
Build-date caused a lot of confusions amongst the users, so from now it is built in the version-number. So Version: 3.09.02 means that the build date of the exe file is 2nd of September. Version number is displayed in the About Box of the Help menu.
From now on Code-Genie supports the new XP-look. So people who use Windows XP can enjoy the new sleek look.

2002-08-26
Corrections: Some links in the help file were dead.
Discovered by: Zenon Ingielewicz

2002-08-26
Fixed bug: Context-menu didn't pop up on the selectors by pressing the context-menu button on the keyboard.
Discovered by: Zenon Ingielewicz

2002-08-22
Corrections: A few typos were fixed in the program and in the help file.

2002-08-15
Fixed bug: File-compare didn't start comparing if the file name was too long and was shortened by '[...]'.
Discovered by: Elton Kong

2002-08-15
Enhancement: CRC-16 calculation was replaced by the much more useful MD5 hash calculation, and from now on you can reach it from the text editor, too.

2002-08-12
Fixed bug: If VirtualSpace was set to true the SelText macro command inserted some extra spaces into the document.
Discovered by: Derek Parnell

2002-08-08
Fixed bug: If you selected some text in the text editor starting from right to the left, and you pressed F1, Code-Genie simply disappeared.
Discovered by: Marcin Kita

2002-08-08
Fixed bug: Uppercase conversion worked for national characters only if the very first letter of the selection was a national character.
Discovered by: Marcin Kita

2002-08-07
Fixed bug: If Word-wrap was on and you changed the font size CG didn't adjusted the wrapping limit to the new font.
Discovered by: Richard Maria Haider

2002-08-07
Serious bug was fixed: Sorting with 'Remove duplicates' caused program crash.
Discovered by: Marcin Kita

2002-07-29
Fixed bug: FileDir and FileTitle macros were not working correctly in the macro interface.
Discovered by: Brian K. Broker and Derek Parnell

2002-07-28
Sorting problems: Due to a speed enhancement in sorting, Code-Genie replaced the sorted text with nothing. Though it did lightning fast indeed :).
Discovered by: Marcin Kita

2002-07-25
Several smaller enhancements and bug fixes.

2002-07-25
Enhancement: Recent File listing/Active help files are now available from the right click menu.

2002-07-25
Enhancement: Recent File listing is now available from the File menu, too.

2002-07-25
Enhancement: Listing of files with longer path names didn't fit it the available space on the 'Compare' and 'Window List' dialogs. From now on the cental part of the path will be replaced with an ellipse: [...].

2002-07-17:
Enhancement: From now on you can define more BlockEnd and BlockNotEnd delimiters in one line in the syntax files. This change was necesary to make the format of syntax files more consistent. Note: you can still use the old (one delimiter at a line) format but its usage is deprecated.

2002-07-16:
Enhancement: FilePath, FileExt, FileDir, FileTitle and FileName properties were added to the macro interface.

2002-07-16:
Fixed bug: The replace dialog uses 'a' as an accelerator for both the replace All, and match cAse controls. Discovered by: Scott Schlesier

2002-07-16:
Fixed bug: Printing with PrintInColor false still uses the BgColor for text background. Discovered by: Scott Schlesier

2002-07-15:
Fixed bug: If you have configured more than 10 user tools, tools with #>10 will be added to the menu each time you click on it. The menu item for user tool #10 shows the shortcut Ctrl+10 instead of Ctrl+0 although it works. All tools with #>10 shows an invalid shortcut (Ctrl+#) and are not working.
Discovered by: Silviu L
Note: From now the number of user defined tools is limited to 10.

2002-07-15:
Fixed bug: Double-click on a full-qualified file name in the OutputBar will open the file, but it will not jump to the line if the line number is 1. For example:

E:\Validate\Bin\index.htm:15:4:E: (invalid message) -it works
E:\Validate\Bin\index.htm:1:4:E: (invalid  message) - does not work
Discovered by: Silviu L

2002-07-15:
Fixed bug: If you select a text that contains special characters (such as ºãîþâ), the find dialog will display it as hex numbers (e.g. BA E3 EE FE E2), and CG will not be able to find the text. However, if you copy/paste the text in the find dialog it works.
Discovered by: Silviu L

2002-07-13
Enhancement: $FO wildcard was added (old 8+3 format of path name) for supporting legacy tools that don't work with long filenames.

Fixed bug: Case-insensitive searching of strings with national caracters in it didn't find all of the matches.
Discovered by: Witold Turzañski

Fixed bug: You couldn't execute tools from CG if the path to the tool contained one or more space characters.
Discovered by: Ryan Pusztai

Fixed bug: When using drag-and-drop text editing, the window automatically scrolled down and right but not up and left.
Discovered by: Silviu L

Fixed bug: Replace dialog always defaulted to replace in Selection if you selected some text prior opening the dialog. Discovered by: Irad

Fixed bug: When you inserted a bookmark at a line and then immediately right clicked on a different line (i.e. not clicking prior with your left mouse button) then the "Delete bookmark" menu item appeared instead of "Insert bookmark".
Discovered by: Marcin Kita

Fixed bug: Macro recording didn't correctly escape " characters in JavaScript macros.
Discovered by: Mitsu Hadeishi

Fixed bug: AddUserTool command in the configuration file ignored the InintialDir argument.
Discovered by: Josep Borrell

Fixed bug: Opening files whose name contained an ampersand (&) were displayed incorrectly on the tabbar.
Discovered by: Antoine

Fixed bug: A resource-leakage was discovered in the binary editor that eat up system memory during editing.

Fixed bug: Open-dialog popped up instead of Save when you wanted to save a recorded macro.
Discovered by: GargajUD

Fixed bug: New line indicator (\n) didn't get converted to new-line during a Replace in files operation
Discovered by: John Hunter

Fixed bug: Replace-all in the binary-editor resulted in an infinte loop, so CG stopped responding
Discovered by: Radek Sterba and Sven Gato Redsun

Fixed bug: Infinite loop stopped Code-Genie to response when you specified

Nest blockname blockname
in the syntax-file.
Discovered by: Petr Bubela

Fixed bug: There was a typo in the config file and in the help file. ('Whitesapce' instead of 'Whitespace')
Discovered by: websearch

Fixed bug: UserTools in the Tools menu duplicated whenever you saved the cgenie.conf file.
Discovered by: Equim

Fixed bug: Search in backward direction didn't work as expected at the very end of the file.
Discovered by: Equim

Fixed bug: Font settings were restored to their default values after you saved the cgenie.conf file.
Discovered by: Eric Jain

Fixed bug: 3 cursor movement-related bugs were fixed.
Reported by: Equim


Installing-Uninstall

System requirements
Windows 98 SE (or higher), Windows NT 4.0 (or higher).

Install
Extract all the files from the zip-archive to a directory you wish, and you are ready: run cgenie.exe. But don't forget that the zip archive contains subdirectories too, so preserve these subdirectories upon extraction.

Remove
In Code-Genie select Uninstall... from the Help menu.


About us

Contact, feedback and support

Below you can find the info you need to reach us and download the very-latest version of the program. On this page you find details about how to report bugs / submit feature-requests or obtain the source-code of the program.

DolfySoft
Budapest, Hungary
e-mail: support@code-genie.com
home-page: http://www.code-genie.com

Copyright notices

Code-Genie is the result of our own development. However, we have used other persons’ ideas and code during the development:

  • the menu-button is from Robert Kelly IV,
  • the MRU List of the directories found in the Open dialog is the idea of Rail Jon Rogout,
  • the Script Control is a free Microsoft product,
  • the sizing control bar was created by Cristi Posea,
  • the color-selector is from Alexander Bischofberger and Chris Maunder,
  • the MD5 algorithm is due to Ron Rivest,
  • while the PCRE regular-expression library is a product of Philip Hazel

Many Thanks to them.


I have found a bug

We hope you will never visit this page, but sometimes it is inevitable.

So you have found a bug. The first question is can you reproduce it? If you can, then it is really a bug.

Next go to the website and make sure that you have the latest version with the latest build-date of the program.

If the bug you just found is not fixed yet, please send us an email to support@code-genie.com with the Subject line filled with Code-Genie Bug. In the body of the letter please describe the bug in a way that I can repeat it later. And very important: We need the version and type of your Operating System along with the version number of Code-Genie (e.g. Ver. 3.11.10) you use. You can found it in the Help-> About Code-Genie... menu.
Please don’t forget these!

That is all.
Thanks.


Incremental search

When you switch this mode on every character you type will be added to the search string. Example: you hit button <A>, and the cursor will jump to the first occurance of the letter 'a' in the document. Now you hit <U> and the cursor will jump to the first occurance of the string 'au'. And so on.

To escape from incremental search mode just hit <ESC>.


What is new in V3.0?

New features:

  • Syntax files are now plain text files.
  • Config files are now plain text files.
  • Line numbering for the text editor.

Enhancements:
  • From now you can define background-colors for syntax elements.
  • Tabify and Tabify All are now separate commands. The first one replaces only leading whitespaces, while the other replaces all spaces to tabs.
  • More configuration options for the header and footer of printed pages.
  • File locking enhancements
  • Smaller enhancements/bug fixes.


Wildcards

Print-Headers, Print-Footers and User defined commands can accept wildcard arguments. The following wildcards are defined.

Description | Wildcard
File name: | $FN
File title: | $FT
File path: | $FP
File path in the old (8+3) notation: | $FO
File dir: | $FD
File extension: | $FE
Current directory: | $CD
Page Number: | $PN
Total No. of pages: | $PT
Time of printing: | $TP
Time of file: | $TF
Date of printing: | $DP
Date of file: | $DF
align Left: | $L
align Center: | $C
align Right: | $R

As you may already found out the last 9 wildcards apply to print-headers and footers only.


Binary Editor | View bytes as integers or floats

View bytes as integers or floats

Select 2, 4 or 8 consecutive bytes and right click on them. From the popup menu you can see what those bytes mean if they are interpreted as 2, 4 or 8 byte-long signed or unsigned integer or as 4 or 8 byte-long floating point number.

Of course the meaning of these bytes will depend on the byte-order of these files.


Text Editor | Cursor positioning and selection handling

Cursor positioning and selection handling

For better understanding treat the document as a one dimensional vector for now. The size of the vector is the size of the document and its elements are the characters themselves.

The text you selected in the editor is identified by two numbers: one represents the start position of the selection (SS) while the other represents the end position (SE) of the selection.

SE represents the position of the blinking cursor. This way SS is always the other end of the selection.

You can select a word in a way that the cursor will blink at the end, but you can select the same word in a way that the cursor will blink at the beginning of the word. This is the reverse selection. Therefore there is no restriction on which is bigger SS or SE. Only one thing is sure: the cursor will always blink at SE.

Obviously if SS=SE it means no selection and the cursor blinks at SE. When you move the cursor (SE) to a different location, SS should follow it or you will select some text. A shorthand for this is SSE (SS and SE).

See also:
SE
SSE
SelText
Macro Interface


Text Editor | Macro | AuxMove method

AuxMove method

Calculates the destination position of the cursor after a movement command, but doesn't move the cursor (i.e. SS and SE are unchanged).

Syntax
Doc.AuxMove posFrom, cgMode Remarks:
Here cgMode can be cgDocStart, cgDocEnd, cgLineStart, cgLineEnd, cgWordLeft or cgWordRight.

Example:

' Find out how long the 3rd line is?
' Move to the 3rd line
lineStart= Doc.LineToPos(3)
lineEnd=Doc.AuxMove(lineStart,cgLineEnd)
nLen=lineEnd-lineStart

See also:
LineToPos
Macro Interface


Text Editor | Macro | ChangeCase method

ChangeCase method

Changes the case of the currently selected text.

Syntax
Doc.ChangeCase cgMode

Remarks:
This method changes the currently selected text to lowercase, UPPERCASE or Capitalizes it. Has no effect if SS=SE.
cgMode can be one of the followings: cgLowerCase, cgUpperCase or cgCapitalize

Example:

' Select the last row of the doc, and UPPERCase it
Doc.SS=Doc.LineToPos(Doc.LineCount()-1)
Doc.SE=Doc.AuxMove(Doc.SS,cgLineEnd)
Doc.ChangeCase cgUpperCase
See also:
Macro Inteface


Text Editor | Macro | Clipboard property

Clipboard property

Get/Set the text content of the Clipboard.

Remarks

Example:

' simulating the Copy command
Doc.Clipboard=Doc.SelText

' simulating the Paste command
Doc.SelText=Doc.Clipboard
See also:
Macro Interface


Text Editor | Macro | Confirm method

Confirm method

The confirm message box lets you ask the user a "yes-or-no" question. Returns true if the user chose "Yes", and returns false in case of "No".

Syntax:
Doc.Confirm "YesNoQuestion"

Example:

bRet=False
while bRet<>True
    bRet=Doc.Confirm("Do you like Code-Genie?")
    if bRet=False Then
        Doc.MsgBox "Wrong answer! Try again"
    end if
wend
Doc.MsgBox "Nice boy/girl!"

See also:
Prompt
MsgBox
Macro Interface


Text Editor | Macro | CopyColumn method

CopyColumn method

Copies the selected column of text onto the Clipboard.

Syntax:
Doc.CopyColumn Separator

Remarks:
This method treats the text file as a separator-delimited data file, where each record is separated by a new line, and the elements of the records are separated by Separator. Separator can be a space, a tabulator, coma, semi-colon etc.
CopyColumn copies the selected column of text onto the Clipboard. For more info on selecting a column see block-selection.

See also:
DelColumn
Macro Interface


Text Editor | Macro | DelColumn method

DelColumn method

Deletes the selected column of text.

Syntax:
Doc.DelColumn Separator

Remarks:
This method treats the text file as a separator-delimited data file, where each record is separated by a new line, and the elements of the records are separated by Separator. Separator can be a space, a tabulator, coma, semi-colon etc.
DelColumn deletes the selected column of text. For more info on selecting a column see block-selection.

See also:
CopyColumn
Macro Interface


Text Editor | Macro | FilePath/FileName/FileTitle/FileExt/FileDir functions

FilePath/FileName/FileTitle/FileExt/FileDir functions

Get the path/name/title/extension/directory of the file the Doc object refers to. Read only.

Syntax

Doc.FilePath
Doc.FileName [file_path]
Doc.FileTitle [file_path]
Doc.FileExt [file_path]
Doc.FileDir [file_path]

As you can see the functions above (except the FilePath) has an optional argument [file_path] which is a string. If given it returns the Name, Title, Extension or Directory part of this string.

Example

Doc.SelText = "File Path  : " + Doc.FilePath + "\n";
Doc.SelText = "File Name  : " + Doc.FileName("c:\\Autoexec.bat") + "\n";
Doc.SelText = "File Title : " + Doc.FileTitle + "\n";
Doc.SelText = "File Ext   : " + Doc.FileExt + "\n";
Doc.SelText = "File Dir   : " + Doc.FileDir + "\n";

------------------------------------------------------
Output for the file
c:\home\progs\cg30\help\texted\macro\filepath.html

File Path  : c:\home\progs\cg30\help\texted\macro\filepath.html
File Name  : Autoxec.bat
File Title : filepath
File Ext   : html
File Dir   : c:\home\progs\cg30\help\texted\macro

See also:
SelText
Macro Interface


Text Editor | Macro | Find method

Find method

Searches for a text or pattern.

Syntax:
Doc.Find szFindWhat [, cgMode]

Returns:
The position of the next occurrence of the string, or –1 if not found.

Remarks:
Searches for the specified string szFindWhat. Search starts from SE, and doesn't wrap at the end of the document. By default the search is not case sensitive and the direction is downward. If there is no more occurrence of the search string the method returns -1. Else it selects the found text, so SelText can be used right after.
cgMode is optional, can be cgFindUp, cgFindCase, cgFindWholeWord and cgFindRegExp.

Example:

Doc.SSE=cgDocStart                           'Moves to the beginning of the document
nPos=Doc.Find("Hello", cgFindWholeWord)      'Searching for the word "Hello"

If nPos<>-1 Then                       'if found:
    Doc.ChangeCase cgUpperCase               'Make it UPPERCASE
Else
    MsgBox "Not found"
End If

See also:
Replace
SelText
ChangeCase
Macro Interface


Text Editor | Macro | GetChar method

GetChar method

Returns the character at the specified position

Syntax:
Doc.GetChar nPos

Remarks
nPos must be in the range of [0,Doc.GetSize).

See also:
Macro Interface


Text Editor | Macro | GetSize method

GetSize method

Returns the number of characters in the document.

Syntax:
Doc.GetSize

Remarks
Each new line (\n )will be counted as a single character.

See also:
Macro Interface


Text Editor | Macro | Indent method

Indent method

Indents the selected text.

Syntax
Doc.Indent

Remarks:
Works exactly as when you select text in the editor, and press TAB. If there is now selection, it is will insert a simple tabulator character at SSE.

Example:

Doc.SS=Doc.LineToPos(4)           'From the 5th line
Doc.SE=Doc.LineToPos(11)          'to the 11th line (inclusive!)
Doc.Indent                        'indent it

See also:
Unindent
Macro Interface


Text Editor | Macro | Short JScript Intro

Short JScript Intro

Preface:
This is an introduction to JScript and not a full documentation or a reference. We try to underline the most important concepts of this language only.

Syntax

  • JScript is not JavaScript, but is very close to it.
  • The language is case-sensitive.
  • Each line (statement actualy) ends with a semi-colon (;)
  • You can write two or more statements in one line by separating them with colon (,)
  • Each line starting with // will be treated as comment to the end of that line
  • For multiline comment use /* */
  • New variables can be declared using the var statement, but it can be omitted.
  • Variables are treated as Variants, so the followings are correct:
    a=1234
a="String"
a=34.56
  • = is used for assignments, == means equal, != means not equal.
  • Grouping: Multiple statements can be groupped in one statement using braces:
    statement={statement1;statement2,.../statementN;}
  • Branching:
    if condition
   statement
[else if(condition-n)
   statement]
[else
   statement]
  • Looping:
    for (initialization; test; increment)
   statement
  • Functions
    function FunctionName( [arglist] )
{
   [body]
   [return val;]
}
    Calling: retVal=FunctionName(arg1,arg2).
  • functions cannot be nested.
  • All the macro routines declared in Code-Genie can be reached under the Doc scope:
    Doc.SS=cgDocStart; //note here that cgDocStart is a constant defined by Code-Genie
nSize=Doc.GetSize();
  • JScript is case-sensitive, but the interface Code-Genie provides for the scripting engine in not-case-sensitive by default, so:
    Doc.selTeXt="text"; // lexically correct, but
Doc.SelText="text"; // should be used for clarity, but
doc.SelText="text"; // is not correct: doc should be Doc
These should be enough for writing your first JScript macros for Code-Genie. For further reading download the official JScript help file from www.code-genie.com/ufiles.html

See also:
VBScript Intro
Macro Interface


Text Editor | Macro | LineCount method

LineCount method

Returns the number of lines of the document.

Syntax:
Doc.LineCount

Remarks:
None

Example:

lines=Doc.LineCount

See also:
GetSize
Macro Interface


Text Editor | Macro | LineToPos method

LineToPos method

Translates line number to the start position of that line.

Syntax:
Doc.LineToPos nLine

Remarks:
Line numbers and positions start from 0. nLine must be in the range of [0, Doc.LineCount).

See also:
PosToLine
Macro Interface


Text Editor | Macro | MReplace method

MReplace method

Multiple-Replace. Similar to Replace, but here the szReplWhat and szReplTo parameters represent two equal-size arrays. The function applies to the selection if there is a selection, or to the whole document if there is no selection (SS<>SE).

Syntax:
Doc.MReplace szReplWhat, szReplTo [,szWhere [,szSeparator]]

Remarks:
szReplWhat and szReplTo are two strings, not Arrays. This is because passing arrays as argument unfortunately doesn't work reliably in VBScript and JScript. Hence we had to introduce an additional string argument szSeparator that specifies where to break apart the two input strings for creating those arrays. szSeparator defaults to |.

So the function will internally break apart the two input strings into two arrays of strings at the the separator you specify. It is obvious that the size of the resulting two arrays must be the same in size.

The other optional parameter is szWhere: if specified, the replacement will be made on this string instead of the text selected. In this case the function will return the resulting string.

Important note:
This function is not equivalent to the Replace() command executed in a loop M-times because it starts replacing all at once, not one after the other. See the example below:

Example:

// html-escaping

// the good-way:
var str=Doc.MReplace("<|>|&","&lt;|&gt;|&amp;");

// the wrong-way:
str=Doc.SelText();
var repl_what=Array("<",">","&");
var repl_to=Array("&lt;","&gt;","&amp;");
for(var i=0;i<repl_what.length;i++)
    str=Doc.Replace(repl_what[i],repl_to[i],0,str);

// the latter not only longer to type-in, but is erroneous too.

See also:
Replace


Text Editor | Macro | MsgBox method

MsgBox method

Displays a message box to the user with a message.

Syntax:
Doc.MsgBox szMsg

Remarks
VBScript users can use the default MsgBox method, too. Unfortunately JScript users cannot use the alert function, because alert is implemented under the window object, and the window object is implemented by the browsers only.

Example:

Doc.MsgBox "Hello World!"

See also:
Prompt
Macro Interface


Text Editor | Macro | PosToLine method

PosToLine method

Translates position to line number.

Syntax:
Doc.PosToLine nPos

Remarks:
Line numbers and positions start from 0. nPos must be in the range of [0, Doc.Size].

See also:
LineToPos
Macro Interface


Text Editor | Macro | Prompt method

Prompt method

Ask the user for input.

Syntax:
Doc.Prompt szPrompt

Example:

nAge=Doc.Prompt "How old are you?"
Doc.MsgBox "So you are "& nAge & " years old."

See also:
MsgBox
Macro Interface


Text Editor | Macro | Replace method

Replace method

Replaces a string with an other inside the selection, or in the whole document if there was no selection (SS=SE).

Syntax:
Doc.Replace szReplWhat, szReplTo [,cgMode [,szWhere]]

Remarks:
szReplWhat and szReplTo are strings. If szReplTo is an empty string, all occurances of szReplWhat will be removed.

The use of cgMode is optional. Its valid values are any combination of the followings: cgFindWholeWord, cgFindCase, cgFindRegExp.

The other optional parameter is szWhere: if specified, the replacement will be made on this string instead of the text selected. In this case the function will return the resulting string.

Note:
JScript/VBScript has a replace method too that works for regular expressions, but the RegExp-syntax inside Code-Genie is not compatible with the one found in JScript/VBScript, i.e. the same regexp behaves differently in most of the time.

Note:
Replace is not case sensitive by default.

Example:

Doc.SelText = Doc.Replace ("/c+/i","x\\0x",cgFindRegExp,"zz cC ss"); // returns 'zz xcCx ss'
// select the whole document
Doc.SS=cgDocStart;
Doc.SE=cgDocEnd;
Doc.Replace("house","House");

See also:
MReplace
Find
Macro Interface


Text Editor | Macro | Save method

Save method

Saves the current document to disk.

Syntax:
Doc.Save szFileName

Remarks:
szFileName must be the fully qualified path name of the destination file (so c:\dir\file.ext instead of file.ext).

See also:
Macro Interface


Text Editor | Macro | Selection End property

Selection End property

Get/Set the end position of the selection.

Set: can be any positive number in the range [0,Doc.GetSize] or cgDocStart or cgDocEnd
Get: returns the position of selection end

Example

Doc.SE=Doc.GetSize     ' position at the end of the file
Doc.SE=cgDocEnd        ' same as above
Doc.SE=5               ' the 5th character of doc
nSEPos=Doc.SE          ' get the pos of SE

See also:
Cursor positioning and selection handling
SS
SSE
SelText
Macro Interface


Text Editor | Macro | SelText property

SelText property

Get/Replace the selection

Replace: can be any string, if an empty string it removes the selected text, if there is no selection (SS=SE) then inserts text at SSE. SSE will be positioned after the inserted text.
Get: returns the selected text if any, or an empty string if there is no selection ( so SE=SS)

Example

' Format the next 5 characters as bold in HTML
Doc.SSE=Doc.SE                  ' SS=SE
Doc.SE=Doc.SS+5                 ' select the next 5 characters
sSelText=Doc.SelText
sSelText="<b>"+sSelText+"</b>"  ' <b>SelTx</b>
Doc.SelText=sSelText            ' and replace the old
' ------------------------------------------------
' Insert the string "Code-Genie" at the end of the document
Doc.SSE=cgDocEnd
Doc.SelText="Code-Genie"

See also:
Cursor positioning and selection handling
SS
SE
SSE
Macro Interface


Text Editor | Macro | Selection Start property

Selection Start property

Get/Set the start position of the selection.

Set: can be any positive number in the range [0,Doc.GetSize] or cgDocStart or cgDocEnd
Get: returns the position of selection start

Example

Doc.SS=Doc.GetSize     ' position at the end of the file
Doc.SS=cgDocEnd        ' same as above
Doc.SS=5               ' the 5th character of doc
nSSPos=Doc.SS          ' get the pos of SS

See also:
Cursor positioning and selection handling
SS
SSE
SelText
Macro Interface


Text Editor | Macro | Selection Start and End property

Selection Start and End property

Get/Set both the start and the end position of the selection in one step. This is a shorthand for SS=nPos,SE=nPos.

Set: can be any positive number in the range [0,Doc.GetSize] or cgDocStart or cgDocEnd
Get: returns SE (, since this is where the cursor blinks)

Example

Doc.SSE=Doc.GetSize     ' position the cursor at the end of the file
Doc.SSE=cgDocEnd        ' same as above
Doc.SSE=5               ' the 5th character of doc is the new cursor pos
nCursorPos=Doc.SSE      ' get the pos of the cursor (same as nCursorPos=Doc.SE)

'------- Append string to the end of the document
Doc.SSE=Doc.GetSize
Doc.SelText=vbNewLine+"This is the last row"

See also:
Cursor positioning and selection handling
SE
SelText
Macro Interface


Text Editor | Macro | Tabify method

Tabify method

Replace spaces with tabs where available.

Syntax: Doc.Tabify

Remarks:
The method applies to the selected text only. It has no effect if there is no selection (SS=SE).

See also:
Untabify
Macro Interface


Text Editor | Macro | TrimLeft method

TrimLeft method

Remove all the spaces and tabs from the beginning of lines.

Syntax:
Doc.TrimLeft [szWhat]

Remarks:
The method applies to the selected lines only. It has no effect if there is no selection (SS=SE).
szWhat is an optional parameter: Specifies what to remove from the beginning of each line. By default it trims spaces and tabs.

Example:

' Select all
Doc.SS=0
Doc.SE=Doc.Size
' Using without arguments
Doc.TrimLeft
' or removing the letter 'a' and 'b' from the beginning of each line
Doc.TrimLeft "ab"

See also:
TrimRight
Macro Interface


Text Editor | Macro | TrimRight method

TrimRight method

Remove all the spaces and tabs from the end of lines.

Syntax:
Doc.TrimRight [szWhat]

Remarks:
The method applies to the selected lines only. It has no effect if there is no selection (SS=SE).
szWhat is an optional parameter: Specifies what to remove from the end of each line. By default it trims spaces and tabs.

Example:

' Select all
Doc.SS=0
Doc.SE=Doc.Size
' Using without arguments
Doc.TrimRight
' or removing all the semi-colons (;) from the end of each line
Doc.TrimRight ";"

See also:
TrimLeft
Macro Interface


Text Editor | Macro | Unindent method

Unindent method

The opposit of Indent.

Syntax:
Doc.Unindent

Remarks:
Same as the Unindent command in the text editor. Similar to TrimLeft, but it doesn't necessarily remove all of the spaces from the beginning of the lines. It has no effect if there is no selection (so SS=SE).

See also:
Indent
Macro Interface


Text Editor | Macro | Untabify method

Untabify method

Replace tabs with spaces where available.

Syntax:
Doc.Untabify

Remarks:
The method applies to the selected text only. It has no effect if there is no selection (SS=SE).

See also:
Tabify
Macro Interface


Text Editor | Macro | Short VBScript Intro

Short VBScript Intro

Preface:
This is an introduction to VBScript and not a full documentation or a reference. We try to underline the most important concepts of this language only.

Syntax

  • The language is not case-sensitive.
  • Each line ends with a new line, so there are no semi-colons (;)!
  • You can write two or more commands in one line by separating them with colon (,)
  • Each line starting with ' will be treated as comment to the end of that line
  • New variables can be declared using the Dim statement, but it can be omitted. E.g.
    Dim variable1
dim myarray(7)
variable2 'Not using Dim
    Dim is for declaration only, so assignments are not allowed in one step:
    Dim a=5 ' not correct, instead:
dim a
a=5     ' correct
b=6     ' but Dim can be omitted if Option Explicit is not declared
  • Variables are treated as Variants, so the followings are correct:
    a=1234
a="String"
a=34.56
  • + is for addition & is for string concatenation of two expressions:
    a=5+7
b="5+7=" & (5+7)
' "b" will be store "5+7=12"
  • / is the division operator, while \ is the integer division operator:
    a=2.5
b=2.5/2 ' b now stores 1.25
c=2.5\2 ' c now stores 1
  • = is used for both assignments and for testing equality, <> means not equal.
  • Branching:
    If condition Then
    [statements]
[ElseIf condition-n Then
    [statements]]
[Else
    [statement]]
End If
  • Looping:
    For counter = start To end [Step step]
    [statements]
    [Exit For]
    [statements]
Next
  • Functions
    Function FunctionName [(arglist)]
    [statements]
    FunctionName=4 ' returns 4
End Function
    Calling: retVal=FunctionName(arg1,arg2)
  • Subs (procedures):
    Sub SubName[(arglist)]
    [statements]
    [Exit Sub]
    [statements]
    ' no return value!!
End Sub
    Calling SubName arg1,arg2 So NO round brackets!!!
  • Subs and Functions cannot be nested.
  • Exit statement: Exits from a sub, function, loop or branch:
    Exit Sub
Exit Function
Exit For
Exit If
  • All the macro routines declared in Code-Genie can be reached under the Doc scope:
    Doc.SS=cgDocStart 'note here that cgDocStart is a constant declared by Code-Genie
nSize=Doc.GetSize
These should be enough for writing your first VBScript macros for Code-Genie. For further reading download the official VBScript help file from www.code-genie.com/ufiles.html

See also:
JScript Intro
Macro Interface