ITT Rule IDL Version 7.0 User Manual Page 243

  • Download
  • Add to my manuals
  • Print
  • Page
    / 430
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 242
Chapter 9: Creating a File Reader 243
iTool Developer’s Guide Creating a New File Reader
Example IsA Method
FUNCTION ExampleReader::IsA, strFilename
iDot = STRPOS(strFilename, '.', /REVERSE_SEARCH)
IF (iDot GT 0) THEN BEGIN
fileSuffix = STRUPCASE(STRMID(strFilename, iDot + 1))
IF (STRUPCASE(fileSuffix) EQ 'PPM') THEN RETURN, 1
ENDIF
self->IDLitIMessaging::ErrorMessage, $
["The specified file is not a PPM file."], $
SEVERITY = 0, TITLE="Wrong File Type"
RETURN, 0
END
Discussion
Note
Our example IsA method will simply check the filename for the presence of the
proper filename extension. A more sophisticated IsA method would actually inspect
the contents of the specified file.
The IsA method accepts a string that contains a file name. Using the supplied file
name, we first search backwards from the end of the name until we locate a dot
character. If the filename contains a dot, we extract the string that follows the dot and
convert it to upper case. If the extracted string is
'PPM', we return success; if the
extracted string is not
'PPM' or if there is no dot in the file name, we issue an error
using the IDLitIMessaging::ErrorMessage method and return failure.
Creating a GetData Method
The file reader GetData method does the work of the file reader, first creating an IDL
variable or variables to contain the data read from the file, then placing the data into
an iTool data object. If this process is successful, the GetData method must place the
created data object in the variable supplied as the method’s only argument and return
1 for success. If the process is not successful, the GetData method must return 0.
See “IDLitReader::GetData” (IDL Reference Guide) for additional details.
Example GetData Method
FUNCTION ExampleReader::GetData, oImageData
Page view 242
1 2 ... 238 239 240 241 242 243 244 245 246 247 248 ... 429 430

Comments to this Manuals

No comments