numToChar(13)
David Bovill
david at openpartnership.net
Mon Mar 31 09:32:36 EDT 2008
Recently had the following problem processing lists from ftp directories -
fetching and displaying the directories in a list field was fine but when I
tried to use the list field to obtain an ftp url the script failed - the
debugging was a nightmare as the ftp url looked correct and manually
entering the url worked fine. The problem? numToChar(13) returned from the
ftp url. So I now use this script to fetch the directory listing:
function ftp_FolderContents ftpDirectory
> libURLSetFTPListCommand "NLST"
> get word 1 to -1 of url ftpDirectory
> replace numToChar(13) with empty in it
> return it
> end ftp_FolderContents
Rev uses numToChar(10) for line endings (showing its Unix origins), but if
written to a file on a Mac, using URL "file:", they're translated to
numToChar(13). if using URL "binfile:", no translation happens, so
numToChar(10) is preserved. I thought the act of putting text into a field
cleaned' up the line endings to standard Rev numToChar(10) = CR's - but
seems not? I am also not quite sure hwat to expect from different ftp
platforms - it seems NLST is CRLF seperated - but my server is Unix not a
PC?
I am wandering if there is any tutorial out there that goes into these
issues in any depth - they also come up when using certain command line
tools, and reading and writing data in CGIs.
More information about the use-livecode
mailing list