AutoLoad source in the IDE native PB

Just starting out? Need help? Post your questions and find answers here.
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

AutoLoad source in the IDE native PB

Post by Kwai chang caine »

Hello at all

How can i load several source code in the native IDE, with the code.

Because, if i launch several runprogram with parameter the name of source code "xxx.pb" or "xxx.pbi" and the IDE option "only one instance" is not checked, runprogram load several IDE with each one source code :?

And i want just one IDE with all the source code inside

Thanks for your help
Good days
Last edited by Kwai chang caine on Thu Nov 27, 2008 9:00 am, edited 2 times in total.
ImageThe happiness is a road...
Not a destination
#NULL
Addict
Addict
Posts: 1499
Joined: Thu Aug 30, 2007 11:54 pm
Location: right here

Post by #NULL »

this works here in a *.bat file, even if "run only one instance" is disabled.

Code: Select all

set filenamelist=""

set filenamelist=%filenamelist% "main.pb"
set filenamelist=%filenamelist% "inc1.pbi"
set filenamelist=%filenamelist% "inc2.pbi"

start C:\Programme\PureBasic430b4\PureBasic.exe %filenamelist%
should work similar with RunProgram().
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Post by Kwai chang caine »

Thanks for your code.
But i search a code for load code, without care the option of the IDE

It's surrely possible, I believe have see that somewhere, but i don't remember where :roll:
ImageThe happiness is a road...
Not a destination
User avatar
idle
Always Here
Always Here
Posts: 5917
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Post by idle »

Do you realize that you can simply select a bunch of files from a folder and drag them into PB or onto PB's desktop icon to open them.

It'd be better if the drop target would actually read the file types in a folder, that way you could just drop the whole folder into or onto PB to open the files.
User avatar
idle
Always Here
Always Here
Posts: 5917
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Post by idle »

Quick n dirty hack: pb src folder opener

edited a with #Null's tip

Note should Backup your PureBasic.prefs file but you may do so your self before you run it.

documents and settings->(useraccount)->applicationdata->purebasic...

I don't know if it'll work on vista

Create the exe to your desktop then just drag a folder onto it.
Will open all the pb src files in the folder and sub directories.

to open only the files in a particular folder no recursion open folder and drag a file onto it.

To open up normally just double click

alternatively copy it into your PB folder and create a short cut to the desktop and one in your sendto folder.

Code: Select all

  

