Feel my pain . . .
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
- Livecode Opensource Backer
- Posts: 10094
- Joined: Fri Feb 19, 2010 10:17 am
Feel my pain . . .
I have a folder containing a large number of text files . . .
They have names like this "Richmond's socks.txt"
Now I want to import ALL of them at once into a stack and bung them into the custom properties of an object: and I want each custom property to be named after the document, a bit like this:
-
They have names like this "Richmond's socks.txt"
Now I want to import ALL of them at once into a stack and bung them into the custom properties of an object: and I want each custom property to be named after the document, a bit like this:
-
Re: Feel my pain . . .
And what is the painful part?
Re: Feel my pain . . .
Richmond.
I am with Klaus. What, apart from reading each text file and a few lines of LC in a handler is the problem?
Or did it have something to do with:
Craig
I am with Klaus. What, apart from reading each text file and a few lines of LC in a handler is the problem?
Or did it have something to do with:
the "all at once" part.Now I want to import ALL of them at once into a stack
Craig
-
- Livecode Opensource Backer
- Posts: 10094
- Joined: Fri Feb 19, 2010 10:17 am
Re: Feel my pain . . .
Indeed: with about 300 text files I would end up with serious W*nk*r's cramp doing that manually.
Re: Feel my pain . . .
Ever heard of a repeat loop? 

-
- Livecode Opensource Backer
- Posts: 10094
- Joined: Fri Feb 19, 2010 10:17 am
Re: Feel my pain . . .
"a repeat loop" ?
I seem to remember something about something called that in BBC BASIC in about 1977.
I seem to remember something about something called that in BBC BASIC in about 1977.

Re: Feel my pain . . .
So do you have a serious question or are you just bored and want to waste a bit of our time, too?
-
- Livecode Opensource Backer
- Posts: 10094
- Joined: Fri Feb 19, 2010 10:17 am
Re: Feel my pain . . .
The serious question boils down to 2 things:
1. How to use a repeat loop to import multiple text files.
2. Set those up as custom properties of an object where each custom property is given the name of the originating text document.

1. How to use a repeat loop to import multiple text files.
2. Set those up as custom properties of an object where each custom property is given the name of the originating text document.
Sarcasm on your part will only result in sarcasm on my part.So do you have a serious question or are you just bored and want to waste a bit of our time, too?

Re: Feel my pain . . .
Code: Select all
on mouseUp
answer folder "Where are the bloody files?"
put it into tFolder
put files(tFolder) into tFiles
## remove DOT files
filter tFiles without ".*"
repeat for each line tLine in tFiles
set the tLine of this stack to url("file:" & tFolder & "/" & tFile)
end repeat
end mouseUp
And I was not sarcastic but actually a tad annoyed!

Re: Feel my pain . . .
Before you ask, you will need to use a variable for this:
Code: Select all
...
put "Richmond's Socks" into tCPName
put the tCPName of this stack into fld "display"
...
-
- Livecode Opensource Backer
- Posts: 10094
- Joined: Fri Feb 19, 2010 10:17 am
Re: Feel my pain . . .
I would have thought that was fairly obvious as otherwise 'Richmond's' and 'Socks' would be treated as 2 different words.
- -
- -
I don't see why: my 'problem' had got nothing to do with a repeat loop, BUT how to set the custom property's name to the name of a text document, and how, then to put the contents of that document into the custom property.And I was not sarcastic but actually a tad annoyed!
Re: Feel my pain . . .
Hi Richmond,
You have to admit that some "obvious" (more or less basic) LC solutions/scripting are/is not really obvious to you despite your +20 years of XTalk experience.
I had asked what the "painful" part was, since that was not obvious to me, and instead of answering directly you wrote:
Best
Klaus
good one!richmond62 wrote: ↑Sat Apr 12, 2025 7:36 pmI would have thought that was fairly obvious as otherwise 'Richmond's' and 'Socks' would be treated as 2 different words.

You have to admit that some "obvious" (more or less basic) LC solutions/scripting are/is not really obvious to you despite your +20 years of XTalk experience.
Why?richmond62 wrote: ↑Sat Apr 12, 2025 7:36 pmI don't see why: my 'problem' had got nothing to do with a repeat loop, BUT how to set the custom property's name to the name of a text document, and how, then to put the contents of that document into the custom property.And I was not sarcastic but actually a tad annoyed!
I had asked what the "painful" part was, since that was not obvious to me, and instead of answering directly you wrote:
I always like to help, even if I have little time, so that's what I call "wasting my time".Indeed: with about 300 text files I would end up with serious W*nk*r's cramp doing that manually.
Best
Klaus
Re: Feel my pain . . .
Richmond.
Klaus, and I, were both trying to understand what you needed.
You know this.
Don't let this go south.
Craig
Klaus, and I, were both trying to understand what you needed.
You know this.
Don't let this go south.
Craig
-
- Livecode Opensource Backer
- Posts: 10094
- Joined: Fri Feb 19, 2010 10:17 am
Re: Feel my pain . . .
HOWEVER . . .
Does NOT appear to put the contents of the files into the customProperties. 
Code: Select all
on mouseUp
answer folder "Where are the bloody files?"
put it into tFolder
put files(tFolder) into tFiles
## remove DOT files
filter tFiles without ".*"
repeat for each line tLine in tFiles
set the tLine of this stack to url("file:" & tFolder & "/" & tFile)
end repeat
end mouseUp

Re: Feel my pain . . .
Oops, sorry, made in a hurry:
Code: Select all
...
repeat for each line tLine in tFiles
### set the tLine of this stack to url("file:" & tFolder & "/" & tFile)
set the tLine of this stack to url("file:" & tFolder & "/" & tLine)
end repeat
...