Menu

#122 abort on an invalid OS file path

open
None
5
2008-01-24
2008-01-10
Tracey
No

Maverick absolutely [needs to/must] allow the basic programmer to gracefully handle errors.

BTW Thanks Tom for you example!!!

I deliberatively entered an invalid OS path to test how I can code MaVerick Basic to handle invalid OS file path errors.

D:\mvDemo>RUN TEST
java.io.FileNotFoundException: C:\TEMP2\TEST.TXT (The system cannot find the path specified)

DOS.FILE='C:/TEMP2/TEST.TXT'
OPENSEQ DOS.FILE TO FV.DOS THEN
O.ITEM=''
EOF=''
LOOP
LINE=''
READSEQ LINE FROM FV.DOS ELSE EOF=1
UNTIL EOF = 1 DO
CRT LINE
CONVERT CHAR(9) TO @VM IN LINE
O.ITEM<-1> = LINE
REPEAT
CRT O.ITEM
NOA = DCOUNT(O.ITEM, @AM)
FOR A = 1 TO NOA
NOV = DCOUNT(O.ITEM<A>, @VM)
FOR V = 1 TO NOV
CRT O.ITEM<A,V>
NEXT V
CRT
NEXT A
END ELSE
CRT 'CANT OPEN OS FILE TEST.TXT'
END
CLOSESEQ FV.DOS
STOP
END

Discussion

  • Robert Colquhoun

    • assigned_to: nobody --> rjc
     
  • Robert Colquhoun

    Logged In: YES
    user_id=11445
    Originator: NO

    Can you try and add an ON ERROR clause to the above i think that will catch an error.

    There are a lot of statements where i could not work out if i should take the ON ERROR or the ELSE clause. If the statement fails with an exception and the program terminates it should take the ON ERROR clause if one is added.

    Also looking at OPENSEQ statement STATUS is not currently set, will add this.

    Finally in the java runtime which maverick works on top of file paths of style 'C:/TEMP2/TEST.TXT' should work on both windows and unix. The jvm allows both '/' and '\' as directory separators. Might need to escape out '\' not 100%.

     

Log in to post a comment.

MongoDB Logo MongoDB