I just noticed something in the Array Passing code discussion (http:// www.powerbasic.com/support/pbforums/showthread.php?t=39196) and thought it worth a separate thread.
{Thinking out loud here}
In the code snippet below (part of Profile_Ordered_with_Variables.Inc - in Source Forum). str1 is Dimmed At (pointing to) an existing array that's part of a Type. In the cases shown here, the VarPtr(pfi.Bytes(1)) is actually 50 chars long per element (as defined by an Equate ), but the first Macro sends a 255 byte element array (address) to the Function. It should have been 'VarPtr(pfi.Procedures(1))
'
The Function works (I'm guessing) because the area pointed to is a pretty large chunk of (contiguous?) memory taken up by the UDT pfi (which has a lot of string arrays in it). And just lucky happenstance it didn't mess up any of the other pfi arrays.
'
I have seldom used Dim At myself and never really thought much about the concept before this. I understand it better now (I think & hope anyway). If anyone sees a flaw or misdirection in the rationale, I would certainly appreciate straightening it out (even if you have to rub it in. {grin}).
==================================
"The difference between
'involvement' and 'commitment'
is like a ham-and-eggs breakfast:
the chicken was 'involved'
the pig was 'committed'."
unknown
==================================
{Thinking out loud here}
In the code snippet below (part of Profile_Ordered_with_Variables.Inc - in Source Forum). str1 is Dimmed At (pointing to) an existing array that's part of a Type. In the cases shown here, the VarPtr(pfi.Bytes(1)) is actually 50 chars long per element (as defined by an Equate ), but the first Macro sends a 255 byte element array (address) to the Function. It should have been 'VarPtr(pfi.Procedures(1))
'
The Function works (I'm guessing) because the area pointed to is a pretty large chunk of (contiguous?) memory taken up by the UDT pfi (which has a lot of string arrays in it). And just lucky happenstance it didn't mess up any of the other pfi arrays.
'
I have seldom used Dim At myself and never really thought much about the concept before this. I understand it better now (I think & hope anyway). If anyone sees a flaw or misdirection in the rationale, I would certainly appreciate straightening it out (even if you have to rub it in. {grin}).
Code:
'Macro which calls "Profile_ProcessAnyArray_Procedures" 'VarPtr(pfi.Procedures(1)) Should be ReDim srt1(1 To %Profile_Array_Elements) As String * %Profile_Procedure_Name_Length At VarPtr(pfi.Bytes(1)) Profile_ProcessAnyArray_Procedures(VarPtr(pfi.Procedures(1))) '255 byte elements Profile_ProcessAnyArray_Procedures(VarPtr(pfi.Macros(1))) ' "" 'End Macro ' Function Profile_ProcessAnyArray_Procedures (pZ As Dword) As Long 'Sort the array point at by pz ReDim Z(1 To %Profile_Array_Elements) As String * %Profile_Procedure_Name_Length At pZ '255 bytes long Array Sort z() 'effectively sorts the array pointed to by pz End Function ' 'Macro which calls "Profile_ProcessAnyArray_Variable" ReDim srt1(1 To %Profile_Array_Elements) As String * %Profile_Variable_Name_Length At VarPtr(pfi.Bytes(1)) Profile_ProcessAnyArray_Variable(VarPtr(pfi.Bytes(1))) '50 byte elements Profile_ProcessAnyArray_Variable(VarPtr(pfi.Integers(1))) ' and so on for 10 more identically sized UDT arrays 'end macro Function Profile_ProcessAnyArray_Variable (pZ As Dword) As Long ReDim Z(1 To %Profile_Array_Elements) As String * %Profile_Variable_Name_Length At pZ '50 bytes long Array Sort z()'effectively sorts the array pointed to by pz End Function '------------------/ProcessAnyArray'
"The difference between
'involvement' and 'commitment'
is like a ham-and-eggs breakfast:
the chicken was 'involved'
the pig was 'committed'."
unknown
==================================
Comment