Computer Science Canada Running turing source files from another turing source file. |
Author: | Insectoid [ Tue Jun 10, 2008 7:57 pm ] |
Post subject: | Running turing source files from another turing source file. |
Well, I have decided to do a huge multi-game program for my final project. I decided this because the many games I have that I did for fun are apparently good enough to be final projects themselves, and all rolled into 2 (computer science/computer engineering) they would make a SUPER final project. Wow, wouldn't that be nice? The problem is, I used the same variable names throughout the different programs. I figured it would be a pain to stick them all into one program and have to change all the variable names, so why not make an extra program that has buttons to open and run the individual games? Sounded like a good Idea to me! Now the question is, how do I do it? Is it possible to run a source file as if the 'run' button has been clicked, or do I have to run compiled versions? Well, either way is fine, they both will get me better marks to make up for all the marks the teacher will doc me for what he sees as a 'bad' variable name (I had the name 'total' to represent the total cost of something; apparently it wasn't 'descriptive' enough, even though I had it commented. He also docked me for having too many comments once. I put in tons because I didn't want to lose marks for having too few.). |
Author: | Tony [ Tue Jun 10, 2008 9:42 pm ] |
Post subject: | RE:Running turing source files from another turing source file. |
You'd have to compile the programs, then use Sys.Exec(). So you'll effectively be building a program launcher. |
Author: | gitoxa [ Tue Jun 10, 2008 9:42 pm ] |
Post subject: | Re: Running turing source files from another turing source file. |
The easiest way around that would just be sticking them in procedures. (And if your programs are already procedural, put each games "main" in a procedure) And if you don't want them all in the same file, just use include |
Author: | Tony [ Tue Jun 10, 2008 9:51 pm ] |
Post subject: | RE:Running turing source files from another turing source file. |
Though since include effectively concatenates the source files, there could be an issue of the scope. If individual programs could be encapsulated in their own namespace (such as via use of procedures, as suggested), then this would work. |
Author: | Insectoid [ Wed Jun 11, 2008 7:31 am ] |
Post subject: | RE:Running turing source files from another turing source file. |
Well, a program launcher is what I'm after. I did say I didn't want them all in the same program, because that would involve changing a assload of variable names. I also think I'd get bonus marks for the launcher, as the teacher has not gone over it in class (which is why I'm asking you guys how to do it). Now I just have to make it! Thanks for the help!. Now on to helping others! Edit: Worked perfectly! A+++ here I come! Better than my E-bay feedback! (well, no, I've never used E-Bay) |
Author: | Insectoid [ Thu Jun 12, 2008 8:39 am ] |
Post subject: | RE:Running turing source files from another turing source file. |
Is there any way I can read a file that is inside a folder that is is the same folder as the program calling it? say, I have it in c:/mainmenu.exe reading from c:/pacman/pacman.exe Of course, that is not where I have it, just as an example. |
Author: | jeffgreco13 [ Thu Jun 12, 2008 8:43 am ] |
Post subject: | Re: Running turing source files from another turing source file. |
just call... foldername/filename.exe thats it.. whatever directory the file that's being executed is in, it will look for a folder with 'foldername' and go in to look for filename.exe |
Author: | Aziz [ Thu Jun 12, 2008 8:50 am ] |
Post subject: | RE:Running turing source files from another turing source file. |
Either call "C:/Mainmenu.exe" or if you want to keep it relative ".." is the parent folder. So in this case "../mainmenu.exe". You can do this many times C:/One/Two/Three.exe can call C:/Ecks/Why/Zed.exe by the following relative path: ../../Ecks/Why/Zed.exe Each .. moves up to the parent directory. So, Three.exe is in "Two/" so ".." would mean "One/". And "../.." would mean the parent of One/, or "C:/". Then, you go as normal from there. |
Author: | Insectoid [ Thu Jun 12, 2008 9:05 am ] |
Post subject: | RE:Running turing source files from another turing source file. |
Thanks, now my folder won't look like such a mess... |
Author: | Insectoid [ Sun Jul 06, 2008 9:06 pm ] |
Post subject: | RE:Running turing source files from another turing source file. |
Ah crap, I forgot the syntax for this... I'm working on a database program and in order to access new entries, the program has to restart. I want this to be done automatically (execute the database, then close the original one) and need someone to help me with this. Wow, I feel like an idiot... I did check the documentation, but it didn't help. Seeing as this is a personal project, it's all right for you to just give me the code (I knew it, but forgot). |
Author: | jeffgreco13 [ Mon Jul 07, 2008 8:49 am ] | ||
Post subject: | Re: Running turing source files from another turing source file. | ||
So is the Turing program simply one exe that loads a database, then you want it to restart and load another? Well one way to do it I guess would be to close the current Turing EXE. This can be done in turing. Then before execution is finished Sys.Exec a special BATCH file that you will make.
something like that... passing variables when launching is a different story tho and is a little more difficult. You might need to pas variables if you plan on loading different things upon the program load. |
Author: | Insectoid [ Mon Jul 07, 2008 5:59 pm ] |
Post subject: | RE:Running turing source files from another turing source file. |
Er..no, I just wanted the program to call itself. My problem actually that there were spaces in the file name (Sys.Exec ("40k Database Reader.exe")). So I changed the spaces to underscores, and found another problem. It can't call itself. So I made a 'middleman' program that is called up, after which the database closes, and the middleman loads up the dataabase. Hehe, silly me |
Author: | gitoxa [ Mon Jul 07, 2008 8:48 pm ] |
Post subject: | RE:Running turing source files from another turing source file. |
Just a question... why does your database have to be re-run to get new data? Maybe I'm just missing something about what you're doing, but from the little database I'd made a while ago, there was no restarting required at all. Everything updated as you went. |
Author: | Warchamp7 [ Tue Jul 08, 2008 2:50 pm ] |
Post subject: | RE:Running turing source files from another turing source file. |
Lumping them into one program wouldn't be too difficult unless one of two (or both) of the following are present 1. BOTH games have a TON of variables 2. All your variables aren't declared at the top of your program If just one of your games has all the variables declared at the top and doesn't have a ton, you can just use the replace function a few times and add like ABC to all the variables in one of the games. Tada, no more duplicates Feel free to keep going with the program launcher though, maybe you'll get some extra marks |
Author: | Insectoid [ Tue Jul 08, 2008 5:21 pm ] |
Post subject: | RE:Running turing source files from another turing source file. |
Warchamp- Read the whole thread next time. That problem was solved nearly a month ago. To answer you anyway: 1. ALL THREE GAMES have a TON of variables, many of which use the same names. 2. Few of my variables were declared at the top. Only universal ones. 3. Sys.Exec is way more fun! Gitoxa- Meh, I could do it with flexible arrays and such, but I don't really feel like looking them up when I could waste your time with stupid questions like these! |
Author: | gitoxa [ Tue Jul 08, 2008 5:28 pm ] |
Post subject: | RE:Running turing source files from another turing source file. |
You don't need flexible arrays... |