Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using ObjectPal breakapart

Status
Not open for further replies.

LRydant

Technical User
Apr 30, 2002
1
US
I'm using the breakapart method and want to assign the substrings to string variables - like

var
ar Array[] String; must be resizable
s, Firstvar, Lastvar string
tc TCursor
endVar

{scan code, etc}

s.breakApart(ar)

Firstvar = ar[1]
Lastvar = ar[2]



Unable to assign substring to Firstvar and Lastvar; get error "the specified array index is out of bounds. The index is 1, and the array limit is 0." How do I assign these variables values? Thank you.
 
The most likely cause is s has no value.

Try these examples.

In Example 1, I check to make sure s has a value. First I remove any leading and trailing blank spaces.
Then, I loop through ar array variable.

In Example 2, It will generate the same error message as yours.

Examples:
Var
ar Array[] String
siElement SmallInt
s String
EndVar

;Example 1
s = "Hello World"

If LTrim(RTrim(s)) <> Blank() Then
s.BreakApart(ar)

For siElement From 1 To ar.Size()
MsgInfo(&quot;&quot;,ar[siElement])
EndFor
EndIf


;Example 2
s = &quot;&quot;

s.BreakApart(ar)

MsgInfo(&quot;&quot;,ar[1])
MsgInfo(&quot;&quot;,ar[2])


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top