MID()

 

Syntax:

       Then: a=MID(f,"s","n")

 

Finds and copies the middle of a field.

 

MID(f,"s", "n")=newvalue

 

Replaces characters within a field.

 

"f" is the field on which to perform the operation.
"s" is the number of the starting position within the field.
"n" is the number of characters starting from "s" to use.

 

Version Ref:  3.x

  5.0(Enhanced)

 

Description:

A system function used to find and copy the middle of a string, and to replace characters within a field.

 

5.0 Version 5.0 enhanced the MID function to allow expressions as the first parameter.

 

Example:

 MESGBOX "You were born in the year" < mid(InfoFile[5],"7","4")

 

The above line gets 4 characters starting in position 7 from field 5 in the file named InfoFile.

Note :

If you use a "true" expression as the first parameter, you have to make sure you know the length/type of the result of the expression. It may not be the same as you think.For example, the expression "1"/"2" is of type (25,F). More likely, you will use this to place lookup fields or array items as the parameter.

 

Examples:

        If: mid(@cd,"7","2") eq "97"
      Then: show "This record was created in 1997." ; end

 

        If: @id ne mid(14,"5","8")
      Then: show "This invoice belongs to someone else." ; end

 

        If:
      Then: mid(14,"5","8")=@id ; end

 

The terms in the MID function are each expressions. However, the start position and the number of characters must be surrounded by quotes if you are using literal numbers. Using real fields in either of these positions requires that you understand that the value of these fields will be substituted before the function is applied.