Page 1 of 1
[Implemented] Passing the address of a pointer
Posted: Thu Oct 07, 2004 3:22 pm
by wilbert
I would like to see a way to pass the address of a string pointer or array pointer to a function. Preferably an extension to the possibilities of the .desc file.
If for example I would like to create a function to insert a string into a string array like this
Code: Select all
ArrayInsert(myArray(), index, value)
, I have to reallocate memory so the pointer to the array will change but there's no way to set the new pointer.
When I pass the address of an array a, the address of the first item is passed like this
push dword [a_a]. I would like the possibility of getting it passed like this
push dword a_a.
Posted: Thu Oct 07, 2004 4:50 pm
by GedB
Something like this?
It would be nice if it could be done without having to use ASM. Perhaps by putting @@ before a variable.
@ Gives a pointer to the value
@@ Gives a pointer to the variable
Code: Select all
Procedure SwapString(A1, A2)
newA1 = PeekL(A2)
PokeL(A2, PeekL(A1))
PokeL(A1, newA1)
EndProcedure
String1.s = "One"
String2.s = "Another"
*p1 = 0
! MOV eax, v_String1
! MOV [p_p1], eax
*p2 = 0
! MOV eax, v_String2
! MOV [p_p2], eax
Debug "Before:"
Debug " String1 [" + Hex(@String1) + "]: " + String1
Debug " String2 [" + Hex(@String2) + "]: " + String2
SwapString(*p1, *p2)
Debug "After:"
Debug " String1 [" + Hex(@String1) + "]: " + String1
Debug " String2 [" + Hex(@String2) + "]: " + String2
Posted: Thu Oct 07, 2004 5:39 pm
by wilbert
@@ would be a possibility but I still would like to see more possibilities for the .desc file when creating a library.
A user should be able to type
String1.s = "One"
String2.s = "Another"
SwapString(String1, String2)
or the array example I gave before. It's very inconvenient to bother a user with @ stuff so he or she has to remember if a function requires no @, 1 @ or 2 @'s. I would like the ability to mention in the .desc file that it should be passed in a certain way.
Posted: Thu Oct 07, 2004 5:46 pm
by GedB
That would be nice. Not just for the desc files but also in the Procedure definitions.
Could something be done with macros?