Some trick. It is a trick to emulate optional parameters.
1) Put your function that needs optional parameters in a codeunit.
2) Create 1 or more extra functions that can be called BEFORE your function to pass the optional parameters, then call the your function
eg. a function that adds lots of 2 or more decimals and gives the result
CODEUNIT START
Function Add(IdecDecimal1 AS Decimal;IdecDecimal2 AS Decimal): OdecReturnValue As Decimal
BEGIN
OdecReturnValue := IdecDecimal1 + IdecDecimal2;
tmpSomeTempTable.RESET;
IF tmpSomeTempTable.FIND('-') THEN
REPEAT
OdecReturnValue += tmpSomeTempTable."Optional Decimal";
tmpSomeTempTable.DELETE(FALSE);
UNTIL tmpSomeTempTable.NEXT = 0;
END;
Function AddOptionalDecimal(IdecOptionalDecimal As Decimal)
BEGIN
intUniqueEntry += 1;
CLEAR(tmpSomeTempTable);
tmpSomeTempTable."Entry No." := intUniqueEntry;
tmpSomeTempTable."Optional Decimal" := IdecOptionalDecimal;
tmpSomeTempTable.INSERT(FALSE);
END;
CODEUNIT STOP
Comments
Sorry
Who would need that, right
Jan Hoek
Product Developer
Mprise Products B.V.
1) Put your function that needs optional parameters in a codeunit.
2) Create 1 or more extra functions that can be called BEFORE your function to pass the optional parameters, then call the your function
eg. a function that adds lots of 2 or more decimals and gives the result
How to use it:
Didn't test the code, so there can be some typo in it.
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
The table record is the only parameter in the function.
Fill the table record, DONT insert, but pass it into the function.
Within the function now some of the 'fields' in the table will be filled and some will not.
Short example:
New table:
Fields:
1 - Item No.
2 - Description
3 - Price
4 - Cost
5 - Salesperson
6 - Vendor
7 - etc...
Code to call function:
NewTable.init; (to clear out values)
NewTable.Item No. := '123456';
NewTable.Cost := 99.00;
NewTable.Vendor := =AAA';
NewFunction(NewTable);
The NewFunction looks like this:
One parameter, type NewTable
NewFunction(NewTable)
If NewTable.Price = 0 then begin
//conditional code here
end else if NewTable.Cost > 10000 then begin
//conditional code here
End else if...
-a
And if you make the table TEMPORARY you don't need to have it in the customer license
Or is this already handled by not inserting the record?
-a