en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en nl en en en en en en de en en en en en nl en en fr en en en en en en en en en en fr en da en en en en en en en nl en en en en en en en en en en en en en en nl en en en en en en en fr en da en en en en de en en en fr en en en en en en en en en pt en en en en en en
By logging into your account, you agree to our Privacy Policy, personal data processing and storage practices as described therein.
Forgot password or user name?
Search in titles only Search in Programming only
You are not logged in. You can browse in the PowerBASIC Community, but you must click Login (top right) before you can post. If this is your first visit, check out the FAQ or Sign Up.
All Time Today Last Week Last Month
All Discussions only Photos only Videos only Links only Polls only Events only
Join Date: Aug 2005
passing dynamic string arrays
15 May 2008, 06:14 AM
I want to pass an array address to a function which populates the array with up to m rows (max of m is known) of n columns (max of n is not known, though there is a limit to the combined length of all ns in a row). It's easy to pass a one-dimensional string array pointer and populate the array, which takes care of m, but how does one copy the entire array into a string and then extract it again? The nature of the data precludes the use of substring delimiters, and because n is unknown to the calling procedure it is not possible to REDIM the passed array to fit.
Looking at GET# and PUT# help, it appears possible that the string could be stored in one of two different formats. Also, do dynamic string arrays always occupy contiguous storage? If so, just a length function would be enough. But LEN() does not appear to work either with arrays or with string pointers.
Sure I've read something on this but I can't find it again, about time the topical index facility was added to these forums!
Join Date: Aug 1998
15 May 2008, 06:39 AM
Why not just pass the entire array and resize it in the load function?
FUNCTION Populate (S() AS STRING) AS LONG REDIM S (m,n) Populate... END FUNCTION ... REDIM X(0,0) AS STRING CALL Populate (X()) nRow = UBOUND (X,1) + 1 ' assuming populated from (0,0) nColumn = UBOUND (X,2) + 1
Yes, string arrays like all arrays in memory use contiguous memory for the string handles (32-bit values), although the string data itself might be 'anywhere'
When a string array is saved to disk, it's not saved that way; that's a whole 'nother thing.
Both memory and disk storage formats are described in the help file.
LEN() works just fine with arrays and STRING PTRs. Show failing code.
Port Washington WI USA
Join Date: Aug 2005
15 May 2008, 07:50 AM
Originally posted by Michael Mattias View Post
Why not just pass the entire array and resize it in the load function?
You mean just like this? It seems to work...
Join Date: Aug 1998
15 May 2008, 11:02 AM
I've been doing that literally for years for "load" functions. It makes it really easy to change "how much" stuff gets loaded.
Also, it's how I discovered the incompatibility between PB 6x- and 7x+ array descriptors. My 7x program failed to load something using a function from a 6x DLL.
Port Washington WI USA
Copyright © 1998-2022 PowerBASIC Tools, LLC - All Rights Reserved.
Powered by vBulletin® Version 5.7.0
Copyright © 2022 vBulletin Solutions, Inc. All rights reserved.
All times are GMT-5. This page was generated at 04:25 AM.
We process personal data about users of our site, through the use of cookies and other technologies, to deliver our services, and to analyze site activity. For additional details, refer to our Privacy Policy.
By clicking "I AGREE" below, you agree to our Privacy Policy and our personal data processing and cookie practices as described therein. You also acknowledge that this forum may be hosted outside your country and you consent to the collection, storage, and processing of your data in the country where this forum is hosted.