Focal Point
Parsing an amper variable

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

January 12, 2005, 05:44 PM
<Derek>
Parsing an amper variable
Does anyone know the correct way to parse an amper variable. I'm passing in a variable called &CENTER from an html form. I want to extract the first 3 chars. and put them in a like statement. I've tried using EDIT and SUBSTR without success.

I tried to use an edit and receive this error... (FOC002) A WORD IS NOT RECOGNIZED: SUB_CENTER/A3

TABLE FILE TBLLIC_BASE
PRINT
OWNING_ORG
LICENSE_NUMBER
FORMAL_NAME
LICENSE_INITIATED
EXECUTION_DATE
CLOSE_DATE
TITLE

SUB_CENTER/A3 = EDIT(&CENTER, '999*');

WHERE TBLLIC_BASE.OWNING_ORG LIKE 'SUB_CENTER%';


I have also tried this and recived an error saying...(FOC36355) INVALID TYPE OF ARGUMENT #2 FOR USER FUNCTION SUBSTR

DEFINE FILE TBLLIC_BASE
SUB_CENTER/A3=SUBSTR(5, &CENTER, 1, 3, 3, SUB_CENTER);
END;

TABLE FILE TBLLIC_BASE
PRINT
OWNING_ORG
LICENSE_NUMBER
FORMAL_NAME
LICENSE_INITIATED
EXECUTION_DATE
CLOSE_DATE
TITLE
WHERE TBLLIC_BASE.OWNING_ORG LIKE 'SUB_CENTER%';
January 12, 2005, 05:54 PM
drew billingslea
try:

-SET &CNTR = EDIT(&CENTER,'999')|'%';

TABLE FILE TBLLIC_BASE
PRINT
OWNING_ORG
LICENSE_NUMBER
FORMAL_NAME
LICENSE_INITIATED
EXECUTION_DATE
CLOSE_DATE
TITLE

WHERE TBLLIC_BASE.OWNING_ORG LIKE '&CNTR';

hth,

drew
January 12, 2005, 05:56 PM
<Pietro De Santis>
You should be able to do the following:

-SET &SUB_CENTER = EDIT(&CENTER, '999');

Then:

TABLE FILE TBLLIC_BASE
...
WHERE TBLLIC_BASE.OWNING_ORG LIKE '&SUB_CENTER.EVAL%';
END
January 12, 2005, 06:09 PM
<Derek>
Thanks for the quick response. Pietro's solution worked. It looks like it needed the .EVAL in the like statement.
January 12, 2005, 06:15 PM
GCohen
You left out the words AND COMPUTE .
eg.
AND COMPUTE SUB_CENTER/A3 = EDIT(&CENTER, '999*');
January 12, 2005, 10:03 PM
j.gross
quote:
Originally posted by Pietro De Santis:
[qb] ... LIKE '&SUB_CENTER.EVAL%'; ...
[/qb]
.EVAL is not necesary here, and can cause problems if &CENTER's value contains an ampersand.

You need something to avoid interpretation of the "%" as part of the & parameter's name. In cases like this (where an & name abuts a non-blank character that can be part of an & name), use "|" to delimit the & name, as in:

LIKE '&SUB_CENTER|%';