Anyone know why this code dies with "In class RdaSot: void main(String
argv[]) is not defined" when it's run using the java command. It compiles fine. import xclasses. class RdaSot Properties Public optionLine = Rexx[] sayLine = Rexx[] temp = Rexx sayLineTemp = Rexx optionLineTemp = Rexx method main(argv=rexx) public parse argv datfile . version() sayLine[0] = 0 optionLine[0] = 0 if datfile = "" then Do say 'No menu file specified - using main.dat' datfile = "main.dat" end loop Forever menu = xfile(datfile) -- get data menu.read() -- read it in loop i = 1 to menu.lines -- parse out the options temp = menu.line[i] parse temp sayLineTemp'::'optionLineTemp sayLine[i] = sayLineTemp optionLine[i] = optionLineTemp End loop i = 1 to menu.lines -- display the menu say sayLine[i] End Say "Enter Option: " -- get the user input option = ask If option.upper = "QUIT" then leave datfile = optionLine[ask] -- figure out the next dat file End Exit 0 method version() Private Static Say 'RDASOT Simulator Version 3.0' Say 'Author: J. Pedone 1998' Say 'E-Mail: [hidden email]' say 'Press ENTER to continue' option = ask return Using OS/2 java 1.1.6 (beta) and NetRexx 1.132 15 Apr 1998 TIA j. [hidden email] (\ /) http://www.flash.net/~jpedone (\ - /) (\ ( ) /) (/ < > \) (/\/\) / \ ( ) Friends encourage friends to use Windows - under OS/2! A bug in the code is worth two in the documentation. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 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> |
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> |
Free forum by Nabble | Edit this page |