File name verfication
#7
Code: (Select All)
ISVALID` = TRUE
    FOR LoopCounter = 1 TO LEN(FileName)
        FOR LoopCounter1 = 1 TO NumberOfVaildCharacters
            IF FileNameParts(LoopCounter) <> Legal(LoopCounter1) THEN ISVALID` = FALSE: EXIT FUNCTION
        NEXT LoopCounter1
    NEXT LoopCounter

Set the function return value and leave straight away, no need to check it and no need to "set the trap" at each character in the "FileName" to check. This was coded also for more consistency with the function body code that appears before this demonstration.

Also I suggest using a "FOR... NEXT" loop to initialize most of the Legal() array. Because you will have to include uppercase and lowercase letters to check on Linux and MacOS. Filenames on Unix and Unix-like operating systems are case sensitive.
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: 3 Guest(s)