Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
File name verfication
#8
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

[Image: DE-Umlaute-2023-03-16.jpg]
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: 15 Guest(s)