Comma in file names thwarting URLdecode(the files)

Jim Ault JimAultWins at yahoo.com
Wed Oct 11 11:50:42 EDT 2006


On 10/11/06 5:45 AM, "Mark Powell" <mark_powell at symantec.com> wrote:

> Sure this has to be a simple question but I can't find anything about it
> in docs or forum.
> 
> -The long files function returns a comma-delimited list of attributes.
> -With URLdecode, a file name with comma skews item delimiting.
> -Without URLdecode, a file name with percentage sign skews delimiting.
> -Checking 'number of items' seems to be OS-dependent (last item empty on
> Windows?!)
> 
> What am I missing?  How can I reliably derive a Windows-OS file name
> from 'the files'?
> 
Part 1 -- last item in xTalk

Caution about the 'last item' being empty.
xTalk counts items this way:

answer the number of items in "red,green,blue" --3
answer the number of items in "red,green,blue,,brown" --5
answer the number of items in "red,green,blue," --3

answer the number of items in ("red,green,blue,,"&null) --4

thus if I don't control the data source, I always use the form

repeat for each item ITM in (itemString &null)

end repeat

The type and creator is always used on Mac OS 9 and earlier, but is optional
for backward compatibility on Mac OSX, and never used in Windows.  Any cross
platform app has to accommodate this, so last item is an issue.
----------------------------------
Part 2
--tab delimited with commas in the file name
on mouseDoubleUp
  put the detailed files into detailedList
  put urlencode(the files) into tempEncoded
  replace "%0D%0A" with cr in tempEncoded
  filter tempEncoded without empty
  get tempEncoded  -- < for some reason this is necessary
  repeat for each line LNN in it
    replace LNN with LNN & tab in detailedList
  end repeat
  put urlDecode(detailedList) into goodList
  set the itemdel to tab
  repeat for each line LNN2 in goodList
    get item 2 of LNN2
    replace comma with tab in it
    put item 1 of LNN2 &tab & it &cr after newList
  end repeat
  delete char -1 of newList
  put newList
  --tab delimited with commas in the file name
end mouseDoubleUp

Hope this helps

Jim Ault
Las Vegas






More information about the use-livecode mailing list