Page 1 of 1
Exporting text files . . . again
Posted: Wed Apr 23, 2025 5:23 pm
by richmond62
So: I have a field that contains my data (let's call it "myGUFF") and another field that contains the title I wish to call my exported text file (let's call it "myHEAD"), and I also want to date stamp the text file.
So, if field "myHEAD" contains "Stuffed Aubergines", on exporting from that field I SHOULD end up with a file called:
Stuffed Aubergines 4/23/25.txt
BUT I cannot seem to manage that:
Code: Select all
on mouseUp
put the fld "myGUFF" into GUFF
put GUFF into url("file:" & fld "myHEAD" && the date & ".txt")
get the longFilePath of it
set the itemDelimiter to slash
set the defaultFolder to item 1 to -2 of the longFilePath of it
end mouseUp
OBVIOUSLY I am going wrong somewhere . . .
Re: Exporting text files . . . again
Posted: Wed Apr 23, 2025 6:11 pm
by Klaus
Hi richmond,
Mac or Windows?
Leave out the THE!
Code: Select all
put GUFF into url("file:" & fld "myHEAD" && the date & ".txt")
1. Unless you have set the defaultfolder to something different than "default",
this will be INSIDE of the Mac application package of LC.
We may not have write permission there.
2. "the date" will contain SLASHES, and these are "forbidden" characters for filenames on a Mac.
What is IT right here?
Probably not what you might exspect or even empty.
Code: Select all
set the defaultFolder to item 1 to -2 of the longFilePath of it
See above...
Best
Klaus
Re: Exporting text files . . . again
Posted: Wed Apr 23, 2025 6:29 pm
by dunbarx
Richmond.
Like Klaus, I have little context. But this:
set the defaultFolder to item 1 to -2 of the longFilePath of it
Looks like you are trying to access a custom property of the variable "it". Variables do not have custom properties only objects like controls, cards and stacks.
Craig
Re: Exporting text files . . . again
Posted: Wed Apr 23, 2025 6:31 pm
by dunbarx
Richmond.
Does "it" contain an object reference? If so, you may be able to work it that way, but will likely need to use a "do" construction, to force another level of evaluation. Otherwise LC will not understand your intent. Let me know if you need an example of that sort of shenanigans.
Craig
Re: Exporting text files . . . again
Posted: Wed Apr 23, 2025 6:48 pm
by richmond62
"the date" will contain SLASHES, and these are "forbidden" characters for filenames on a Mac.
Ouch.
This makes me feel a bit mental:
-
Re: Exporting text files . . . again
Posted: Wed Apr 23, 2025 7:07 pm
by Klaus
Save some typing:
Code: Select all
...
put the date into XDATE
replace "/" with "$" in XDATE
...
And what about IT?
Re: Exporting text files . . . again
Posted: Wed Apr 23, 2025 7:17 pm
by richmond62
Code: Select all
on mouseup
set itemDel to "/"
set the defaultfolder to item 1 to -2 of (the effective fileName of this stack)
put the date into XDATE
set the itemDelimiter to "/"
put item 1 of XDATE into X1
put item 2 of XDATE into X2
put item 3 of XDATE into X3
put X1 & "$" & X2 & "$" & X3 into XXX
put fld "myGUFF" into GUFF
put GUFF into url("file:" & fld "myHEAD" && XXX & ".txt")
end mouseup
works a charm!
Thank you very much for your help.
Mind you, I wonder if there might not be something more sensible than a dollar sign that MacOS will not object to.
OK, OK: changed "$" to "-".

Re: Exporting text files . . . again
Posted: Wed Apr 23, 2025 7:23 pm
by Klaus
No need to set "the defaultfolder"!
The folder where "this stack" resides -> specialfolderpath("resources")
Re: Exporting text files . . . again
Posted: Thu Apr 24, 2025 9:47 am
by richmond62
Save some typing:
Thank you, I will.
