« il: 24 Luglio 2014, 19:23:50 »
Vi riporto la seguente discussione:
"
Is there any way to exec scripts inside project folder without copy it to
another place?
Is there any way to copy a lot of files, or even, a folder with a lot of
files located inside your project folder to any path in your home?
Right now, I pack everything in a tar.gz and then copy to another place and
decompress all files. But if I change some file, I have to make again the
tar.gz...
Is there any simple way to do this?
Sánchez "
"
There are multiple ways. First, you can just execute the script from an
absolute path using Application.Path &/ "myscript".
This method, however, will fail when your project is compiled into an
executable archive (.gambas) because then there is no file actually. Since
there is no concept of a CWD in Gambas, relative paths are used to address
this issue: they identify files in your project directory, even if your
Gambas process runs from an executable archive. This is the reason why you
mostly see code that first copies project files to temporary locations
before they're passed to external processes.
If it's a script, or any data you can *pipe* into some process to have it
handled, you can also read the project file into a String and pipe it to the
process. No need to copy the file then. But IMHO, this is a little
cumbersome as you have to open your interpreter as a pipe'd Process:Dim hProc As Process
hProc = Exec ["sh"] For Read
Write #hProc, File.Load("myscript")
I don't know if this code works by copy and paste but the working pendant
should be at least very similar.
> Is there any way to copy a lot of files, or even, a folder with a lot of
> files located inside your project folder to any path in your home?
>
As said above, you can use relative paths to address your project files.
This works transparently in Gambas, i.e. you can use this feature in any
filesystem-related function and it will work (I hope I'm not making too
strong promises here). So to list all project files recursively, try:Dim sRel As String
For Each sRel In RDir(".")
Print sRel
Next
It's analog for specific folders. Of course you would use Copy to copy
these relative paths to somewhere.
Regards,
Tobi
Registrato
« Chiunque, non ricorrendo lo stato di necessità, nel proprio progetto Gambas fa uso delle istruzioni Shell o Exec, è punito con la sanzione pecuniaria da euro 20,00 a euro 60,00. »