getting text of current line

Working on new editor enhancements?
User avatar
sirrab
Enthusiast
Enthusiast
Posts: 106
Joined: Thu Dec 07, 2006 8:52 am
Location: New Zealand

getting text of current line

Post 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
User avatar
sirrab
Enthusiast
Enthusiast
Posts: 106
Joined: Thu Dec 07, 2006 8:52 am
Location: New Zealand

Post 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
Amundo
Enthusiast
Enthusiast
Posts: 200
Joined: Thu Feb 16, 2006 1:41 am
Location: New Zealand

Post 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).
Win10, PB6.x, okayish CPU, onboard video card, fuzzy monitor (or is that my eyesight?)
"When the facts change, I change my mind" - John Maynard Keynes
Post Reply