1. CHAIN PROGRAM
- Posted by mark <marktio at hotmail.com> Dec 20, 2006
- 574 views
i post a message previously to ask : how to chain eu program I find a way to do it but not sure if it loaded more copies of the intepreter at the point the program is to "CHAIN" the code will be: exitcode = system_exec("p2.ex",2) it works, but i am not sure if it will exhaust the memory, i.e. is the intepreter executing the parent program , executing the seccond 'child' program (p2.ex) or another copy of intepreter is loaded? The message on the forum on this subject is rather confuding to me Sorry I am new at this computer stuff and dont quiet understand the memory issue I am concerned that the memory is overloaded and the files are corrupted thanks
2. Re: CHAIN PROGRAM
- Posted by Derek Parnell <ddparnell at bigpond.com> Dec 20, 2006
- 566 views
mark wrote: > > > i post a message previously to ask : how to chain eu program Why do you want to chain programs? This is a technique used by BASIC and COBOL programs many many years ago to get over the problem that some programs were too big to fit into memory so they were broken up into stages and the stages were chained together. Modern computers have lots of memory so this is very rarely an issue today. > I find a way to do it but not sure if it loaded more copies of the intepreter > > at the point the program is to "CHAIN" > > the code will be: > > exitcode = system_exec("p2.ex",2) > > it works, but i am not sure if it will exhaust the memory, i.e. > is the intepreter executing the parent program , executing the seccond 'child' > program (p2.ex) or another copy of intepreter is loaded? > The message on the forum on this subject is rather confuding to me > Sorry I am new at this computer stuff and dont quiet understand the memory > issue > > I am concerned that the memory is overloaded and the files are corrupted > thanks Why not just write 'p2' as an include file and call it from within 'p1'? -- Derek Parnell Melbourne, Australia Skype name: derek.j.parnell
3. Re: CHAIN PROGRAM
- Posted by Derek Parnell <ddparnell at bigpond.com> Dec 20, 2006
- 540 views
mark wrote: > i post a message previously to ask : how to chain eu program One simple way is to write your programs and then used the command interpreter to chain them. For example, say you have three programs ... One called pro1.ex ... // Program 1 puts(1, "Program 1\n") and another called pro2.ex ... // Program 2 puts(1, "Program 2\n") and another called pro3.ex ... // Program 3 puts(1, "Program 3\n") then a Batch file to chain them ... A file called 'run.bat' ... echo off cmd /C exwc pro1.ex cmd /C exwc pro2.ex cmd /C exwc pro3.ex If you are using an old Windows or DOS system you would use 'command' rather than 'cmd'. -- Derek Parnell Melbourne, Australia Skype name: derek.j.parnell
4. Re: CHAIN PROGRAM
- Posted by Al Getz <Xaxo at aol.com> Dec 20, 2006
- 584 views
Hi there Mark, I have chained a number of my Eu programs as well. I had a few times where it was easier to call a program from another program and pass data via the command line rather than rewrite the whole thing. The 2nd program has to be bound the way i did it, and the syntax for calling it looks something like this: system("DirectoryName\\Program2.exe data",0) The data gets passed to the second program this way. I havent used this very often, but when i needed to do it that way it worked very well. The drawback is that you have to bind p2 first, but with the Eu being open source now that shouldnt be a problem for anyone. Take care, Al E boa sorte com sua programacao Euphoria! My bumper sticker: "I brake for LED's" From "Black Knight": "I can live with losing the good fight, but i can not live without fighting it". "Well on second thought, maybe not."
5. Re: CHAIN PROGRAM
- Posted by mark <marktio at hotmail.com> Dec 20, 2006
- 557 views
Hi Derek Thank you I will try it
6. Re: CHAIN PROGRAM
- Posted by mark <marktio at hotmail.com> Dec 20, 2006
- 538 views
Thank you Al Really appreciate your help Have a great Holidays season!
7. Re: CHAIN PROGRAM
- Posted by mark <marktio at hotmail.com> Dec 20, 2006
- 557 views
Hi Derek Thanks for the help Question re calling p2 from within p1 the way i understand it is in p2. ex i will have include p1.ex then do the call but what is the call statement? is that system (st,i) or system_exec command? Thanks
8. Re: CHAIN PROGRAM
- Posted by irv mullins <irvm at ellijay.com> Dec 20, 2006
- 567 views
- Last edited Dec 21, 2006
Mark: Can you please explain exactly WHY you want to chain one program from another? That would make it easier for us to give useful advice.
9. Re: CHAIN PROGRAM
- Posted by mark <marktio at hotmail.com> Dec 20, 2006
- 569 views
- Last edited Dec 21, 2006
Hi irv i am trying to set up a database program so the first program is a menu that display several modules, eg 1. customer module 1.1 customer file maintenance (ie add,delete and update customer info) 1.2 customer list .... etc 2. product file module 2.1 product file maintenance 2.2 product list the first program is called say p1.ex if user enter a selection say 2.2 , the program will execute another program called p2.ex if use enter 2.1 the program will execute another program p3.ex so there could be 30 to 40 programs that can be run from a menu program so how can i code when running p1.ex to go to say any other program, return back to the menu program? Thanks for your time and help I really appreciate all the kind reply the member has given me! Merry Christam and wish you all great holiday season and a healthy New Year
10. Re: CHAIN PROGRAM
- Posted by Chris Burch <chriscrylex at aol.com> Dec 20, 2006
- 567 views
- Last edited Dec 21, 2006
mark wrote: > > Hi irv > > i am trying to set up a database program > > so the first program is a menu that display several modules, eg > 1. customer module > 1.1 customer file maintenance (ie add,delete and update customer info) > 1.2 customer list > .... etc > 2. product file module > 2.1 product file maintenance > 2.2 product list > > the first program is called say p1.ex > if user enter a selection say 2.2 , the program will execute another > program called p2.ex > if use enter 2.1 the program will execute another program p3.ex > so there could be 30 to 40 programs that can be run from a menu program > > so how can i code when running p1.ex to go to say any other program, > return back to the menu program? > > Thanks for your time and help > I really appreciate all the kind reply the member has given me! > Merry Christam and wish you all great holiday season and a healthy New Year Hi You really really don't want to do that. Chaining the program will lead to a lot of duplicated effort Euphoria can accomodate HUGE programs - what you want to do is fairly trivial (no derogatory comment / insult intended) Look at JetvetSQL for an example (in the archives, text mode only). Hint - start simple with the database, then build on it. Add includes for a new module. Choose your database before you start, edb, eusql, sqlite, mysql tsunami etc - all have their pros and cons. Remember to reference the tables to each other with record ids (usually integers) - see CKs site for a very simple sql intro. Chris http://euallegro.wikispaces.com http://members.aol.com/chriscrylex/euphoria.htm http://uboard.proboards32.com/ http://members.aol.com/chriscrylex/EUSQLite/eusql.html
11. Re: CHAIN PROGRAM
- Posted by irv mullins <irvm at ellijay.com> Dec 21, 2006
- 574 views
Chris is correct. I've done the type of program you're talking about for several different companies over the years. There really hasn't been a problem of them being too large. You just need to spend some time deciding how to organize your code. By that, I mean not putting EVERYTHING in one file, but dividing your code into logical chunks so that it's easier and quicker to locate areas which need editing, debugging, etc. Just as a hint, your 'main program' will probably have nothing but a main menu, preceeded by a number of include ___ statements. You may find it helpful to use namespacing on these, so you can use similarly-named calls for similar procedures, e.g.: Cust:Add, Prod:Add, ...
12. Re: Re: CHAIN PROGRAM
- Posted by cchris005 at fastmail.fm Dec 21, 2006
- 568 views
- Last edited Dec 22, 2006
> Subject: Re: CHAIN PROGRAM > > > posted by: mark <marktio at hotmail.com> > > Hi irv > > i am trying to set up a database program > > so the first program is a menu that display several modules, eg > 1. customer module > 1.1 customer file maintenance (ie add,delete and update customer info) > 1.2 customer list > .... etc > 2. product file module > 2.1 product file maintenance > 2.2 product list > > the first program is called say p1.ex > if user enter a selection say 2.2 , the program will execute another > program called p2.ex > if use enter 2.1 the program will execute another program p3.ex > so there could be 30 to 40 programs that can be run from a menu program > > so how can i code when running p1.ex to go to say any other program, > return back to the menu program? > > Thanks for your time and help > I really appreciate all the kind reply the member has given me! > Merry Christam and wish you all great holiday season and a healthy New > Year > As someone suggested, just don't chain anything. I assume you already have programs, say p2_1.ex, p3_14.ex and so on. Then, at the beginning of the main (menu) program, add a buch of include statements:
include p2-1.ex as p2_1 --... include p3_14.ex as p3_14 </endcode> In each of the programs, lump all top level code that may be executed several times inside a global routine, say execute(object data). Now, when your menu program gets a selection from user, it figures out the data (you already did this if your system works), and then issue }}} <eucode> call_proc(routine_id(prog_name&":execute"),{data})
Use call_func() instead if your programs return anything you may use, like an error code. If you programs are used to get their data from the command line, you'll have to pass data in the format they expect, and to change instances of command_line() i your programs to data. This looks like the way to achieve your goal with the less file edition. Since data can be anything, this may simplify and speed up the code in your programs that was getting actual data from the command line. Your program files are still separate, but only one copy of the intermreter will be running in memory, as you tricked it into thinjing it executes the same main code (your menu program). TIA CChris -- cchris005 at fastmail.fm -- http://www.fastmail.fm - Accessible with your email software or over the web
13. Re: Re: CHAIN PROGRAM
- Posted by mark <marktio at hotmail.com> Dec 22, 2006
- 563 views
Thank you Chris