Hi Gurus,
I need your help!
I have the following problem:
Given is a table in file proc_tab.dat:
and I want to do a program which reads the table line by line and if it founds in the 4.th column y/Y it executes the procedure which name it constructs dynamically according to the value in 2.column - for example:
1. In the 1.line is in the 4.th column y and in the 2.column ABC, so then program should call the procedure named proc_ABC.
2. In the 4.line we have in the last column Y and in the 2.column KPQ, so the program should call proc_KPQ
3. In the last column of 3.line is N, so there should be nothing called.
Ok, I coded it using the REXX INTERPRET statement as follows:
proc_pgm_01.rex
But I have not coded all necessary procedures: I forgot proc_ZZZ and proc_KKK. What happens? I guess it fails on syntax error..
Running it with ooREXX gives this result
i.e. it fails as I guessed.
But running it with Regina surprised me:
[green]
Regina processed all 5 lines without aborting!
How it is possible? Is the syntax error behaviour of REXX not standardized?[/green]
To make the program more robust and suitable for ooREXX I coded the syntax error trapping in (new added code is [red]red[/red]):
proc_pgm_02.rex
With ooREXX the new program runs as I expected
But if I try it with Regina it ignores all syntax error handling I coded in
[green]
Why has Regina other syntax error handling as ooREXX?
Did I do something wrong?
Is there a better way to do in REXX what i done?
[/green]
Your help is most appreciated!
I need your help!
I have the following problem:
Given is a table in file proc_tab.dat:
Code:
0001 ABC nnn y
0002 ZZZ nnn y
0003 XYZ mmm N
0004 KPQ nnn Y
0005 KKK nnn Y
1. In the 1.line is in the 4.th column y and in the 2.column ABC, so then program should call the procedure named proc_ABC.
2. In the 4.line we have in the last column Y and in the 2.column KPQ, so the program should call proc_KPQ
3. In the last column of 3.line is N, so there should be nothing called.
Ok, I coded it using the REXX INTERPRET statement as follows:
proc_pgm_01.rex
Code:
/***************************/
/* Main program */
/***************************/
input_file = 'proc_tab.dat'
/* Read lines in loop and process them */
do while lines(input_file) \= 0
line = strip(linein(input_file))
say "Processing line:"
say line
/* strip blanks and uppercase 4.th column*/
special_process = translate(strip(word(line, 4)))
if special_process = 'Y' then do
/*compose procedure name from 2.nd column*/
procname = "proc_"||translate(strip(word(line, 2)))
say "creating procname: "||procname
/* fill arguments */
arg1 = 'my_argument1'
arg2 = 'my_argument2'
/* compose call statement */
callstmt= "call "||procname||" arg1, arg2"
say "creating call statement: "||callstmt
/* call using REXX-interpret-statement */
say "Try to call procedure.."
interpret callstmt
end
else do
say "special_process = '"||special_process||"'=> nothig to do."
end
say
end
/* close file */
call lineout input_file
/*-------------------------*/
exit
/***************************/
/* Procedures */
/***************************/
proc_ABC: procedure
parse upper arg arg1, arg2
say "Processing arguments:"
say " arg1='"||arg1||"', arg2='"||arg2||"'"
say "from proc_ABC"
return
proc_KPQ: procedure
parse upper arg arg1, arg2
say "Processing arguments:"
say " arg1='"||arg1||"', arg2='"||arg2||"'"
say "from proc_KPQ"
return
But I have not coded all necessary procedures: I forgot proc_ZZZ and proc_KKK. What happens? I guess it fails on syntax error..
Running it with ooREXX gives this result
Code:
c:\Users\Roman\Work>rexx proc_pgm_01.rex
Processing line:
0001 ABC nnn y
creating procname: proc_ABC
creating call statement: call proc_ABC arg1, arg2
Try to call procedure..
Processing arguments:
arg1='MY_ARGUMENT1', arg2='MY_ARGUMENT2'
from proc_ABC
Processing line:
0002 ZZZ nnn y
creating procname: proc_ZZZ
creating call statement: call proc_ZZZ arg1, arg2
Try to call procedure..
25 *-* call proc_ZZZ arg1, arg2
25 *-* interpret callstmt
Error 43 running c:\Users\Roman\Work\proc_pgm_01.rex line 25: Routine not found
Error 43.1: Could not find routine "PROC_ZZZ"
But running it with Regina surprised me:
Code:
c:\Users\Roman\Work>regina proc_pgm_01.rex
Processing line:
0001 ABC nnn y
creating procname: proc_ABC
creating call statement: call proc_ABC arg1, arg2
Try to call procedure..
Processing arguments:
arg1='MY_ARGUMENT1', arg2='MY_ARGUMENT2'
from proc_ABC
Processing line:
0002 ZZZ nnn y
creating procname: proc_ZZZ
creating call statement: call proc_ZZZ arg1, arg2
Try to call procedure..
'PROC_ZZZ' is not recognized as an internal or external command,
operable program or batch file.
Processing line:
0003 XYZ mmm N
special_process = 'N'=> nothig to do.
Processing line:
0004 KPQ nnn Y
creating procname: proc_KPQ
creating call statement: call proc_KPQ arg1, arg2
Try to call procedure..
Processing arguments:
arg1='MY_ARGUMENT1', arg2='MY_ARGUMENT2'
from proc_KPQ
Processing line:
0005 KKK nnn Y
creating procname: proc_KKK
creating call statement: call proc_KKK arg1, arg2
Try to call procedure..
'PROC_KKK' is not recognized as an internal or external command,
operable program or batch file.
Regina processed all 5 lines without aborting!
How it is possible? Is the syntax error behaviour of REXX not standardized?[/green]
To make the program more robust and suitable for ooREXX I coded the syntax error trapping in (new added code is [red]red[/red]):
proc_pgm_02.rex
Code:
/***************************/
/* Main program */
/***************************/
input_file = 'proc_tab.dat'
/* Read lines in loop and process them */
[red]process_lines:[/red]
do while lines(input_file) \= 0
line = strip(linein(input_file))
say "Processing line:"
say line
/* strip blanks and uppercase 4.th column*/
special_process = translate(strip(word(line, 4)))
if special_process = 'Y' then do
/*compose procedure name from 2.nd column*/
procname = "proc_"||translate(strip(word(line, 2)))
say "creating procname: "||procname
/* fill arguments */
arg1 = 'my_argument1'
arg2 = 'my_argument2'
/* compose call statement */
callstmt= "call "||procname||" arg1, arg2"
say "creating call statement: "||callstmt
/* call using REXX-interpret-statement */
say "Try to call procedure.."
[red]signal on syntax name interpret_error[/red]
interpret callstmt
end
else do
say "special_process = '"||special_process||"'=> nothig to do."
end
say
end
/* close file */
call lineout input_file
/*-------------------------*/
exit
/***************************/
/* Procedures */
/***************************/
proc_ABC: procedure
parse upper arg arg1, arg2
say "Processing arguments:"
say " arg1='"||arg1||"', arg2='"||arg2||"'"
say "from proc_ABC"
return
proc_KPQ: procedure
parse upper arg arg1, arg2
say "Processing arguments:"
say " arg1='"||arg1||"', arg2='"||arg2||"'"
say "from proc_KPQ"
return
[red]
interpret_error:
say "Error RC="||RC
if RC='43' then do
say "**********************************************"
say "*Procedure "||procname||" not defined in program !*"
say "**********************************************"
say
/* Continue with next line*/
signal process_lines
end
else do
say errortext(RC)
end
return
[/red]
With ooREXX the new program runs as I expected
Code:
c:\Users\Roman\Work>rexx proc_pgm_02.rex
Processing line:
0001 ABC nnn y
creating procname: proc_ABC
creating call statement: call proc_ABC arg1, arg2
Try to call procedure..
Processing arguments:
arg1='MY_ARGUMENT1', arg2='MY_ARGUMENT2'
from proc_ABC
Processing line:
0002 ZZZ nnn y
creating procname: proc_ZZZ
creating call statement: call proc_ZZZ arg1, arg2
Try to call procedure..
Error RC=43
**********************************************
*Procedure proc_ZZZ not defined in program !*
**********************************************
Processing line:
0003 XYZ mmm N
special_process = 'N'=> nothig to do.
Processing line:
0004 KPQ nnn Y
creating procname: proc_KPQ
creating call statement: call proc_KPQ arg1, arg2
Try to call procedure..
Processing arguments:
arg1='MY_ARGUMENT1', arg2='MY_ARGUMENT2'
from proc_KPQ
Processing line:
0005 KKK nnn Y
creating procname: proc_KKK
creating call statement: call proc_KKK arg1, arg2
Try to call procedure..
Error RC=43
**********************************************
*Procedure proc_KKK not defined in program !*
**********************************************
But if I try it with Regina it ignores all syntax error handling I coded in
Code:
Processing line:
0001 ABC nnn y
creating procname: proc_ABC
creating call statement: call proc_ABC arg1, arg2
Try to call procedure..
Processing arguments:
arg1='MY_ARGUMENT1', arg2='MY_ARGUMENT2'
from proc_ABC
Processing line:
0002 ZZZ nnn y
creating procname: proc_ZZZ
creating call statement: call proc_ZZZ arg1, arg2
Try to call procedure..
'PROC_ZZZ' is not recognized as an internal or external command,
operable program or batch file.
Processing line:
0003 XYZ mmm N
special_process = 'N'=> nothig to do.
Processing line:
0004 KPQ nnn Y
creating procname: proc_KPQ
creating call statement: call proc_KPQ arg1, arg2
Try to call procedure..
Processing arguments:
arg1='MY_ARGUMENT1', arg2='MY_ARGUMENT2'
from proc_KPQ
Processing line:
0005 KKK nnn Y
creating procname: proc_KKK
creating call statement: call proc_KKK arg1, arg2
Try to call procedure..
'PROC_KKK' is not recognized as an internal or external command,
operable program or batch file.
Why has Regina other syntax error handling as ooREXX?
Did I do something wrong?
Is there a better way to do in REXX what i done?
[/green]
Your help is most appreciated!