Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
francofiorillo
Partner - Creator
Partner - Creator

loop within a load in the script

In a LOAD I have a field called, for example, ACTION.

Within the script I need to create a number of fields equal to the length of the field containing the character of the extracted position.

I can not do the cycle within the script.

Thanks in advance.

1 Solution

Accepted Solutions
petter
Partner - Champion III
Partner - Champion III

If you want each character to be loaded into a separate row:

C:

MAPPING LOAD *

INLINE [

C1,C2

A,|A

I,|I

+,|+

];


[EACH CHAR IN ROWS]:

LOAD

    RowNo() AS R#,

    SubField( Mid( MapSubString('C',S),2) , '|' ) AS C

INLINE [

S

AI+IIIIIIIII+++I+I+IIIIIIIIIIIIIIIIIIIIIAIAIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII++IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII

];

If you want each character in a separate field:

f=;

FOR i=1 TO 128

  f=f&'  Mid(S,'&i&',1) AS C'&i&If(i<128,',')&Chr(10);

NEXT


[EACH CHAR IN FIELDS]:

LOAD

  RowNo() AS R#,

  $(f)

INLINE [

S

AI+IIIIIIIII+++I+I+IIIIIIIIIIIIIIIIIIIIIAIAIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII++IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII

];

View solution in original post

4 Replies
petter
Partner - Champion III
Partner - Champion III

Could you explain a little bit more please? I didn't understand quite what you meant

Maybe if you create an example of the kind of rows and fields you have and what you want to get in the end...

regards

Petter

petter
Partner - Champion III
Partner - Champion III

Maybe you are looking for something like the FROM_FIELD clause of the LOAD statement.

This allows you to take the content of a single FIELD and process it as if it is a regular LOAD ... FROM with format specifications and all.

So that way a single field can for instance contain a comma/tab/semicolon separated text that can be parsed into new fields.

francofiorillo
Partner - Creator
Partner - Creator
Author

I have a field of a table with a length of 128 characters.

every position of the field has a meaning and can have a particular value.

for example, the ACTION field of a table contains the following value:

AI + IIIII IIII ++ + I + I + IIIIIIIIIIIIIIIIIIIIIAIAIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII + + IIIIII IIIIIIIIIIIIIIIIIIIIIIIIIIIII.

I have to analyze the value of each position.

the A value in the first position, for example, refers to the Last Cost that goes Updated. in other cases there may be value I which means that the last cost must be ignored.

I can extract the various characters in a graphic with the MID function. I would like to do it in the script.

petter
Partner - Champion III
Partner - Champion III

If you want each character to be loaded into a separate row:

C:

MAPPING LOAD *

INLINE [

C1,C2

A,|A

I,|I

+,|+

];


[EACH CHAR IN ROWS]:

LOAD

    RowNo() AS R#,

    SubField( Mid( MapSubString('C',S),2) , '|' ) AS C

INLINE [

S

AI+IIIIIIIII+++I+I+IIIIIIIIIIIIIIIIIIIIIAIAIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII++IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII

];

If you want each character in a separate field:

f=;

FOR i=1 TO 128

  f=f&'  Mid(S,'&i&',1) AS C'&i&If(i<128,',')&Chr(10);

NEXT


[EACH CHAR IN FIELDS]:

LOAD

  RowNo() AS R#,

  $(f)

INLINE [

S

AI+IIIIIIIII+++I+I+IIIIIIIIIIIIIIIIIIIIIAIAIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII++IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII

];