Compiling error

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
athelene
Posts: 18
Joined: Sun Jul 26, 2015 9:19 pm

Compiling error

Post by athelene » Fri Aug 28, 2015 9:22 pm

I am having a problem compiling my code. I also noticed that my functions have disappeared from the left column of the script window. (That happened to me before but I realized at that time that there was a syntax error in the code, corrected it and they all came back. This time I can't find the error.)

The first error I got was:

"compilation error at line 68 (Handler: bad command), char 1.

That line read:

set the gSelected of card "cardHome" to myVar1

I'm trying to create a custom property on the card with that line. So I commented that whole line out and tried again and it gave me the same error. After searching the forum on compiling errors on lines commented out, I saw that there could be some invisible codes that could be a problem. The suggestion was to comment out the entire function to see what happens. I did that and got a new error which was:

compilation error at line 52 (Script: garbage character in script.)

Line 52 is where the commented area begins. I'm confused why anything in a commented area would throw an error at all. But, more importantly, I can't see any weird characters or why the first line above would be a problem?

UPDATE: OK, through completely deleting certain sections of the code, I can see that the problem is clearly with how I'm trying to set the value of the custom property. But I'm using examples I have found on various tutorials and chapter 7 of the User Guide. Any thoughts or suggestions on what I'm doing wrong there?

Thanks in advance.

Athelene

athelene
Posts: 18
Joined: Sun Jul 26, 2015 9:19 pm

Re: Compiling error

Post by athelene » Fri Aug 28, 2015 10:16 pm

UPDATE: I figured it out!! Thank you to anyone who had taken some time to look at this.

For future reference should anyone ever find this searching for answers, I simply had to take the name of the card out of quotes. Interestingly, I had used this link as a guide: http://www.hyperactivesw.com/mctutorial/rrfeatures.html, and found this sample in the user guide: put the lastCall of this card into field "Date".

But once I removed the quotes around the card name, it all worked fine.

Athelene

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4172
Joined: Sun Jan 07, 2007 9:12 pm

Re: Compiling error

Post by bn » Fri Aug 28, 2015 11:40 pm

Hi Athelene,
But once I removed the quotes around the card name, it all worked fine.
you really should quote the name of the card. The only thing that would explain to me what you have seen is that you accidentally had curly quotes instead of straight quotes.
If you copied the code from some external source it can easily happen that you have curly quotes copied. At times depending also on font they are hard to tell apart.

You should always put literals = names and such in quotes.

field "date" is OK
field date is bad since date is a reserved name in livecode and livecode gets confused.

Although Livecode can work with a name without quotes it is easy to mix up variable names with names and then you have a hard time to figure out what happened.

Please try to put the name of the field into straight quotes and see if it compiles.

Kind regards
Bernd

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Compiling error

Post by Simon » Sat Aug 29, 2015 12:53 am

Hi Athelene,
You can set your comment preference in the Edit > Preferences > Script editor.
In there they show
--
#
//
I think you have to actually set it to get it to work.
--
is the default.

Simon
edit

Code: Select all

on mouseUp
   #beep
   //beep
   --beep
end mouseUp
Rats they all seem to work without setting them in preferences.
Ok go with Bernds idea, yeah, sounds like it's the quotes or possibly an invisible character. If you are copying and pasting, paste it into a text editor then copy that.
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

athelene
Posts: 18
Joined: Sun Jul 26, 2015 9:19 pm

Re: Compiling error

Post by athelene » Sun Aug 30, 2015 11:39 pm

I'll look at it again. But I'm aware that quotes can be a problem when copying. I typed them in manually. Very confused but I'll go back (now that I've slept since!) and try it again to be sure I did use quotes that I actually typed in.

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Compiling error

Post by Simon » Mon Aug 31, 2015 1:19 am

Don't forget about invisible characters, they are ummm hard to see :D

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Post Reply