--------------- FIDO MESSAGE AREA==> TOPIC: 214 POWER BASIC Ref: F2500008 Date: 02/02/98 From: PAUL SMITH Time: 12:41pm \/To: ALL (Read 1 times) Subj: REDIM PRESERVE in PBv3.5 I hope someone can help me with a problem I'm having trying to use the REDIM PRESERVE feature for dynamic arrays of strings and/or long integers. Seems that it causes my system to CRASH all the time. Doesn't seem to get along with dos or windows 95. Equip = Tandy 4000...16mb memory...MR Bios 1.6 Im doing the following ======================================================================== defint a-z dim dynamic num&(0) read a file & index the lines of text open file for input as file while not eof(file) num&(x) = seek(file) incr x redim preserve num&(x) wend close file ======================================================================= Cannot find any info on Redim Preserve in the Reference under dim, redim, or preserve. ^^^^^^^^^ This works flawlessly in the other guy's BASIC 7.1 What am I doing wrong? Is this a bug or what?... Finally... Where's the PowerBASIC BBS? Not all of us are nutty enough to go Net/Web or Compu$erve.... Thanks in advance.... ... Who was that masked interrupt? --- VBD-QwkMail v1.0 (c) Great River Computing Svcs. All Rights Reserved. --- WILDMAIL!/WC v4.12 * Origin: Toast House * (314) 994-0312 * (1:100/560.0) --------------- FIDO MESSAGE AREA==> TOPIC: 214 POWER BASIC Ref: F2500009 Date: 02/02/98 From: BRIAN MCLAUGHLIN Time: 06:54pm \/To: ALL (Read 1 times) Subj: Re: memory questions From: brianm@ims.com (Brian McLaughlin) Subject: Re: memory questions dnskiesling@telis.org (David Kiesling) writes: |> I've been using PowerBasic for some time but never really understood |> exactly how memory is structured. [...] Memory is a complex subject. Here is some background info, as it applies to PowerBasic: Part of an EXE file's header contains instructions to the operating system about how much memory the program needs. All compiled Basic programs follow a convention of asking for far more memory than could ever exist. In that case, the loader takes all available convenitonal memory and assigns it to the program. However much memory is given to the program, it is divided up in the following major ways: One segment is set aside as DGROUP. This segment contains all the static variables and arrays in your program, the stack, and a fair number of other pieces of data. One or more segments are set aside for program code. Any memory that is left over is the far heap. This is where dynamic arrays and string segments are allocated. It is important to understand that a memory segment can be as small as 16 bytes, or as large as 64K, but no larger. |> It mentions the stack is used by a program for local variables in |> procedures and functions [...] But where is this "stack"? Is it |> somewhere in the 640k conventional memory? The stack is located in the 640K conventional memory. It is in the DGROUP segment. |> What about string segments? What's up with |> those? Is that where all other strings in a program are stored? Do |> numeric variables go there too? String segments are dynamically allocated, as they are needed. The size of a string segment defaults to 32K, but you can adjust it using the $STRING metacommand. String segments only hold variable length string data, no numeric data. They are in the far heap. |> What about RAM, and files on the hard disk? How are those structured |> and how is stuff stored in those places? Under DOS, the hard disk is governed by the FAT system. That is a whole 'nother complex subject. RAM is the same as memory, so I'm not sure what you are asking there. |> What about static and dynamic variables? How are those stored/used? Since a static variable is known at compile time, it's actual value is stored in the EXE file at compile time. At run time, the value is stored in DGROUP. Dynamic variables are stored in the far heap. Local variables are stored on the stack. |> If I were to dimension a dynamic string array with each variable |> having a maximum (but not fixed) length of 12 (I'm thinking of 8.3 |> filenames here), how would I be able to tell, before dimensioning the |> array, what the maximum number of elements is that I could fit into |> memory? (using PowerBasic 3.5) I would need to have the documentation of FRE in front of me, and, sadly, I don't. Variable length strings have some overhead involved, beyond the length of the string data itself. So, if you have 1000 bytes of memory available, you cannot fit 100 strings of 10 bytes each in that amount of memory. I don't have all the details at hand, though. Sorry. |> Then, what about into EMS memory? Does PB35 allow you to put variable length string data in EMS? -- Brian McLaughlin, Technical Writer |"Thanks to the Internet, misinformation Integrated Measurement Systems, Inc.| now travels faster than ever before!" Beaverton, OR, USA | ---- Standard disclaimer applies ---- *** QwkNews (tm) v2.1 * [TN71] Internet Newsgroup: alt.lang.powerbasic --- GEcho 1.20/Pro * Origin: Toast House Remote (1:100/561) --------------- FIDO MESSAGE AREA==> TOPIC: 214 POWER BASIC Ref: F2500010 Date: 02/02/98 From: MARC VAN DEN DIKKENBERG Time: 09:29pm \/To: ALL (Read 1 times) Subj: Re: memory questions From: pb@excelsior.xs4all.nl.REMOVE-THIS (Marc van den Dikkenberg) Subject: Re: memory questions On 2 Feb 1998 18:54:09 GMT, brianm@ims.com (Brian McLaughlin) wrote: >|> If I were to dimension a dynamic string array with each variable >|> having a maximum (but not fixed) length of 12 (I'm thinking of 8.3 >|> filenames here), how would I be able to tell, before dimensioning the >|> array, what the maximum number of elements is that I could fit into >|> memory? (using PowerBasic 3.5) I don't know where you plan to store your data... If you want to use 'normal' arrays, you can check the available amount of memory with FRE(-1). If your arrays contain a maximum of 12 characters, you could dimension them as ASCIIZ. In this case, you can reserver 12 bytes of memory for each line, but if it only contains 8 (just an example) then LEN(a(10)) will return '10', too. You can't store dynamic length strings in memory. but, if you're sure that 12 positions will be enough, use ASCIIZ. From your point of view, they behave exactly the same. FreeBase = FRE(-1) ' This will be the maximum # of bytes you can use in conventional memory FreeEMS = FRE(-11) ' This will be the maximum # of bytes you can use in EMS. You now know how much meory you can use, and hence how large you can dimension you array. If you want to use as much memory for your array as possible, you simple have to devide the outcome by 12, and enter the number in the DIMensioning lines below. DIM a( <...> ) AS ASCIIZ*12 DIM VIRTUAL a( <...> ) AS ASCIIZ*12 -- Marc van den Dikkenberg ----------------------- The PowerBasic Archives http://www.xs4all.nl/~excel/pb.html *** QwkNews (tm) v2.1 * [TN71] Internet Newsgroup: alt.lang.powerbasic --- GEcho 1.20/Pro * Origin: Toast House Remote (1:100/561) --------------- FIDO MESSAGE AREA==> TOPIC: 214 POWER BASIC Ref: F2500011 Date: 02/03/98 From: ANEKE & JEROME Time: 12:08am \/To: ALL (Read 1 times) Subj: Dynamic memory allocation From: "Aneke & Jerome" Subject: Dynamic memory allocation ... pointer ?? -----Message d'origine----- De : Aneke & Jerome Mons*avoir * : d83@ath.forthnet.gr Date : mardi 3 f*vrier 1998 00:01 Objet : Re: Memory management and big array in PowerBASIC or QuickBASIC : Help :In fact i have to manage 2 BIG array in memory (process result of file :database). I can not schedule the size will be used by the process for each :array (result of process of input files). How to manage the memory ? I can :not make a choice like 1/3 2/3 or 1/2 1/2 of the FULL availble memory to be :divide for each array. for example : If i book and divide the FULL memory :like 1/2 1/2 and if the first array is very small and the second become very :large i will be stop because of lack of memory in the second array and waste :memory for the first. : :In Pascal you can create a PTR variable, if you need a new one, just create :by NEW ... : :I don't want to use Pascal ... I FEEL there is a solution to this problem :... don't you : :Me to, i don't like to waste memory place for nothing, particulary in this :case !!! : :thanks : :regard : :-----Message d'origine----- :De : Don Schullian :* : aneke and jerome :Date : lundi 2 f*vrier 1998 16:14 :Objet : Re: Memory management and big array in PowerBASIC or QuickBASIC : :Help : : :On Mon, 2 Feb 1998 07:55:08 +0100, you wrote: : :>With PB 3.2 HUGE is not working !! : :Ok.. I generally try to avoid overloading memory so I'm not too familiar :with :HUGE but I understand what it does so send me the code and tell me EXACTLY :what you're attempting to do... and I'll see what I can figure out. : :C'ya, : : : ____ _ ____ ____ _____ :| _ \ / \ / ___) __ | ___)(_ _) :| |_) / _ \ \____\/ \| _) | | :|____//_/ \_\(____/\__/|_| |_| : Reply to: d83@ath.forthnet.gr : www.basicguru.com/schullian : : : *** QwkNews (tm) v2.1 * [TN71] Internet Newsgroup: alt.lang.powerbasic --- GEcho 1.20/Pro * Origin: Toast House Remote (1:100/561) --------------- FIDO MESSAGE AREA==> TOPIC: 214 POWER BASIC Ref: F2500012 Date: 02/03/98 From: ANEKE & JEROME Time: 12:18am \/To: ALL (Read 1 times) Subj: Dynamic memory allocation From: "Aneke & Jerome" Subject: Dynamic memory allocation : pointer ??? -----Message d'origine----- De : Aneke & Jerome Mons*avoir * : d83@ath.forthnet.gr Date : mardi 3 f*vrier 1998 00:01 Objet : Re: Memory management and big array in PowerBASIC or QuickBASIC : Help :In fact i have to manage 2 BIG array in memory (process result of file :database). I can not schedule the size will be used by the process for each :array (result of process of input files). How to manage the memory ? I can :not make a choice like 1/3 2/3 or 1/2 1/2 of the FULL availble memory to be :divide for each array. for example : If i book and divide the FULL memory :like 1/2 1/2 and if the first array is very small and the second become very :large i will be stop because of lack of memory in the second array and waste :memory for the first. : :In Pascal you can create a PTR variable, if you need a new one, just create :by NEW ... : :I don't want to use Pascal ... I FEEL there is a solution to this problem :... don't you : :Me to, i don't like to waste memory place for nothing, particulary in this :case !!! : :thanks : :regard : :-----Message d'origine----- :De : Don Schullian :* : aneke and jerome :Date : lundi 2 f*vrier 1998 16:14 :Objet : Re: Memory management and big array in PowerBASIC or QuickBASIC : :Help : : :On Mon, 2 Feb 1998 07:55:08 +0100, you wrote: : :>With PB 3.2 HUGE is not working !! : :Ok.. I generally try to avoid overloading memory so I'm not too familiar :with :HUGE but I understand what it does so send me the code and tell me EXACTLY :what you're attempting to do... and I'll see what I can figure out. : :C'ya, : : : ____ _ ____ ____ _____ :| _ \ / \ / ___) __ | ___)(_ _) :| |_) / _ \ \____\/ \| _) | | :|____//_/ \_\(____/\__/|_| |_| : Reply to: d83@ath.forthnet.gr : www.basicguru.com/schullian : : : *** QwkNews (tm) v2.1 * [TN71] Internet Newsgroup: alt.lang.powerbasic --- GEcho 1.20/Pro * Origin: Toast House Remote (1:100/561) --------------- FIDO MESSAGE AREA==> TOPIC: 214 POWER BASIC Ref: F2500013 Date: 02/03/98 From: DAVID KIESLING Time: 04:06am \/To: ALL (Read 1 times) Subj: Re: memory questions From: dnskiesling@telis.org (David Kiesling) Subject: Re: memory questions >Part of an EXE file's header contains instructions to the >operating system about how much memory the program needs. >All compiled Basic programs follow a convention of asking >for far more memory than could ever exist. In that case, the >loader takes all available convenitonal memory and assigns >it to the program. So I take it programs compiled from some other languages don't do this? >One segment is set aside as DGROUP. This segment contains >all the static variables and arrays in your program, the >stack, and a fair number of other pieces of data. Just static arrays or all arrays? I'll assume just static. That makes more sense to me. How large is DGROUP? If a static array and the stack together equaled more than 64k, then what? Does it automatically create another segment? >One or more segments are set aside for program code. Any >memory that is left over is the far heap. This is where >dynamic arrays and string segments are allocated. Okay, got that much. >It is important to understand that a memory segment can be >as small as 16 bytes, or as large as 64K, but no larger. So the advantage of making string segments less than 32k is because I might end up with the final 32k string segment holding only a puny little 2-byte string, hogging all that 32k of memory? >String segments are dynamically allocated, as they are needed. So a new string segment would take away another 32k (or whatever $STRING is set to) of free memory from the far heap, or however much free memory is left if it's less than 32k? >The size of a string segment defaults to 32K, but you can adjust >it using the $STRING metacommand. String segments only hold >variable length string data, no numeric data. They are in the >far heap. So the rest of the far heap holds everything that string segments and DGROUP will not? >Since a static variable is known at compile time, it's actual >value is stored in the EXE file at compile time. At run time, >the value is stored in DGROUP. >Dynamic variables are stored in the far heap. Local >variables are stored on the stack. Thanks! I understand more now than I did before. What happens when a (hypothetically) s$ contains "hello" and starts at position 10 in a string segment, then another string variable starts at position 15, right after "hello", but then s$ changes to "hello world!"? Would s$ have to move to the "end of the line" of the variables in that segment to accomodate the larger string? What happens to that 5-byte (plus overhead?) space it left behind? If another string variable is created and less than 5 bytes, will it hop in that empty space instead of jumping on the end of the line of strings, to conserve space? >Does PB35 allow you to put variable length string data in EMS? No. Quoting PB: "A VIRTUAL array is another extension of the DYNAMIC type. Memory is allocated at run time, and it may use any amount of available EMS memory. You must choose VIRTUAL allocation explicitly with DIM VIRTUAL. VIRTUAL arrays support array bounds within the long integer range. All data for VIRTUAL arrays is stored in EMS memory. The FRE(-11) function can be used to determine if enough EMS memory is available for allocation. Note: Dynamic strings and Flex strings are not supported in VIRTUAL arrays." *** QwkNews (tm) v2.1 * [TN71] Internet Newsgroup: alt.lang.powerbasic --- GEcho 1.20/Pro * Origin: Toast House Remote (1:100/561) --------------- FIDO MESSAGE AREA==> TOPIC: 214 POWER BASIC Ref: F2500014 Date: 02/03/98 From: MARKUS SVILANS Time: 02:53am \/To: ALL (Read 1 times) Subj: Scalar and Planar variabl From: bh447@freenet.carleton.ca (Markus Svilans) Subject: Scalar and Planar variables -- what are they? Hi, Just one quick question: I've noticed that sometimes when I forget to include an argument in a sub or function in PowerBasic, it tells me something like "Planar integer variable expected" or "Scalar integer variable expected", and I'm just wondering what the difference between scalar and planar variables are, and what they are. Thanks. -- Markus Svilans bh447@Freenet.Carleton.CA -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Early bird gets the worm, but second mouse gets the cheese. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= *** QwkNews (tm) v2.1 * [TN71] Internet Newsgroup: alt.lang.powerbasic --- GEcho 1.20/Pro * Origin: Toast House Remote (1:100/561) --------------- FIDO MESSAGE AREA==> TOPIC: 214 POWER BASIC Ref: F2500015 Date: 02/03/98 From: MARKUS SVILANS Time: 02:55am \/To: ALL (Read 1 times) Subj: PB 3.5 and XMS From: bh447@freenet.carleton.ca (Markus Svilans) Subject: PB 3.5 and XMS Everyone who has bought the latest PowerBasic: Does pb3.5 support XMS (I know it supports EMS)? Thanks. -- Markus Svilans bh447@Freenet.Carleton.CA -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Early bird gets the worm, but second mouse gets the cheese. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= *** QwkNews (tm) v2.1 * [TN71] Internet Newsgroup: alt.lang.powerbasic --- GEcho 1.20/Pro * Origin: Toast House Remote (1:100/561) --------------- FIDO MESSAGE AREA==> TOPIC: 214 POWER BASIC Ref: F2B00000 Date: 02/03/98 From: MARC VAN DEN DIKKENBERG Time: 07:17pm \/To: ALL (Read 1 times) Subj: Re: PB 3.5 and XMS From: pb@excelsior.xs4all.nl.REMOVE-THIS (Marc van den Dikkenberg) Subject: Re: PB 3.5 and XMS On 3 Feb 1998 02:55:04 GMT, bh447@freenet.carleton.ca (Markus Svilans) wrote: >Everyone who has bought the latest PowerBasic: > >Does pb3.5 support XMS (I know it supports EMS)? No, it doesn't. (Just EMS.) there are, however, free sources which will enable you to use XMS from PowerBasic. You can find these (among others) in the ABC packets. The Juli 1997 ABC packets features one of these. You can download it at http://www.xs4all.nl/~excel/pbabc.html Don't forget to download the ABC reader to extract the code! -- Marc van den Dikkenberg