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 ja en en en en en en en en en en en en en en en en en en nl en nl en ja en ru en en en en nds en hu en de en en nl en en en en en en en en en en en nl en en en en en en en en en en fr en da en en fr en en en en nl en en en en en en en en en en fr en en fr pt en en nl en nl en en en en en en nds en hu en 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 PowerBASIC for Windows 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
16 Apr 2000, 07:50 AM
Does anyone know of a quick way to assign all the data from one string array to another (maybe in assembler), at the moment I am using a FOR\NEXT loop, but it is quite slow on large arrays.
The arrays are identical in length.
16 Apr 2000, 10:07 AM
In lieu of resorting to inline assembler code, the API "RtlMovememory" (MoveMemory) should work.
Search the Topics. This has probably been discussed before.
Join Date: Aug 1998
16 Apr 2000, 10:41 AM
PB/Win 32 uses OLE strings; correct? And the array itself physically holds OLE string handles; correct? (I *think* that's correct, anyway).
If so (and I may be way off base here), can't you just
DIM NewArray(size) AT VARPTR(OldArray()) AS STRING
.. and now NewArray is working on the same data? That is, changing one changes the other, but you may now refer to the data by either name?
This is not the same as copying, but I thought I'd ask (i.e., I'm getting lazy in my old age and don't feel like testing it today).
Port Washington WI USA
Join Date: Aug 1998
17 Apr 2000, 03:47 AM
The PB RTL & OLE string engine handle the allocation and storage of the actual dynamic string data (you can check the address of the actual data if you use STRPTR()). The location of the string data itself will change as the string data is changed/manipulated during normal program execution - however, it does not change unless the string data is altered.
Therefore, the problem is that there is no way to guarantee that the actual string data (in a dynamic string array) will be stored sequentially in memory, hence there is no simple way to be able to read the data within a whole dynamic string array in one go.
In addition, the string engine also adds an additional NULL byte to each string in memory, and this would have to be taken into account (this is also true for other PB string types).
The simple answer is that if you are using a dynamic string array, you'll have to loop through each array element to duplicate the string array - there is no simple workaround.
However, if you use a fixed-length or asciiz string array, you'll find that the string data occupies a fixed location in memory, so it is possible to duplicate an entire array with a pair of POKE$ and PEEK$ functions - it can be supprisingly simple:
' PBCC code, to show technique FUNCTION PBMAIN DIM a(1:10) AS STRING * 10, b(1:10) AS STRING * 10 FOR x& = 1 TO 10 a(x&) = FORMAT$(x&, "##########") NEXT x& [b]POKE$ VARPTR(b(1)), PEEK$(VARPTR(a(1)), UBOUND(a(1)) * (SIZEOF(a(1)) + 1))[/b] FOR x& = 1 TO 10 PRINT x&, $DQ b(x&) $DQ NEXT x& WAITKEY$ END FUNCTION
17 Apr 2000, 05:33 AM
OK thanks lance, thats all I wanted to know.
Looks like I will have to stick with FOR\NEXT because the array isn't fixed length.
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 01:18 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.