Crestron
SIMPL+
Software
DIGITAL_INPUT readCompactFlashCard;
DIGITAL_INPUT writeCompactFlashCard;
INTEGER myInt;
LONG_INTEGER myLongInt;
STRING myStr[50];
PUSH writeCompactFlashCard
{
SIGNED_INTEGER nFileHandle;
INTEGER nNumBytes;
StartFileOperations()
nFileHandle = FileOpen( "\\CF0\\MyFile.txt",
_O_WRONLY | _O_CREAT );
if( nFileHandle >= 0 )
{
nNumBytes = WriteInteger( nFileHandle, myInt );
nNumBytes = WriteLongInteger( nFileHandle, myLongInt );
nNumBytes = WriteString( nFileHandle, myStr );
FileClose( nFileHandle );
}
EndFileOperations();
}
PUSH readCompactFlashCard
{
SIGNED_INTEGER nFileHandle;
INTEGER nNumBytes;
StartFileOperations()
nFileHandle = FileOpen( "\\CF0\\MyFile.txt", _O_CREAT );
if( nFileHandle >= 0 )
{
nNumBytes = ReadInteger( nFileHandle, myInt );
nNumBytes = ReadLongInteger( nFileHandle, myLongInt );
nNumBytes = ReadString( nFileHandle, myStr );
FileClose( nFileHandle );
}
EndFileOperations();
}
The functions,
ReadStructure
and
WriteStructure
, automate the reading and writing
of the individual fields within the structure. These functions do not return the
number of bytes read or written. Instead, both functions have an additional argument
that will contain the number of bytes read or written after the function call executes.
The following example demonstrates this:
DIGITAL_INPUT readCompactFlashCard;
DIGITAL_INPUT writeCompactFlashCard;
STRUCTURE myStruct
{
INTEGER myInt;
LONG_INTEGER myLongInt;
STRING myStr[50];
Programming Guide – DOC. 5789A
SIMPL+
•
41