PG.DLL     Adept V+ Extensions for CodeWright
   by: Dave Templin


BUG FIXES AND ENHANCEMENTS

	Revision History

	  10/04/93
		- Updated for CodeWright V3.0

	  08/11/93
		- Fixed indenting so that the cursor is now correctly placed
		  beneath the IF..GOTO statement.
		- Fixed MC line colorization so that comments are still colored
		  in the comment color, instead of being colored with the rest
		  of the line in the monitor command color.
	  08/08/93
		- Fixed indenting so that the cursor is now correctly placed
		  beneath all control structure keywords (i.e. DO, WHILE, FOR,
		   CASE, VALUE).
		- Added color category for monitor command lines under
		  COLOR_ALTERNATE_4.
	  07/15/93
		- Updated for CodeWright V2.0i
		- Support for string and number coloring.
		- Added line number coloring.
	  01/15/93
		Initial code for CodeWright V2.0h and Adept V+ Version 10.4.

	Known Bugs

		- ChromaCoding of values with "^" includes the plus/minus sign
		  in the digit count.  (i.e. ^11111111 is colored but ^-11111111
		  is not colored).

		- Some keywords are not colored after a template expansion.
		  Seems to be related to some type of buffer over-run when the
		  user is typing rapidly immediatly following a template
		  expansion.

		- Smart indenting doesn't work after control structure keywords
		  that are followed by a comment.

		- Should not colorize text that is not within a ".PROGRAM"..".END"
		  text block.


INTRODUCTION

	This file provides documentation of the Adept V+ language extensions for
	the CodeWright editor.  The language extensions come in the form of a
	single file, PG.DLL, that can be easily installed into the CodeWright
	application.

	Adept V+ is the native programming language of all Adept robot/vision
	controllers from Adept Technology, Inc [San Jose, CA, (408) 432-0888].

	CodeWright is a professional quality programmers editor that runs under
	Microsoft Windows 95, 98, 2000, or NT 4.0.  CodeWright is manufactured by Starbase
	Corp. [Portland, OR, (503) 647-9902].

	The PG.DLL file is a DLL (Dynamic Link Library) written especially for
	CodeWright to enhance the programming environment when working on
	Adept V+ code.  Specifically, support for the following features has
	been added:
		- ChromaCoding
		    colorizing keywords and programming structures in the body
		    of your code
		- Language Indentation
		    automatic indentation of control structures
		- Template Expansion
		    simple keystrokes that expand into more verbose code
		    expressions
		- Selective Mode
		    ability to collapse and expand files containing multiple
		    programs

	The programming environment provided on the standard Adept platform is
	regarded by many to be too difficult to develop large programming
	applications.  The minimalistic file operating system, lack of programming
	tools for global file operations, and slow file transfer performance are
	serious inconveniences to those who are used to developing under more
	sophisticated environments.

	CodeWright is very useful for developing large programming applications
	for those who prefer to work from MS-DOS and Windows.  Programs can be
	edited off-line from the Adept controller where the programmer has
	access to CodeWright and any other DOS utilities that s/he may have.
	The code can then be transferred back onto the Adept controllers for
	debug and final installation via 3- inch diskettes or RS-232 serial
	communications.


DISTRIBUTION FILES

	The following files are included:

		PG.DLL        - The Adept V+ CodeWright extensions DLL
		PG            - Makefile for Microsoft C; change for Borland
		PG.C          - The modified Starbase C source code
		PG.DEF        - The object definition file, for Windows
		README.TXT    - This file, describing the package

	Only the PG.DLL file is required for use of the Adept V+ language
	extensions.  All other files may be deleted.


INSTALLING THE DLL


	Installation of the Adept V+ extensions for CodeWright are provided
	below in three (3) simple steps.

	1. Start out by ensuring that the CodeWright application is not loaded into
	   memory. With the Windows Explorer or from the DOS command line, copy the
	   PG.DLL file to your ..\CWRIGHT directory.
	  
	2. Load CW and go to the Customize|Libraries dialog. 
	3. Click 'Add'.
	4. Browse for the file pg.dll.
	5. Double click pg.dll to load it.
	6. Click OK. The above steps will insert the following line in your
	   CWRIGHT.INI file under the [LibPreload] section:

		LibPreLoad=pg.dll

	   This tells CodeWright to load the Adept V+ DLL program into memory when
	   the CodeWright application is starting.


	3. From the CodeWright pull-down menus, select the
	   Customize|Language|Coloring dialog.
	   
		a. Click 'New Type'.
		b. Type pg.
		c. On the Templates tab check the TEMPLATE EXPANSION check box.
		d. On the Tabs/Indenting tab, type "9 17" into the TAB COLUMNS text box.
	    e. Press the OK button to accept the changes and close the dialog box.
	  
	CodeWright will now recognize all file-names with the ".PG" extension as
	Adept V+ files.  The ChromaCoding, Language Indentation, Template
	Expansion, and Selective Mode features will now be available for use while
	editing Adept V+ files!

	Initially, the ChromaCoding colors may not be set.  Change the ChromaCoding
	colors to suit your preferences, refer to the section entitled CHROMACODING
	below.


