Menu

SysCls problems

2005-02-21
2012-08-14
  • Francesc Rosés

    Francesc Rosés - 2005-02-21

    Hello,

    I have a problem with SysCls RexxUtil function. If I call this function as a procedure (i.e., Call SysCls) it works as expected, but if I call it as a function (i.e., SysCls()), an error appears: "0 is an unknown internal or external command" [I translate the error message from Spanish].

    It seems the return code is issued as a OS command.

    I use other RexxUtil functions without problem.

    My OS is a Spanish W2K (at latest level available).

    Anyone more with this problem?

    Thanks,

    Francesc Ross

     
    • Rick McGuire

      Rick McGuire - 2005-02-21

      This is not a problem with SysCls(), but rather standard Rexx behavior for any function call. Rexx is not the C language, so

      call SysCls

      and

      SysCls()

      are not the same thing. The first is a CALL instruction, which calls the SysCls utility function. The second is a COMMAND instruction, so the command expression is evaluated (your call to the SysCls() function), and the expression result is issued as a command to the current ADDRESS environment. You can see the same behavior using other functions. For example,

      substr("echo Hello World", 1)

      will display "Hello World" on a Windows system. To issue the function without making the instruction a command, you need to turn it into an assignment.

      rc = SysCls()

       
    • Rick McGuire

      Rick McGuire - 2005-02-22

      I'm note sure I understand what you mean by "as it is a String"....SysCls() returns a string. If it appears it is doing nothing, then it is because SysDriveInfo() actually returns a string that is a valid Windows command...it appeas like it is doing nothing because it is actually doing something! This is generally very dangerous to rely on!.

       
    • Francesc Rosés

      Francesc Rosés - 2005-02-22

      Hi Rick,

      SysDriveInfo("C:") returns a String (in my computer: "C: 97880567808 120031477760") I think this String is forwarded to the default environment (in my computer, "CMD") but CMD does nothing with the SysDriveInfo() returned string. May be the returned string is a valid Windows command, I think the command is C: and the parameters to this command ("97880567808 120031477760") are ignored.

      In this case nothing happens but as you said, it is very, very dangerous. So the principle must be "If you call a function, assign the result to a variable". I'm wrong?

      Francesc Ross

       
    • Rick McGuire

      Rick McGuire - 2005-02-22

      Yes, that's the principle!

       
    • Francesc Rosés

      Francesc Rosés - 2005-02-22

      Hi Rick,

      Thanks for your answer. I don't remember this detail.

      I suppose when I issue SysDriveInfo("C:") the returned value is forwarded to default environment but as it is a String W2K does nothing.

      Thanks a lot for your work!

      Francesc Ross

       

Log in to post a comment.