
-----------------------------------
TWizard
Tue Oct 05, 2010 12:13 am

Calling one program from another
-----------------------------------
I know you can use one program of Turing to open another I would like to know how thats done i'v tried a few myself but have not gotten the results I wanted I already know you have to set to a unit then call it in the main program im just looking for a quick fix I wont be on for a little while so please take your time answering.

-----------------------------------
DanShadow
Tue Oct 05, 2010 12:20 am

RE:Calling one program from another
-----------------------------------
Out of curiousity, I wonder if anybody knows how to this in C++ as well :)

-----------------------------------
TheGuardian001
Tue Oct 05, 2010 4:11 am

Re: Calling one program from another
-----------------------------------
Turing:
[code]
Sys.Exec("command")
[/code]
where "command" is replaced by the command you wish to run. the functionality here is identical to the Windows command prompt. Sys.Exec("notepad") will launch notepad. Sys.Exec("explorer \"C:\\Users\"") Will open C:\Users in an explorer window.

C++:
[code]
#include 
int main(int argc, char** argv)
{
    system("command")
    return 0;
}
[/code]
As before, replace "command" with the command you wish to run, and the functionality is the roughly same as if you had typed the given command into a command prompt.

-----------------------------------
DanShadow
Tue Oct 05, 2010 10:43 pm

RE:Calling one program from another
-----------------------------------
Interesting, thanks.

-----------------------------------
Coldkick
Wed Oct 06, 2010 9:20 pm

RE:Calling one program from another
-----------------------------------
Just to add to TheGuardian001, if you want to organize different parts of your Turing project into different files you can call those parts by using

import "filepath"


An example of use for this is if you want to have your character movement seperate.  You could give it the name "movement.t" and call it in the program by using:


import "movement.t"


-----------------------------------
TWizard
Sat Oct 23, 2010 6:05 pm

RE:Calling one program from another
-----------------------------------
How exactly would you call a turing program from the one your useing i'v tried my self but i do not fully understand how to do it.  Please provide a vivid example.

-----------------------------------
SNIPERDUDE
Sat Oct 23, 2010 11:12 pm

Re: Calling one program from another
-----------------------------------
There are a few  methods, not sure which one you want.

Method 1:
The include method. This enables you to have a large program to be split up as you wish, with no real preparation.
%FILE: next.t
num := 34
%say this is your main program
var num : int
include "next.t"
put num

Method 2:
The import method. There is already plenty of material on this one.

Method 3:
sys.execute method.
Sys.Exec("program.exe")

-----------------------------------
TWizard
Sat Oct 23, 2010 11:24 pm

RE:Calling one program from another
-----------------------------------
Lol thanks for the information but i'v previously gotten my anwsers from the chat.

-----------------------------------
Krocker
Fri Nov 12, 2010 9:36 am

Re: Calling one program from another
-----------------------------------
does the file being opened haved to be in the same file as the one opening the file? :?:  :vi:

-----------------------------------
DemonWasp
Fri Nov 12, 2010 12:00 pm

RE:Calling one program from another
-----------------------------------
The file being opened has to:

1. With include, it must be either in the same folder, or in a descendent folder that is then named. For example, if you have "main.t" which includes "addition.t" in the folder "includes" then main.t should use the line:
[code]include "includes/addition.t"[/code]

2. With import, the same sort of rule applies as #1, but import also allows you to use the "from" directive:
[code]import addition from includes[/code]

3. With Sys.Exec, then the other program must be on the PATH environment variable. Typically, this means that either it must be in the same directory, or it must be one of a select few other directories that will be searched. For more information, http://en.wikipedia.org/wiki/PATH_(variable)
