viewpoint-particle

Author Topic: Variable value is changing when I click the OK button  (Read 7467 times)

jtrask

  • Jr. Member
  • **
  • Posts: 71
Variable value is changing when I click the OK button
« on: June 02, 2015, 08:19:13 am »
I have created a Dynamic Dialog with a subroutine callback procedure.  Everything is working great except for the one stupid checkbox I added to the dialog.

I go into the dialog with the variable vintRunMode = 2.  It retains that value, as it should, but when I come out of the subroutine that is my dialog, the value is set to 1.  I added the line vintTest = vintRunMode, right before the Return(@retDefault) for my OK button.  The value is still set to 2.  I continue processing and the value is immediately set to 1.

I tried a different vintRunMode value going in and determined that something is decreasing its value by 1.  If I go in with vintRunMode = 1, it gets set to 0. 

I have set breakpoints on every line that set/change the value of vintRunMode and they all seem to be behaving like they should. I'm slowly being driven mad!

JTaylor

  • Pundit
  • *****
  • Posts: 1939
    • Data & Stuff Inc.
Re: Variable value is changing when I click the OK button
« Reply #1 on: June 02, 2015, 08:59:18 am »
The value of a checkbox ends up as 1 or zero.   It would be nice if one could set/retrieve the "Value" as something else.  It makes you think you can do that in the setup but it is all illusion.

Jim

jtrask

  • Jr. Member
  • **
  • Posts: 71
Re: Variable value is changing when I click the OK button
« Reply #2 on: June 02, 2015, 11:04:11 am »
I'm taking that 1/0 from the checkbox and using that to set vintRecursive.  Then I use the value to vintRecursive to determine what the value of vintRunMode should be.  It's vintRunMode that magically changes when I leave my dialog.

JTaylor

  • Pundit
  • *****
  • Posts: 1939
    • Data & Stuff Inc.
Re: Variable value is changing when I click the OK button
« Reply #3 on: June 02, 2015, 11:27:07 am »
Sorry...Misunderstood.

Jim

td

  • Tech Support
  • *****
  • Posts: 4382
    • WinBatch
Re: Variable value is changing when I click the OK button
« Reply #4 on: June 02, 2015, 02:01:40 pm »
I'm taking that 1/0 from the checkbox and using that to set vintRecursive.  Then I use the value to vintRecursive to determine what the value of vintRunMode should be.  It's vintRunMode that magically changes when I leave my dialog.

Control variables are only updated to reflect the control's state when you press the dialog's 'OK' button (or whatever you call the button with a value of 1) to dismiss the dialog, otherwise, all control variables are untouched and retain whatever value you last assigned to them.   The dialog function can use values other than 0 or 1 if more than one checkbox shares the same variable.  In this situation the 0 or 1 state of the bits of the integer variable represent the states of each checkbox that shares the variable.

Since the variable ' vintRunMode' is a control variable for only one checkbox, it will be set to 0 or 1 by the dialog function only when the 'OK' button is pressed to dismiss the dialog.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

jtrask

  • Jr. Member
  • **
  • Posts: 71
Re: Variable value is changing when I click the OK button
« Reply #5 on: June 03, 2015, 06:47:01 am »
I figured it out.  In my callback procedure, I was treating the value of my checkbox to set one variable (vintRecursive) because vintRunMode could be more than just a 0/1.  What I forgot is that when I created the diagram, I set the checkbox to set vintRunMode.  I changed my dialog and it all started working like I thought I'd set it up in the first place.

Thank you for your help.