jeudi 21 novembre 2019

Why is my Applescript IF Loop and "Equals To" operator not working properly?

I have an applescript Progress Bar Simulator and I have the user select a menu item from a list:

set gameMenuOption to choose from list simMenu with prompt "
Slot: " & item slot of gameslots & "

Mulla: $" & gameMulla & "
Assets: " & gameAssets & "
Speed: " & gameLoadSpeed & "Assets Per Second"

The prompt is basically the user's assets, money, etc. So when they select something from the menu, they can also take a look at their stats. So when they select something, it processes the input:

if gameMenuOption = "Shop" then
    set gameShopOption to choose from list simShop with prompt "Shop: "
else if gameMenuOption is equal to "Load Progress Bar" then
    --not finished yet!
else if gameMenuOption is equal to "Sell Assets" then
    set gameMulla to gameMulla + gameAssets
else
    error -128
end if

The if statement doesn't work! I have researched the syntax of an IF loop on applescript and operators and re-read my code over and over again but I don't see any errors! When the user selects an option, it just returns the -128 error that I purposely wrote but It isn't supposed to do that... I even tested it with display dialog:

--> User enters: Sell Assets
display dialog gameMenuOption
--> Returns: Sell Assets

But when I do this:

display dialog gameMenuOption = "Sell Assets"
--> Returns: False

Also, I thought I needed to convert it to a string but that didn't work:
Expected expression but found “to”.

Please help me!

Aucun commentaire:

Enregistrer un commentaire