Global Vars

  1. 5 weeks ago

    Gary D

    Mar 20 London

    In VB6 I used lots of global variables choice1, choice2..... answer1, answer2..... etc to track user input.
    Is that good practice in Xojo?
    Better to put all this into 1 array variable?
    Thanks.

    I have been using a dictionary for that kind of thing. It is far easier to use than an array.
    http://developer.xojo.com/dictionary

  2. Norman P

    Mar 20 Xojo Inc

    Globals are an awful idea for a lot of reasons besides making debugging really darned hard

    Hard to give much more advice without knowing more about the context for your question

  3. just make an array an put them in

  4. Gary D

    Mar 20 London
    Edited 5 weeks ago by Gary D

    it's several pages of colours to choose, then several pages of questions. Sounds neat to put all user input into 1 array, yes.
    Just a regular "array" ?

    Create a module, etc, yes?

  5. Norman P

    Mar 20 Xojo Inc

    colors for ? are these "preferences" - ie/ what colors would you like to use for the questionairre ?

    questions ? multiple choice ? .. yes no true false ?

    If the answers to both are "yes" then you might have a "user preferences" class that holds all those selected colors
    And for questions you might have a Question class that holds the question itself + the users response (and a flag to know if they responded at all so maybe you can go back through them and see they all have answers)

    Then you'd want to have an array of questions

  6. Gary D

    Mar 20 London

    thanks! - will try tomorrow - getting late here

  7. Gary D

    Mar 21 London

    Over some pages, user clicks and selects 20 colour choices (blue is "1" red is "2").
    (eg choice1 ="1", choice2="2" etc.)
    Then the user clicks 20 multiple choice answers ( eg ans1="a", ans2="b")
    Then I say final_choice = choice1+choice2+choice3+choice4
    This could be "1212"
    Then I look this up in a database.

    Best with a module with a global array?

  8. Michel B

    Mar 21 Pre-Release Testers, Xojo Pro Answer

    I have been using a dictionary for that kind of thing. It is far easier to use than an array.
    http://developer.xojo.com/dictionary

  9. Gary D

    Mar 21 London

    Thank you all so much! I'm slowly grinding this thing out.

or Sign Up to reply!