ADDING MORE EXTENSION NAMES

	You may use file-name extensions in addition to ".PG" to denote Adept V+
	program files.  If so, then follow the procedure below to add the
	extensions that you would like CodeWright to recognize as Adept V+ files.

	This procedure shows how to tell CodeWright to recognize files with a ".V2"
	extension as Adept V+ files, in addition to files with a ".PG" extension.


	1. Go to Customize|Language

	2. Click 'New Type'

	3. Type the extension of the file type you would like to use

	4. Click OK.

	5. Click 'Map Type To...'.

	6. Type .pg.

	7. Click OK.
	
	8. Repeat this procedure for any other extensions that you wish to add.



ADDING FILE FILTERS

	You may want to create file filters for the FILE..OPEN dialog box.
	This will allow CodeWright to display only file names that are Adept V+
	files when opening files.


	1. From the CodeWright pull-down menus, select the FILE..FILTERS menu item.
	   The FILE FILTERS dialog box should appear.


	2. Type the following into the DESCRIPTION text box:

		Adept V+ (*.pg;*.v2)


	3. Type the following into the PATTERN text box:

		*.v2;*.pg


	4. Press the OK button to accept the changes and close the dialog box.


	Note: Be sure to include any other file extensions that you may have
	      specified from the ADDING MORE EXTENSION NAMES section.


