Am Freitag, 16. Februar 2024, 18:48:19 CET schrieb Patrick Fitzpatrick:
> Hi gang,
> ;
> 
> I haven't used execution tokens in many years (F-83 timeframe).
> 
> What I want to do is build a jump table like this:
> 
> create t 5 allot
> 
> : t1 ." t1" cr
> : t2 ." t2 " cr ;
> 
> '  t1 t 0 + !
> '  t2 t 1 + !
> 
> Then to execute t2, I would:
>  t 1 + @ execute
> 
> Is this correct?

Almost. You need to sprinkle in some CELLS, because the size of what ! stores 
is a cell, not 1.

I.e.

Create t 5 cells allot

…

' t1 t 0 cells + !
' t2 t 1 cells + !

t 1 cells + @ execute

It is often more convenient to define t1 and t2 beforehand, and then

create t  ' t1 , ' t2 , ' t3 , ' t4 , ' t5 ,

-- 
Bernd Paysan
"If you want it done right, you have to do it yourself"
net2o id: kQusJzA;7*?t=uy@X}1GWr!+0qqp_Cn176t4(dQ*
https://net2o.de/

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to