Editor updates to come

The Annex CNN channel
User avatar
cicciocb
Site Admin
Posts: 2194
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 470 times
Been thanked: 1461 times
Contact:

Re: Editor updates to come

Post by cicciocb »

Why not simply use gosub?
It returns automatically at the right place :D
User avatar
Electroguard
Posts: 945
Joined: Mon Feb 08, 2021 6:22 pm
Has thanked: 310 times
Been thanked: 352 times

Re: Editor updates to come

Post by Electroguard »

I don't think I used to be able to declare global variables from inside a gosub routine, but I haven't tried for a while, so maybe it's now possible.
User avatar
Electroguard
Posts: 945
Joined: Mon Feb 08, 2021 6:22 pm
Has thanked: 310 times
Been thanked: 352 times

Re: Editor updates to come

Post by Electroguard »

Yeah, you are right of course, looks like global vars (d$) can be declared in gosub routines, so that would be a simple way to interact with the imports without needing to pass parameters.

Code: [Local Link Removed for Guests]

a$ = "Main"
b$ = "main"
goto import1
returnfromimport1:
wlog "after import1", a$, b$
goto import2
returnfromimport2:
wlog "after import2", a$, b$, c$
gosub import3
wlog "after import3", a$, b$, c$, d$
end

import1:
b$ = "import1"
goto returnfromimport1

import2:
b$ = "import2"
c$ = "new var1"
goto returnfromimport2

import3:
b$ = "import3"
d$ = "new var2"
return
User avatar
Electroguard
Posts: 945
Joined: Mon Feb 08, 2021 6:22 pm
Has thanked: 310 times
Been thanked: 352 times

Re: Editor updates to come

Post by Electroguard »

Branching to imports as Gosubs allows them to define global vars, but would be even better If you could make Gosubs also recognise LOCAL similar to user subs, Francesco.

Code: [Local Link Removed for Guests]

a$ = "Main"
b$ = ""
gosub import1
wlog "after import1", a$, b$, c$
end

import1:
local a$
a$ = "not main"
b$ = "import1"
c$ = "new global var"
wlog "inside import1", a$, b$, c$
return
Post Reply