A
typical 'c' example is as follows
switch (
input
)
{
case "DC":
DCfunc();
break;
case
"DCT":
DCTfunc();
break;
case
"C":
Cfunc();
break;
case
"D":
Dfunc();
break;
default :
defunc();
}
public DCfunc() {..................}
public DCTfunc() {..................}
public Cfunc() {..................}
public Dfunc() {..................}
public defunc() {................} |
The equivalent method is shown below
LOAD(chkstr , "," , input , ",");
CALC(tmp, ",C,D,DC,DCT," , chkstr, "FIND");
IF(tmp< 0 ? case_default : [LOAD(chkstr,"case_",input); RUN(chkstr);]);
This 3 line technique adds "," to front and end of the input value
and loads into chkstr
If input="DC" then chkstr=",DC,"
A CALC command compares the chkstr with a list to identify if the input
value exists
The existing commands are defined by ",C,D,DC,DCT,"
If tmp is -1 the input does not exist and the default function "case_default" is RUN.
If tmp is 0+n, the command exists and a prefix is added to input and
RUN.
Where input = "DC", it exists so the function name "case_DC" is
created and RUN
tmp and chkstr are predefined variables type S8 and TXT.
FUNC(case_DC) {..............}
FUNC(case_DCT) {..............}
FUNC(case_C) {..............}
FUNC(case_D) {..............}
FUNC(case_default) { ............} |