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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

need help with array error

Status
Not open for further replies.

AZdesertdog

IS-IT--Management
Dec 2, 2003
88
US
Using CE10/CR10 against MSSQL db.

Have a report that has an NT error log memofield.

Memofield example:
User Logoff:^` User Name: SAYSQL$^` Domain: METRO^` Logon ID: (0x0 0xA7928C)^` Logon Type: 3^`

I want to be able to search against the various segments of this field so I have parsed it out into 8 fields using formulas:
@Split1
ltrim(Split({events.messagebody}, "^`")[1])
@Split2
ltrim(Split({events.messagebody}, "^`")[2])
@Split3
ltrim(Split({events.messagebody}, "^`")[3]) etc.. to [8]

I've found that the number of parts of the memo can be up to 8 so I have 8 seperate formulas for parsing. What is happening is when the memo field has less than 8, I get the error message:
"a subscript must be between 1 and the size of the array"

I think I need to use ubound to evaluate the number of elements in the array but haven't been able to get the syntax right- if that's the solution. Any help appreciated. Thanks!


 
Got it figured out.

if ubound(split({events.messagebody},"^`")) >= 8 then
split({events.messagebody},"^`")[8]

works like a charm.
 
Your formulas aren't doing any searching.

stringvar array MyArray :=split("User Logoff:^` User Name: SAYSQL$^` Domain: METRO^` Logon ID: (0x0 0xA7928C)^` Logon Type: 3^`","^");
numbervar Counter;
Booleanvar FoundIt:=False;
for Counter := 1 to ubound(MyArray) do(
if instr(MyArray[Counter],"SAY") > 0 then
FoundIt:=True
);

-k
 
I see. So I can search the entire memo that way. Is it safe to say that I an replace the "SAY" with a search parameter or formula?
 
Sure, and the string with your {table.field}.

If you want to limit rows returned to those containing some text in that field, use the report->record selection formula->Record:

{table.field} like "*"+{?MyParm}+"*"

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top