Search code examples
commandsignalsrexx

CMD, REXX, need a way to detect an error


I'm very very new to programming/coding. And I have a very specific question, which I didn't find any answers to. This command below executes perfectly fine if the command is valid. If I enter an invalid command, an error occurs and the cmd exits. enter image description here

But how do I make it, if an error happens, the program starts from the beginning rather than the cmd window closes?

So, in short, I want "SIGNAL start" to happen if an error occurs.

I hope you understand, thank you very much.

other:
    SAY "Enter your own command:"
    PULL command
    command

        IF command=ERROR THEN DO
        SIGNAL start

Solution

  • It would be helpful if you published all of your code but it seems that what you really need to do is code a loop.

    /* REXX */
    
    do forever
      say "Enter a command"
      pull command
      "where" word(command,1)
      if rc <> 0 then iterate
      command
    end