Procedure.s GetSpecialFolderLocation(Value.l)
  If SHGetSpecialFolderLocation_(0, Value, @File_ID) = 0
    SpecialFolderLocation.s = Space(#MAX_PATH)
    SHGetPathFromIDList_(File_ID, @SpecialFolderLocation)
    If SpecialFolderLocation
      If Right(SpecialFolderLocation, 1) <> "\"
        SpecialFolderLocation + "\"
      EndIf
    EndIf
  EndIf
  ProcedureReturn SpecialFolderLocation.s
EndProcedure

Procedure NukeSettings(filepath.s,strWorkPath.s)

Protected strpath.s

If OpenPreferences(filepath + "PureBasic\PureBasic.prefs")
    PreferenceGroup("FolderLaunch")
    If ReadPreferenceLong("Backedup", 0) = 0
       WritePreferenceLong("Backedup", 1)
       CopyFile(filepath + "PureBasic\PureBasic.prefs",filepath + "PureBasic\PureBasic_Back.prefs")
    EndIf 
    RemovePreferenceGroup("OpenedFiles")
    PreferenceGroup("Global")
    strpath = ReadPreferenceString("SourceDirectory", "")
    If strpath <> strWorkPath 
       WritePreferenceString("SourceDirectory",strWorkPath +"\")
       PreferenceGroup("Explorer")
       WritePreferenceString("Path",strWorkPath +"\")
       PreferenceGroup("FileViewer")
       WritePreferenceString("Path",strWorkPath +"\")
    EndIf 
    ClosePreferences()
EndIf     
EndProcedure 

Procedure.s dirlist(dir.s,bRec=0)
  Static strFiles.s 
  Static ct1
  mDir = ExamineDirectory(#PB_Any, dir, "*.*")  
  If mDir  
    While NextDirectoryEntry(mDir)
      If DirectoryEntryType(mDir) = #PB_DirectoryEntry_File
          Directory$ = dir
          FileName.s = DirectoryEntryName(mDir)
          If FindString(FileName,".pb", 1)
            FullFileName.s = dir + "\" + FileName
            Debug FullFileName
            strFiles + Chr(34) + FullFileName + Chr(34)  
            ct1+1
          EndIf   
      Else
         tdir$ = DirectoryEntryName(mDir)
         If tdir$ <> "." And tdir$ <> ".."
           If bRec = 0
           dirlist(Dir + "\" + tdir$)
           EndIf 
         EndIf 
      EndIf
   Wend
   FinishDirectory(mDir)
  EndIf
  
  ProcedureReturn strFiles 

EndProcedure 



filepath.s = GetSpecialFolderLocation(26)

If filepath 
   tdir$ = ProgramParameter()
   If FindString(tdir$,".pb",1)
      tdir$= GetPathPart(tdir$)
      recursive = 1
   EndIf    
   If tdir$ <> "" 
      NukeSettings(filepath,tdir$)
      param$ = dirlist(tdir$,recursive)
            
   EndIf     
EndIf 



RunProgram(#PB_Compiler_Home+"purebasic.exe",param$,".\")

Last edited by idle on Sat Nov 29, 2008 1:09 am, edited 6 times in total.
#NULL
Addict
Addict
Posts: 1499
Joined: Thu Aug 30, 2007 11:54 pm
Location: right here

Re: AutoLoad source in the IDE native PB

Post by #NULL »

Kwaï chang caïne wrote:Because, if i launch several runprogram
why do you do that? it works with one RunProgramm()

Code: Select all

param.s = "C:\test\test.txt "
param   + "C:\test\test.pb "
param   + Chr(34) + "C:\test\test with spaces.pbi" + Chr(34)
RunProgram("C:\Programme\PureBasic430b4\PureBasic.exe", param, ".")
opens all 3 sources in one new pb instance, regardless the preferences.
maybe you want to load it into an already existing pb-instance? i don't know how to do that.
User avatar
idle
Always Here
Always Here
Posts: 5917
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: AutoLoad source in the IDE native PB

Post by idle »

#NULL wrote:

Code: Select all

param   + "C:\test\test.pb "
param   + Chr(34) + "C:\test\test with spaces.pbi" + Chr(34)
RunProgram("C:\Programme\PureBasic430b4\PureBasic.exe", param, ".")
opens all 3 sources in one new pb instance, regardless the preferences.
maybe you want to load it into an already existing pb-instance? i don't know how to do that.
That would beat hacking the prefs file, though I'm a bit tired to understand why it handles the spaces in the file names and between them. :?
#NULL
Addict
Addict
Posts: 1499
Joined: Thu Aug 30, 2007 11:54 pm
Location: right here

Post by #NULL »

the typed double quotes (") are not part of the string content, only the chr(34) ones (try 'Debug param'), so the shell is splitting into paramters by splitting into words or parts from " to ".

i just noticed: if 'one instance' enabled, my last code wont start a new pb-instance for the sources, but uses one which is there already. but it never loads an instance per source.
User avatar
idle
Always Here
Always Here
Posts: 5917
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Post by idle »

I'm way to tired, I noticed as soon as I printed the result to the console.
I should be thanking KCC too, wouldn't have bothered to write a drag and drop. Works great now and I can finally switch between projects with no fuss
#NULL
Addict
Addict
Posts: 1499
Joined: Thu Aug 30, 2007 11:54 pm
Location: right here

Post by #NULL »

i have a tool for filelists ("PB_Projecz").
it's in the 'fileTools' package for download at
http://www.wannabephoenix.de/html2/pb.php?stuff=progs
(for Windows)

btw: you can even sort the source tabs by sorting the parameter passed.
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Post by Kwai chang caine »

Thanks, thanks for your help

@IDLE
WaaaaOoooohh !!!!
I don't know it's possible to drop a file in the shortcut of an application, KCC should be put to a knitting :oops:
Or perhaps i have forgotten (I have so a little head)

Your code works fine, i go to see if i can use it for my program 8)

@NULL
Thanks too, for your help.
I go to your link, for see your "PB_Projecz"

Again thanks :D
I'm not alone, I'm not alone :D
ImageThe happiness is a road...
Not a destination
User avatar
idle
Always Here
Always Here
Posts: 5917
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Post by idle »

@#Null
I was thinking of adding Named tabs with the folder names so you can use them for notes as the recursion makes them come out sorted within their folders.

@KCC

You're welcome.

You could also probably add a short cut to the launcher in your send to menu. Documents Settings->(your user account)->SendTo
I haven't tried it but that would make it easier still.
Post Reply