Script_Save

 

The "Script_Save()" function is called when the user has selected the "Script save as..." from the "File" menu.

 

The function receive a file pointer as argument, it should then write a series of script commands to that file.  These commands should be recognized by your parser and they should restore your module to the same configuration as it had when the save function was called.  We also suggest that you write a short description of each command as comments (comment lines start with a semi-colon ";").

 

 

Syntax

 

extern "C" __declspec(dllexport) int          Script_Save(

          FILE *fd

)

 

 

Parameters

 

fd

File pointer f\to the target file.

 

 

Return value

 

The function returns 0 if an error occurred, 1 otherwise.

 

 

Remarks

 

This function is optional.

 

 

Requirements

 

Header:

          sliceO_include.hpp

 

 

Library:

          sliceO_Structures.lib

 

 

Example

 

This is the "Script_Save" function for the "Morpho.dll" module.

 

...

 

// ----------------------------------------------------------------------------

//

//          Function:          Script_Save

//

//          Parameters:          fd (FILE *)          File to write to

//          Returns:          (int)                    0 if errors

//

//          Write the current state of this module as a script

//

// ----------------------------------------------------------------------------

extern "C" __declspec(dllexport) int          Script_Save( FILE *fd )

{

          // --- save the current mode ---

          fprintf( fd, "; --- Define the overlay line thickness ---\n" ) ;

          fprintf( fd, "; morpho: line value (value=0|1|2) (default=1)\n" ) ;

          fprintf( fd, "morpho: line %d\n", Morpho_Line_Mode )  ;

          fprintf( fd, "\n" ) ;

 

          fprintf( fd, "; --- Define the overlay line color ---\n" ) ;

          fprintf( fd, "; morpho: color r g b\n" ) ;

          Color col ;

          col.color = Morpho_Line_Color ;

          fprintf( fd, "morpho: color %d %d %d\n", col.col.R, col.col.G, col.col.B )  ;

          fprintf( fd, "\n" ) ;

 

          fprintf( fd, "; --- Define the merge parameters ---\n" ) ;

          fprintf( fd, "; morpho: param id surf dist (id=0|1...%d)\n", MORPHO_MERGE_MAX+1 ) ;

          for ( int i=0; i < MORPHO_MERGE_MAX; i++ )

              fprintf( fd, "morpho: param %d %.0f %.2f\n", i+1, Morpho_Param_Surf[i], Morpho_Param_Dist[i] ) ;

          fprintf( fd, "\n" ) ;

 

          return( 1 ) ;

}

 

...

 

See also

 

Script_Register

Script_Parse