Re: Why .... In class RdaSot: void main(String argv[]) is not defined

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Re: Why .... In class RdaSot: void main(String argv[]) is not defined

Andre Gillieron


Mike Cowlishaw <[hidden email]> writes:

>Yes .. Java requires that there be a static 'main' method that takes
>an array of Strings (one word per String, C-style).  NetRexx provides
>that automatically for you only when it also provides the CLASS
>instruction (as in hello.nrx).
>
>Something like this is probably what you want:
>
>    method main(argstrings=3DString[]) static
>      argv=3DRexx(argstrings)
>

I originally did this but got into trouble with my indexed variables. I
declared them as:

-- 4. Assign properties.
     Properties Public
     optionLine = Rexx[]

-- 5. Main method (ignored when loaded by a browser).
     method main(argstrings=String[]) public static
     arg=Rexx(argstrings)

with the keyword STATIC in the main method I received compile errors
saying I could not reference non-static  method OPTIONLINE directly
from a in a static method.

  So I took STATIC out and changed STRING[] to REXX[]. (if STRING[] was
left in it method main defaulted to STATIC.)  It compiled but obviously
did not work.
  I did find that if I declare main as everyone suggested, got rid of
properties and rearranged the declarations as:

-- 5. Main method (ignored when loaded by a browser).
     method main(argstrings=String[]) public static
     arg=Rexx(argstrings)
     optionLine = Rexx[]

     parse arg ........

everything worked.  So... I guess this has something to do with the
scope of declared variables ?  Does netrexx recognize such a thing as a
global declaration or do variables always have to be passed between
functions as arguments ?

j.

[hidden email]                         (\         /)
http://www.flash.net/~jpedone        (\    -   /)
                                                       (\   ( )  /)
                                                       (/ <  > \)
                                                          (/\/\)
                                                          /    \
                                                        (        )
OS/2 VirusScan - "Windows found: Remove it? (Y/y)"
Bug?  That's not a bug, that's a feature.       -T. John Wendel

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~
To unsubscribe from this mailing list ( ibm-netrexx ), please send a note
to
[hidden email]
with the following message in the body of the note
unsubscribe ibm-netrexx <e-mail address>


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To unsubscribe from this mailing list ( ibm-netrexx ), please send a note to
[hidden email]
with the following message in the body of the note
unsubscribe ibm-netrexx <e-mail address>