Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

How do I use variable on first "run" and then discard

DamselDamsel Member Posts: 88
Hi

Not sure is this is an advanced question for you guys but it is for me. I need to make a variable1 with a value of 1. When you run the program for the first time this variable needs to put this 1 in another variable(easy), but then the program needs to ignore the first variable from there on in, and use the second one. And if program is closed completely how do I have variable2 keep its value until user changes it, and then keep that value at this stage it is only 1 or 2 but can become more later on in project.

Damsel

Comments

  • raymcdraymcd Member Posts: 284
    : Hi
    :
    : Not sure is this is an advanced question for you guys but it is for me. I need to make a variable1 with a value of 1. When you run the program for the first time this variable needs to put this 1 in another variable(easy), but then the program needs to ignore the first variable from there on in, and use the second one. And if program is closed completely how do I have variable2 keep its value until user changes it, and then keep that value at this stage it is only 1 or 2 but can become more later on in project.
    :
    : Damsel
    :

    There is a number of ways you could do this. First would be to have text file that gets created on first run and therefore if it doesn't exist, must be first run. You can then put persistent data in that text file.

    You could use a command line parameter on the first run only and check for the parameter. Handle your persistent as you would any other persistent data.

    -Ray
Sign In or Register to comment.