relative filePath to XML file

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
AlexAdams
Posts: 38
Joined: Sat Jan 17, 2009 8:49 pm
Contact:

relative filePath to XML file

Post by AlexAdams » Thu Aug 13, 2009 7:03 pm

I don't really know where to post this subject. I hope here is okay.

I am using this command:
put revCreateXMLTreeFromFile(lvFileName, false, true, false) into lvDocID

Rather than using the answer file command that is used in the XMLDemo stack I want to use a programmed relative path to a known file. How do I phrase that?

I have tried several things, none of which are working.
I've tried putting the file in the same directory as the main stack:
Contacts.xml
I've tried relative phrasing of several sorts:
./HVResources/HawkXMLFiles/Contacts.xml
//HVResources/HawkXMLFiles/Contacts.xml
/HVResources/HawkXMLFiles/Contacts.xml

HVResources is a directory located in the same directory as the main stack.

My greeness must be showing.

I look forward to enlightenment.

Thanks,
Alex Adams
(a)2 Technology Parnters
alex@a2technology.com
www.a2technology.com
www.promisstudio.com
831-726-8013

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4174
Joined: Sun Jan 07, 2007 9:12 pm

Post by bn » Thu Aug 13, 2009 7:55 pm

Alex,
try this script:

Code: Select all

on mouseUp
    -- assuming that "HVResources" etc is a directory in the directory where your main stack lives
    -- and that this script is called from your main stack
    put the filename of this stack into tPathToMainStack
    set the itemdelimiter to "/"
    put item 1 to -2 of tPathToMainStack into tMainStackDirectory
    put "/" after tMainStackDirectory
    put tMainStackDirectory & "HVResources/HawkXMLFiles/Contacts.xml" into tFullpathToXMLFile
    put tFullpathToXMLFile
end mouseUp
it should give you the path to the xml file in the message box
regards
Bernd

AlexAdams
Posts: 38
Joined: Sat Jan 17, 2009 8:49 pm
Contact:

That works very well.

Post by AlexAdams » Thu Aug 13, 2009 9:57 pm

Bernd,

That works well. I needed to name the main stack to get the path, but that's fine with me.

Thanks again,
Alex Adams
(a)2 Technology Parnters
alex@a2technology.com
www.a2technology.com
www.promisstudio.com
831-726-8013

Post Reply