Some procedure names are not accepted (bug?)

This is where most of us started. Classic Spectrum basic.

Moderator: Programming Moderators

User avatar
programandala.net
Posts: 45
Joined: Thu Nov 02, 2017 11:55 am
Location: Spain
Contact:

Some procedure names are not accepted (bug?)

Postby programandala.net » Tue Apr 06, 2021 12:15 pm

I have discovered some procedure names are not allowed, without reason. First I thought the problem was caused when the procedure name contained certain keywords of certain lenght at the start and the end, e.g. "ERASEthebAND" or "PLAYthedoOR", but after many tries I conclude the error condition is simpler: procedure names having exactly 9 characters followed by "or" or "and" are not allowed (the error cursor flashes at the start of those trailing "or" or "and").

Examples:

Code: Select all

defproc xxxxxxxxand():rem OK
defproc xxxxxxxxxand():rem INVALID
defproc xxxxxxxxxxand():rem OK
defproc xxxxxxxxor():rem OK
defproc xxxxxxxxxor():rem INVALID
defproc xxxxxxxxxxor():rem OK
It seems the issue is the number of characters (9) before the trailing "or" or "and", not the characters used.

Is this known? It seems a strange bug. I hope this information helps to fix it.
Marcos Cruz (programandala.net)

Alcoholics Anonymous
Posts: 775
Joined: Mon May 29, 2017 7:00 pm

Re: Some procedure names are not accepted (bug?)

Postby Alcoholics Anonymous » Tue Apr 06, 2021 6:31 pm

Actually it sounds like procedure names are limited to 9 characters and rather than ignoring any excess it is parsing what follows.

User avatar
programandala.net
Posts: 45
Joined: Thu Nov 02, 2017 11:55 am
Location: Spain
Contact:

Re: Some procedure names are not accepted (bug?)

Postby programandala.net » Tue Apr 06, 2021 8:23 pm

Alcoholics Anonymous wrote:
Tue Apr 06, 2021 6:31 pm
Actually it sounds like procedure names are limited to 9 characters and rather than ignoring any excess it is parsing what follows.
You're right, it seems to happen with all keywords, provided they start at character 10.

The manual reads (p. 56) that procedure names follow the rules of numeric variables, which can be longer than 9 characters... I tried, and it happens the same with variables!:

Code: Select all

LET xxxxxxxxerase=1: rem OK
LET xxxxxxxxxerase=1: rem NOT ALLOWED
LET xxxxxxxxxxerase=1: rem OK
There's as obscure bug somewhere.
Marcos Cruz (programandala.net)

garrylancaster
Posts: 36
Joined: Mon Feb 19, 2018 2:44 pm

Re: Some procedure names are not accepted (bug?)

Postby garrylancaster » Tue Apr 06, 2021 10:29 pm

This is actually a known bug with the tokeniser, and is on my list to be fixed.

Keywords are checked for by building up a word in a buffer until a space (or other delimiter, such as most symbols) is detected - then the word in the buffer is converted to a keyword if appropriate, or flushed as text if not.

The buffer also gets flushed as text when it becomes full (the buffer being 9 chars in length). So, any long identifier will be split into 9-character long sections. After each section, the following characters could be interpreted as a keyword since they are now at the start of the keyword buffer. This leads to the behaviour you see.

User avatar
programandala.net
Posts: 45
Joined: Thu Nov 02, 2017 11:55 am
Location: Spain
Contact:

Re: Some procedure names are not accepted (bug?)

Postby programandala.net » Sat Apr 10, 2021 11:14 am

Thank you for the detailed explanation.
Marcos Cruz (programandala.net)


Who is online

Users browsing this forum: No registered users and 2 guests