Jump to content

Still having issues...


Recommended Posts

I'm having an issue where is my variable is above the while statement the case inside the while won't pick it up.

Case $rankup
         $cost = ($rank * 125)
      If $cost - 1 > $bal Then
         Call(disable())
      EndIf
      If GUICtrlRead($label) > 0 Then
      $rank = $rank + 1
         If $cost < $bal Then
      $bal = ($bal - $cost)
      GUICtrlSetData($label,$bal)
      GUICtrlSetData($currentrank,$rank)
   Else
          MsgBox(4096,"ERROR","Sorry you do not have enough money to rankup continue playing to make more!")
      EndIf
   EndIf

If I put $cost = ($rank * 125)  outside the Case $rankup nothing inside $rankup will catch it.

However if I change the code to this.

Case $rankup
       If $testcost = "1" Then
             $cost = ($rank * 125)
           endif
      If $cost - 1 > $bal Then
         Call(disable())
      EndIf
      If GUICtrlRead($label) > 0 Then
      $rank = $rank + 1
         If $cost < $bal Then
      $bal = ($bal - $cost)
      GUICtrlSetData($label,$bal)
      GUICtrlSetData($currentrank,$rank)
   Else
          MsgBox(4096,"ERROR","Sorry you do not have enough money to rankup continue playing to make more!")
      EndIf
   EndIf

And put $testcost = "1" outside the Case $rankup the if/then works and $cost will then = ($rank * 125).

Another problem though is if I make it so $testcost = ($rank * 125) outside the Case $rankup and change the if/then accordingly nothing will happen.

I'm trying to make it so it disables the button if $bal isn't high enough for $cost but I have to press the button in order for it to actually work. I've been testing and moving stuff around for about 2 hours now and I can't get it to work.

Any ideas on how I can get this to work?

Thanks (Sorry for all the questions I'm really trying to learn and everyone's comments really helping)(If you need the full code I'll gladly post it for you)

Edited by gottygolly
Link to comment
Share on other sites

When you say outside If I put $cost = ($rank * 125)  outside the Case $rankup, where did you put it ?

If you put it between Switch and Case, then is no change that this work

$a = 1

Switch $a
    $a = 2 ; ignored
    Case 1
        ConsoleWrite(1 & @CRLF)
EndSwitch

Also the Call() syntax that you used is not good, you may replace it by Call("disable")

Link to comment
Share on other sites

I put it above the while lopp where all the other variables are such at buttons, labels and other stuff.

Call(disable()) works too but I'll try the Call("disable")

The problem is the if statement to make the $rankup disabled is inside the actual button so you have to press it so it can use the if/then statement to disable the button.

Is there a away to make it check all the time so you won't have to press the button for it to be disabled?

Edited by gottygolly
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...