Understanding Split

Hello All,

I expect the following to give me the same results but it does not, by referring to the string as a variable I don't get the same results as splitting the string directly:
put "/tuser1/Navigate_Here/" into varPathInsideRepository
split varPathInsideRepository by "/"
put it

split "/tuser1/Navigate_Here/"  by "/"
put it

OUTPUT:
IT
(,tuser1,Navigate_Here)

Can someone please explain the difference? If possible, please suggest how I can split up the individual elements of the variable

Thanks,
Elliot

Comments

  • SenseTalkDougSenseTalkDoug ForumAdmin admin
    You already did split the variable. The difference between the two commands is this: When you split a variable, the resulting value is put back into that variable. When you split a value that isn't a variable, there's no place for the result to go, so it gets put into the IT variable.

    If you change your script to this, you'll see what you were expecting:
    put "/tuser1/Navigate_Here/" into varPathInsideRepository 
    split varPathInsideRepository by "/" 
    put varPathInsideRepository -- this variable now contains a list 
    
    split "/tuser1/Navigate_Here/"  by "/" 
    put it
    

    By the way, the latest version of eggPlant (10.2 and above) includes several new functions for working with file paths, including pathList() to get a list of path components from a string, and filePath() which can turn a list back into a path string. SenseTalk can also accept a path list directly now as well as a path string in any place where a file path is needed.
  • This makes sense, I appreciate the explanation.
Sign In or Register to comment.