Jump to content

Flushing a variable?


MariusN
 Share

Recommended Posts

I would just like to know if its allowed to change a Variable while a program is running. ie At the moment i'm using "timerint" and have the following --->

$input = 1000

But, i also have a function (while the program is runing) that will change the $input to $input = 2000...

It's working 100%, but i was just wondering if i wont get a buffer overflow by using this type of scheme...

Edited by MariusN
Link to comment
Share on other sites

As long as you stay away of DllStruct* and DllCall you're normally not concerned by buffer overflow, only the developpers are!

Now we generally call "constant" a value that doesn't get ever changed. A contrario, you're free to assign whatever value to whatever variable, as long as no language or function requirement is invalidated doing so.

That being said, it's impossible to have the faintest clue about what you refer to in your vague post. Please post short code which doesn't work as you expect, explain what you expect and you may hope some help.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

It's working 100%, but i was just wondering if i wont get a buffer overflow by using this type of scheme...

His question wasn't about broken code but about the language. And his question seemed perfectly readable to me. Edited by BillLuvsU

[center][/center]Working on the next big thing.Currently Playing: Halo 4, League of LegendsXBL GT: iRememberYhslaw

Link to comment
Share on other sites

OK, my bad to be unable to read english. BTW given the grammar/spelling used in some brit/yank posts around, I don't feel that much ashamed...

But then, which "scheme" precisely are you both refereing to?

Is it the "are we allowed to change a variable while the program is running" part?

Up to now, the OP uses TimerInit. Well, fine.

He/she has a variable $input = 1000. Still fine.

He/she has a function. Fine again

And wonders if executing $input = 2000 would shake earth or not.

At this point, I just can't see what I'm missing that could make the above anything close to a "scheme", leading itself to some form of analysis/diagnosis.

Care to enlighten me?

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

OK, my bad to be unable to read english. BTW given the grammar/spelling used in some brit/yank posts around, I don't feel that much ashamed...

But then, which "scheme" precisely are you both refereing to?

Is it the "are we allowed to change a variable while the program is running" part?

Up to now, the OP uses TimerInit. Well, fine.

He/she has a variable $input = 1000. Still fine.

He/she has a function. Fine again

And wonders if executing $input = 2000 would shake earth or not.

At this point, I just can't see what I'm missing that could make the above anything close to a "scheme", leading itself to some form of analysis/diagnosis.

Care to enlighten me?

Don't stress Spammer...RELAX...lololol

I'm not English myself :mellow:

Ok, i'll try again...You see, i have a program that IS WORKING 100%...no doubt about that, but i am just a little concerned about the following...

My program does a "check" to the internet every 10 minutes, but i ALSO have a button in the program, that will actually CHANGE the 10 minutes to 5 minutes...WHILE THE PROGRAM IS STILL RUNNING!

I was just worried that IF i change the 10 minutes to 5 minutes (while the program is stil running), that it might interfere with the veriable (ie $test = 10 will become $test = 5 WHILE the program is running)

While we are on the topic, i also have a function --->

If $ping > 0 Or $ping2 > 0 Or $ping3 > 0 Or $ping4 > 0 Or $ip <> -1 Then

...is there a way you can assign a variable to an "if" statement?

For example

$var = If $ping > 0 Or $ping2 > 0 Or $ping3 > 0 Or $ping4 > 0 Or $ip <> -1 Then

This doesnt work, but i need something to replace the "$var" statement...if possible.

thx guys

Link to comment
Share on other sites

No problem, I'm perfectly relax (except against a failing LaCie NAS)

I see, you ask if you can change on the fly a target variable against which you test the result of a TimerDiff(). I hardly see how this can break anything, at the engine level at least.

What TimerInit does is derive a millisecond value from the current value of a Windows 10MHz timer originating at Windows epoch (01/01/1601). When you do TimerDiff($timerstart), another millisecond "snapshot" of the fast timer is taken and you are returned the difference between the two values.

So if your code is doing repeatedly If TimerDiff($timerstart) > $polldelay Then [do something] , with $polldelay set to 10 * 60 * 1000 (10 minutes) your [something] will fire about every 10 minutes but if you change the value of $polldelay to whatever you want, the test will succeed or fail accordingly. Thus you "see" you just can't harm anyone with this, at least if your [something] is never dangerous.

...is there a way you can assign a variable to an "if" statement?

No, as If ... is not an rvalue (are you thinking of the C ternary operator, here?). Anyway, it would be assigning *** to a variable, not the other way round.

Make your assignment like this:

$var = $ping > 0 Or $ping2 > 0 Or $ping3 > 0 Or $ping4 > 0 Or $ip <> -1

; now $var is a boolean variant

If $var Then ...

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...