<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8"> <TITLE>CAD_Appli_en.htm</TITLE> <META NAME="GENERATOR" CONTENT="OpenOffice.org 2.4 (Linux)"> <META NAME="CREATED" CONTENT="0;0"> <META NAME="CHANGEDBY" CONTENT="David Young"> <META NAME="CHANGED" CONTENT="20090913;7465500"> <META NAME="CHANGEDBY" CONTENT="David Young"> </HEAD> <BODY LANG="en-US" DIR="LTR"> <PRE> Applications are scriptprograms (directly executable). <h2>Functions Menu Applications:</h2> <B>Applications / Start </B> Selection and start of a program. Directory: {baseDir}/prg Filetyp: .gcap The program executed last can be started directly with Ctrl-P. Each program will automatically get a window; each window automatically gets 3 buttons: an Update, a Cancel and an OK button. <B>Update button: </B> (also rightMouseButton) the program is processed and displayed, but not saved. <B>Cancel button: </B> Cancel the program. <B>OK button: </B> (also Ctrl-rightMouseButton) Program is processed, all non-internal objects are transferred to the main program. <B>Applications / Edit </B> Starts a text editor for the active program. For further details, see "General program structure" below <B>Applications / Create </B> Creates a new program. Directory/file name of the executable files: {baseDir}/prg/{Programname}.gcap The program directory can be set/modified only in file: "{baseDir}/tmp/xa.rc" <I>How to create / test a new program: </I> Create an empty program (Create); Insert code (eg from examples); save (KEdit: Ctrl-S); Start program (with Ctrl-P); Cancel or OK. </PRE> <HR> <PRE> <B>General programme structure: </B> <I># block Declarations </I> INTERN .. # See INTERN. DLG .. # The DLG codes (dialogue) can place input fields in the form. # See definition Input form. <I># block initialize DLG-variables </I> # All variables used in input fields ( "DLG ..") must # be declared here. # This will also define the primary values of the fields specified. .. <I># Block Program Code </I> .. </PRE> <HR> <PRE><B>Program Code: </B> <B>Comment </B> The # character as the first character of a line defines a comment line. Lines with # at the beginning exist only in the program (.gcap); Lines with ## at the beginning are copied into the main program (.gcad). <B>Test output of text/variable content: </B> # (Only for testing purposes in the message window) PRI "text" PRI "Point1 =" p1 PRI "Var 1 =" v1 <B>Branch, unconditional jump command. </B> JUMP Label .. :Label # The target. Note: Label is case-sensitive. <B>Conditional branching with if </B> if value condition value ; command There are the following conditions: EQ equal, NE not the same, LT smaller, GT bigger, L_E less than or equal to, G_E bigger or equal. # Example: V20 = 10 :Next PRI "Var 20 =" V20 V20=V20+10 IF V20 LT 55 ; JUMP Next <B>V{#}=NEW({objTyp},{startIndex})</B> Returns the next free object number objTyp: P (point) L (line) C (circle) D (vector) S (curve) A (area) Example: V1=NEW(P,20) # Returns the first free point index number > 20 into variable 1. # Application: see the evaluation function (top brackets) <B>Evaluation function (top brackets) </B> An expression between brackets is replaced by its result. The result must be a numerical value. Examples: V1=10 V2=20 P<V1>=P(<V2> 0 0) gives: P10=P(20 0 0) P11=P(<X(P10)+1> 0 0) gives: P11=P(21 0 0) (Function X(P10) extracts the X-coordinate from point P10). D10=DZ D11=D(0 0 <Z(D10)>) gives: D11=P(0 0 1) (Function Z(D10) extracts the Z coordinate from vector D10). <B>DEBUG ON|OFF </B> ON: Display of test output; continue to the next program line with the Esc key. <B>EXIT </B> Exits the program. <B>INTERN {range ..}</B> Definition of variables that are needed only for calculations inside the program; these are not exported into the main model. INTERN must be within the first part of the programme (Declarations). Example: INTERN P1-P20 P50 V1-V20 V33 L1-L3 # All points from P1 to P20 and point P50 and ... # are only used internally, no export into the main model. </PRE> <HR> <PRE><B>Definition Input form: </B> # Display additional information: DLG TXT "{InfoText}" # Input from numerical values into V variables: DLG V{#} "{InfoText}" {fieldWidth} # Info text is next to the input field. # Input of points in point variables P: DLG P{#} "{InfoText}" {fieldWidth} # Input of vectors in vector variables D: DLG D{#} "{InfoText}" {fieldWidth} # Select checkbox DLG CKB V{#} "{InfoText}" # Check boxes, which are mutually exclusive, # get the same output variable. Example: TXT DLG test window DLG V1 "Length -" 150 DLG P1 "position" 150 DLG CKB V7 "Point" DLG CKB V7 "Circ" # V7 contains 1 if the "Point" is active # 2 if "Circ" is active. </PRE> <HR> <PRE><B>Key assignment: </B> Ctrl P starts last executed program; Esc: go into previous input field; during program execution: stop the process. in debug mode: continue with next program line. Tab: next input field. Right/outer mouse button: starts Update; Ctrl-right/outer mouse button: starts OK; </PRE> <HR> <PRE><B>Example programs: </B> </PRE> <HR> <PRE>#------------------ Declarations----------------- # do not export V1,V2 (internal use only) INTERN V1-2 DLG TXT Test CheckBox DLG V1 "X-Coord - " 60 DLG CKB V2 "Point" DLG CKB V2 "Circ" #------------------ Init Variables -------------- V1=10 # preSet 1="Point", 2="Circ" V2=1 #------------------ Program Code ----------------- if V2 eq 2; jump L_Circ P1=P(<V1> 0 0) PRI "V2=" V2 EXIT :L_Circ C1=P(<V1> 0 0) 2 # </PRE> <HR> <PRE>## create a single chain of points #------------------ Declarations----------------- # do not export the following variables with OK: INTERN P1 V1-10 D1 # put text lines into the panel DLG TXT Create linear point-pattern. DLG TXT Select or indicate starting point; DLG TXT Give offset (X-offset,y-offset,z-offset) DLG TXT Define number of points; DLG TXT Update: Button or right/outer mouse button DLG TXT in the main Window; DLG TXT OK: button or Crtl-Right/outer mouse button. # get starting point from user into P1; # input field size 150 DLG P1 " Startpoint " 150 # get point offset from user # Offset must be a Vector (3 values !) DLG D1 " OffsetVec." 150 # get number of points from user DLG V1 " nr of points" 150 #-------- initialise all dialog variables---------- P1=P(0 0 0) D1=D(10 0 0) V1=3 #----------program Code --------- #DEBUG ON # get a new point index for the output points # beginning with index 5 (preserve P1) V2=NEW(P,5) # initialise point Counter V3=0 # decode the starting point V4=X(P1) V5=Y(P1) V6=Z(P1) # decode the offset Vector V7=X(D1) V8=Y(D1) V9=Z(D1) :Next # increment counter V3=V3+1 # add offset V4=V4+V7 V5=V5+V8 V6=V6+V9 # create point with next index v2 P<V2>=P(<V4> <V5> <V6>) # increment point index V2=V2+1 if V3 lt V1 ; jump Next # </PRE> <HR> <PRE>Send bug reports and suggestions for improvement to franz.reiter@cadcam.co.at </PRE> </BODY> </HTML>