[Gambas-user] File -> Add
Jean-Marc Varvenne
jean-marc.varvenne at ...27...
Mon Dec 2 00:07:49 CET 2002
Hi Charlie,
you're right, we must copy the files into the project's directory.
That's because the way the project are managed in GAMBAS.
We could suggest to Benoït to change this case in order to enable
several projects to share the same files. So, the changes on the code
into a file will therefore be shared with the all projects using this file.
Nevertheless, you'll find hereafter the changes I made to my IDE:
1. In the module FMain.class, I added a menu : &File -> &Add ->
&Existing File, mnuAddExistingFile, img/16/open-file.png
2. In the module FMain.class, I added the code:
PUBLIC SUB mnuAddExistingFile_Click()
DIM sFile AS String
sfile = project.getexistingfile()
Project.LoadExistingFile(sfile)
END
3. In the module Project, I added the code:
PUBLIC FUNCTION GetExistingFile() AS String
Dialog.Title = "Select a Gambas file"
Dialog.Filter = ""
IF Dialog.Openfile() THEN RETURN
RETURN Dialog.Path
END
PUBLIC FUNCTION LoadExistingFile( sFile AS String) AS Boolean
DIM sProjectPath AS String
DIM sClassName AS String
DIM sFileName AS String
IF NOT sfile THEN RETURN
sProjectPath = FGetBaseName(Path)
sFileName = FGetName(sFile)
IF FGetExt(sFile) = ".form" THEN
' We must test the existance of sFile.class before ...
sClassName = Replace$(sFile, ".form", ".class" )
EXEC "cp " & sClassName & " " & sProjectPath & Replace$(sFileName,
".form", ".class" ) WAIT
END IF
EXEC "cp " & sfile & " " & sProjectPath & Fgetname (sfile) WAIT
refresh
END
PUBLIC FUNCTION FGetName(sFile AS String) AS String
DIM iPos AS Integer
ipos = RInstr(sfile,"/")
IF ipos THEN
RETURN Mid$(sfile, ipos + 1)
ELSE
RETURN sfile
END IF
END
PUBLIC FUNCTION FGetExt(sFileName AS String) AS String
DIM iPos AS Integer
DIM sExt AS String
sExt = sFileName
iPos = RInstr(sExt,"/")
IF iPos THEN sExt = Mid$(sExt, ipos + 1)
iPos = RInstr(sExt, ".")
IF iPos THEN RETURN Mid$(sExt, iPos )
RETURN ""
END
PUBLIC FUNCTION FGetBaseName(sFileName AS String) AS String
DIM iPos AS Integer
DIM sBaseName AS String
iPos = RInstr(sFileName,"/")
IF iPos THEN RETURN Left$(sFileName, iPos )
RETURN ""
END
This is not perfect, we must add some check deci-delà, but it does the job.
Hoping this is usefull,
Jean-Marc
Charlie a écrit:
> Jean-Marc Varvenne schrieb:
>
>>
>> I already made some implementations of whatever I talked before like :
>>
>>> + Pouvoir ajouter un fichier déjà existant au projet en cours:
>>> File -> Add
>>
>>
>>
> Salut Jean-Marc,
>
> how does it work your File -> Add, is the file copied to the
> project-directory or
> rest it on his origin place and a link in the project-directory points
> to the file.
>
> Why ?
>
> I tried this way, but if I had changes to save on this file , the file
> is saved as it in the the project-directory.
>
> Why I don't like that?
>
> Some sub's , function'S etc. are usefull in other programms, but they
> are never perfect.
> So after makeing them better you have to do copy work.
>
> Charlie
>
> -------------------------------------------------------
> This SF.net email is sponsored by: Get the new Palm Tungsten T
> handheld. Power & Color in a compact size!
> http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0002en
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>
>
More information about the User
mailing list