Validating user input for wave name

Hello,

I'm creating a function that allows the user to enter the name of an output wave using a simple input dialog, and I want to make sure the user entered a valid wave name before proceeding (note that I'm not concerned about liberal wave names, just truly invalid ones, e.g. ":::"). If the wave name entered is invalid, I want to present the user with the opportunity to re-enter a name without encountering an Igor runtime error message. My first thought was PossiblyQuoteName, but that passes some invalid names through (e.g. Print PossiblyQuoteName(":::") returns ':::'). My other ideas are to 1) search the input string for all invalid characters before using it, or 2) use the input string to make the wave in a try-catch block, similar to this:

    String strWaveName
    Do
        Prompt strWaveName, "Enter a wave name: "
        DoPrompt "Output Wave Name", strWaveName
       
        Try
            Make $strWaveName; AbortOnRTE
        Catch
            Variable err = GetRTError(1) //get and clear the error, since we either try again or quit
            If (err != 0)
                DoAlert/T="Invalid Wave Name" 1, "You entered an invalid wave name.  Would you like to try again?"
                If (V_flag != 1) // 1 is yes, 2 is no, 3 (not used here) is cancel
                    Return -1
                EndIf
                Continue
            EndIf
        EndTry
        Break
    While (1)


Are there any other/better suggestions out there?
Thanks!
Compare the users entered name with the output of CleanupName(usersName,1).

If they're the same, the name is valid.

Maybe also use exists(usersName) to check for a name conflict.

--Jim Prouty
Software Engineer, WaveMetrics, Inc.
Ah, thank you! I wasn't aware of this set of functions, but that's exactly what I needed.