$delete

Deletes a portion of a character string.

Syntax

$delete(source,position,length)

Parameters

sourcea character string or an expression that evaluates to a character string
positiona number or an expression that evaluates to a number
lengtha number or an expression that evaluates to a number

Return Value

Character string, consisting of source, less those characters starting at position, for a length of length.

Comments

In a string, the position of the first character is always 1. If position is beyond the end of source, or if position is zero or negative, then no characters are deleted from source.

If length is zero or negative, then no characters are deleted from source.

If there are fewer than length characters from position to the end of source, then all characters from position to the end of source are deleted.

Example

$delete("abcdef",2,2)

Evaluates to “adef”.

$delete("613-555-1234",1,4)

Evaluates to “555-1234”.

See Also

$concat

$fill

$insert

$left

$position

$replace

$right

$squeeze

$substring

About Character Literals

About Data Types

About Functional Expressions

$Exist$

Checks whether a given Zim object exists in a Zim directory.

Syntax

$exist$([Zim directory name | Object Owner], object name, object type)

Parameters

Zim directory name or Object OwnerA character string or an expression that evaluates to a character string, naming the ZIM directory or the object owner to which the object would belong
object nameA character string or an expression that evaluates to a character string specifying the object name to be checked in the Zim directory name or within the object owner for its existence
object typeA number or an expression that evaluates to a number determining the type of the object name

Return Value

It returns a $True value if the object name is defined in the Zim directory and is of the specified object type.

It returns a $False value if the object name is not defined in the Zim directory or is not of the specified object type or the Zim directory name is already accessed.

If the object type is 0 (zero), the function will return the object type of the object for subsequent reading of the status of this object (see example).

If the object type is non-zero and the Zim directory name is empty (“”), then the return value is the owning directory name of that object.

Comments

The types of the object are described as the following table:

Object TypeMeaning
0Returns the Object Type
1A Null Object
2Shadow Directory
3Directory
4Entity Set
5Field
6Relationship with no Fields
7Relationship with Fields
8Set
9Document
10List
11Form
12Role
13Variable
14Display
15Virtual Field
16CSet
17Window
18Constant
19Menu

Examples

Check whether the directory “Accounting” is defined in Zim:

$exist$("ZIM", "Accounting", 2)

Investigate the type of the object “Customers” in directory Zim and then test whether it exists or not:

let Var = $exist$("ZIM", "Customers", 0)
out $exist$("ZIM", "Customers", Var)

$ObjRunMethod

Run the methods of an ActiveX object.

Syntax

$ObjRun[Method] (Object, MethodName, «Parameters»)

Parameters

Objectan object variable or formfield of type OLE
MethodNamea string or an expression that evaluates to a string
Parametersone or more optional arguments as per the specifications of the object

Return Value

Returns a result as per the specification of the object.

Note: Zim attempts to convert to the assigned type. Ensure a proper variable type is assigned.

Comments

Parameters can be named. If they are named, they do not need to be entered in any particular order. Named parameters contain the name of the parameter, an equal sign, and the value of the parameter.

$null can be used to maintain position of optional parameters in unnamed argument list. Unnamed parameters must precede named parameters in argument list.

If you require it, you can have OLE objects return values by reference, since ZIM passes all variables by reference to OLE objects.

Example

The add method of Treeview is described as having the following syntax:

INode* Add(
      [in, optional] VARIANT* Relative,
      [in, optional] VARIANT* Relationship,
      [in, optional] VARIANT* Key,
      [in, optional] VARIANT* Text,
      [in, optional] VARIANT* Image,
      [in, optional] VARIANT* SelectedImage);

Assume you have a form called treeview with a treeview component on it called tree.

Assume vNode is a variable of type object. The syntax to add a node to the treeview’s nodes object is provided below.

compute all myset wh $distinct (custs.cc) is not $null evaluate 
 ( let vNode = $ObjRunMethod ( vNodes, 'Add', 
     % placeholder for relative
     % placeholder for relationship
    $squeeze('', 'c',$trim(custs.cc)), %unnamed argument for Key
    $squeeze('','text=',$trim(custs.company)))) %named argument for Text

Assume the variables sWidth and sHeight are integers and the variable vole is an object. The following example retrieves the object’s width and height given a display with two months high and three months wide:

let vole = $ObjCreate("mscomctl2.monthview.2")
out $ObjRunMethod(vole,"ComputeControlSize",3,2,sWidth,sHeight)

Warning

COM objects are being discontinued by Microsoft and may not be available in future releases of Zim-X.

$translate

Replaces segments of a character string with new text.

