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 / T1 - Compiler thinks a function is a variable

Author
Message
monotonic
18
Years of Service
User Offline
Joined: 24th Mar 2006
Location: Nottinghamshire, England
Posted: 11th Apr 2014 21:18 Edited at: 11th Apr 2014 21:22
Hi Guys,

I'm trying to compile my project, which has been fine up until now. I have added the code file below and the compiler cannot understand a custom function call. It seems to think that my function call is a variable?!?!? This is really annoying, the compiler error messages a pathetically bad.

Can anybody see what the problem is with this code please.

When I try and compile I get a "variable 'SoundManager_LoadSound(Name)' is not valid at line 14 ..." the error happens when I call SoundManager_LoadSound(..)



Edit: I'm using the latest build (not v2) and I'm running in Windows 8.1

Thanks in advance

All programmers are playwrights and all computers are lousy actors.
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 11th Apr 2014 22:32
i got other wrong error message and change this
_nSoundID=g_arrSounds[i].SoundID
ExitFunction _nSoundID



AGK 108 (B)19 : Windows 8.1 Pro 64 Bit : AMD Radeon HD 6670
monotonic
18
Years of Service
User Offline
Joined: 24th Mar 2006
Location: Nottinghamshire, England
Posted: 11th Apr 2014 23:22
Hi Markus,

Thanks for the reply, I have made the change you suggested and the original error has no been resolved. However, another helpful error has appeared "Process terminated with status -1073741819 (0 minutes, 2 seconds)"



Any ideas on this would be a great help, thank you.

All programmers are playwrights and all computers are lousy actors.
Naphier
13
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 11th Apr 2014 23:33
I've had problems with the compiler recognizing functions when the ENDFUNCTION return
is on the last line of a file.
So I've built a habit of adding a carriage return or two and a ` to the end of the file
like this:


I'm not sure if this will help you or not

JimHawkins
14
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 12th Apr 2014 00:29
It might be the order of declaration. Try moving loadsound to the top.

-- Jim - When is there going to be a release?
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 12th Apr 2014 08:18
i can compile this part of code also with 180 21.
maybe try remark all and unremark block for block, you can exclude
parts.
hidden text format chars can also be a problem.

AGK 108 (B)19 : Windows 8.1 Pro 64 Bit : AMD Radeon HD 6670
monotonic
18
Years of Service
User Offline
Joined: 24th Mar 2006
Location: Nottinghamshire, England
Posted: 12th Apr 2014 09:27 Edited at: 12th Apr 2014 09:30
Good morning guys, thanks for the suggestions

OK so this morning I moved the loadsound method to the top of the file and commented everything else out (apart from the type def), it now complains that "Cannot perform 'string' cast on type 'Name' at line ..."

This line is where I assign the Name parameter to my type



I've had enough fighting with the compiler, I haven't used C++ for a while but it shouldn't take me too long to get back up to speed. How much harder is it to port your code over from a Windows target to Android and eventually iOS? I intend to code in Windows and get it up and running then port it to Android and then iOS when I find a cheap enough Mac to compile on.

All programmers are playwrights and all computers are lousy actors.
JimHawkins
14
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 12th Apr 2014 09:33 Edited at: 12th Apr 2014 09:36
Shouldn't that be name$ ?

Maybe not.

-- Jim - When is there going to be a release?
monotonic
18
Years of Service
User Offline
Joined: 24th Mar 2006
Location: Nottinghamshire, England
Posted: 12th Apr 2014 09:36
I thought you could use the nicer type declaration with method params? I used to use this method in DBP years ago.

I have tried changing it from Name as string to Name$, then it complains about the type variable and the parameter being incompatible types. Somehow Name as string and Name$ are not the same type?!?!?!?

All programmers are playwrights and all computers are lousy actors.
JimHawkins
14
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 12th Apr 2014 12:01 Edited at: 12th Apr 2014 14:52
This is all a lot simpler and less error-prone using AppGameKit for Pascal.

Here's a complete unit to implement what you have, without comments, which will be below.



Because there is (in the original) only the need for a name, a StringList is fine. It has the possibility for each entry in the list to have a string and a pointer.

If you wanted a more structured type then you would simply create that instead of the TagkSound and add it to the list in the same way. The object itself would have a pointer to an TagkSound object.

Instead of using indices here were are using object pointers. It is entirely possible to do it with an index if you wish, but it complicates things unnecessarily.

Usage is like this:



-- Jim - When is there going to be a release?
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 12th Apr 2014 14:29 Edited at: 12th Apr 2014 14:30
this time paul work on the compiler for v2.
can u give exact the project or mini project that did not work as zip.
and are u sure u start 108 19 / 21 and not a older version?
if u have other installs maybe rename the agk.ex_ to prevent start.
sure is Name as string and Name$ the same but not always for agk compiler
maybe try .Name = with Parameter NameX as string , means rename parameter other than in udt.

AGK 108 (B)19 : Windows 8.1 Pro 64 Bit : AMD Radeon HD 6670
JimHawkins
14
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 12th Apr 2014 15:02
Or - as monotonic suggests - use a better compiler and a less ambiguous compiler!

-- Jim - When is there going to be a release?
Kevin Picone
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 12th Apr 2014 15:38
Quote: "
I'm trying to compile my project, which has been fine up until now. I have added the code file below and the compiler cannot understand a custom function call. It seems to think that my function call is a variable?!?!? This is really annoying, the compiler error messages a pathetically bad.
"


