Page 1 of 1

getting text of current line

Posted: Fri Aug 01, 2008 5:49 am
by sirrab
Hi All,

can you get the text from the current line of code and pass it to an external program without selecting the line?

Thanks
Craig :D

Posted: Fri Aug 01, 2008 7:43 am
by sirrab
hi, found the answer.

in case anyone can use it

Code: Select all

Procedure.s getidelinetext()
lineno$ = ProgramParameter(1)
linenumber = Val(StringField(lineno$,1,"x"))
pbfilename$ = ProgramParameter(0)
linecount = 1
fh = OpenFile(#PB_Any,pbfilename$)
If fh > 0
 While Eof(fh) =0 
    ld$ = ReadString(fh)
    linecount + 1
    If linecount = linenumber + 1
     linetext$ = ld$    
    EndIf
    
 Wend
 CloseFile(fh)
EndIf
ProcedureReturn linetext$
EndProcedure
arguments must be
"%file" "%cursor"

Craig :D

Posted: Mon Sep 29, 2008 2:29 am
by Amundo
Kia ora mate! :)

Thanks for sharing the info (better late than never!).

Just out of interest, where did you find it, and is there more of it?

(I've been wanting to write a PXVars type program for ages, but more along the lines of a class/object browser.
Until PB gets modules, it's a hell of a chore (at least for me) to keep track of what variable gets clobbered where, etc).