Focal Point
STRREP function and numbers

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/4501001092

July 01, 2008, 04:23 PM
dcj
STRREP function and numbers
We have a HTML page that allows a user to select mutiple selections of an AGENT value. Values are 0000, 0010, 0020, etc.. In the following example, the fex variable value for AGENT is '0000' OR '0010' or '0020' as expected for a multiple select listbox.

I'm trying to use STRREP to change the 0000 value of the string to TOT for heading display.

-SET &AGENT_LEN = &agent.LENGTH;
-SET &lagent = STRREP(&AGENT_LEN, &agent, 4, '0000', 3, 'TOT', &AGENT_LEN, 'A&AGENT_LEN.EVAL');

Translated: STRREP(26, '0000' OR '0010' OR '0020', 4, '0000', 3, 'TOT', 26, 'A26');

The problem seems to be the use of numbers in the searchstring paramter (4) of the STRREP function. Does anyone know what this issue is or how to replace the 0000 value to TOT.

I use the STRREP function regularly, but have never needed to replace numbers within a string just characters.

Thanks
David


wf: 7.6.4
App. and reporting server: UNIX/AIX 5.3
July 01, 2008, 05:43 PM
Alan B
Ah, the joys of WebFOCUS.

Try:
-SET &AGENT_LEN = &agent.LENGTH;
-SET &lagent = STRREP(&AGENT_LEN, &agent, 4, '0000X', 3, 'TOT', &AGENT_LEN, 'A&AGENT_LEN.EVAL');

By keeping the search length at 4, but convincing the search string its alpha with an 'X', you should get what you want.


Alan.
WF 7.705/8.007
July 01, 2008, 06:10 PM
dcj
Thanks Alan, that works perfect!!!!


wf: 7.6.4
App. and reporting server: UNIX/AIX 5.3
July 01, 2008, 10:55 PM
Waz
FYI

You don't need to use a separate variable for the length, just use .LENGTH instead.
-SET &lagent = STRREP(&agent.LENGTH, &agent, 4, '0000X', 3, 'TOT', &agent.LENGTH, 'A&agent.LENGTH');


Thanks Tony for spotting the oversight. Unfortunately, there is no more haste at my age.

This message has been edited. Last edited by: Waz,


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

July 02, 2008, 02:54 AM
Tony A
quote:
-SET &lagent = STRREP(&agent.LENGTH, &agent, 4, '0000X', 3, 'TOT', &AGENT_LEN, 'A&agent.LENGTH');

Warren,

In your haste to reply, you missed one Wink

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
July 02, 2008, 03:54 AM
Danny-SRL
fmi,

Beware of the case where your user will choose only '0000'! The function will not like to have &agent be 0000 because it will be a number and not a string.


Daniel
In Focus since 1982
wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF

July 02, 2008, 04:23 AM
Alan B
Danny

You are right if this were to come across as just 0000, but as this is being passed from a multi-select, it should always have single quotes around it, in which case it is viewed as an alpha field, as what the function sees is:
STRREP(06, '0000', 4, '0000Z', 3, 'TOT', 06, 'A06');
which is acceptable to it.


Alan.
WF 7.705/8.007
July 03, 2008, 10:50 AM
dcj
Thanks to everyone, I saw that it didn't work with a single select and below is how I handle it.

-SET &lagent = IF &lagent EQ 0000 THEN TOT ELSE &lagent;

-IF &lagent.LENGTH LT 7 THEN GOTO A1;

-SET &AGENT_LEN = &lagent.LENGTH;
-SET &lagent = STRREP(&AGENT_LEN, &lagent, 4, '0000X', 3, 'TOT', &AGENT_LEN, 'A&AGENT_LEN.EVAL');

-A1


wf: 7.6.4
App. and reporting server: UNIX/AIX 5.3