After an odd bug and a bit of testing I have found that the parameters in Delphi (tested 6 and 2006) are evaluated very strangely.
The 3rd parameter is evaluated first followed by 4, 5, 6 etc and then the 2nd and then the 1st. This appears to be because the default calling convention is register which (from the documentation) puts up to 3 parameters in registers and the rest on the stack. It seems to process the stack ones first from parameters 3 onwards (Why 3? Shouldn't it be 4 if we are putting 3 into registers. Must be only putting 2 in the registers), and then the first 2 in reverse order into the registers. The documentation also says that is supposed to pass the from left to right, but it obviously doesn't. You can download an example to see for yourself! http://www.verner.co.nz/download/FunctionCall.zip If you are interested how we found this, we have a simple function that strips the first delimited item from a string returning the item and removing it from the input string. You can have a string something like: LString := 'Stacey,G,Verner'; and call: LFirstName := Extract(LString, ','); LInitial := Extract(LString, ','); LLastName := Extract(LString, ','); In this case if we had a function like: function FullName(PFirstName, PInitial, PLastName: String): String; and you call it with: LName := FullName(Extract(LString, ','), Extract(LString, ','), Extract(LString, ',')); then we'll get the wrong result. Stacey Stacey Verner Ph: +64-9-4154790 Software Developer Fax: +64-9-4154791 DDI: +64-9-4154797 Email: [EMAIL PROTECTED] <BLOCKED::mailto:[EMAIL PROTECTED]> CJN Technologies Ltd. PO Box 302-278, North Harbour, Auckland 1330, New Zealand 12 Piermark Drive, North Harbour, Auckland, New Zealand Visit our website at http://www.cjntech.co.nz/ <BLOCKED::http://www.cjntech.co.nz/>
_______________________________________________ Delphi mailing list [email protected] http://ns3.123.co.nz/mailman/listinfo/delphi
