f0057@uafhp.uucp (James E. Ward) (09/22/89)
Well, it's time to call on your collective net.wisdom folks. We have an old Turbo 3.0 database application that has a text field which is limited to 88 characters. Our job is to expand this field, preferably to unlimited size. The idea I want to try is to call an editor on a text file from within the application so the user will have the ultimate in expandability and editing of this field. My question to you is: Can this be done in Turbo Pascal 3.0? Must we convert the massive thing to Turbo 5.0 (we have it)? Can it be done from Turbo Pascal 5.0? If so, how? In psuedocode, I believe it would go something like: command = "editor " + filename system(command) Any and all help will be appreciated. Please take a stab at this if you have an idea. James Everett Ward f0057@uafhp.uark.edu It seems like the less a statesman amounts to, the more he loves the flag.
wyoung@ksuvax1.cis.ksu.edu (William J. Young) (09/22/89)
In article <5644@decvax.dec.com> f0057@uafhp.uucp (James E. Ward) writes: >... The idea I want to try is to call an editor on a >text file from within the application so the user will have the >ultimate in expandability and editing of this field. My question to >you is: >Can this be done in Turbo Pascal 3.0? Must we convert the massive >thing to Turbo 5.0 (we have it)? Can it be done from Turbo Pascal >5.0? If so, how? >In psuedocode, I believe it would go something like: >command = "editor " + filename >system(command) Your pseudocode is basically right. However, TP3.x does not have the EXEC procedure that is found in TP4 and TP5. You could use the DOS function call (using the TP3 MSDOS procedure - not sure that is the right name for the procedure, as I no longer have my TP3 docs). You'll have to get yourself a tech manual or a book on DOS function calls to find out what the right function is. CAUTION: I don't remember how TP DB Toolbox allocates memory (if that is what you are using - or I don't know how you are allocating memory), but it is up to you to free sufficient memory for whatever you are calling before you make the DOS function call. This includes the heap space! Good luck. -- ---------------------------- Bill Young 1408 Cambridge Place, Apt 19 Manhattan, KS 66502 (913) 537-6840 Internet: wyoung@ksuvax1.cis.ksu.edu, wyoung%ksuvax1@harris.cis.ksu.edu BITNET: wyoung@ksuvax1.bitnet, wyoung%ksuvax1.bitnet@cunyvm.cuny.edu
cs4g6ag@maccs.dcss.mcmaster.ca (Stephen M. Dunn) (09/24/89)
You can call other programs from Turbo Pascal 3, but it's not the most pleasant task in the civilized world. Turbo 3 doesn't have the EXEC function that Turbo 4 and above includes, so you'll have to use the DOS function 4Bh. To use 4Bh, you must set AL to 0; DS:DX must point to an ASCIIZ string giving the complete filespec of the program you want to execute (including the path to it if it isn't in the current directory, and the extension .COM or .EXE; the EXEC call doesn't handle searching the PATH); ES:BX must point to the parameter block. The parameter block is as follows: Byte 0- 1: segment of environment block (if zero, DOS will give the program a copy of your program's environment; this is probably quite adequate) Byte 2- 3: Offset of command tail Byte 4- 5: Segment of command tail (described below) Byte 6- 7: Offset of first FCB for new program Byte 8- 9: Segment of first FCB for new program Byte 10-11: Offset of second FCB for new program Byte 12-13: Segment of second FCB for new program The command tail is the list of parameters you want to pass to the program (e.g. a filename and/or some option switches). It consists of a count byte, then the list of parameters, then a carriage return (which is not to be included in the count). The two FCBs are a relic of DOS 1.x; most programs in DOS 2 and higher don't use FCBs. However, DOS still sets them up just in case the program expects them (historically, DOS 1 used to parse the first two parameters and set up FCBs for them, assuming they were filenames; more recent versions still do this for backward compatibility). Chances are, the program you're invoking won't care whether you set these up or not; if it does, you'll have to use function 29h ... but don't bother with this unless you find the program complaining. The EXEC function clears the carry flag if it worked; otherwise, it sets the carry flag and returns an error code in AX: 2: if file not found or path invalid 5: if access denied 8: if insufficient memory to load the program 10: if environment invalid 11: if format invalid (note that these numbers are in decimal as I've written them) You'll have to determine how much memory your main program needs, and then go into the Options - COM file section and set the Maximum Dynamic Memory option (or whatever they call it - essentially, heap + stack). COM files are given the entirety of memory when they're invoked and unless you tell your program to give some of this memory back, you won't have any memory left to run your child process in! The information on the EXEC function came from _Advanced MS-DOS_ by Ray Duncan (Microsoft Press) - an excellent book; similar information can also be found in _Programmer's Guide to the IBM PC_ by Peter Norton (also Microsoft Press) - another excellent book. Hope this helps! Feel free to write or post if you have any questions. -- Stephen M. Dunn cs4g6ag@maccs.dcss.mcmaster.ca ********************************************************************** <std_disclaimer.h> = "\nI'm only an undergraduate!!!\n"; "VM is like an orgasm: the less you have to fake, the better." - S.C.
cs4g6ag@maccs.dcss.mcmaster.ca (Stephen M. Dunn) (09/25/89)
You can call other programs from Turbo Pascal 3, but it's not the most pleasant task in the civilized world. Turbo 3 doesn't have the EXEC function that Turbo 4 and above includes, so you'll have to use the DOS function 4Bh. To use 4Bh, you must set AL to 0; DS:DX must point to an ASCIIZ string giving the complete filespec of the program you want to execute (including the path to it if it isn't in the current directory, and the extension COM or .EXE; the EXEC call doesn't handle searching the PATH); ES:BX must point to the parameter block. The parameter block is as follows: Byte 0- 1: segment of environment block (if zero, DOS will give the program a copy of your program's environment; this is probably quite adequate) Byte 2- 3: Offset of command tail Byte 4- 5: Segment of command tail (described below) Byte 6- 7: Offset of first FCB for new program Byte 8- 9: Segment of first FCB for new program Byte 10-11: Offset of second FCB for new program Byte 12-13: Segment of second FCB for new program The command tail is the list of parameters you want to pass to the program (e.g. a filename and/or some option switches). It consists of a count byte, then the list of parameters, then a carriage return (which is not to be included in the count). The two FCBs are a relic of DOS 1.x; most programs in DOS 2 and higher don't use FCBs. However, DOS still sets them up just in case the program expects them (historically, DOS 1 used to parse the first two parameters and set up FCBs for them, assuming they were filenames; more recent versions still do this for backward compatibility). Chances are, the program you're invoking won't care whether you set these up or not; if it does, you'll have to use function 29h ... but don't bother with this unless you find the program complaining. The EXEC function clears the carry flag if it worked; otherwise, it sets the carry flag and returns an error code in AX: 2: if file not found or path invalid 5: if access denied 8: if insufficient memory to load the program 10: if environment invalid 11: if format invalid (note that these numbers are in decimal as I've written them) You'll have to determine how much memory your main program needs, and then go into the Options - COM file section and set the Maximum Dynamic Memory option (or whatever they call it - essentially, heap + stack). COM files are given the entirety of memory when they're invoked and unless you tell your program to give some of this memory back, you won't have any memory left to run your child process in! The information on the EXEC function came from _Advanced MS-DOS_ by Ray Duncan (Microsoft Press) - an excellent book; similar information can also be found in _Programmer's Guide to the IBM PC_ by Peter Norton (also Microsoft Press) - another excellent book. Hope this helps! Feel free to write or post if you have any questions. -- Stephen M. Dunn cs4g6ag@maccs.dcss.mcmaster.ca ********************************************************************** <std_disclaimer.h> = "\nI'm only an undergraduate!!!\n"; "VM is like an orgasm: the less you have to fake, the better." - S.C.