Clarion 9.1 - use Variable for Routine Name

172 views Asked by At

I need to pass the name of a Clarion routine to a Variable and run it.

E.g:

!************************

RoutineName='CalculateSomething'

DO RoutineName

!************************

It does not work in this format so I've also tried other characters (brackets, quotations etc) before and after the variable. No luck.

Please note that the Routine 'CalculateSomething' exists and runs fine with the basic command:

!************************

DO CalculateSomething

!************************

2

There are 2 answers

1
brahnp On

How about using a case statement to do this?

RoutineName='CalculateSomething'

CASE RoutineName
OF 'CalculateSomething'
  DO CalculateSomethingRoutine
OF 'SomethingElse'
  DO SomethingElseRoutine
ELSE
  Stop('Unknown routine named: ' & RoutineName)
END
1
Y. M. On

I think there no option like that on the Clarion programing language.

The only way that I suggest to CASE statement like that:

RoutineName='CalculateSomething' 

    CASE UPPER(RoutineName)  
    OF 'CALCULATESOMETHING' 
        DO CalculateSomething
    OF 'CALCULATESOMETHINGELSE' 
        DO CalculateSomethingElse 
    OF 'CALCULATENOTHING'
        DO CalculateNothing 
    END