Search code examples
gisrasteridl-programming-language

SYSTIME causes IDL program error


I have been assigned an IDL coding assignment for a class. This language is new to me but I have been programming awhile so this error perplexes me. I cannot use the systime() function to add the date and time to an outputted filename.

Not shown in code: created mosaicRaster containing a mosaicked raster image of 4 geotiffs.

outputRaster = filepath + 'outputFile' + SYSTIME() + '.tif'
mosaicRaster.Export, outputRaster, 'TIFF'

The program completes with no errors.. just does not output my file. If I change it to:

outputRaster = filepath + 'outputFile.tif'

the program runs fine.

I have tried to put STRING() around SYSTIME(), and also around outputRaster.

The funny/weird/miserable thing is that SYSTIME(/SECONDS) runs fine. It is only when SYSTIME does not have a parameter it gives a problem.

Additionally, these statements work:

time = SYSTIME(/SECONDS)

PRINT, SYSTIME()

This does not work (Program exits without outputting my raster):

time = SYSTIME()

Again, there are no errors. I have scoured help documentation and nothing is to be found. My professor has looked at my code and says his looks exactly the same (he runs a mac, I am using a windows VM in the lab). The file is just not outputted. You may ask why do I need to append the filename with the current date... its a requirement on this final project.

Any help is greatly appreciated.


Solution

  • Colon's are not valid on Windows and spaces are usually a pain to deal with. Easiest fix is to use IDL_VALIDNAME to fix the date up:

    IDL> print, idl_validname(systime(), /convert_all)
    Thu_Feb__8_11_01_05_2018