The following example does not use any of the simplifications that have been included to make writing Maplet applications easier which leads to longer code but faster execution and for more complex Maplet applications, greater control of the Maplet application appearance and behavior. The required changes are:
1. An onstartup action must be specified. This action must be referenced and contain a RunDialog element which starts the FileDialog element.
2. Actions associated with onapprove and oncancel must be given by a reference and located outside the FileDialog element. The command elements must be wrapped in Action elements.
3. All option names must be specified, including reference and value.
>
|
with(Maplets[Elements]):
# Define the "onstartup" option to be referenced by A0.
maplet2 := Maplet( 'abnormalshutdown' = "FAIL",
'onstartup' = 'A0',
FileDialog( 'reference' = 'FD1',
'title' = "Read File",
'approvecaption' = "OK",
'onapprove' = 'A1',
'oncancel' = 'A2'
),
# Start the FileDialog.
Action( 'reference' = 'A0',
RunDialog( 'dialog' = 'FD1' )
),
# Define the resulting action if "OK" is clicked.
Action( 'reference' = 'A1',
Shutdown( '`return`' = 'R1' )
),
# Define the resulting action if "Cancel" is clicked.
Action( 'reference' = 'A2',
Shutdown( 'value' = "FAIL" )
),
# Return the value of "R1" to Maple session.
Return( 'reference' = 'R1',
ReturnItem( 'item' = 'FD1' )
)
):
|
>
|
result := Maplets[Display](maplet2);
|
>
|
if type( result, ['string'] ) then
read result[1];
end if;
|