Appendix A. Caché Objectscript Reference
Total Page:16
File Type:pdf, Size:1020Kb
Appendix A. Caché ObjectScript Reference Commands Command Description Break[:cond] Interrupt execution of the current routine for debugging purposes. Break[:cond] [status] Activate or deactivate user interrupts. Close[:cond] device[:parameter] Close the device, make it available again for other users and, possibly, set the device characteristics. CONTINUE[:cond] End the current execution of the code block of a For, WHILE, or Do/WHILE loop and check the condition to determine whether a further iteration follows. Do[:cond] Invoke a subroutine or code block and continue the Do[:cond] {…} WHILE expression program processing with the next command after com- pletion. Do[:cond] entryref[(parameter)] Invoke a subroutine, pass the optional parameter and [:cond] continue the program processing with the next com- mand after completion. Else Execute the following commands only if the value of $Test is 0. Else {…} Execute the following code block only if none of the preceding If and ElseIf conditions were true. ElseIf expression {…} Execute the following command block only if none of the preceding If and ElseIf conditions were true and expres- sion is true. For Execute the remainder of the line or the following code For {…} block until a Quit or Goto command ends the loop. For variable=expression[,...] Repeat the execution of the following commands in the For variable=expression[,...] {…} routine line or the following code block for different For variable=start:increment:[end] values of a local variable. For variable=start:increment:[end] {…} Goto[:cond] Resume the normal execution of a routine that was interrupted with the Break command. Goto[:cond] location[:cond] Continue the program execution at another line or in another routine. Halt[:cond] Terminate the current Caché job and close the terminal session. Hang[:cond] seconds Suspend routine execution for the specified time. If Execute the following commands only if the value of $Test is true. If expression Test the expression and execute the remainder of the line If expression {…} or the following code block if the result is true. Job[:cond] routine[:cond][(routine- Start execution of a new Caché process. parms)][:[process-prams] [:timeout]] 351 Appendix A. Caché-ObjectScript Command Description Reference Kill[:cond] Delete all variables, only the specified variables, or all Kill[:cond] variable except the specified variables. Kill[:cond] (variable) Lock[:cond] Set or remove locks on local or global variables. Lock[:cond] [+/–]variable[,...] [:timeout] Lock[:cond] [+/–](variable[,...]) [:timeout] Merge[:cond] target=source Copy variable trees. New[:cond] Hide all, the specified, or all except the specified local New[:cond] variable[,...] variables in a subroutine. New[:cond] (variable[,...]) Open[:cond] device[:(parameter)] Open a device for later use and optionally set the device [:timeout][:"mnespace"] characteristics. Print [line1[:line2]] Output the specified routine lines to the current device. Quit[:cond] End the execution of a subroutine invoked with Do, Xecute, or For. Quit[:cond] expression End the execution of a user-defined function and return the value of the expression as result. Read[:cond] [f,][string,][f,] Read information from the current device. variable[:timeout] Read[:cond] [f,][string,][f,] *variable[:timeout] Read[:cond] [f,][string,][f,] variable#n[:timeout] Set[:cond] variable=expression Assign a value to one or more variables. Set[:cond] (variablelist)=expression TCommit[:cond] Confirm the current transaction and make all database changes permanent. TROllback[:cond] Abort the current transaction and revoke all database changes. TStart[:cond] Mark the start of a transaction. Use[:cond] device[:(parameter)] Make a previously opened device the current device and [:timeout][:"mnespace"] optionally set the device characteristics. View block Modify a memory location or read and write database View offset:mode:length:new-value blocks. Reserved for internal use by Caché. WHILE expression {…} Repeat execution of the following code block until expression evaluates to false. Do {…} WHILE expression Define the end condition after a Do/WHILE code block. Write[:cond] [f,]expression Output characters to the current device. Write[:cond] [f,]*expression Xecute[:cond] expression[:cond] Execute Caché ObjectScript code that is stored as data. ZBreak Set a break point for debugging purposes. ZInsert "code"[:location] Insert a line into the routine currently being edited. ZKill variable Delete a local or global variable without deleting its child nodes. ZLoad [:cond] Load a routine for editing. ZLoad routine ZNspace expression Change the current namespace. ZPrint Output the specified routine lines to the current device. ZPrint line1[:line2] 352 Command Description Functions ZQuit Remove all or a specified number of execution levels ZQuit[:cond] expression from the execution stack. ZRemove Delete all or the specified lines from the routine currently ZRemove line1[:line2] being edited. ZSave Store the routine (possibly with a different name). ZSave routine ZSYNC Ensure that all logical transactions have also physically completed. ZTrap[:cond] Force an error with the specified message or with the ZTrap[:cond] expression default message <ZTRAP>. ZWrite Write the values of all local variables or of the specified ZWrite variable local or global variable to the current device. ZZDUMP (expression) Write the string as hexadecimal dump to the current device. Functions Function Description $Ascii(expression[,position]) Return the ASCII code of a character. $BIT(bitstring,position[,bitvalue]) Create a new bit string if needed and optionally set the bit value at the specified position. $BITCOUNT(bitstring[,bitvalue]) Count the number of bits in the bit string, either all or those with the specified bit value. $BITFIND(bitstring,bitvalue[,startpos]) Search for a bit value in a bit string and return that position. $BITLOGIC(bitstring_expression Perform a bit logic operation on the bit string. [,length]) $CASE(expression,result:value,…) Evaluate expression and return the value after the result that applies. $Char(expression[,...]) Produce a string with the specified ASCII code from a list of integers. $Data(variable) Specify whether a variable reference is defined, has successors, or both or none applies. $Extract(expression[,from[,to]]) Return apart of a string from a start position to an end position. $Find(string,substring[,position]) Return the end position of the substring in a string. $FNumber(number,format[,decimal]) Return the value of an expression in the format specified by the user. $Get(variable[,default]) Return the value of a variable if it exists. $Increment(variable[,num]) Increment the specified variable by 1 or the specified value. $INumber(number,format[,erropt]) Check a number for the specified format and convert it into the internal representation. $ISOBJECT(variable) Check whether the specified variable is a valid OREF. $Justify(expression,width[,decimal]) Return a right-justified value and optionally format and round it numerically. $Length(expression[,delimiter]) Return the length of a string in characters or the number of substrings separated by the specified delimiter. $LIst(list[,from[,to]]) Return the list elements in the specified range. $ListBuild(element,...) Create a list with the elements specified as arguments. 353 Appendix A. Caché-ObjectScript Function Description Reference $ListData(list[,position]) Test whether an element in the list is present and has a value. $ListFind(list[,value [,start]]) Search for a value in a list beginning at the specified start position. $ListGet(list[,position[,default]]) Return the value of a list element if it exists. $ListLength(list) Return the number of elements in a list. $NAme(variable[,number]) Return the name of variable in canonical form with at most the specified number of dimensions. $Next(variable) Return the next index of a variable in the specified di- mension. $NUMber(number[,format[,min Validate a number and convert it into the canonical [,max]]]) Caché format. $Order(variable[,direction]) Return the next or previous index of a variable in the specified dimension. $Piece(expression,delimiter Return one or more substrings separated by the specified [,from[,to]]) delimiter. $QLength(reference) Return the number of dimensions for the indexed vari- able. $QSubscript(reference,number) Extract the specified number of dimensions from the indexed variable. $Query(reference[,direction]) Return the next or previously defined reference for an indexed variable. $Random(range) Return a pseudo random number in the specified range. $REverse(string) Return the characters of the string in reversed sequence. $Select(expression:value,...) Return the value after the first expression that evaluates to TRUE (i.e., 1). $SORTBEGIN(global) Start a special sorting mode for the specified global. $SORTEND(global[,save]) End the sorting mode for the global and save any up- dated data. $STack(context_level[,code_string]) Return information about the active execution context on the call stack. $Text(location) Return the source text of a routine line. $TRanslate(string,replace[,by]) Return a string in which specified characters were re- placed by other specified characters (or were removed). $View(address[,mode,length]) Return the contents of a memory location. $ZABS(n) Return the absolute value of a number (without sign). $ZARCCOS(n) Return the arccosine of a number between –1 and 1. $ZARCSIN(n) Return the arcsine of a number between –1 and