Dumb Question

alband

Senior Member
Hi,
I've got this error:
goto 5_Shot_Grp
^

Error: Syntax error in this line!
I've got a label named "5_Shot_Grp" and I though I could jump to it like any other. There's a rule I've missed...?
 

alband

Senior Member
I really advise you not to ask that. :D - It's horrible (gibberish). I've been going at it for months and haven't used names for anything; it's all "label_70_1_11" and of course all those "b0,b1,b2's...". I'm now going through it trying to give all the "label's" sensible names.
I Can post them if you want (them because it's two 40X's talking), but if I can answer your reason for needing it, it may save you a lot of time...
 

eclectic

Moderator
I really advise you not to ask that. :D - It's horrible (gibberish). I've been going at it for months and haven't used names for anything; it's all "label_70_1_11" and of course all those "b0,b1,b2's...". I'm now going through it trying to give all the "label's" sensible names.
I Can post them if you want (them because it's two 40X's talking), but if I can answer your reason for needing it, it may save you a lot of time...
The reason is, that, as far as I know,
no-one on this forum can understand gibberish.

And as far as one line, in an ocean of gibberish, is concerned ????

Perhaps the British Museum can help?

e
 

alband

Senior Member
I'm going through it trying to "ungibberfy" it and need to change the label names (e.g. "beginning") but it wont let me. Do you want the code?
 

alband

Senior Member
But what about the error :(.
Is there some kind of rule for label's that they have to start with label or can't start with numbers or something.
 

Michael 2727

Senior Member
Well it's a bit hard trying to find a fault without any other clues.

Like the customer who goes to the repair shop, plonks an item on the bench
saying "It's Broken" then walks out. They are the ones you tell the new part is
on back order, it should arrive in September 2048, we'll call you !

Look at the Spelling/Syntax in the Symbol line for that symbol.
Look at the previous line of code that sent you to that particular goto.
There could be 1000 different reasons why it's not working and my Crystal
Ball is also broken, the parts are on back order :)
And yes the title is correct ;)
 

Jeremy Leach

Senior Member
No need to post code - the leading number is clearly the problem. Just try creating any line label in the editor and stick a number in front and it'll error.
 

westaust55

Moderator
Alband,
it is really a case of reading the manuals. By page 5 you would have had a the answer . . . .

Labels are used as markers throughout the program. Labels are used to mark a
position in the program to ‘jump to’ at a later point using a goto, gosub or other
command. Labels can be any word (that is not already a reserved keyword) and
may contain digits and the underscore character. Labels must start with a letter
(not digit)
, and are defined with a colon ( : ) at the marker position. The colon is
not required within the actual commands.
Sure, Jeremy has just given you the answer but reading would have equally solved the error.
 
Last edited:

Jeremy Leach

Senior Member
I'm not sure if this quirk is documented anywhere in the manual, but should be if not. Better still update the editor so it doesn't error - because to me it seems an unnecessary restriction. Although having said that, labels starting with numbers are a bit wierd ;)

Edit: Er, yes WA, maybe I was too ready to just give the answer. I must say it was after a 10 second dabble with the editor which you could have done yourself Alband ;)
 
Last edited:

westaust55

Moderator
Having a BASIC program label or variable name stating with other than a letter has been against the rules in every version of BASIC I have ever used.

For the PICAXE, the same applies to alias in the SYMBOL command:

Symbols can contain numeric characters and underscores (flash1, flash_2 etc.) but the first character cannot be a numeric (e.g. 1flash)
The moral is: read, read, read, then ask questions
 

moxhamj

New Member
I don't think that is a dumb question at all. I just had a very similar error last night while writing machine code for a Z80. Yes, those sorts of errors are documented but sometimes the bit you want to know is really hard to find. Eg one of my compilers wants .equ and one wants equ Some error when labels are more than 8 characters. Some don't like numbers as the first character. And I often forget to put the colon after a label, or put a ' instead of a ; for comments, especially when changing languages.

Welcome to coding. These are the sorts of hair-puller syntax errors that send us bald!
 

Jeremy Leach

Senior Member
To be honest WA, I'm sure you're right about Basic - but I'm being bold and challenging 'why'. If you can visually understand that something is a label when it's got a numeric first character, then a machine should be able to figure this out too. But I'm not going to lose sleep over it ;)
 

alband

Senior Member
Sorry. :eek:
I checked the 1st manual assuming it would be there as it isn't a command.
I only thought of the number thing as I was typing it as a suggestion. I considered it but decided it couldn't be that; "Why would only the first character matter if is a number not letter".
Why is it like that?