Syntax

$translate(source,pattern,replace)

Parameters

sourcea character string, or an expression that evaluates to a character string
patterna character string, or an expression that evaluates to a character string
replacea character string, or an expression that evaluates to a character string

Return Value

Character string, consisting of source, with replace substituted for all occurrences of pattern.

Comments

Use $translate to substitute portions of source with replace. If source, pattern, or replace are not of a character data type, they are converted to a character data type before the function is applied.

If source is of data type ALPHA or VARALPHA, searches for pattern are case-insensitive; otherwise, searches for pattern are case-sensitive.

Example

$translate("the slow brown fox","slow","quick")

Evaluates to “the quick brown fox”.

% translates Smith to Smythe
list all Employees where LastName = "Smith"
format FirstName $translate(LastName,"ith","ythe")

Translates occurrences of Smith to Smythe in the field LastName.

See Also

$concat

$delete

$fill

$left

$position

$replace

$right

$squeeze

$substring

About Character Literals

About Functional Expressions

$copytoclient

Copies files from the server side to the client side.

Syntax

$copytoclient(source file name, destination file name, file type)

where

source file namean expression that evaluates to a character string containing a valid file address
destination file namean expression that evaluates to a character string containing a valid file address
file typean expression that evaluates to a character string that starts either with “B” (from “Binary”) or “T” (from “Text”)

Return Value

The value return by this function is the file address of the destination if it is executed correctly; otherwise, it will return a $Null value.

Comments

This function is designed to work under ZIMTC and copies file from the server side to the client side using the file type specified. Files of the binary type are sent as they are, without their contents being checked (like images, videos, etc). On the other hand, files of the text type are copied using text file conventions for Windows and Unix.

Both the source and the destination file names can be either relative or absolute file paths. The following remarks apply to these paths:

source file is absolutethe file is taken from the absolute path
destination file is absolutethe file is written onto the absolute path. Care should be taken because this absolute path refers to a location in the client’s machine; if there are many different users running, all users must have the same valid address
source file is relativenormally, the current directory is the database directory; therefore, the file will be taken from an address calculated inside the current directory
destination file is relativethe file goes to place that is relative to the current directory in the client session which is always where the Zimtc session has been started; therefore, if the file is needed for subsequent operations, then the same relative path must be used. If the file will be needed after the current session is finished, then it is suggested to provide an absolute path to the destination file as Zimtc does not guarantee that files will be preserved after the session finishes

Because ZIMTC actually acts like a Web Browser in most respects, the client side (managed by ZIMTC) does not have the files needed to perform certain operations which should be located in a place only known by the server. This situation is specially important when the file is needed by an external processing capability like an ActiveX component or any other program that uses a file without the direct control of ZIMTC.

If the destination file name contains sub-directories that don’t exist, they are created.

The ZIM executable ignores this function as it makes no sense copying a file to itself.

Example

This is an invocation of an ActiveX property to edit the file specified. It reads the file from a fixed location but writes it to the directory where the session has been started.

let vResult = $objsetproperty(Object, "image", $copytoclient("c:\myfiles\myimage.bmp", "myfiles\myimage.bmp", "binary"))

This example copies the text file from the database path to a fixed location in the client’s machine.

out $copytoclient("mytext.txt", "c:\mextext.txt", "T")

Related Topic

$copytoserver

$substring

Extracts a segment of a character string.

Syntax

$substring(source,position,length)

Parameters

sourcea character string, or an expression that evaluates to a character string
positiona number, or an expression that evaluates to a number
lengtha number, or an expression that evaluates to a number

Return Value

Character string, containing a string extracted from source, whose first character is position characters into source, and whose length is length characters.

Comments

Use $substring to extract a portion of source. The resulting string contains length characters, starting position characters into source.

If source is not a character data type, it is converted to a character data type before the function is applied.

If position is beyond the end of source or if length is zero or negative, the result is the null string.

If position+length is longer than source, the result consists of all characters from position to the end of source.

Example

$substring("the quick brown fox jumped",7,5)

Extracts “ick b” from the string.

$substring(9999,1,1)

Evaluates to ” ” (the number is converted to a string).

$substring(5+4,17,1)

Evaluates to “9” (the number is converted to a string).

See Also

$concat

$delete

$fill

$insert

$left

$position

$right

$squeeze

$translate

About Character Literals

About Functional Expressions

$replace

Replaces a portion of a character string with another character string.

Syntax

$replace(source,position,length,string)

Parameters

