Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!purdue!gatech!udel!rochester!pt.cs.cmu.edu!andrew.cmu.edu!ba0k+ From: ba0k+@andrew.cmu.edu (Brian Patrick Arnold) Newsgroups: comp.sys.mac.hypercard Subject: Re: How do I get the pathname? Message-ID: Date: 22 Aug 89 15:25:51 GMT References: <716@pmafire.UUCP> Organization: Mechanical Engineering, Carnegie Mellon, Pittsburgh, PA Lines: 65 This sample HyperTalk code may be of some use - I use these all the time. Make sure you really need to use these and use them smartly because Mac users should not to have to deal with file paths. If you want the path without the ending colon, simply "delete last char of " after calling "put PathOnly() into " where and are your containers. PathFromStackName is the handler you need, I think. ------------------------------------------------- -- Handlers for extracting path and file names -- ------------------------------------------------- FUNCTION PathOnly aFileName -- return the path only of a given valid Mac OS file path name -- algorithm: if contains a path, strip end characters to last colon IF HasPath(aFileName) THEN REPEAT until IsPath(aFileName) delete last char of aFileName END REPEAT ELSE put empty into aFileName RETURN aFileName END PathOnly FUNCTION NameOnly aFileName -- return the name only of a given valid Mac OS file path name -- algorithm: if contains a path, push end chars into container -- and delete end chars to last colon - container should then be name only IF HasPath(aFileName) THEN put empty into theName REPEAT until IsPath(aFileName) put last char of aFileName before theName delete last char of aFileName END REPEAT ELSE put aFileName into theName RETURN theName END NameOnly FUNCTION HasPath aFileName RETURN (offset(":",aFileName) <> 0) END HasPath FUNCTION IsPath aFileName RETURN (last char of aFileName = ":") END IsPath FUNCTION PathFromStackName aStackName -- given a long name of a stack (if empty then use current stack name), -- extract the path. Cake. IF aStackName is empty THEN put the long name of this stack into aStackName delete first word of aStackName -- remove word "Stack" delete first char of aStackName -- remove open quote delete last char of aStackName -- remove end quote RETURN PathOnly(aStackName) END PathFromStackName ------------------------------------------------- - Brian