Notifications
Clear all

[Closed] the \t problem

I think i saw a solution to this before, but don’t really know how to look for it here in the forum in terms of subject matter.

Does anyone have a solution to the and other various string entries

example

C:\Documents and Settings\DanN\Desktop est.dat

will be read as desktop est.dat

i know you can add double \ to solve this, but does someone have a function or a line of code that does this for you?

Thanks

5 Replies

Another solution is to use regular / slashes which are equivalent to \ in MAXScript.
Also NOTE that the problem only occurs when EXECUTING the script, either via execute(), File>Evaluate All (Ctrl+E), readValue() or fileIn(). Otherwise, single backslashes are not a problem, thus entering c: emp est\ in an edittext field does NOT turn into tabs, same with reading strings from an ASCII file using readLine() or via getIniSetting (as long as you don’t execute the value).

I forgot about using /…thanks

I have had issues when using getopenfilename, and then transfering that string to getMaxFileObjects…actually with most of the “get” commands, i am having this issue…maybe i have been doing it wrong, but the only solution i came up with was to call one inside the other

so for exampe…

getMAXFileObjectNames(New_file = getopenFileName)

but this isn’t always convient

so to swap out back slashes would have i have to call that finds them in a string and then switches them with the other type, or am not using these calls effectively, or am i just wrong in general :).

Thanks

Storing path values in variables should NOT cause any troubles with backslashes.
You should be able to get the file name, pass it to any other methods, put it in UI controls, get it back from there, read is as a string from text files and so on.

There must be something more that you are doing to the path name related to evaluating the string as a MAXScript value as opposed to just using it as a string value.
If you print the string to the Listener and then try to use it or if you type it in a script, you HAVE to either double the backslashes or turn them to forward slashes.

1 Reply
(@ericdlegare)
Joined: 11 months ago

Posts: 0

Bobo, youre tha best and your DVD “The Matrix Explained” is Awesome :deal:

fn returnForwardSlashPath thePath =
(
local newPath = thePath

if (classOf thePath) == String then (
    for i = 1 to thePath.count do (
        if (substring thePath i 1) == "\\" then 
            newPath[i] = "/"
    )
)
return newPath

)