Page 1 of 2
Feel my pain . . .
Posted: Sat Apr 12, 2025 5:15 pm
by richmond62
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:
-
Re: Feel my pain . . .
Posted: Sat Apr 12, 2025 5:16 pm
by Klaus
And what is the painful part?
Re: Feel my pain . . .
Posted: Sat Apr 12, 2025 5:21 pm
by dunbarx
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:
Now I want to import ALL of them at once into a stack
the "all at once" part.
Craig
Re: Feel my pain . . .
Posted: Sat Apr 12, 2025 5:48 pm
by richmond62
Indeed: with about 300 text files I would end up with serious W*nk*r's cramp doing that manually.
Re: Feel my pain . . .
Posted: Sat Apr 12, 2025 6:01 pm
by Klaus
Ever heard of a repeat loop?

Re: Feel my pain . . .
Posted: Sat Apr 12, 2025 6:19 pm
by richmond62
"a repeat loop" ?
I seem to remember something about something called that in BBC BASIC in about 1977.

Re: Feel my pain . . .
Posted: Sat Apr 12, 2025 6:27 pm
by Klaus
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 . . .
Posted: Sat Apr 12, 2025 6:30 pm
by richmond62
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.
So do you have a serious question or are you just bored and want to waste a bit of our time, too?
Sarcasm on your part will only result in sarcasm on my part.

Re: Feel my pain . . .
Posted: Sat Apr 12, 2025 6:41 pm
by Klaus
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
Do you know how to access a custom property with SPACES in its name like "Richmond's Socks"?
And I was not sarcastic but actually a tad annoyed!

Re: Feel my pain . . .
Posted: Sat Apr 12, 2025 7:12 pm
by Klaus
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"
...
Re: Feel my pain . . .
Posted: Sat Apr 12, 2025 7:36 pm
by richmond62
I would have thought that was fairly obvious as otherwise 'Richmond's' and 'Socks' would be treated as 2 different words.
-
-
And I was not sarcastic but actually a tad annoyed!
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.
Re: Feel my pain . . .
Posted: Sat Apr 12, 2025 9:00 pm
by Klaus
Hi Richmond,
richmond62 wrote: ↑Sat Apr 12, 2025 7:36 pm
I would have thought that was fairly obvious as otherwise 'Richmond's' and 'Socks' would be treated as 2 different words.
good one!
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.
richmond62 wrote: ↑Sat Apr 12, 2025 7:36 pm
And I was not sarcastic but actually a tad annoyed!
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.
Why?
I had asked what the "painful" part was, since that was not obvious to me, and instead of answering directly you wrote:
Indeed: with about 300 text files I would end up with serious W*nk*r's cramp doing that manually.
I always like to help, even if I have little time, so that's what I call "wasting my time".
Best
Klaus
Re: Feel my pain . . .
Posted: Sat Apr 12, 2025 10:50 pm
by dunbarx
Richmond.
Klaus, and I, were both trying to understand what you needed.
You know this.
Don't let this go south.
Craig
Re: Feel my pain . . .
Posted: Mon Apr 14, 2025 10:00 am
by richmond62
HOWEVER . . .
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
Does NOT appear to put the contents of the files into the customProperties.

Re: Feel my pain . . .
Posted: Mon Apr 14, 2025 10:05 am
by Klaus
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
...