Return multiple values: Difference between revisions
Content added Content deleted
Line 2,657:
=={{header|Plain English}}==
Since parameters are passed by reference by default in Plain English, returning values ends up being unnecessary in most cases. The only functions that actually return a value are Boolean functions, called deciders.
It is possible, however, to call an auxiliary routine to change fields in a record and:
Start up.▼
Shut down.▼
# Concatenate these values, assigning the concatenated string to a new string (see code below);
# Write the concatenated string on the console; or
# As is done in C style, obtain the address of the registers and save the value in a number for later manipulation.
<syntaxhighlight line="1" start="1">The example record is a record with
A string called second field,
A flag called third field.
To run:
▲ Start up.
Fill the example record.
Write the example record on the console.
▲ Shut down.
To fill the example record:
Put 123 into the example's record's first field.
Put "Hello World!" into the example's record's second field.
Set the example's record's third field.
To Write the example record on the console:
Convert the example's example's record's first field to a string.
Convert the example's example's record's third field to another string.
Put the string then " "
then the example's record's second field
then " " then other string into a return string.
Write the return string on the console.
</syntaxhighlight>When it is necessary to get the return value of a Win 32 API function, the syntax is as follows:
''Call "dllname.dll" "FunctionNameHereIsCaseSensitive" returning a <type>.''
Example:s
''Call "gdi32.dll" "GetCurrentObject" with the printer canvas and 6 [obj_font] returning a handle.''
''Call "kernel32.dll" "SetFilePointer" with the file and 0 and 0 and 2 [file_end] returning a result number.''
''Call "kernel32.dll" "WriteFile" with the file and the buffer's first and the buffer's length and a number's whereabouts and 0 returning the result number.''
''Call "kernel32.dll" "HeapAlloc" with the heap pointer and 8 [heap_zero_memory] and the byte count returning the pointer.''{{out}}
<pre>
123 Hello World! yes
</pre>
|