Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!ut-sally!husc6!bu-cs!bucsb.bu.edu!madd From: madd@bucsb.bu.edu.UUCP (Jim "Jack" Frost) Newsgroups: comp.sys.ibm.pc Subject: Re: Cannot putenv() in MSC 4.0 Message-ID: <972@bucsb.bu.edu.UUCP> Date: Tue, 19-May-87 13:02:13 EDT Article-I.D.: bucsb.972 Posted: Tue May 19 13:02:13 1987 Date-Received: Wed, 20-May-87 05:37:56 EDT References: <2301@tekgvs.TEK.COM> Reply-To: madd@bucsb.bu.edu.UUCP (Jim "Jack" Frost) Distribution: na Organization: ODO (Organization for the Disorganization of Organization) Lines: 76 Keywords: pushd,popd,putenv,Turbo Pascal,Microsoft C V4.0 In article <2301@tekgvs.TEK.COM> toma@tekgvs.UUCP (Thomas Almy) writes: >I had been using a clever version of PUSHD/POPD, written in Turbo Pascal, >which saved the directory stack in an environmental variable string. (This >program was posted here about a year ago). Well it worked fine until my >environment became greater than 20 paragraphs. At that point the Turbo >program dies because the maximum string size in Turbo is 255 characters. >[...] >Now it looks like I will have to rewrite putenv() (using the Turbo version as >a guide), but before I do, has anyone done this already? Or is there a >public domain PUSHD/POPD out there that will do the job? If you already have the Turbo source, it might be easier to redefine the string functions supported in TP. I once wrote a series of functions that operated on strings of up to 64K by defining strings the way C does -- series of chars null terminated. To do this, define a type like: type str = ^array[0..0] of char; [This of course will be limited to 32K strings because that's MAXINT, but it's simple enough to start the array at -MAXINT to get 64K (almost) strings.] Then declare your string as an array of chars, making it as big as you like: var bigstring = array[0..20000] of char; A sample function would look like: function strlen(s : str); var l; begin l:= 0; while s^[l] <> chr(0) do l:= l+1; strlen:= l end; Pass the string to functions using the addr() function: slen = strlen(addr(bigstring)); If you know C, then you realize that the str type is equivalent to the (char *) type, while array[] of char is (char). It's nice of TP not to do array subscript checking by default, since it makes it easy to create these kinds of functions (which are really really illegal in standard Pascal, but terribly useful). Of course, these functions will operate considerably slower than their TP counterparts, but in practice this is usually negligible. I wrote most of a shell program using them, with no problems. The only thing that's annoying is having to pass addr(stringname) instead of just stringname, but you can get around this as follows: var strspace : array[0..whatever] of char; bigstr : str; len : integer; {...} begin bigstr:= addr(strspace); {...} len:= strlen(bigstr); {...} end. You get the idea. This might be a better solution to your problem, because you can just replace functions within the program you already have. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Jim Frost * The Madd Hacker | UUCP: ..!harvard!bu-cs!bucsb!madd H H | ARPA: madd@bucsb.bu.edu H-C-C-OH <- heehee +---------+---------------------------------- H H | "We are strangers in a world we never made"