CHROMACODING

	ChromaCoding is a feature in CodeWright that recognizes Adept V+
	keywords and code structures and colorizes them accordingly.  This
	feature gives the programmer some immediate feedback on the structure
	of his/her code.  The chapter entitled, "View Setups and Language Support" in 
	the CodeWright User's Guide provides documentation on this feature.

	The table below shows the diffent attributes of Adept V+ code that
	CodeWright is able to recognize and color.  All colors may be adjusted from
	the Customize|View Setups dialog box.  This dialog box is accessed by selecting
	by selecting the Customize|View Setups menu item from the CodeWright pull-down
	menus.

	Attribute          Screen Element
	----------------   -----------------------
	comment            Comments
	keyword            Keywords
	string literal     Alternate 1: strings
	number             Alternate 2: numbers
	monitor command    Alternate 4: preprocess
	operator           Alternate 5
	line number        Alternate 6

	Comment
		A comment is any text that follows a semi-colon (;) character on
		a line.

		EXAMPLE:   ; This is a comment.

	Keyword
		A keyword is any text that is in the dictionary of Adept V+
		keywords and not a part of a variable name, comment, or string
		literal.  All of the documented (and some undocumented!) keywords
		for Adept V+ and AdeptVision are known by the module.

		EXAMPLES:  MOVE, IF, GOTO, TRUE, DEPART

	String Literal
		A string literal is any text that is closed within a set of two
		quote (") characters on a single line.

		EXAMPLES:   "This is a string literal...", "Hello world!"

	Number
		A number is any one of the following:

		  1. real numbers
		       Text that includes digits, a period, and the 'E' character
		       in the proper sequence.

		       EXAMPLES:  42, -3.14E+12, 0.667

		  2. character constants
		       The two character sequence of an approstrophe followed by
		       any character.

		       EXAMPLES:  'A, '1, 'z

		  3. binary, octal, or hexadecimal numbers
		       Digits and letters that follow the circumflex (^)
		       character.

			   EXAMPLES:  ^B1101, ^7237, ^H3D0, ^H-4F

	Monitor Command
		A monitor command is any text that follows the 'MC' keyword,
		when the 'MC' keyword is the first word on a line.

		EXAMPLE:  MC FCOPY c:\auto.v2=a:\auto.v2

	Operator
		An operator is any of the following characters:
		   +   -   *   /   (   )   [   ]   :

	Line Number
		A line number is any sequence of digits that follows a "GOTO"
		keyword, or that appears as the first set of characters on a
		line.

		EXAMPLES:   GOTO 45
			    45 RETURN


LANGUAGE INDENTATION

	CodeWright is aware of how to properly indent Adept V+ control
	structures.  When the <ENTER> key is pressed on a line that contains a
	control structure keyword (i.e. IF, FOR, WHILE, CASE) CodeWright will
	place the cursor so that the new line is properly indented with respect
	to the previous line.

	To enable language indentation, refer to step 3c from the
	INSTALLING THE DLL section of this document.


TEMPLATE EXPANSION

	Template expansion is a feature in CodeWright that automates certain
	key sequences in order to save the programmer some typing work.  When
	the first few characters of a word are typed, followed by pressing
	<SPACE>, CodeWright will expand the text into Adept V+ code and will
	place the cursor at a conveiniant location.  The chapter entitled,
	"Editing and Printing" in the CodeWright User's Guide
	provides documentation on this feature.

	To enable template expansion, refer to step 3c from the INSTALLING THE DLL
	section of this document.

	With this feature is enabled, template expansion may be avoided for a
	single instance by pressing <SHIFT>-<SPACE> instead of <SPACE> alone
	after text that is a valid template.

	EXAMPLES:

	    Typing ".p" followed by <SPACE> expands into:
		.PROGRAM ()
		.END
	    The cursor will be placed just to the left of the opening
	    parenthesis.

	    Typing "ifg" followed by <SPACE> expands into "IF  GOTO".
	    The cursor will be placed between the "IF" and the "GOTO".

	    Typing "enp" followed by <SHIFT>-<SPACE> avoids template expansion
	    that otherwise would have been expanded into "ENABLE POWER".

	Below are listed all the templates that are built into the Adept V+
	language extensions module.  Text in upper-case indicates the minimum
	amount of the template that must be typed before the tempate will be
	expanded.  The rest of the text, in lower-case, is optional.
	The ampersand (&) shows the placement of the cursor after expansion has
	been performed.

		.Program              .PROGRAM &()
		                      .END

		ANY                   ANY

		Auto                  AUTO &

		AR                    AUTO REAL &

		AL                    AUTO LOC &

		APpro                 APPRO &, 

		APpro Break           APPRO &, 
		                      BREAK

		APproS                APPROS &, 

		APproS Break          APPRO &, 
		                      BREAK

		ATtach                ATTACH (&)

		BReak                 BREAK

		CALL                  CALL &()

		CASe                  CASE & OF
		                      END

		CASe;                 CASE & OF
		                      END ; case

		DECompose             DECOMPOSE &[] = 

		DePart                DEPART &

		DePartS               DEPARTS &

		DePart Break          DEPART &
		                      BREAK

		DePartS Break         DEPARTS &
		                      BREAK

		DETach                DETACH (&)

		DISable               DISABLE &

		DISP                  DISABLE POWER

		DO                    DO
		                      UNTIL &

		DOS                   DOS "&"

		ENable                ENABLE &

		ENP                   ENABLE POWER

		ENV                   ENABLE VISION

		EXecute               EXECUTE &()

		FOR                   FOR & TO 
		                      END

		GOto                  GOTO &

		IF                    IF & THEN
		                      END

		IF;                   IF & THEN
		                      END ; if

		IFElse                IF & THEN
		                      ELSE
		                      END

		IFElse;               IF & THEN
		                      ELSE
		                      END ; if/else

		IFG                   IF & GOTO 

		Local                 LOCAL &

		MC                    MC &

		MCS                   MCS "&"

		MoVe                  MOVE &

		MoVe Break            MOVE &
		                      BREAK

		MoVeS                 MOVES &

		MoVeS Break           MOVES &
		                      BREAK

		PARameter             PARAMETER & = 

		PRompt                PROMPT "&", 

		RELease               RELEASE

		RETurn                RETURN

		SET                   SET & = 

		SIgnal                SIGNAL &

		SPeed                 SPEED &

		SPA                   SPEED & ALWAYS

		TYpe                  TYPE &

		VALue                 VALUE &:

		VFind.Arc             VFIND.ARC(&)

		VFind.Line            VFIND.LINE(&)

		VFind.Point           VFIND.POINT(&)

		VLOCate               VLOCATE(&)

		VPICture              VPICTURE(&)

		VRULer                VRULER(&)

		Wait                  WAIT

		W.                    WAIT.EVENT , &

		WHile                 WHILE & DO
		                      END

		WHile;                WHILE & DO
		                      END ; while

		WRite                 WRITE (&)


	Note: Any of these templates may be altered directly from the CodeWright
	      menus.  Follow the procedure below to add to or alter the templates.

	1. From the CodeWright pull-down menus, select the
	   Customize|Lanaguage|Templates menu item.
	   The Templates dialog box will appear.

	2. Select the ".PG" item from the File type list box.
	   ( Note that you cannot select any of the ".PG" aliases, i.e. ".V2";
	     however the changes will apply to all aliases. )

	3. Modify the templates as desired.
	   When done, press the OK button to accept the changes and close the
	   dialog box.


SELECTIVE MODE

	CodeWright has a feature that allows the user to get a collapsed view
	of a file that contains several programs.  This feature is supported for
	Adept V+ with the API routine named, "routines".  The chapter entitled,
	"Search and Replace and Navigational Tools" in the CodeWright User's Guide provides
	documentation on this feature.

	To use this feature, select the Tools|API Command menu item from the
	CodeWright pull-down menus and type the word, "routines" into the
	diaglog box.  This will collapse the text in your current buffer to show
	only the lines starting with ".PROGRAM".

	While in selective mode, you can collapse and expand sections of the
	buffer at will by positioning the mouse pointer over a
	collapsed/expanded line(s) and double-clicking the right mouse button.
	This provides an "outline view" of a complex file with many programs.

	To exit selective mode and return to normal mode, simply press <ESC>.

	This feature can be more convieniantly accessed by binding the
	"routines" API command to a key.  Use the "Assign Keys" dialog box from
	the Customize|Keyboard menu item on the CodeWright pull-down menus.  

	It is recommended that you bind the "routines" API command to the
	<CONTROL>-<SHIFT>-<SPACE> key combination.  This is consistant with the
	key-bindings for other modes (i.e. hex mode) and this key combination is
	unassigned in the default CodeWright configuration for both the CUA and
	BRIEF keymaps.

