The Museum of HP Calculators

HP Forum Archive 08

[ Return to Index | Top of Index ]

RPL help. . .
Message #1 Posted by Tal on 11 Aug 2002, 4:04 a.m.

Hi, All!

I have a repeatable file result that stored in "xxx" variable.

Does anyone could help to check if this file is exist and if so the result file name will be changed and will be stored as "xxx1" and so on.

Best regards, Tal

      
Re: RPL help. . .
Message #2 Posted by James M. Prange on 11 Aug 2002, 5:15 p.m.,
in response to message #1 by Tal

To check whether the variable exists, use RCL within an IFERR structure, like this:

\<<
  'XXX'
  IFERR
    RCL
  THEN
    (whatever action to take if the variable doesn't exist goes here)
  ELSE
    DROP (whatever action to take if the variable does exist goes here)
  END
\>>
You may want to refine the THEN clause by nesting a conditional (IF... or CASE...) structure in there with ERRN to check that the error was really #204h, "Undefined Name".

But note that this checks whether the variable exists anywhere on the current path. To restrict the search to the current directory, maybe:

\<<
  VARS 'XXX'
  IF
    POS
  THEN
    (whatever action to take if the variable does exist goes here)
  ELSE
    (whatever action to take if the variable doesn't exist goes here)
  END
\>>
But note that VARS is slow when the current directory is large.

What you want to do resembles what happens when the calculator receives a file with the same name as an existing variable in the same directory and flag -36 is clear, so there may well be a SysRPL entry that would help you.

Regards,
James


[ Return to Index | Top of Index ]

Go back to the main exhibit hall