You can sort UDT arrays by member using their position. You can SCAN them the same way, unless the item is an ASCIIZ member.
The attached program illustrates my problem. I am looking for the first non-match in a UDT array (which contains more members than the example here, of course). I can SCAN and match a standard ASCIIZ array, but not a UDT array containing an ASCIIZ member. I am not indicating there is anything "wrong" with the tools provided by the wonderful PB team, probably it is just the blockhead using them.
So, am I doing something wrong? Or can you just "not get there from here?" I know how to work around this problem, but I want to know if it can be done with the fine tools produced by Bob's group.
Regards, Ian Cairns.
The attached program illustrates my problem. I am looking for the first non-match in a UDT array (which contains more members than the example here, of course). I can SCAN and match a standard ASCIIZ array, but not a UDT array containing an ASCIIZ member. I am not indicating there is anything "wrong" with the tools provided by the wonderful PB team, probably it is just the blockhead using them.
So, am I doing something wrong? Or can you just "not get there from here?" I know how to work around this problem, but I want to know if it can be done with the fine tools produced by Bob's group.
Regards, Ian Cairns.
Code:
#COMPILE EXE #DIM ALL #INCLUDE "c:\basic\pbwin8\winapi\win32api.inc" TYPE AzTestTYPE xFirst AS ASCIIZ * %MAX_PATH END TYPE '------------------------ '######################## '------------------------ FUNCTION PBMAIN () AS LONG DIM noItems AS LONG, _ ndx AS LONG, _ sp1 AS LONG, _ sp2 AS LONG, _ retVal1 AS LONG, _ retVal2 AS LONG, _ azString AS ASCIIZ * %MAX_PATH DIM AzTest(0:500) AS LOCAL ASCIIZ * %MAX_PATH DIM AzTest2(0:500) AS LOCAL AzTestTYPE noItems = 6 AzTest(1) = "C:\temp" : AzTest2(1).xFirst = AzTest(1) AzTest(2) = "C:\temp" : AzTest2(2).xFirst = AzTest(2) AzTest(3) = "C:\temp" : AzTest2(3).xFirst = AzTest(3) AzTest(4) = "F:\temp" : AzTest2(4).xFirst = AzTest(4) AzTest(5) = "D:\temp" : AzTest2(5).xFirst = AzTest(5) AzTest(6) = "X:\temp" : AzTest2(6).xFirst = AzTest(6) ' Get position of xFirst member within UDT sp1 = VARPTR(AzTest2(1).xFirst) - VARPTR(AzTest2(1)) +1 sp2 = sp1 + SIZEOF(AzTest2(1).xFirst)-1 ndx = 1 ' value to scan for - want first non-match. azString = AzTest2(ndx).xFirst ' First scan is position within ASCIIZ standard array - this works properly ARRAY SCAN AzTest(ndx) FOR noItems, <> azString, TO retVal1 ' Second scan is position within ASCIIZ UDT array ARRAY SCAN AzTest2(ndx) FOR noItems, FROM sp1 TO sp2, <> azString, TO retVal2 ' This returns incorrect results also: ' ARRAY SCAN AzTest2(ndx) FOR noItems, <> azString, TO retVal2 MSGBOX "Return values should be item 4, the first non-match" + $CR _ + "Standard ASCIIZ array search returns: " + FORMAT$(retVal1) + $CR _ + "ASCIIZ UDT search returns: " + FORMAT$(retVal2) END FUNCTION '------------------------ '######################## '------------------------
Comment