[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

LOGO-L> File path manipulation in MSWLogo



I have found these two routines to be useful when writing code that
accesses files from within MSWLogo.

The first returns the file name part of a fullpath specification.
show fileNameFrom "C:\\home\\frank\\logo\\file.lgo
-> file.lgo


to fileNameFrom :fullPath 
;; Answer the filename part of the :fullPath
;; Answer nil if :fullPath is empty
;; Will answer nil if :fullPath ends in \ 

	if emptyp :fullPath [op " ]
	
	test (memberp "\\ :fullPath)
	iffalse [op :fullPath]
	op fileNameFrom bf member "\\ :fullPath
end


The second returns the path part of the file name.
show filePathFrom "C:\\home\\frank\\logo\\file.lgo
-> C:\\home\\frank\\logo

to filePathFrom :fullPath
;; Answer the path part of the :fullPath
;; Answer nil if :fullPath is empty
;; Answer nil if no \ in :fullPath

	if or (emptyp :fullPath) (not memberp "\\ :fullPath) 
		[op " ]

	op (bl reverse member "\\ reverse :fullPath )
end


-- 
Frank Caggiano
caggiano@atlantic.net
http://www.atlantic.net/~caggiano
---------------------------------------------------------------
Please post messages to the Logo forum to logo-l@gsn.org.  Mail
questions about the list administration to logofdn@gsn.org.  To
unsubscribe send    unsubscribe logo-l    to majordomo@gsn.org.



Global SchoolNet Foundation - Linking Kids Around the World!
Copyright GSN - All Rights Reserved - Comments & Questions
Visit GSN's Global Schoolhouse for more exciting learning resources!
Search our Site - Home