This is horrible, I too get annoyed at people like me who don't read, and now I've become one;
I feel dirty. :(
Again, soz.
 

lbenson

Senior Member
It's an old, arbitrary convention, going back at least to FORTRAN in the sixties, that labels can't begin with a number. This makes life easier for the compiler/interpreter writer. But that isn't a requirement in some languages, and it isn't obviously a requirement at all, so people will get caught out by it and will scratch their heads and tear their hair out. While the answer to this question may have been in the manual, I don't imagine that even Hippy remembers everything that is in the manuals. But a little experimenting in the Editor can answer many questions.
 

westaust55

Moderator
Yes BASIC was derived out of Fortran II. With Fortran IV for example, integer variables had to start with the letter I, J, K and L from memory otherwise had to be specifically declared as an integer.

There is no such thing as a DUMB question.

Even I do not recall all that is in the manuals :( . . the thing to remember it that the manuals are there to REFER TO in the first instance.
 
Last edited:

moxhamj

New Member
No need to be sorry. It is the compiler writers who should add a check for characters 0-9. I wrote a compiler once and it wasn't hard to look for labels. I used the combination of a colon then a space to flag for a label, then looked for the characters to the left of that combination.

As Westaust says "Having a BASIC program label or variable name stating with other than a letter has been against the rules in every version of BASIC I have ever used".

With the exception, of course, of MBASIC where every line starts with a number:
10 PRINT "Hello"
20 END

The numbers become the labels. So it can be done. And for backwards compatability to an MBASIC program it might even be useful to allow numbers to be labels.

Numbers like in MBASIC were sort of frowned upon as not being a real language, but there was a good reason for it - it meant you didn't need a complex text editor like Wordstar with the ability to move up and down lines and pages. Instead you could edit one specific line with EDIT 10
or LIST 100-150.

Bring back numbers for labels, I say!!
 

westaust55

Moderator
Agree, there is no need to be sorry.

As I said earlier there is no such thing as a dumb question.

The issue is to learn, which also involves learning where to look first.

True Dr_A, early BASIC's such as on Apple, OSI, Commodore PET used line numbers and did not have labels. Later versions of BASIC deleted line number s and implemented labels as part of endeavouring to encourage more structured programming.

As for rules, some years ago a standard was written to reduce the miryad of versions of BASIC
http://www.springerlink.com/content/45214n615r01h783/fulltext.pdf?page=1
but there will always be variants to cover specific hardware etc.
 
Last edited:

Jeremy Leach

Senior Member
Ok, I'm an anorak ...
In Annex A of ISO standard doc ISO/IEC JTC 1/SC 22 N (see draft at http://std.dkuug.dk/jtc1/sc22/wg20/docs/n699.pdf !!), it says ...
Programming language standards generally have restrictions on what characters may be allowed as the first
character of an identifier. For example, digits are often constrained from appearing as the first character of an
identifier. To assist in their identification, the decimal digits in ISO/IEC 10646-1 are separately noted in the list
below. In addition, combining characters should not appear as the first character of an identifier. To maximize the
chances of interoperability between programming languages (as for example, when linking compiled objects
between languages), programming language standards and their implementations should follow these restrictions
when making use of the extended repertoire for user-defined identifiers.
Please don't mention to anyone that I looked this up ;)
 

moxhamj

New Member
Jeremy - lucky this forum is a completely private forum with no links to anything public, especially to the Internet LOL...

I'm just going to have to change my MBASIC programs now. They are clearly not ISO standard!
 
Last edited:

PhilipS

New Member
I think that a clue as to why it is like that is present in some of the replies. Historically BASIC programs used line numbers to indicate the sequence the lines. My guess would be that a leading number on a label could misdirect the parser into thinking "here's a line number", in the same way that a leading digit on a variable name could fox it into thinking "here's a literal numeric". Once it gets that wrong the rest of the line is going to be gibberish.
 

Jeremy Leach

Senior Member
True, although I don't think it would be difficult for a parser to spot that a number immediately followed by some text is a label. I was trying to browse the roots of this syntax rule, but couldn't find anything - my guess is that it was enforced more because a human might misread a label starting with a number. Only a guess though.

In the history of the picaxe I think only Alband has tried a label with a leading number ;)
 
Last edited:

hippy

Ex-Staff (retired)
I'm going through it trying to "ungibberfy" it and need to change the label names (e.g. "beginning") but it wont let me. Do you want the code?
When you say "it wont let me" - what is "it" and how will it not let you ?
 

Michael 2727

Senior Member
Alband no question is dumb, thats how we all learn, if you don't understand something it
could have be explained badly in the first instance or even not at all.
"Error on this line" Does not always help either.
I was being slightly sarcastic at the amount of information supplied to work with ;)
As all too often the "It's broken" posts appear with no other supporting info, what, when
how etc.
Luckily there are clever people in the brains trust here who spotted the problem.
I learned something too :)

If you get an error and you can't find the problem it is worthwhile breaking the code
into tiny pieces, starting with the Symbol for the Label, the line with the Error in it
and the line above the error and or the line code that sent you to lie line that has stopped.
This way with only four or five lines you can nail the problem.
 

westaust55

Moderator
True, although I don't think it would be difficult for a parser to spot that a number immediately followed by some text is a label. I was trying to browse the roots of this syntax rule, but couldn't find anything - my guess is that it was enforced more because a human might misread a label starting with a number. Only a guess though.

In the history of the picaxe I think only Alband has tried a label with a leading number ;)
The Full BASIC specification including syntax is in ANSI standard X3.113-1987 with an ammendment dated 1994 from memory. I don't have a copy, so cannot give any specific examples
 
Top