If the fragment (in the code snippet above) compiles fine separately, then it sounds like there's a potential keyword/naming collision somewhere. Could any of those keywords have been used as globals / array / function / label names some where else in the program ?

monotonic
18
Years of Service
User Offline
Joined: 24th Mar 2006
Location: Nottinghamshire, England
Posted: 12th Apr 2014 22:22
@Markus

I will try and put something together later tonight as a test.

I have tried renaming the parameter and the compiler still shows the same error, so it's not a name collision.


@Kevin Picone

I have checked and double checked to see if the names have a collision somewhere, I even tried renaming everything to make sure, alas, all was in vane.


I'm going to try recreating the code one step at a time and see what happens. If this fails then I'm going to switch over to T2.

All programmers are playwrights and all computers are lousy actors.
monotonic
18
Years of Service
User Offline
Joined: 24th Mar 2006
Location: Nottinghamshire, England
Posted: 13th Apr 2014 11:35
Are you ****** kidding me!!!

OK, so I solved the problem after many hours of frustrating commenting/compiling, uncommenting/recompiling loops.

Guess what it was? There must have been some strange whitespace characters in the file somewhere, I copied all of the code from that include into Notepad, then copied it all back and it now works. Seriously, what the hell is going on with this?

I have attached this file for any of the TGC staff to see so they can modify the compiler so that it can handle whitespace.

Thanks for all of the help and suggestions guys, I appreciate it.

All programmers are playwrights and all computers are lousy actors.

Attachments

Login to view attachments
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 14th Apr 2014 06:59
Depending on what you use to edit the file, the strange whitespace is probably hidden formatting stuff.

Make sure to only use pure text only editors for files (Crimson Editor, Textpad, Notepad are all okay). Stay away from Wordpad, it adds hidden formatting, not visible to human beings and not necessarily easily recognized by compilers as 'white space'.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 14th Apr 2014 09:20 Edited at: 14th Apr 2014 09:21
in past i had trouble with the code template in agk ide.
it was a line break in linux format 10 13 , not windows 13 10.
i saw at notepad. the compiler say also nonsense.

i believe the codeblocks editor in agk ide understand both
and the compiler only one linebreak format.

AGK 108 (B)19 : Windows 8.1 Pro 64 Bit : AMD Radeon HD 6670
monotonic
18
Years of Service
User Offline
Joined: 24th Mar 2006
Location: Nottinghamshire, England
Posted: 14th Apr 2014 11:22
Quote: "Depending on what you use to edit the file, the strange whitespace is probably hidden formatting stuff."


I currently use the standard AppGameKit editor, I did try using a third party editor on these forums but I kept getting exceptions.

Quote: "Make sure to only use pure text only editors for files (Crimson Editor, Textpad, Notepad are all okay). Stay away from Wordpad, it adds hidden formatting, not visible to human beings and not necessarily easily recognized by compilers as 'white space'."


I can understand file corruption being a problem, but to be honest disallowed white space characters should be removed during the lexical analysis step by the compiler.


Quote: "i believe the codeblocks editor in agk ide understand both
and the compiler only one linebreak format."


Hopefully in V2 there will be better error messages so that things like this can be solved quickly and easily. Other than the compiler problems, I really like AGK.

I was using Monkey X to write my game. While Monkey has a much better language (with OOP) and compiles to native code, I have managed to accomplish the same amount in 1 week with AppGameKit what took 2.5 weeks with monkey. Let's face it, indie developers don't really have much time to indulge in their hobbies, so time saving is of the utmost importance. AppGameKit has great potential, it just needs a bit of time spent ironing out the bugs that seem to plague all TGC products.

All programmers are playwrights and all computers are lousy actors.
Paul Johnston
TGC Developer
21
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 14th Apr 2014 15:10
It looks like the original file had some line endings that were \n only, whilst the rest were \r\n. I tested this with the new compiler code I'm working on and it handled this without issue.
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 14th Apr 2014 15:28 Edited at: 14th Apr 2014 15:38
Quote: " I copied all of the code from that include into Notepad, then copied it all back and it now works. Seriously, what the hell is going on with this?"


I used to get this problem from time to time in DBP. The first time around it drove me mad for hours.

[EDIT] I was looking for my thread on the DBP problem, and found a reference to it from VanB in January 2004!

monotonic
18
Years of Service
User Offline
Joined: 24th Mar 2006
Location: Nottinghamshire, England
Posted: 14th Apr 2014 16:07
Quote: "It looks like the original file had some line endings that were \n only, whilst the rest were \r\n. I tested this with the new compiler code I'm working on and it handled this without issue."


Perfect, thank you Paul. I cannot think of a reason why one of the new line chars would be missing. I do run my project directly in my OneDrive folder so it's always backed up, maybe there was a sync issue which caused a bit of corruption!

Anyway, thank you.


Quote: "I used to get this problem from time to time in DBP. The first time around it drove me mad for hours."


It really does doesn't it! Now I know how to fix it, I'm happy. I think this is all part of getting to know the product, it's the flaws that keep things interesting and make them endearing!

All programmers are playwrights and all computers are lousy actors.
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 14th Apr 2014 20:30
Quote: "I used to get this problem from time to time in DBP. "

I get it in both DBP and AGK.

Only when I create a new source file from within the IDE. To prevent this, I have to create a new text file in windows explorer, rename it .agc, then add it to the project.

Login to post a reply

Server time is: 2024-04-25 08:40:54
Your offset time is: 2024-04-25 08:40:54