Focal Point
Amper Variables

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

July 04, 2005, 04:38 PM
<RBC007>
Amper Variables
SAMPLE VALUES FOR REF with characters like dash, periods, etc as delimiter.

I just need to get REF without any variable after

In the table I have one field called REF and that will have the values like ANY of the single lines below, Im trying to achieve

Sale- NEW SALES (oc Jim Watzrs
Delivery Complete : May 15 2005 (oc Jim Watzrs
Sent Package - June 13 2005 (oc Max Wxlters
Network Mail list (oc Max Wxlters
Sale- NEW SALES (oc Max Wxlters
Sale- NEW SALES (oc Mike Wxlters
Sale- NEW SALES (oc Dave Wxlters
Sent Package - June 18 2005
Delivery Complete : June 21 2005
Sent Package - June 18 2005

while I'm displaying these values in report, I need to show as grouped and total times

Sale 69
Delivery Complete 7
Sent Package 5
Network Mail list 8

using:
T1VAL/A40=GETTOK(REF,40,1,'(',40,'A40');
T2VAL/A40=GETTOK(REF,40,1,':',40,'A40');
T3VAL/A40=GETTOK(REF,40,1,'+',40,'A40');
T4VAL/A40=GETTOK(REF,40,1,'-',40,'A40');
SHORT_REF/A99=
IF T1VAL NE REF THEN T1VAL ELSE
IF T2VAL NE REF THEN T2VAL ELSE
IF T3VAL NE REF THEN T3VAL ELSE
IF T4VAL NE REF THEN T3VAL ELSE
REF;

So I need it to check for "loop" for '(', ':', '-', '+' all the delimiter using OR, because it will hit the first '(' and not check for the second variable


Am i missing something here, what can I do?
Please help!!!
July 04, 2005, 05:16 PM
reFOCUSing
Question would the following work for you
COMPUTE TEST/A20 =
IF REF LIKE 'Sale-%' 
THEN 'Sales'
ELSE IF REF LIKE 'Delivery 
Complete :%' 
THEN 'Delivery Complete'
ELSE IF REF LIKE 
'Sent Package -%' 
THEN 'Sent Package
 ELSE IF REF LIKE 
'Network Mail list 
(' THEN 'Network Mail list'
 ELSE 'N/A';

This message has been edited. Last edited by: <Mabel>,
July 04, 2005, 06:01 PM
<RBC007>
quote:
Originally posted by CurtisA:
[qb] Question would the following
work for you?
COMPUTE TEST/A20 =
IF REF LIKE 'Sale-%' THEN 'Sales'
 ELSE IF REF LIKE 'Delivery 
Complete :%' 
THEN 'Delivery Complete
ELSE IF REF LIKE 'Sent Package -%' 
THEN 'Sent Package'
ELSE IF REF LIKE 'Network Mail list 
(' THEN 'Network Mail list'
ELSE 'N/A';
[/qb]
Great suggestion however
my concerns are the list or
variables are too many, my
"else" would be a long list.

This message has been edited. Last edited by: <Mabel>,
July 05, 2005, 11:04 AM
Tony A
RBC007
irstly, a bit of data analysis.
From your data the first character
to appear would be the hyphen and
the last would be the brace. The
brace doesn't appear
in the 'Delivery Complete' data
line etc.... Build up your
understanding of the data you are
trying to interpret.<br /><br />
Then adjust the defines to pull out
the required characters in the order
that they are likely to appear -
'-', ':', '+' and '
('.<br /><br />Then find the
position of the character in the
input string so that you can
determine which one appears first.
Finally, take a substring of the
input field up unto the first 'special' character appearance.
Have a go with this code.
Details taken exactly from
your example data -
CREATE FILE REFS
MODIFY FILE REFS<br />DATA
Sale- NEW SALES (oc Jim Watzrs,
Delivery Complete : 
May 15 2005 (oc Jim Watzrs,$
Sent Package - June 13 2005 
(oc Max Wxlters,$
>Network Mail list (oc Max Wxlters,$
Sale- NEW SALES (oc Max Wxlters,$
Sale- NEW SALES (oc Mike Wxlters,$
Sale- NEW SALES (oc Dave Wxlters,$
Sent Package - June 18 2005,$
Delivery Complete : June 21 2005,$
Sent Package - June 18 2005,$
>END<br />-RUN
DEFINE FILE REFS
T_POS1/I2 = POSIT(REF,50,'-',1,'I2');
T_POS2/I2 = POSIT(REF,50,':',1,'I2');
T_POS3/I2 = POSIT(REF,50,'+',1,'I2'
T_POS4/I2 = POSIT(REF,50,'(',1,'I2');
T_POS/I2  = IF T_POS1 NE 0 THEN 
T_POS1 ELSE 
IF T_POS2 NE 0 THEN T_POS2 ELSE
 IF T_POS3 NE 0 THEN T_POS3 ELSE
IF T_POS4 NE 0 THEN T_POS4 ELSE 0;
SHORT_REF/A40 = SUBSTV
(40,REF,1,T_POS,'A40');
/>END<br />TABLE FILE REFS
SUM CNT.SHORT_REF AS 'Count'
BY SHORT_REF AS 'Ref. Type'
ON TABLE NOTOTAL
ON TABLE SET PAGE-NUM OFF
ON TABLE SET HTMLCSS ON
ON TABLE SET PRINT ONLINE
ON TABLE SET STYLE *<br />
ENDSTYLE
<br />END<br />
CREATE FILE REFS
If anyone e
lse wants to try it then the
REFS.mas is a single segment,
single (A50) field FOCUS file.
The output recieved is -
Ref. Type Count <br />
Delivery
Complete :
2 <br />Network Mail list ( 1
Sale- 4 <br />Sent Package - 3
I prefer to use boolean logic in the
multiple IF statement (T_POS)
but then it sometimes makes it
hard for others to
follow.<br /><br />
Hope this helps? All cheques
gratefully
recieved Wink

This message has been edited. Last edited by: <Mabel>,
July 05, 2005, 09:06 PM
<RBC007>
Thanks for all the advise and direction, it was awesome - a real time saver.

Thanks for sharing!!!!
July 05, 2005, 09:08 PM
<RBC007>
quote:
Originally posted by Tony Alsford:<br />[qb] RBC007<br /><br />Firstly, a bit of data analysis. From your data the first character to appear would be the hyphen and the last would be the brace. The brace doesn't appear in the 'Delivery Complete' data line etc....
Build up your understanding of the data you are trying to interpret.<br /><br />Then adjust the defines to pull out the required characters in the order that they are likely to appear - '-', ':', '+' and '('.
Then find the position of the
character in the input string
so that you can determine which
one appears first.
Finally, take a substring of the
input field up unto the first
'special' character
appearance.
Have a go with this code. Details taken exactly from your example data
CREATE FILE REFS
MODIFY FILE REFS<br />DATA
ale- NEW SALES (oc Jim Watzrs,$
>Delivery Complete : May 15 2005 
(oc Jim Watzrs,$<br />Sent Package - J
une 13 2005 (oc Max Wxlters,$<br />Network Mail list (oc Max Wxlters,$
ale- NEW SALES (oc Max Wxlters,$
Sale- NEW SALES (oc Mike Wxlters,$
Sale- NEW SALES (oc Dave Wxlters,$
Sent Package - June 18 2005,$
Delivery Complete : June 21 2005,$
Sent Package - June 18 2005,$
END<br />-RUN<br />DEFINE FILE REFS
T_POS1/I2 = POSIT(REF,50,'-',1,'I2');
T_POS2/I2 = POSIT(REF,50,':',1,'I2')
T_POS3/I2 = POSIT(REF,50,'+',1,'I2')
T_POS4/I2 = POSIT(REF,50,'(',1,'I2');
T_POS/I2  = IF T_POS1 NE 0 THEN T_POS1 ELSE
IF T_POS2 NE 0 THEN T_POS2 ELSE
IF T_POS3 NE 0 THEN T_POS3 ELSE           
IF T_POS4 NE 0 THEN T_POS4 ELSE 0;
SHORT_REF/A40 = SUBSTV(40,REF,1,T_POS,'A40');
END
TABLE FILE REFS
SUM CNT.SHORT_REF AS 'Count'
BY SHORT_REF
 AS 'Ref. Type'
ON TABLE NOTOTAL
ON TABLE SET PAGE-NUM OFF
ON TABLE SET HTMLCSS ON
ON TABLE SET PRINT ONLINE
ON TABLE SET STYLE *<br />ENDSTYLE
END<br />CREATE FILE REFS
If anyone else wants to try
it then the REFS.mas is a single segment,
single
(A50) field FOCUS file.
The output recieved is -<br /><br />
Ref. Type Count <br />Delivery Complete :
2 <br />Network Mail list ( 1 <br />Sale- 4
<br />Sent Package - 3 <br /><br />
I prefer to use boolean logic in the
multiple IF statement (T_POS) but
then it sometimes makes it hard for o
thers to follow.<br /><br />Hope
this helps? All cheques gratefully
recieved Wink [/qb]
Tony
thanks for the time it must have took to (detail) document your advise.<br />.

This message has been edited. Last edited by: <Mabel>,