proc argument

Hi!
Please tell me why it works with num, but does not work with string?

it work:
PROC main
    test 1;
    test 2;
ENDPROC

PROC test (num x)
    IF x = 1 THEN
        ...
    ELSEIF x = 2 THEN
        ...
    ENDIF
ENDPROC

it will be error:

PROC main
    test first;
    test second;
EMDPROC

PROC test (string x)
    IF x = first THEN
        ...
    ELSEIF x = second THEN
        ...
    ENDIF
ENDPROC

Best Answers

  • Maxim Riabichev
    Maxim Riabichev Sweden admin
    edited January 11 Accepted Answer
    Don't use "test" as proc identifier. It looks like it's reserved.

    This syntax seems to work:

       PROC abc(string x)
            IF x="first" THEN
            ELSEIF x="second" THEN
            ENDIF
        ENDPROC

        PROC abcd(num x)
            IF x=2 THEN
            ELSEIF x=3 THEN
            ENDIF
        ENDPROC


  • lemster68
    lemster68 United States ✭✭✭
    Accepted Answer
    Also your syntax when calling:
      Test "first";
    To indicate that it is passing a string into the procedure.
    And, same as Maxim's example, you need to have the quotation marks to indicate string data type:
    IF x = "first" THEN
    UNLESS it is the name of an already declared string data.

Answers

  • lemster68 said:
    Also your syntax when calling:
      Test "first";
    To indicate that it is passing a string into the procedure.
    And, same as Maxim's example, you need to have the quotation marks to indicate string data type:
    IF x = "first" THEN
    UNLESS it is the name of an already declared string data.
    The quotation marks. Here's what I missed when working with string. Thanks!

    p.s.

    I used "test" just for the sample code