Author Topic: Running a check on a variable to see when it comes back without a value  (Read 1632 times)

0 Members and 1 Guest are viewing this topic.

Offline PauloniusTopic starter

  • Elite
  • *
  • *
  • Posts: 2040
  • Activity:
    0%
  • Reputation Power: 29
  • Paulonius is on the verge of being accepted.Paulonius is on the verge of being accepted.Paulonius is on the verge of being accepted.Paulonius is on the verge of being accepted.Paulonius is on the verge of being accepted.
  • Respect: +162
  • Referrals: 1
    • View Profile

I am working on a script that runs a series of acts based on a string of data input.  I am thinking that I want to put in a conditional to break out of the sub when the variable comes back empty.  I am not sure what value I should put in to represent a variable with no assigned value, but I think I have seen people use -1 for this. Would this work to to jump out of my sub when it hits an unassigned variable?

If %Variable = -1
 Return

 
This coin declares Caesar is "Dictator for Life." He did serve as Dictator for the remainder of his life, but his life would end only a few weeks after this issue. For Caesar to put his image on coins and essentially declare himself king was too much for Brutus and his republican allies.

"If everything seems under control, you're not going fast enough'
-Mario Andretti

"If everyone is thinking alike, someone isn't thinking."
- General George Patton Jr

Offline Masscre

  • Gran Master Jester !!
  • Scripthack
  • *
  • Posts: 4615
  • Activity:
    0%
  • Reputation Power: 55
  • Masscre is leading the good life!Masscre is leading the good life!Masscre is leading the good life!Masscre is leading the good life!Masscre is leading the good life!Masscre is leading the good life!Masscre is leading the good life!Masscre is leading the good life!Masscre is leading the good life!Masscre is leading the good life!Masscre is leading the good life!
  • Gender: Male
  • Air Guitar Commander !!
  • Respect: +144
  • Referrals: 1
    • View Profile
Re: Running a check on a variable to see when it comes back without a value
« Reply #1 on: November 12, 2009, 06:55:43 PM »
0
You will need a loop of some type to hold you in the process. Here is an example but is not the gospel.

Sub Continue
repeat
do alot of stuff here
until %variable = -1
return

I can help alot more if you can give me some code to work with though or pass me the code you are trying to figure out and I will step you into it.

Offline PauloniusTopic starter

  • Elite
  • *
  • *
  • Posts: 2040
  • Activity:
    0%
  • Reputation Power: 29
  • Paulonius is on the verge of being accepted.Paulonius is on the verge of being accepted.Paulonius is on the verge of being accepted.Paulonius is on the verge of being accepted.Paulonius is on the verge of being accepted.
  • Respect: +162
  • Referrals: 1
    • View Profile
Re: Running a check on a variable to see when it comes back without a value
« Reply #2 on: November 12, 2009, 07:10:55 PM »
0
I built a ladder and the script drops down it one step at a time executing a series of subs. I wanted to the use the conditional to check each time after the first to decide whether to take the next step, or return. 

If -1 is the value I can use to check, then that is what I needed.

Thanks M!!!
This coin declares Caesar is "Dictator for Life." He did serve as Dictator for the remainder of his life, but his life would end only a few weeks after this issue. For Caesar to put his image on coins and essentially declare himself king was too much for Brutus and his republican allies.

"If everything seems under control, you're not going fast enough'
-Mario Andretti

"If everyone is thinking alike, someone isn't thinking."
- General George Patton Jr

Tags: