Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / "Failed" variable name in type

Author
Message
EdzUp
22
Years of Service
User Offline
Joined: 8th Sep 2002
Location: UK
Posted: 13th Aug 2022 14:50
I was going to have a variable called "Failed" in a type to keep a list of how many items has well Failed but AppGameKit will not compile at all with that variable. In the 3nd i called it "Fail".

Is there a list of protected variable names?
-EdzUp
Patreon: https://www.patreon.com/EdzUp
Buy me a coffee:https://www.buymeacoffee.com/EdzUp
Steve Ancell
18
Years of Service
User Offline
Joined: 16th Feb 2006
Location: Brighton, East Sussex, UK
Posted: 13th Aug 2022 22:18 Edited at: 13th Aug 2022 22:25
I don't know what's happening your end mate, I just tried creating a variable with that name and there were no problems.

I tried Failed as a string, integer and float. All three worked with the print command as output.
Steve Ancell
18
Years of Service
User Offline
Joined: 16th Feb 2006
Location: Brighton, East Sussex, UK
Posted: 13th Aug 2022 22:32
Working inside a type too.


adambiser
AGK Developer
9
Years of Service
User Offline
Joined: 16th Sep 2015
Location: US
Steve Ancell
18
Years of Service
User Offline
Joined: 16th Feb 2006
Location: Brighton, East Sussex, UK
Posted: 14th Aug 2022 00:28
I just realised I'm using AppGameKit Studio, I'll install AppGameKit Classic and try this again.
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 14th Aug 2022 00:45
working fine here:

Classic 2022.06.27
Steve Ancell
18
Years of Service
User Offline
Joined: 16th Feb 2006
Location: Brighton, East Sussex, UK
Posted: 14th Aug 2022 00:45
Working on AGK2 here, may be worth doing an uninstall-reinstall Ed.
EdzUp
22
Years of Service
User Offline
Joined: 8th Sep 2002
Location: UK
Posted: 14th Aug 2022 15:54
In the type I have "Failed as integer" and I get "Error: variable declaration must start with a variable name"

the type is just a type of equipment classes and the failed variable:
Type MyType
Eq1 as EquipmentClass[ 0 ]
Eq2 as EquipmentClass[ 0 ]
Failed as integer
EndType

sort of thing
-EdzUp
Patreon: https://www.patreon.com/EdzUp
Buy me a coffee:https://www.buymeacoffee.com/EdzUp
EdzUp
22
Years of Service
User Offline
Joined: 8th Sep 2002
Location: UK
Posted: 14th Aug 2022 15:58 Edited at: 14th Aug 2022 16:00


Is what I get with the source provided by Virtual Nomad.

Uninstall and reinstalled and still the same error :/
-EdzUp
Patreon: https://www.patreon.com/EdzUp
Buy me a coffee:https://www.buymeacoffee.com/EdzUp
Steve Ancell
18
Years of Service
User Offline
Joined: 16th Feb 2006
Location: Brighton, East Sussex, UK
Posted: 14th Aug 2022 16:22
Works fine here mate.


Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 14th Aug 2022 16:45 Edited at: 14th Aug 2022 17:35
run the test code in its own project?

you're using it inside your larger project where you may have already declared Failed or some other code is conflicting somewhere?

the Unexpected Token is probably referring to your use of GetStringToken() or GetStringToken2() somewhere, so...

i dont know what gets compiled when but i'm pretty sure it's not in the exact order that we enter the code? in other words, just because that test code is near the top of your code, it doesn't mean "later" code doesn't make it to the compiler first. someone please feel free to correct me here

add, this compiles/runs fine for me:

which version of Classic are you running. this is now ringing a bell from a couple of years ago. i'll start searching...

THIS is what i was referring to and doesn't seem related but reading raven's response in the thread may provide some insight (i don't have time to get through it all ATM).

meanwhile, i've added #option_explicit:

...and i still have no issues where i expected:

to "error: "Failed" has not been defined" along with "Succeeded" but didn't.
EdzUp
22
Years of Service
User Offline
Joined: 8th Sep 2002
Location: UK
Posted: 14th Aug 2022 17:58
Im running 2022.06.27 under steam.

On its own it compiled but if I add it to the top of the main.agc file so it runs without anything else (its remed out with /*...*/) it fails. It wouldnt be to bad if there was something else declared in the type called 'Failed' but there isnt and for it to fail in such a manner doesnt leave me much room to wonder where its gone wrong especially as changing it to "Fail" works flawlessly.
-EdzUp
Patreon: https://www.patreon.com/EdzUp
Buy me a coffee:https://www.buymeacoffee.com/EdzUp
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
MadBit
VIP Member
Gold Codemaster
15
Years of Service
User Offline
Joined: 25th Jun 2009
Location: Germany
Posted: 14th Aug 2022 19:27 Edited at: 14th Aug 2022 19:31
Maybe a constant defined as Failed causes this error?
Share your knowledge. It\'s a way to achieve immortality. (Tenzin Gyatso)
EdzUp
22
Years of Service
User Offline
Joined: 8th Sep 2002
Location: UK
Posted: 14th Aug 2022 22:18 Edited at: 14th Aug 2022 22:20
Gone through the source even done a forward declaration with constant, global and local at the top of the main source file and it fails in the same way. There is nothing called "Failed" in the aource which is why I was wondering about hidden variables for thw agk interpreter maybe

Seeing as a seperate file compiles though its gonna have to be one of those oddities for large projects (over 85000 linea in total now)
-EdzUp
Patreon: https://www.patreon.com/EdzUp
Buy me a coffee:https://www.buymeacoffee.com/EdzUp
adambiser
AGK Developer
9
Years of Service
User Offline
Joined: 16th Sep 2015
Location: US
Posted: 15th Aug 2022 03:06
Be sure to look for files you've #included or #inserted that might not be in the project itself.
EdzUp
22
Years of Service
User Offline
Joined: 8th Sep 2002
Location: UK
Posted: 15th Aug 2022 17:35
Weirdly enough it was a corrupted AppGameKit file i think it was probably thinking the variable was in there, after replacing it all it seems to be fine now. Certainly had a lot of head scratching with that one
-EdzUp
Patreon: https://www.patreon.com/EdzUp
Buy me a coffee:https://www.buymeacoffee.com/EdzUp

Login to post a reply

Server time is: 2024-11-21 13:17:50
Your offset time is: 2024-11-21 13:17:50