03-16-2023, 05:47 PM
(This post was last modified: 03-16-2023, 05:49 PM by Kernelpanic.)
Quote:@RhoSigma - This is my verification function, feel free to use it and/or adapt to your needs
QB64 cannot read German umlauts or special characters in file names or folders. The program doesn't recognize them either. That is, for example the Übungen (Exercises) folder will not found. -- 132 = ä
Code: (Select All)
'Ueberpruefung eines anzugebenen Dateinamens, RhoSigma - 16. Maerz 2023
Option _Explicit
Declare Function ValidFilename(file As String) As Integer
Dim As String file
Locate 2, 3
Line Input "Filename: "; file
If ValidFilename(file) Then
Locate CsrLin + 1, 3
Print "Filename is ok."
Else
Locate CsrLin + 1, 3
Beep: Print "Filename contains invalid chars."
End If
End 'Main program
Function ValidFilename (file As String)
Dim As Integer i
'--- so far, assume invalid ---
ValidFilename = 0
'--- now check all chars ---
For i = 1 To Len(file)
Select Case Asc(file, i)
Case 34, 38, 42, 44, 47, 60, 62, 63, 64, 124, 132
'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
This condition does not work, the program is aborted even if the name is correct. I put that after the FOR loop.
Code: (Select All)
If Asc(file) = 132 Or 142 Or 148 Or 151 Or 153 Or 154 Then
Locate CsrLin + 2, 3
Beep: Print "QB64 cannot read German umlauts or special characters in file names."
Sleep 3
System
End If