1

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.

sappjw
  • 373
  • 1
  • 14
Zach
  • 113
  • 1
  • 9

2 Answers2

2

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
mgalloy
  • 2,356
  • 1
  • 12
  • 10
1

SYSTIME() produces a string with characters that are illegal in a Windows path (namely, colon).

c:\>mkdir "Mon Jan 18 20:14:07 2038"
The filename, directory name, or volume label syntax is incorrect.

c:\>mkdir "Mon Jan 18 20-14-07 2038"
(no error)

SYSTIME(/SECONDS) produces a string with numerals and a dot, which is legal. https://www.harrisgeospatial.com/docs/systime.html

asynchronos
  • 583
  • 2
  • 14