11.04.2013 Views

UniBasic Commands Reference - Rocket Software

UniBasic Commands Reference - Rocket Software

UniBasic Commands Reference - Rocket Software

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

INDEX<br />

Syntax<br />

INDEX(str.expr1,str.expr2,num.expr)<br />

Description<br />

The <strong>UniBasic</strong> INDEX function returns the starting position of the num.expr occurrence<br />

of str.expr2 within str.expr1. INDEX supports multibyte languages.<br />

Parameters<br />

The following table describes each parameter of the syntax.<br />

Parameter Description<br />

Examples<br />

In the following example, the program segment searches STR.VAR for the second<br />

occurrence of the letter t and returns that location in the variable LOC. In this<br />

example, it returns a value of 8.<br />

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

str.expr1 Specifies the string to search.<br />

str.expr2 Specifies the string for which to search in str.expr1.<br />

num.expr Specifies which occurrence of str.expr2 to return.<br />

INDEX Parameters<br />

STR.VAR = "It was the best of times"<br />

LOC = INDEX(STR.VAR,"t",2)<br />

In the next example, the INDEX function operates like the COL() functions used in<br />

conjunction with the FIELD function. It returns the beginning position of the string<br />

212 within the string variable STR. The result stored in the variable NY.STR is 15.<br />

STR = "303-433-3199, 212-999-1212"<br />

NY.STR = INDEX(STR,"212",1)

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

Saved successfully!

Ooh no, something went wrong!