Skip to Content
0

How to get element from Array

Sep 27, 2017 at 09:04 AM

33

avatar image

Hello...

I have this string where is parsing mark ' | '

F1E|I21|R|4|30|50|180|35|BG340SR|S10|D11|T10|1P|PVC|PZS-Z25|HS|/|F11|R20|K7035|T7035|/|SNAL|/,|/,/|TOB,S|H,2|/|VZKT|VZKT|SD|

this string elements I need to insert into Array, so I created Formula:

Global StringVar Array myString;
Redim myString [32];
myString:= Split({Command.Parameter},'|');

but now I do not know how can I get n-element/index from the Array

Thank You for any hint

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

5 Answers

Best Answer
Ian Waterman Sep 27, 2017 at 11:13 AM
0

Try

WhilePrintingRecords ;
Shared NumberVar Qty := Sum({Command.Quantity},{Command.Parameter});
Global StringVar Array myString;
Redim myString [32];
myString:= Split({Command.Parameter},'|');
If UBound(myString)>=4
Then Tonumber(myString[4]) * Qty

Or
WhilePrintingRecords ;
Shared NumberVar Qty := Sum({Command.Quantity},{Command.Parameter});
Global StringVar Array myString;
Redim myString [32];
myString:= Split({Command.Parameter},'|');
Global Numbervar Amt:=0;
If UBound(myString)>=4
Then Amt:= Tonumber(myString[4]);

Amt* Qty


Show 1 Share
10 |10000 characters needed characters left characters exceeded

SUPER!

Thank You Master, both works perfectly!

how it will be in case when the element will not be Number, but string?

in such case will not be possible use UBound

Regards ZAJDAN

0
Ian Waterman Sep 27, 2017 at 09:23 AM
0

Global StringVar Array myString;

myString[n];

Ian

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Thank You..

it was the first what I have tried , but in this way appears problem:

'A subscript must be between 1 and the size of the array'

0
Zdenek Chladek Sep 27, 2017 at 10:06 AM
0

I also tried this:

If UBound(myString)>=4 
Then myString[4] 

it returns correct value/element, but I need somehow pass the value into variable for next use (multiplication)

Share
10 |10000 characters needed characters left characters exceeded
Zdenek Chladek Sep 27, 2017 at 11:45 AM
0

how it will be in case when the element will not be Number, but string?

in such case will not be possible use UBound

Share
10 |10000 characters needed characters left characters exceeded
Ian Waterman Sep 27, 2017 at 10:32 AM
0

Just use it as you have

If UBound(myString)>=4

Then myString[4] * yourfield or formula
Ian
Show 1 Share
10 |10000 characters needed characters left characters exceeded

This I already tried:

WhilePrintingRecords ;
Shared NumberVar Qty := Sum({Command.Quantity},{Command.Parameter});
Global StringVar Array myString;
Redim myString [32];
myString:= Split({Command.Parameter},'|');
If UBound(myString)>=4
Then myString[4] * Qty

but it returns:

'A number, or currency amount is required here.'

strange, because UBound returns Number and also the variable Qty is datatype Number.

0