Shop OBEX P1 Docs P2 Docs Learn Events
Trying to create 'methods'//issues with 'global' arrays. — Parallax Forums

Trying to create 'methods'//issues with 'global' arrays.

steve_bsteve_b Posts: 1,563
edited 2005-01-28 20:28 in General Discussion
Hi Guys,
I'm slowly making progress doing some simple rs232 string manipulation.·

I've come to the realization that, similar to using gosubs/returns in Pbasic, that I'd like to do something similar in the Javelin IDE.· I think these are called methods or functions.

Anyhow, I've gotten my variables moved in to global spots, ( static int x = 0; ) which works well enough.
But I get errors when trying to push my array out there.
So...outside of main(), I have: public static char [noparse]/noparse testarray;
········································ ·testarray = new char [noparse][[/noparse]59];
Even if I take out the 'public static' from teh first line I get the same error, which is: "Syntax: , expected instead of this token"· Double clicking on the error refers me back to the last ';' after testarray.· I don't know what to do with this.· Replacing the ; with a , gets me an error of: "Error: Duplicate declaration of field "testarray" in type "ACUtest2" "

Now if a put: "public static char [noparse]/noparse testarray;
···················public static testarray = new char [noparse][[/noparse]59];"·
My error becomes: " Syntax: VariableDeclaratorld expected after this token " which refers to the testarray in the 2nd line (in bold).

I'm expecting I'll have to change my whole program around for other reasons, but would still like to know (for future use) what I'm doing wrong!

The code is attached!

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·

Steve
http://members.rogers.com/steve.brady
"Inside each and every one of us is our one, true authentic swing. Something we was born with. Something that's ours and ours alone. Something that can't be learned... something that's got to be remembered."

Comments

  • Jon KeinathJon Keinath Posts: 146
    edited 2005-01-28 19:32
    try this...

    public static char [noparse]/noparse testarray = new char [noparse][[/noparse]59];
  • steve_bsteve_b Posts: 1,563
    edited 2005-01-28 20:28
    That worked...thanks Jon.



    Certainly is more nice to be able to use 'functions/methods' rather than a whole lot of nested loops (easier to follow too!).



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·

    Steve
    http://members.rogers.com/steve.brady
    "Inside each and every one of us is our one, true authentic swing. Something we was born with. Something that's ours and ours alone. Something that can't be learned... something that's got to be remembered."
Sign In or Register to comment.