Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 03:06 14 Nov 2025 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 : "variable already defined"?

Author Message
Tinine
Guru

Joined: 30/03/2016
Location: United Kingdom
Posts: 1646
Posted: 05:44pm 09 Jul 2020
Copy link to clipboard 
Print this post

Not sure if the above message is verbatim because I'm away from my system.

Executing my program and I decide to break out. This is in MM Edit.

I want to use "chat" to run a function or a sub but I get the error shown in the subject.

Pretty sure it sometimes works OK but naturally, not when I really need it.  

Have I messed up or am I missing something?

Regards,

Craig
Edited 2020-07-10 03:45 by Tinine
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3472
Posted: 06:15pm 09 Jul 2020
Copy link to clipboard 
Print this post

This gives it; can it be something related?

DOS MMBasic Ver 5.05.02
Copyright 2011-2019 Geoff Graham

> i%=1
> i$=1
Error: I already declared
>

PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
Tinine
Guru

Joined: 30/03/2016
Location: United Kingdom
Posts: 1646
Posted: 07:29pm 09 Jul 2020
Copy link to clipboard 
Print this post

  lizby said  This gives it; can it be something related?

DOS MMBasic Ver 5.05.02
Copyright 2011-2019 Geoff Graham

> i%=1
> i$=1
Error: I already declared
>


Oh, I should have been more specific.



SUB MySub(MyParam)

Do Something

End Sub



In "Chat", I type "MySub 5" and I get the error that MyParam is already defined.

Regards,

Craig

Edit: Oh it probably is declared, not defined.
Edited 2020-07-10 05:31 by Tinine
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3472
Posted: 07:53pm 09 Jul 2020
Copy link to clipboard 
Print this post

Curious. In MMBasic DOS, this works for me:

> list
mysub(5)
End
Sub mysub(x)
Print x
End Sub
> run
5
> mysub 3
3
>


But with an undeclared variable:

> mysub A
[3] Sub mysub(x)
Error: X already declared
>


Or with the wrong type:

> mysub "9"
Error: Incompatible type: "9"
>

Edited 2020-07-10 06:03 by lizby
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
Tinine
Guru

Joined: 30/03/2016
Location: United Kingdom
Posts: 1646
Posted: 12:33pm 13 Jul 2020
Copy link to clipboard 
Print this post

I have been revisiting this and I can make it work if I ERASE the "already declared" variable in chat before calling the procedure.
 
Print this page


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

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025