Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
File name verfication
#3
This is my verification function, feel free to use it and/or adapt to your needs:
Code: (Select All)
LINE INPUT "Filename: "; f$

IF ValidFilename%(f$) THEN
    PRINT "Filename is ok."
ELSE
    PRINT "Filename contains invalid chars."
END IF
END

FUNCTION ValidFilename% (file$)
'--- so far, assume invalid ---
ValidFilename% = 0
'--- now check all chars ---
FOR i% = 1 TO LEN(file$)
    SELECT CASE ASC(file$, i%)
        CASE 34, 42, 47, 60, 62, 63, 124
            'invalid chars, list above is for Windows,
            'may need adjustment for other OS
            EXIT FUNCTION
    END SELECT
NEXT i%
'--- check succesfully passed ---
ValidFilename% = -1
END FUNCTION
Reply


Messages In This Thread
File name verfication - by NasaCow - 03-15-2023, 04:44 AM
RE: File name verfication - by SMcNeill - 03-15-2023, 05:37 AM
RE: File name verfication - by RhoSigma - 03-15-2023, 07:39 AM
RE: File name verfication - by mnrvovrfc - 03-15-2023, 12:15 PM
RE: File name verfication - by NasaCow - 03-16-2023, 03:57 AM
RE: File name verfication - by SpriggsySpriggs - 03-16-2023, 05:08 AM
RE: File name verfication - by mnrvovrfc - 03-16-2023, 03:37 PM
RE: File name verfication - by NasaCow - 03-17-2023, 02:29 AM
RE: File name verfication - by SMcNeill - 03-17-2023, 06:11 AM
RE: File name verfication - by Kernelpanic - 03-16-2023, 05:47 PM
RE: File name verfication - by mnrvovrfc - 03-16-2023, 06:17 PM
RE: File name verfication - by SpriggsySpriggs - 03-16-2023, 09:15 PM
RE: File name verfication - by SpriggsySpriggs - 03-17-2023, 04:58 AM
RE: File name verfication - by NasaCow - 03-18-2023, 02:56 AM
RE: File name verfication - by SpriggsySpriggs - 03-18-2023, 11:55 PM



Users browsing this thread: 10 Guest(s)