Hi, since there seems to be no way to get at this with Peek and Poke, I've made a small SBasic extension to tget the value on the return stack, called RET_STK and RET_STK2:
A small extension to get the line number of the line having called a function or procedure, in an Sbasic program. USE: line_nbr = RET_STK2 gets the value of the calling line into the variable line_nbr. USE : PRINT RET_STK prints the calling line. NOTE THE DIFFERENT VARIETIES, USE RET_STK ONLY WITH "PRINT". Use RET_STK2 when assigning to a variable. If the keyword is called in a procedure (not a function, then the line number printed/returned is the one AFTER the line having called the procedure. If you use this in a direct program (i.e. not within a procedure/function) the result returned will be 0. NB You can't call this directly from the command line, that will always return 0. I haven't had much time to test this, in the follwing progrm, this works as expected: 100 DEFine PROCedure p 110 CLS 120 temp = t2 130 t 140 PRINT " end p" : REMark we shouldn't get here due to the error in procedure t 150 END DEFine p 160 : 170 DEFine PROCedure t 180 PRINT RET_STK 190 caller_nbr=RET_STK2 200 nbr=1/0 : REMark generate error 210 END DEFine t 220 : 270 DEFine PROCedure sa 280 SAVE_O ret_stack_bas 290 END DEFine sa 300 : 310 DEFine FuNction t2 320 caller_nbr2=RET_STK2 330 PRINT RET_STK 340 RETurn 5 350 END DEFine t2 Calling p will do the trick. You can download this extension from www.wlenerz.com/QLStuff Have fun W. Lenerz _______________________________________________ QL-Users Mailing List http://www.q-v-d.demon.co.uk/smsqe.htm
