03-15-2023, 07:39 AM
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
GuiTools, Blankers & other Projects:
https://qb64phoenix.com/forum/forumdisplay.php?fid=32
Libraries & useful Functions:
https://qb64phoenix.com/forum/forumdisplay.php?fid=23
https://qb64phoenix.com/forum/forumdisplay.php?fid=32
Libraries & useful Functions:
https://qb64phoenix.com/forum/forumdisplay.php?fid=23