![]() |
Forum Index : Microcontroller and PC projects : LOCAL problem.....
Author | Message | ||||
Grogster![]() Admin Group ![]() Joined: 31/12/2012 Location: New ZealandPosts: 9610 |
Hi all. ![]() QUESTION: With the LOCAL command for use in Sub's, can different subs have different LOCAL commands with the same variable name? I thought you could, but it it throwing a wobbly when I try: I am getting 'E already declared.' errors. As one sub calls the other, D$ is throwing an error, but I figured you could have LOCAL D$,E$ in one Sub, and another LOCAL D$,E$ in another sub and it would not care - as they are local to the sub they are defined in, and vanish into the great RAM monster in the sky when the Sub ends. Do I actually have that wrong? If I change the string names to something else, no problem, so that is the workaround I am using for now. Smoke makes things work. When the smoke gets out, it stops! |
||||
Phil23 Guru ![]() Joined: 27/03/2016 Location: AustraliaPosts: 1667 |
That's a bit Strange Grog, I'd expect you could & this little bit of code works in DOS. Phil. |
||||
Phil23 Guru ![]() Joined: 27/03/2016 Location: AustraliaPosts: 1667 |
This works too, when Sub2 is called while still in Sub1. Edit:- Still works if I call Sub2 before the NEXT N in Sub1 also. |
||||
Azure![]() Guru ![]() Joined: 09/11/2017 Location: AustraliaPosts: 446 |
You are using E$ as the passed argument and a local variable. |
||||
Grogster![]() Admin Group ![]() Joined: 31/12/2012 Location: New ZealandPosts: 9610 |
OH ![]() ![]() ![]() ![]() ![]() How the hell did I miss that, for God's sake.......(rhetorical!) All fixed. Feeling a little silly now. ![]() ![]() Smoke makes things work. When the smoke gets out, it stops! |
||||
Azure![]() Guru ![]() Joined: 09/11/2017 Location: AustraliaPosts: 446 |
Glad I spotted it first then. ![]() Even more happy it is all working. |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6283 |
I don't think you should be using 'CONST" in a SUB/FUNCTION If it is a true CONST, it belongs in the main code with the GLOBALs If not a true CONST, use a LOCAL variable Jim VK7JH MMedit |
||||
Phil23 Guru ![]() Joined: 27/03/2016 Location: AustraliaPosts: 1667 |
Was pretty easy to look straight past that. P&G Zero. Azure One. |
||||
Grogster![]() Admin Group ![]() Joined: 31/12/2012 Location: New ZealandPosts: 9610 |
@ Jim - I will take your comments about CONST under advisement. Yes, I will change that. [Quote=Phil23]P&G Zero[/Quote] I see what you did there. ![]() Smoke makes things work. When the smoke gets out, it stops! |
||||
Azure![]() Guru ![]() Joined: 09/11/2017 Location: AustraliaPosts: 446 |
Lets not start any scoring, I am just a newbie to the MM and grogster designs some lovely boards ![]() |
||||
Grogster![]() Admin Group ![]() Joined: 31/12/2012 Location: New ZealandPosts: 9610 |
Very kind, but Azure does get an approval tick for noticing this one! ![]() Smoke makes things work. When the smoke gets out, it stops! |
||||
Chopperp![]() Guru ![]() Joined: 03/01/2018 Location: AustraliaPosts: 1097 |
You're way ahead in the number of Posts count though , Mr Grogster ![]() ChopperP |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |