file name

Jim Ault JimAultWins at yahoo.com
Mon Jan 30 21:50:52 EST 2006


There is more than one way of doing it.
Decide if the actual number is important, or just needs to be different so
that you have different files

Easiest method 
prefix the file name with the seconds, thus all files will be unique and
sort in the order they were written

  put "/Users/hudson/Documents/MCA.SCORES/" into pathh
  if there is not a folder pathh then create folder pathh
  put the seconds & "testing1" into FN
  put pathh & FN into pathhFN
  put studentanswers into URL ("file:"&pathhFN)

---------
Method 2
adding a suffix such as ".txt" and want to keep adding to the ending number
until it won't overwrite an existing file

 put ("/Users/hudson/Documents/MCA.SCORES/") into pathh
  if there is not a folder pathh then create folder pathh
  
  put false into goodName
  put 1 into countrr
  
  repeat until goodName is true
    put ("testing" &  countrr & ".txt") into FN
    put (pathh & FN) into pathhFN
    if there is not a file pathhFN then
      put studentanswers into URL ("file:"&pathhFN)
      exit repeat --don't need to bother with goodname
      --we are bailing out now
    end if
    --name was taken, so try again
    add 1 to countrr
  end repeat

Method 3 and beyond could be that you add the short date to the filename,
some data from the test, etc.
adding the date could be done by

 get the short date
  set the itemdel to "/"
  put char -2 to - 1 of ("00" & item 3 of it) into yy
  put char -2 to - 1 of ("00" & item 2 of it) into dd
  put char -2 to - 1 of ("00" & item 1 of it) into mm
  put (yy & mm & dd) into dateStr
  put ("testing" & dateStr & ".txt") into FN
  put (pathh & FN) into pathhFN


Hope this helps

Jim Ault
Las Vegas


On 1/30/06 6:12 PM, "Jeff Hudson" <hudsonj at stillwater.k12.mn.us> wrote:

> How can I change the name when I am saving an ascii text  file.
> 
> I want a separate text file saved as each student finishes their work.
> 
> PUT studentanswers into URL "file:/Users/hudson/Documents/MCA.SCORES/testing1"
> 
> This saves the file I want.   I can't find a way to change testing1 to adjust
> for the variable       first & last
> 
> 
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution





More information about the use-livecode mailing list