Telling the IDE to load source code using RunProgram()

Working on new editor enhancements?
User avatar
StarBootics
Addict
Addict
Posts: 1006
Joined: Sun Jul 07, 2013 11:35 am
Location: Canada

Telling the IDE to load source code using RunProgram()

Post by StarBootics »

Hello everyone,

While using my ToolBoxFile manager I have discovered that loading source code to the IDE using RunProgram() don't work anymore. I have used this technique for years without issues and I don't know when it became broken.

Do I need to do something differently ? Something broken in the IDE ? (If so this topic should be moved to Bug - IDE section)

Code: Select all

; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Project name : Loading source code to IDE
; File Name : Loading Source IDE.pb
; File version: 1.0.0
; Programming : Seems to be OK from this side
; Programmed by : StarBootics
; Date : October 12th, 2023
; Last Update : October 12th, 2023
; PureBasic code : V6.03 LTS
; Platform : Windows, Linux, MacOS X
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Notes
;
; You need to compile this tiny program and set it 
; as a custom tool in order to see the problem.
;
; I have used this technique for years without any
; issues, but since recently it no longer work.
; When launched from the Tools menu, I see the
; correct path to the IDE and RunProgram() return
; 1.
;
; What I would like to do is to tell the IDE to
; load a specific source code from another  
; program.
;
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

SourceFile.s = GetHomeDirectory() + "MySourceCode.pb"

If CreateFile(0, SourceFile)
  
  WriteString(0, "; Something to see")
  
  CloseFile(0)
EndIf

IDE.s = GetEnvironmentVariable("PB_TOOL_IDE")
MessageRequester("PB_TOOL_IDE", IDE)

If IDE <> ""
  Result.i = RunProgram(IDE, SourceFile, GetPathPart(IDE))
  MessageRequester("RunProgram", Str(Result))
EndIf


; <<<<<<<<<<<<<<<<<<<<<<<
; <<<<< END OF FILE <<<<<
; <<<<<<<<<<<<<<<<<<<<<<<  
Best regards
StarBootics
The Stone Age did not end due to a shortage of stones !
BarryG
Addict
Addict
Posts: 4173
Joined: Thu Apr 18, 2019 8:17 am

Re: Telling the IDE to load source code using RunProgram()

Post by BarryG »

This returns an empty string for me with 6.03:

Code: Select all

Debug GetEnvironmentVariable("PB_TOOL_IDE") ; Nothing shown.
Are you saying it shows something for you?
User avatar
StarBootics
Addict
Addict
Posts: 1006
Joined: Sun Jul 07, 2013 11:35 am
Location: Canada

Re: Telling the IDE to load source code using RunProgram()

Post by StarBootics »

BarryG wrote: Thu Oct 12, 2023 11:57 pm This returns an empty string for me with 6.03:

Code: Select all

Debug GetEnvironmentVariable("PB_TOOL_IDE") ; Nothing shown.
Are you saying it shows something for you?
If you run the program just by launching it directly it will show nothing. You really need to launch it form the Tool menu. So you need to add an entry for it in the Configure Tools.

Best regards
StarBootics
The Stone Age did not end due to a shortage of stones !
BarryG
Addict
Addict
Posts: 4173
Joined: Thu Apr 18, 2019 8:17 am

Re: Telling the IDE to load source code using RunProgram()

Post by BarryG »

I see. So I just tried it as a tool and it works as expected: a new PureBasic instance was run with "MySourceCode.pb" as a blank source. You don't have "only one instance" enabled in PureBasic's prefs by mistake?

Also, is the new source meant to blank? Or is it meant to load an existing source? It doesn't load existing sources for me if I do this:

Code: Select all

SourceFile.s = "C:\My\Other\Existing\Source.pb" ; Fails to load.
User avatar
StarBootics
Addict
Addict
Posts: 1006
Joined: Sun Jul 07, 2013 11:35 am
Location: Canada

Re: Telling the IDE to load source code using RunProgram()

Post by StarBootics »

BarryG wrote: Fri Oct 13, 2023 3:37 am I see. So I just tried it as a tool and it works as expected: a new PureBasic instance was run with "MySourceCode.pb" as a blank source. You don't have "only one instance" enabled in PureBasic's prefs by mistake?
I was meant to load the source code in the running IDE instance. As I have said it used to work until recently. If I disable "Run only one instance" it work as expected, but it's completely useless. I don't want to have multiple instances of the IDE running.
BarryG wrote: Fri Oct 13, 2023 3:37 am Also, is the new source meant to blank? Or is it meant to load an existing source? It doesn't load existing sources for me if I do this:
The loaded source was not meant to be blank. It's supposed to load the source code from a directory full of non compiled libraries. With the given example, you should have the comment inside the source.

Code: Select all

; Something to see
If it's not, it mean that something is broken on the IDE side I suppose.

Best regards.
StarBootics
The Stone Age did not end due to a shortage of stones !
BarryG
Addict
Addict
Posts: 4173
Joined: Thu Apr 18, 2019 8:17 am

Re: Telling the IDE to load source code using RunProgram()

Post by BarryG »

Yes, I get "Something to see" in the new IDE instance, but no code from the existing source that I named is loaded:

Image
Post Reply