sourcea character string, or an expression that evaluates to a character string
positiona number, or an expression that evaluates to a number
lengtha number, or an expression that evaluates to a number
stringa character string, or an expression that evaluates to a character string

Return Value

Character string, consisting of source, with the characters starting at position for a length of length replaced by the characters from string.

Comments

Use $replace to replace, in source, the characters starting at position for a length of length, with string.

In a string, the position of the first character is always 1. If position is beyond the end of source, or if position is zero or negative, then source is left unchanged.

If length is zero or negative, then string is embedded in source starting at position (effect is like $insert).

If there are fewer than length characters from position to the end of source, all characters from position to the end of source are replaced by string.

Example

$replace("abcdef",2,2,"123")

Evaluates to “a123def”.

See Also

$concat

$delete

$fill

$insert

$left

$position

$squeeze

$substring

$translate

About Character Literals

About Functional Expressions

$compilestatus

Checks if an application program needs to be recompiled.

Syntax

$compilestatus(docname)

Parameters

docnamethe name of an application document (not in quotation marks)

Return Value

Number, with no decimal places.

Comments

$compilestatus checks, in order, a series of conditions in relation to docname. As soon as docname fails to meet a condition, $compilestatus returns the code number (1 through 8) associated with that condition. If docname meets all the conditions, $compilestatus returns a 0.
A $compilestatus expression can be compiled, but its value is fixed at compile time and does not change thereafter.

CodeCondition
1The docname is not currently compiled.
2The source file for docname is missing.
3The compiled file for docname is missing.
4The source file bears a date more recent than that of the compiled file.
5No dependency information could be found for docname.
6The dependency information predates the most recent compile and could therefore be out of date.
7An object that docname depends on could not be found, it can be erased or located in an unaccessed directory.
8An object that docname depends on has been modified since docname was last compiled.
0No inconsistencies in the compilation status of docname were noted.

Example

let status = $compilestatus(MyZIMProgram)
case
   when status = 0
      output "No need to compile"
   when status =2
      output "No source file"
   when status = 7
      output "Could not find a dependent object"
   otherwise
      compile MyZIMProgram
endcase

$fill

Fills part of a string with a specified character

Syntax

$fill(source,position,length,string)

Parameters

sourcea character string, or an expression that evaluates to a character string
positiona number, or an expression that evaluates to a number
lengtha number, or an expression that evaluates to a number
stringa character string, or an expression that evaluates to a character string

Return Value

Character string, consisting of source filled with the first character from string, starting at position, for a length of length.

Comments

Use $fill to initialize strings to specific values. The function fills source with the (first) character from string, starting at position, for length number of characters. The fill character replaces any characters that already exist in the string in the specified positions.

In a string, the position of the first character is always 1. If position is beyond the end of source, or if position is zero or negative, then source is left unchanged.

If length is zero or negative, then source is left unchanged.

If there are fewer than length characters from position to the end of source, then all characters from position to the end of source are replaced by the fill character.

If string is the null string, then a space is used as the fill character.

Example

$fill(Title,1,$length(Title)," ")

The above expression fills Title with spaces.

See Also

$concat

$delete

$insert

$left

$position

$replace

$right

$squeeze

$substring

$translate

About Character Literals

About Functional Expressions

$messagebox

Presents a message box to the application user and waits for a response.

Syntax

$messagebox(message,type,style,defaultbutton[,heading])

Parameters

messageA character string, or an expression that evaluates to a character string.
typeA number that determines the type of message box. It also determines the icon that appears in the message box.
styleA number that determines the responses (push buttons) available to the application user.
defaultbuttonA number that determines which push button is the default button. Buttons are numbered 1, 2, and 3 from left to right.
headingA title for the message box. If you do not specify a heading, one is assigned based on type.

Message box types include:

TypeMeaningConstant Name

1

Error

cErrorMsg

2

Warning

cWarningMsg

3

Information

cInfoMsg

4

Question

cQuestionMsg

Push button styles include:

TypeButtons SuppliedConstant Name
1OKcOKStyle
2OK, CancelcOKCancelStyle

3

Retry, CancelcRetryCancelStyle

4

Yes, NocYesNoStyle

5

Yes, No, CancelcYesNoCancelStyle

6

Abort, Retry, IgnorecAbortRetryStyle

Return Value

Character string.

Comments

Use $messagebox to display a message in a dialog box of the specified type, with the specified heading or a default heading in the caption. The application user responds by activating one of the buttons provided by style, one of which is a defaultbutton. $Messagebox returns a character string containing the label of the button pressed by the application user.

Example

$messagebox("Delete file?",2,5,2,"File Operations")
pt_BRPortuguese