Create Directory Using IDE

How can I check if a directory exists, and if not, then create the directory using the IDE?

I’m currently using the script from Topic 411, but I want an hourly file put into a daily folder. The file writing portion requires that the path already exist though.

I have modified the script below, to include the new pathname, but it throws the error:

uact-Export block descriptor writing failed (invalid filename)

Rem --- eWON start section: Cyclic Section
eWON_cyclic_section:
Rem --- eWON user (start)
Rem --- eWON user (end)
End
Rem --- eWON end section: Cyclic Section
Rem --- eWON start section: Init Section
eWON_init_section:
Rem --- eWON user (start)
CLS
    REM GENERATE REPORT EVERY HOUR
    ONDATE 1,"0 * * * *","GOTO GENERATE_REPORT"
    ONSTATUS "GOTO SCHEDULEDACTION_END"
    GOTO GENERATE_REPORT
    END
    GENERATE_REPORT:
    //Check if SD card is inserted or if there is enough space
    SETSYS INF,"LOAD"
    SDCardSize$ = GETSYS INF, "SDExtFree"
    SDCardSize_Int% = Val  SDCardSize$
    IF SDCardSize_Int% > 5000 THEN   // 5 MB remains
       GOSUB READ_LASTTMS
       CURR_DAY$ = @GetDay$()
       LAST_TIME$ = @GetCurrentTimeStamp$()
       EBD_STRING$ = "$dtHT$ftT$et" + LAST_TIME$ + "$st" + LASTTMS$
       FILENAME$ = "/usr/sdext/" + CURR_DAY$ + "/" + "DataReport_" + LAST_TIME$ + ".csv"
       WRITEEBD  EBD_STRING$, FILENAME$
       ActionID% = GETSYS Prg, "ACTIONID"
    ELSE 
      LOGEVENT "EUM Card full or not present", -1
    ENDIF
    END
    SCHEDULEDACTION_END:
      CurID% = GETSYS Prg,"EVTINFO" : REM Get ActionID
       REM : Check if it is the right schedule action to save last timestamp otherwize do nothing
       If ActionID% = CurID% THEN
         SETSYS Prg, "ACTIONID", CurID%
         CurID_Status% = GETSYS Prg,"ACTIONSTAT"
         REM Action successfully done --> Write last timestamp in file
         IF CurID_Status% = 0 THEN 
           LOGEVENT "FILE " + FILENAME$ + " SUCCESSFULLY EXPORTED", 100
           @WRITETMS(LAST_TIME$)
          ELSE
            LOGEVENT "FILE " + FILENAME$ + " NOT SUCCESSFULLY EXPORTED", 0
         ENDIF
       ENDIF
    END
    READ_LASTTMS:
    SETSYS PRG,"RESUMENEXT",1
     REM GET LAST TIMESTAMP
    OPEN "file:/usr/tms.dat" FOR BINARY INPUT AS 1
      LASTTMS$ = GET 1,15
    CLOSE 1
    Cur_Err% = GETSYS PRG,"LSTERR"
     
    IF Cur_Err% = 33 THEN //REM File does not exist
      LASTTMS$= "01011970_000000"
      SETSYS PRG,"LSTERR",0
    ENDIF
    SETSYS PRG,"RESUMENEXT",0
    CLS
    RETURN

    FUNCTION WriteTMS($LastTimeStamp$):
    OPEN "file:/usr/tms.dat" FOR BINARY OUTPUT AS 1
      PUT 1,$LastTimeStamp$
    CLOSE 1
    ENDFN
    
    FUNCTION GetCurrentTimeStamp$()
    REM TIME$ = dd/mm/yyyy hh:mm:ss
    $EWON_TIME$ = TIME$ 
    $GetCurrentTimeStamp$ = $EWON_TIME$(1 To 2) + $EWON_TIME$(4 To 5) + $EWON_TIME$(7 To 10) + "_" + $EWON_TIME$(12 To 13) + $EWON_TIME$(15 To 16) + $EWON_TIME$(18 To 19)
    ENDFN

    FUNCTION GetDay$()
    $EWON_TIME$ = TIME$
    $GetDay$ = $EWON_TIME$(1 To 2) + $EWON_TIME$(4 To 5) + $EWON_TIME$(7 To 10)
    ENDFN

    

Rem --- eWON user (end)
End
Rem --- eWON end section: Init Section

Hello,

I will review this code and work to find a solution for you. I will follow up with you tomorrow with an update.

In the meantime, please let me know if I can provide any updates that you recieve on your end.

Thanks,
Kevin

Thanks, Kevin. Any word?

While we’re on it. Is there a command to reinitialize the SD card, so that it doesn’t require a Power Cycle when one is inserted?

Hello Justin,

Unfortunately, you cannot create a directory strictly using BASIC. YOu can FTP to the device, and create a new directory that way.

As for the power cycle, inserting and removing the SD card must be performed when the power is off. As this prevents furthere issues down the road.

Ok. That may just do. Thank you.