Oberon Community Platform Forum
November 21, 2019, 07:33:29 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: command line argument  (Read 3141 times)
fnecati
Jr. Member
**
Posts: 60


« on: May 31, 2011, 01:18:05 PM »

If command line argument M.P contains a number in module name or command name, it is not executed; for example, aos -x MyXGear1.Test2

Here is my a quick solution for getCmd() in Unix.BootConsole.Mod;

PROCEDURE getCmd( ): BOOLEAN;
VAR cmd: ARRAY 65 OF CHAR; (* plus dot if available *)
   i, j, k: INTEGER;  c: CHAR;
   BEGIN
      Unix.GetArgval( "-x", cmd );
      IF cmd = "" THEN  RETURN FALSE
      ELSE
         i := 0;
         
         (* return false if first character is a number in module name *)
         c := cmd;
         IF ("0" <= c) & (c <= "9") THEN
            Trace.String( "first character is not a character in module name" ); Trace.Ln;
            RETURN FALSE;
         END;
         modName := c;
         INC(i);
         
         REPEAT  c := cmd;  modName := c;  INC( i );
            IF i > 31 THEN
               Trace.String( "# of characters is > 31 in module name" ); Trace.Ln;
               RETURN FALSE
            END;
         UNTIL ~( ("a" <= c) & (c <= "z") OR ("A" <= c) & (c <= "Z") OR ("0" <= c) & (c <= "9"));
         IF (c = '.') & (i > 1) THEN
            modName[i - 1] := 0X;  j := i;  k := 0;

            (* return false if first character is a number in command name*)
            c := cmd[j];
            IF ("0" <= c) & (c <= "9") THEN 
               Trace.String( "first character is not a character in command name" ); Trace.Ln;
               RETURN FALSE;
            END;
            cmdName[k] := c;
            INC(j); INC(k);
            
            REPEAT  c := cmd[j];  cmdName[k] := c;  INC( j );  INC( k );
               IF k > 31 THEN
                  Trace.String( "# of characters is > 31 in command name" ); Trace.Ln;
                   RETURN FALSE;
               END;
            UNTIL ~(("a" <= c) & (c <= "z") OR ("A" <= c) & (c <= "Z") OR ("0" <= c) & (c <= "9"));
            cmdName[k - 1] := 0X;
            IF k > 1 THEN  RETURN TRUE  END
         END  ;
         Trace.String( "bad command line parameter: -x " );  Trace.String( cmd );  Trace.Ln;
         RETURN FALSE
      END;
   END getCmd;




Logged
gfeldm
Moderator
Newbie
*****
Posts: 29


« Reply #1 on: June 01, 2011, 05:56:33 PM »

Thank you 'fnecati'. Fixed in rev. 4166.

BTW: your program MyXGear.Open works in SolarisAos (on OpenIndiana) as well.

-- Guenter
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!