Exporting multiple files#1

Pat Trendler ptrendler at bigpond.com
Fri Feb 4 23:22:01 CST 2005

Hello Dwayne,

The item delimiter is still set to TAB - set it back to "|" before the last 
"end repeat" line.


patrend at bigpond.com

----- Original Message ----- 
From: "Dwayne Rothe" <drothe at optusnet.com.au>
To: <use-revolution at lists.runrev.com>
Sent: Saturday, February 05, 2005 1:12 PM
Subject: Exporting multiple files#1

Hi All,
I need help writing multiple files from a list!
I have a text file with items delimited by "|"
Amongst those items I have have more data delimited by TAB

eg. Name|Age|Favorite Color|Hobby1    Hobby2     Hobby3|Pet1  Pet2     Pet3

the fourth & fifth items may contain hobbies & pets which could be of any 

What I am trying to do is write a seperate .txt file for each line, saved as 
the first
item as the file name.

e.g Say I have two lines as follows

John Doe|16|Blue|Fishing     Cars     Computers|Dog    Cat     Bird
Jane Doe|14|Pink|Shopping     Boys|Canary     Goldfish

I want to save file as below;

Text file 1:
Name: John Doe

Age: 16

Favorite Color: Blue

Hobbies:Fishing, Cars, Computers

Pets:Dog, Cat, Bird

saved as John Doe.txt

Text file 2:
Name: Jane Doe

Age: 14

Favorite Color: Pink

Hobbies:Shopping, Boys

Pets:Canary, Goldfish

saved as Jane Doe.txt
Here is the code I have so far that doesnt work properly!

put "John Doe" & cr & "Jane Doe" into tNames

put URL ("file:" & list.txt) into tList
set itemDel to "|"

repeat for each line x in tNames
  put x into tName

  get lineOffset(tName, tList)
put line it of tList into tListData
put item 1 of tListData into tName
put item 2 of tListData into tAge
put item 3 of tListData into tColor
put item 4 of tListData into tHobby
put item 5 of tListData into tPet

set itemDel to TAB
repeat for each line x in tHobby
  put x & comma & space after tHobbies
end repeat

repeat for each line x in tPet
  put x & comma & space after tPets
end repeat

Put "Name:" && tName & cr & cr into tDataFile
Put "Age:" && tAge & cr & cr after tDataFile
Put "Favorite Color:" && tColor & cr & cr after tDataFile
Put "Hobbies:" && tHobbies & cr & cr after tDataFile
Put "Pets:" && tPets & cr & cr after tDataFile

put tDataFile into URL ("file:" & tName & ".txt")
end repeat

This writes only one file!

Any help would be great!!!  Thanx D.Rothe

use-revolution mailing list
use-revolution at lists.runrev.com

More information about the use-livecode mailing list