Running Turing file from Turing program
Author |
Message |
higi1024
|
Posted: Fri May 25, 2012 9:08 am Post subject: Running Turing file from Turing program |
|
|
What is it you are trying to achieve?
I am trying create a menu program that has the ability to run other turing files.
What is the problem you are having?
I looking at using import but I'm not quite sure how to use it. The documentation is a bit confusing for me...
Describe what you have tried to solve this problem
As said above, I experimented with import, but it doesn't quite do what I need it to do.
Please specify what version of Turing you are using
Turing 4.1.1
Any help would be greatly appreciated! |
|
|
|
|
|
Sponsor Sponsor
|
|
|
mirhagk
|
Posted: Fri May 25, 2012 9:31 am Post subject: RE:Running Turing file from Turing program |
|
|
Sys.Exec is what you need. However the other turing programs must be executable then (since last time I checked you couldn't compile turing from the command line)
The other option is using either import or include and using modules. That means the other files won't be able to run on their own though, so I'm not sure if that's what you want. |
|
|
|
|
|
jr5000pwp
|
Posted: Fri May 25, 2012 12:08 pm Post subject: RE:Running Turing file from Turing program |
|
|
Include statements are what you want, they paste turing code into your file in place of the include statement, because of that they only work if known at runtime. What I would do is have a procedure to convert your files all to "runnableFilex.t" where x is the number of the file. You can then check for the file when displaying the menu and have a built in include function for it as the file name will be controlled by you.
You can create a new Window before you run the file and switch to it so that it looks like you "launched" the file. You can also create a txt file with the original names and label your files in your menu based on that.
That is if you wanted the user to be able to drag and drop their programs into the folder, if its a launcher for a personal collection of games or something, then it becomes a lot easier as you can hardcode it. |
|
|
|
|
|
Insectoid
|
Posted: Fri May 25, 2012 12:21 pm Post subject: RE:Running Turing file from Turing program |
|
|
This is possible with OpenTuring iirc, but not with Holtsoft's Turing releases. Otherwise, you have to select 'generate standalone program' in Turing for each of the programs you want to execute. This generates exe files that you can call with Sys.Exec() as per mirhagk's response.
jr5000pwp's solution is probably the 'most correct', since you're likely creating a menu for a single large project rather than a menu to launch other individual programs. |
|
|
|
|
|
trishume
|
Posted: Fri May 25, 2012 3:30 pm Post subject: Re: Running Turing file from Turing program |
|
|
I think what you are looking for is some kind of "eval" function. But Turing does not have this.
In general though, any program that "needs" to use eval can almost definitely be written in a better way that does not require.
Technically, you can save to a .t file, then call OpenTuring from the command line using Sys.Exec with the -run command line flag.
However, this is buggy and would make any well-trained software engineer scream in agony at the horrible design.
Solution:
Make the programs that need to be called with the menu be enclosed in procedures like "Program1" or "RunCoolGame".
Then you can include the files normally and then simply call the procedure when the menu button is pressed. |
|
|
|
|
|
|
|