I have included the none working code and working code. Maybe I'm doing something wrong and someone can tell me what it is.
Also can you see any reason why I should not use my work around.
-TYPE None working code -* Variable passed by GUI. -SET &RPT_MULTI = 'Hello People,This is the End'; -* -* Report variables. -TYPE RPT_MULTI: &RPT_MULTI -SET &LP_STEP = 1; -SET &INDX = 1; -RUN -* -* Find the number of Report Tokens in the string. -REPEAT :RPT_TOK1 WHILE &LP_STEP NE -1; -SET &TOKEN = GETTOK(&RPT_MULTI,&RPT_MULTI.LENGTH,&LP_STEP,',',&RPT_MULTI.LENGTH,'A20'); -SET &TOKEN = TRIM('B', &TOKEN, 20, ' ', 1, 'A20'); -TYPE > &TOKEN < -SET &INDX_CUR = &LP_STEP - 1; -SET &LP_STEP = IF &TOKEN EQ '' THEN -1 ELSE &LP_STEP + 1; -:RPT_TOK1 -* -SET &INDX_RPT = &INDX_CUR; -TYPE Number of RPT: &INDX_RPT
-TYPE Working code. -* Variable passed by GUI. -SET &RPT_MULTI = 'Hello People,This is the End'; -* -* Report variables. -TYPE RPT_MULTI: &RPT_MULTI -SET &LP_STEP = 1; -SET &INDX = 1; -RUN -* -* Find the number of Report Tokens in the string. -REPEAT :RPT_TOK2 WHILE &LP_STEP NE -1; -SET &TOKEN = GETTOK(&RPT_MULTI,&RPT_MULTI.LENGTH,&LP_STEP,',',&RPT_MULTI.LENGTH,'A20'); -SET &TOKEN = '''' || &TOKEN || '''' || ';'; -SET &TOKEN = &TOKEN.EVAL -TYPE > &TOKEN < -SET &INDX_CUR = &LP_STEP - 1; -SET &LP_STEP = IF &TOKEN EQ '' THEN -1 ELSE &LP_STEP + 1; -:RPT_TOK2 -* -SET &INDX_RPT = &INDX_CUR; -TYPE Number of RPT: &INDX_RPT
This message has been edited. Last edited by: <Maryellen>,
September 27, 2005, 09:15 PM
Håkan
I agree, TRIM does not seem to work in DM, but you might try this.
-SET &STR = 'THIS IS A STRING '; -SET &LEN = ARGLEN(&STR.LENGTH,&STR,'I2'); -SET &STR2 = SUBSTR(&LEN,&STR,1,&LEN,&LEN,'A|&LEN');
/H�kan
September 27, 2005, 09:29 PM
j.gross
TRIM "works" -- it's just that the Format argument stretches the result back to a fixed length.
ARGLEN + SUBSTR (with 'A&LEN.EVAL' to make the format dynamic) overcomes that, as HL noted.
September 27, 2005, 09:47 PM
reFOCUSing
I forgot about ARGLEN.
I modified the code to us TRIM and ARGLEN and it now works fine.
-* Variable passed by GUI. -SET &RPT_MULTI = 'Hello People,This is the End'; -* -* Report variables. -TYPE RPT_MULTI: &RPT_MULTI -SET &LP_STEP = 1; -SET &INDX = 1; -RUN -* -* Find the number of Report Tokens in the string. -REPEAT :RPT_TOK1 WHILE &LP_STEP NE -1; -SET &TOKEN = GETTOK(&RPT_MULTI,&RPT_MULTI.LENGTH,&LP_STEP,',',&RPT_MULTI.LENGTH,'A20'); -SET &LEN = ARGLEN(&TOKEN.LENGTH,&TOKEN,'I2'); -SET &TOKEN = TRIM('B', &TOKEN, 20, ' ', 1, 'A&LEN.EVAL'); -TYPE > &TOKEN < -SET &INDX_CUR = &LP_STEP - 1; -SET &LP_STEP = IF &TOKEN EQ '' THEN -1 ELSE &LP_STEP + 1; -:RPT_TOK1 -* -SET &INDX_RPT = &INDX_CUR; -TYPE Number of RPT: &INDX_RPT
This message has been edited. Last edited by: <Maryellen>,
September 27, 2005, 09:47 PM
Francis Mariani
quote:
How to Remove Leading and Trailing Occurrences TRIM(trim_where, string, string_length, pattern, pattern_length, outfield) where: trim_where Alphanumeric Is one of the following, which indicates where to remove the pattern: 'L' removes leading occurrences. 'T' removes trailing occurrences. 'B' removes both leading and trailing occurrences. string Alphanumeric Is the source character string enclosed in single quotation marks, or the field containing the string. string_length Integer Is the length of the string in characters. pattern Alphanumeric Is the pattern to remove enclosed in single quotation marks. pattern_length Integer Is the number of characters in the pattern. outfield Alphanumeric Is the field to which the result is returned, or the format of the output value enclosed in single quotation marks. In Dialogue Manager, the format must be specified.
That last line from the documentation seems to defeat the purpose of the function.
September 28, 2005, 03:09 PM
reFOCUSing
Mickey PM'ed me last night and asked why I was not using the function TRUNCATE. I don't know why I did not think of it?
Here is the updated code using TRUNCATE:
-* Variable passed by GUI. -SET &RPT_MULTI = 'Hello People,This is the End'; -* -* Report variables. -TYPE RPT_MULTI: &RPT_MULTI -SET &LP_STEP = 1; -SET &INDX = 1; -RUN -* -* Find the number of Report Tokens in the string. -REPEAT :RPT_TOK1 WHILE &LP_STEP NE -1; -SET &TOKEN = GETTOK(&RPT_MULTI,&RPT_MULTI.LENGTH,&LP_STEP,',',&RPT_MULTI.LENGTH,'A20'); -SET &TOKEN = TRUNCATE(&TOKEN); -TYPE > &TOKEN < -SET &INDX_CUR = &LP_STEP - 1; -SET &LP_STEP = IF &TOKEN EQ '' THEN -1 ELSE &LP_STEP + 1; -:RPT_TOK1 -* -SET &INDX_RPT = &INDX_CUR; -TYPE Number of RPT: &INDX_RPT
This really makes the code a lot cleaner and easier to read.
Well I don't know what I was programming yesterday but it was not FOCUS.This message has been edited. Last edited by: <Maryellen>,
September 28, 2005, 03:48 PM
Francis Mariani
I guess TRUNCATE is a new function in 7.1.
It will be years before my client will be upgrading.
September 28, 2005, 03:53 PM
Francis Mariani
Correction!
It's just not documented.
I did not find any reference to the TRUNCATE function in the PDF documentation for WebFOCUS 5.3.2 Functions, but it's there in the Developing Application PDF documentation.
I learnt something new today.
September 28, 2005, 04:20 PM
reFOCUSing
I believe this function will work in WF 4.3. But don't hold me too it, I remember it from a couple years back.