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?
Posted: 13th Aug 2022 22:18
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.
Posted: 13th Aug 2022 22:32
Working inside a type too.

+ Code Snippet
// Project: FailedVariable 
// Created: 22-08-13

// show all errors

SetErrorMode(2)

// set window properties
SetWindowTitle( "FailedVariable" )
SetWindowSize( 1024, 768, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window

// set display properties
SetVirtualResolution( 1024, 768 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 )


global myInstance as MyType
myInstance.Failed = 123


do
    Print(myInstance.Failed)
    Sync()
    
loop


type MyType
	Failed as integer
	
endtype

Posted: 13th Aug 2022 23:22
What is the compile error?
Posted: 14th Aug 2022 0:28
I just realised I'm using AppGameKit Studio, I'll install AppGameKit Classic and try this again.
Posted: 14th Aug 2022 0:45
working fine here:
+ Code Snippet
SetErrorMode(2)

// set window properties
SetWindowTitle( "Failed" )
SetWindowSize( 1280,720, 0 )
SetWindowAllowResize( 1 )

// set display properties
SetVirtualResolution( 1280,720)
SetOrientationAllowed( 1, 1, 1, 1 )
SetSyncRate( 30, 0 ) 
SetScissor( 0,0,0,0 )
UseNewDefaultFonts( 1 ) 

Type Result
	Failed, Succeeded
EndType

Results as Result

do

    If GetRawKeyState(27) then End    

	If Last# + 0.25 <= Timer()
		If Random(1,2) = 1 then INC Results.Failed else INC Results.Succeeded
		Last# = Timer()
	EndIf
	Print(Results.Failed)
	Print(Results.Succeeded)
	
    Sync()
loop

Classic 2022.06.27
Posted: 14th Aug 2022 0:45
Working on AGK2 here, may be worth doing an uninstall-reinstall Ed.
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
Posted: 14th Aug 2022 15:58


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

Uninstall and reinstalled and still the same error :/
Posted: 14th Aug 2022 16:22
Works fine here mate.

+ Code Snippet
// Project: Failed2 
// Created: 22-08-14

// show all errors

SetErrorMode(2)

// set window properties
SetWindowTitle( "Failed2" )
SetWindowSize( 1024, 768, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window

// set display properties
SetVirtualResolution( 1024, 768 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 )


type Result
	Failed, Succeded
	
endtype

results as Result


do
	if GetRawKeyState(27) then end
	
	if GetRawKeyPressed(32)
		if random(1, 2) = 1
			inc results.Failed
			
		else
			inc results.Succeded
			
		endif
		
	endif
	
	print (results.Failed)
	print (results.Succeded)
	
    Sync()
    
loop

Posted: 14th Aug 2022 16:45
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:
+ Code Snippet
Failed as String	:	Failed = "Failed String"

Type Result
	Failed, Succeeded
EndType
Results as Result

do
    If GetRawKeyState(27) then End    
	If Last# + 0.25 <= Timer()
		If Random(1,2) = 1 then INC Results.Failed else INC Results.Succeeded
		Last# = Timer()
	EndIf
	Print(Results.Failed)
	Print(Results.Succeeded)
	Print(Failed)
    Sync()
loop

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:
+ Code Snippet
SetErrorMode(2)
#option_explicit

// set window properties
SetWindowTitle( "Failed" )
SetWindowSize( 1280,720, 0 )
// set display properties
SetVirtualResolution( 1280,720)
SetOrientationAllowed( 1, 1, 1, 1 )
SetSyncRate( 30, 0 ) 
SetScissor( 0,0,0,0 )
UseNewDefaultFonts( 1 ) 

Failed as String	:	Failed = "Failed String"
Last# as Float

Type Result
	Failed, Succeeded
EndType
Results as Result

do
    If GetRawKeyState(27) then End    
	If Last# + 0.25 <= Timer()
		If Random(1,2) = 1 then INC Results.Failed else INC Results.Succeeded
		Last# = Timer()
	EndIf
	Print(Results.Failed)
	Print(Results.Succeeded)
	Print(Failed)
    Sync()
loop

...and i still have no issues where i expected:
+ Code Snippet
Type Result
	Failed, Succeeded
EndType

to "error: "Failed" has not been defined" along with "Succeeded" but didn't.
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.
Posted: 14th Aug 2022 18:49
yah, weird
Posted: 14th Aug 2022 19:27
Maybe a constant defined as Failed causes this error?
Posted: 14th Aug 2022 22:18
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)
Posted: 15th Aug 2022 3:06
Be sure to look for files you've #included or #inserted that might not be in the project itself.
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