Chang 'Goto <label>' To 'Goto <?label>'

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
gurj
Enthusiast
Enthusiast
Posts: 664
Joined: Thu Jan 22, 2009 3:48 am
Location: china
Contact:

Chang 'Goto <label>' To 'Goto <?label>'

Post by gurj »

Chang 'Goto <label>' To 'Goto <?label>'
so will can use Variables for label

Code: Select all

n=?label_1
For a=0 To 9
 Goto n
 label_1: :Debug 1:n=?label_2
 label_2: :Debug 2
Next
my pb for chinese:
http://ataorj.ys168.com
User avatar
gurj
Enthusiast
Enthusiast
Posts: 664
Joined: Thu Jan 22, 2009 3:48 am
Location: china
Contact:

Re: Chang 'Goto <label>' To 'Goto <?label>'

Post by gurj »

And add
Syntax:
Chang 'Gosub <label>' To 'Gosub <?label>'
so will can use Variables For label
my pb for chinese:
http://ataorj.ys168.com
User_Russian
Addict
Addict
Posts: 1443
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

Re: Chang 'Goto <label>' To 'Goto <?label>'

Post by User_Russian »

Code: Select all

EnableASM
n=?label_1
For a=0 To 9
 jmp n
 label_1: :Debug 1:n=?label_2
 label_2: :Debug 2
Next
User avatar
gurj
Enthusiast
Enthusiast
Posts: 664
Joined: Thu Jan 22, 2009 3:48 am
Location: china
Contact:

Re: Chang 'Goto <label>' To 'Goto <?label>'

Post by gurj »

thanks User_Russian!
my pb for chinese:
http://ataorj.ys168.com
User avatar
gurj
Enthusiast
Enthusiast
Posts: 664
Joined: Thu Jan 22, 2009 3:48 am
Location: china
Contact:

Re: Chang 'Goto <label>' To 'Goto <?label>'

Post by gurj »

as Gosub:

Code: Select all

EnableASM

n=?label_1
m=?re_1
JMP n
re_1:

n=?label_2
m=?re_2
JMP n
re_2:

Debug 3

End

label_1: :Debug 1
JMP m

label_2: :Debug 2
JMP m
my pb for chinese:
http://ataorj.ys168.com
User avatar
mk-soft
Always Here
Always Here
Posts: 5409
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Chang 'Goto <label>' To 'Goto <?label>'

Post by mk-soft »

Not saved...

Code: Select all

EnableASM

Define n
n=?label_1

push rsp
call qword [v_n]
pop rsp


n=?label_2
push rsp
call [v_n]
pop rsp

Debug 3

End

label_1:
a = 1
Debug 1
ret

label_2:
a = 2
Debug 2
ret
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
mk-soft
Always Here
Always Here
Posts: 5409
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Chang 'Goto <label>' To 'Goto <?label>'

Post by mk-soft »

I do not know what you're up to. But the techniques with 'Goto' and 'Gusub' are not up-to-date.

There are better methods with jump marks to work. Here is a small example.

Code: Select all

Prototype ProtoInvoke()

Structure udtInvoke
  Invoke.ProtoInvoke[0]
EndStructure

Procedure fc0()
  Debug 0
EndProcedure

Procedure fc1()
  Debug 1
EndProcedure

Procedure fc2()
  Debug 2
EndProcedure

Procedure fc3()
  Debug 3
EndProcedure

*fc.udtInvoke = ?MyFunctions

For i = 0 To 3
  *fc\Invoke[i]()
Next

DataSection
  MyFunctions:
  Data.i @fc0()
  Data.i @fc1()
  Data.i @fc2()
  Data.i @fc3()
EndDataSection

Code: Select all

Prototype ProtoInvoke()

Structure udtInvoke
  Invoke.ProtoInvoke
EndStructure

Procedure fc0()
  Debug 0
EndProcedure

Procedure fc1()
  Debug 1
EndProcedure

Procedure fc2()
  Debug 2
EndProcedure

Procedure fc3()
  Debug 3
EndProcedure

Global NewList ToDo.udtInvoke()

Macro AddToDo(Function)
  AddElement(ToDo())
  ToDo()\Invoke = Function
EndMacro

AddToDo(@fc0())
AddToDo(@fc1())
AddToDo(@fc2())
AddToDo(@fc3())

ForEach ToDo()
  ToDo()\Invoke()
Next
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
gurj
Enthusiast
Enthusiast
Posts: 664
Joined: Thu Jan 22, 2009 3:48 am
Location: china
Contact:

Re: Chang 'Goto <label>' To 'Goto <?label>'

Post by gurj »

thanks mk-soft !
my pb for chinese:
http://ataorj.ys168.com
Post Reply