Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 17:58 18 May 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : new$ ???

Author Message
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9081
Posted: 09:28pm 16 Jun 2014
Copy link to clipboard 
Print this post

Full-size Colour Maximite, firmware version V4.4

When I try to use new$, I am getting an error.

new$="XXX"

...results in...

Error: Unexpected text

I have looked in the latest manual, in case new$ is a reserved variable or something, but I was not able to find anything. What am I doing wrong?

The variable name comes from my want to have a old$ and a new$ for the purposes of using the NAME command for file renaming.

This error does not occur with the likes of o$ and n$, so it is an easy workaround, but I am just curious.....Edited by Grogster 2014-06-18
Smoke makes things work. When the smoke gets out, it stops!
 
greybeard
Senior Member

Joined: 04/01/2010
Location: Australia
Posts: 158
Posted: 09:54pm 16 Jun 2014
Copy link to clipboard 
Print this post

Maybe check for 'new' without the trailing dollar Just don't type it onto the command line by itself unless you've made sure to backup your code.
ps try checking under commands on page 35 of the latest manualEdited by greybeard 2014-06-18
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9081
Posted: 10:03pm 16 Jun 2014
Copy link to clipboard 
Print this post

Page 35 of latest manual mentions NEW but nothing about new$...
I did see that one, as I have been reading the manual looking for reasons for this.


Edited by Grogster 2014-06-18
Smoke makes things work. When the smoke gets out, it stops!
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5923
Posted: 10:18pm 16 Jun 2014
Copy link to clipboard 
Print this post

It would be very courageous to use a variable which is too close to a command.

The interpreter is finding the NEW but fortunately getting upset about the extra characters. The $ can be seen as an end of word character.
I wouldn't try goto$ etc either.

(MMEdit highlights NEW$ as a keyword but that doesn't mean that the maximite will act the same way.)

Jim

VK7JH
MMedit   MMBasic Help
 
ajkw
Senior Member

Joined: 29/06/2011
Location: Australia
Posts: 290
Posted: 11:55pm 16 Jun 2014
Copy link to clipboard 
Print this post

I think it is safe to say that no command can or should be used as a variable name and doing so rightly generates an error.

I have also found on occasion when updating the firmware I get caught with variable ,subroutine or interupt names I have used becoming illegal with the new added commands in the firmware.

Cheers.
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9081
Posted: 01:10pm 17 Jun 2014
Copy link to clipboard 
Print this post

All fair comments - as I say - change that to o$ and n$ and the problem is gone - I was just curious. New rule for me: "Thou shalt not use any commands or keywords as variable names"

Sounds like good advise.
Smoke makes things work. When the smoke gets out, it stops!
 
ajkw
Senior Member

Joined: 29/06/2011
Location: Australia
Posts: 290
Posted: 10:29pm 17 Jun 2014
Copy link to clipboard 
Print this post

Hi Grogster,

My previous post was probably a little forthright, perhaps I should have also offered another idea.

n$, although quite adequate, doesn't really describe the variable and there are times when new in a variable name is what you want, therefore is newtext$, newname$, newsomething$, newvalue etc a better alternative??

Cheers,
Anthony.
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9081
Posted: 10:37pm 17 Jun 2014
Copy link to clipboard 
Print this post

Yeah, fair enough comment.

I just like SHORT variable names.

But I could always use the likes of OD$ and NW$, for example....
Smoke makes things work. When the smoke gets out, it stops!
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024