Page 1 of 1

IDE - Insert path or path/file into code

Posted: Fri Jan 18, 2008 6:36 am
by USCode
Occasionally I find the need to insert a path or a file path into code.

It might be a useful new feature for the IDE to be able to look up a path/file using the Path or Open File requesters which would then insert that path/file into code at the current cursor position.

E.g.
If OpenFile(0, "")
...
After entering in the above code you would put the cursor in between the quotes, then select the new IDE 'Insert Path...' or 'Insert File Path...' option & do the path/file lookup to be inserted into the code.

If OpenFile(0, "c:\myprog\data\test.dat") ;Inserted full file path
...

myfile.s = "test.dat"
If OpenFile(0, "c:\myprog\data\" + myfile) ;Inserted just path
...

Re: IDE - Insert path or path/file into code

Posted: Fri Jan 18, 2008 6:43 am
by PB
LOL, this was first requested six years ago. :)

http://www.purebasic.fr/english/viewtopic.php?t=2435

Posted: Fri Jan 18, 2008 12:05 pm
by freak
Things like this could be easily added as an external tool...
No need to wait for a builtin solution

Posted: Fri Jan 18, 2008 7:14 pm
by USCode
An external tool can insert text directly into the IDE editor?
(Not paste from clipboard but insert directly into the text after selecting the path/file)

Posted: Fri Jan 18, 2008 9:28 pm
by inc.
USCode wrote:An external tool can insert text directly into the IDE editor?
(Not paste from clipboard but insert directly into the text after selecting the path/file)
Get the Scintilla handle provided by the IDE via arguments or envVariable and just start taking control of the IDEs Scintilla gadget ;-)

Posted: Sat Jan 19, 2008 2:41 am
by PB
> An external tool can insert text directly into the IDE editor?

Sure. Here's my example. Make it an exe, then add it to the Tools menu.
Just set the "Commandline", "Name" and "Event to trigger" fields for it.

> Not paste from clipboard but insert directly into the text after selecting
> the path/file

Mine uses the clipboard but doesn't lose the existing contents, if that's
what you're worried about?

Code: Select all

p$=PathRequester("Select path to paste into the IDE:","")
If p$
  c$=GetClipboardText()
  SetClipboardText(Chr(34)+p$+Chr(34))
  keybd_event_(#VK_CONTROL,0,0,0)
  keybd_event_(#VK_V,0,0,0)
  keybd_event_(#VK_V,0,#KEYEVENTF_KEYUP,0)
  keybd_event_(#VK_CONTROL,0,#KEYEVENTF_KEYUP,0)
  SetClipboardText(c$)
EndIf

Posted: Sat Jan 19, 2008 11:26 am
by Trond
PB wrote:Mine uses the clipboard but doesn't lose the existing contents, if that's what you're worried about?
That's in fact exactly what it does if the clipboard contains a picture, sound, rich text, filenames or custom data.

Posted: Sat Jan 19, 2008 12:35 pm
by PB
Okay, I meant any plain text in the clipboard. :)

cross-platform ?

Posted: Sat Jan 19, 2008 6:58 pm
by USCode
Can this be done in a cross-platform manner, with pure PB or does it require platform-specific API calls?