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

Examples In the following example, the program segment begins with an array of two values, each with two subvalues. The SUM function sums the subvalues and returns a string with two numeric values. 1-890 UniBasic Commands Reference NUM.ARRAY = 12:@SM:10:@VM:15:@SM:15 VAL1 = SUM(NUM.ARRAY) This results in: VAL1 = 22:@VM:30 In the next example, the program statement sums VAL1 and returns the numeric value 52 with no dynamic array delimiters: VAL1 = SUM(VAL1)

SWAP Syntax SWAP str.expr1 WITH str.expr2 IN var Description The UniBasic SWAP command replaces all occurrences of one substring with a second substring. The search string does not have to be the same length as the replacement string. SWAP supports mulitbyte languages. Tip: CONVERT compares and replaces substrings on a character-by-character basis. CONVERT cannot exchange strings of different lengths. Parameters The following table describes each parameter of the syntax. Parameter Description str.expr1 Specifies the string expression to replace with str.expr2. str.expr2 Specifies the string expression with which to replace str.expr1. IN var Specifies the variable in which to replace str.expr1 with str.expr2. SWAP Parameters Examples In the following example, the program segment replaces all occurrences of the string “AB” with the string “AZ” in the variable VAR. The new string assigned to VAR is “THE TAZ WAS GRAZBED”. VAR = "THE TAB WAS GRABBED" SWAP "AB" WITH "AZ" IN VAR SWAP 1-891

Examples<br />

In the following example, the program segment begins with an array of two values,<br />

each with two subvalues. The SUM function sums the subvalues and returns a string<br />

with two numeric values.<br />

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

NUM.ARRAY = 12:@SM:10:@VM:15:@SM:15<br />

VAL1 = SUM(NUM.ARRAY)<br />

This results in:<br />

VAL1 = 22:@VM:30<br />

In the next example, the program statement sums VAL1 and returns the numeric<br />

value 52 with no dynamic array delimiters:<br />

VAL1 = SUM(VAL1)

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

Saved successfully!

Ooh no, something went wrong!