Computer Science Canada

Calling one program from another

Author:  TWizard [ Tue Oct 05, 2010 12:13 am ]
Post subject:  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.

Author:  DanShadow [ Tue Oct 05, 2010 12:20 am ]
Post subject:  RE:Calling one program from another

Out of curiousity, I wonder if anybody knows how to this in C++ as well Smile

Author:  TheGuardian001 [ Tue Oct 05, 2010 4:11 am ]
Post subject:  Re: Calling one program from another

Turing:
code:

Sys.Exec("command")

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 <cstdlib>
int main(int argc, char** argv)
{
    system("command")
    return 0;
}

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.

Author:  DanShadow [ Tue Oct 05, 2010 10:43 pm ]
Post subject:  RE:Calling one program from another

Interesting, thanks.

Author:  Coldkick [ Wed Oct 06, 2010 9:20 pm ]
Post subject:  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
Turing:

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:

Turing:

import "movement.t"

Author:  TWizard [ Sat Oct 23, 2010 6:05 pm ]
Post subject:  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.

Author:  SNIPERDUDE [ Sat Oct 23, 2010 11:12 pm ]
Post subject:  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.
Turing:
%FILE: next.t
num := 34

Turing:
%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.
Turing:
Sys.Exec("program.exe")

Author:  TWizard [ Sat Oct 23, 2010 11:24 pm ]
Post subject:  RE:Calling one program from another

Lol thanks for the information but i'v previously gotten my anwsers from the chat.

Author:  Krocker [ Fri Nov 12, 2010 9:36 am ]
Post subject:  Re: Calling one program from another

does the file being opened haved to be in the same file as the one opening the file? Question BooHoo

Author:  DemonWasp [ Fri Nov 12, 2010 12:00 pm ]
Post subject:  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"


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


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)


: