UniBasic Commands Reference - Rocket Software

UniBasic Commands Reference - Rocket Software UniBasic Commands Reference - Rocket Software

rocketsoftware.com
from rocketsoftware.com More from this publisher
11.04.2013 Views

In the next example, UniData replaces every occurrence of the constant FULLNAME with the expression in the EQUATE statement. The program segment prints “Mary Jones”. 1-264 UniBasic Commands Reference EQUATE FULLNAME LITERALLY "FIRST_NAME:' ':LAST_NAME" FIRST_NAME = "Mary" LAST_NAME = "Jones" PRINT FULLNAME After the program is compiled, the print statement looks like this: PRINT FIRST_NAME:' ':LAST_NAME The following example shows the same program segment using the TO form of the statement syntax. In this case, the quotation marks around FIRST_NAME:' ':LAST_NAME are removed. EQUATE FULLNAME TO FIRST_NAME:' ':LAST_NAME FIRST_NAME = "Mary" LAST_NAME = "Jones" PRINT FULLNAME

EREPLACE Syntax EREPLACE(expression, substring, replacement [,occurrence [,begin] ] ) Description The EREPLACE function replaces substring in expression with another substring. If you do not specify occurrence, each occurrence of substring is replaced. Parameters The following table describes each parameter of the syntax. Parameter Description expression The expression in which you want to replace substring. substring The substring you want to replace. If substring is an empty string, replacement is prefixed to expression. If replacement is an empty string, all occurrences of substring are removed. replacement The replacement value for substring. occurrence Specifies the number of occurrences of substring to replace. To replace all occurrences, specify occurrence as a number less than 1. begin Specifies the first occurrence of substring to replace. If you omit begin, or specify a value less than 1, it defaults to 1. EREPLACE Parameters If expression evaluates to the null value, null is returned. If substring, replacement, occurrence, or begin evaluates to the null value, the EREPLACE function fails and the program terminates with a run-time error message. Note: The EREPLACE function behaves like the CHANGE function except when substring evaluates to an empty string. EREPLACE 1-265

In the next example, UniData replaces every occurrence of the constant FULLNAME<br />

with the expression in the EQUATE statement. The program segment prints “Mary<br />

Jones”.<br />

1-264 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />

EQUATE FULLNAME LITERALLY "FIRST_NAME:' ':LAST_NAME"<br />

FIRST_NAME = "Mary"<br />

LAST_NAME = "Jones"<br />

PRINT FULLNAME<br />

After the program is compiled, the print statement looks like this:<br />

PRINT FIRST_NAME:' ':LAST_NAME<br />

The following example shows the same program segment using the TO form of the<br />

statement syntax. In this case, the quotation marks around FIRST_NAME:'<br />

':LAST_NAME are removed.<br />

EQUATE FULLNAME TO FIRST_NAME:' ':LAST_NAME<br />

FIRST_NAME = "Mary"<br />

LAST_NAME = "Jones"<br />

PRINT FULLNAME

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!