Page 1 of 1

Setting the defaultfolder on the fly

Posted: Sat Jan 20, 2024 7:50 pm
by oldummy
I'm having a problem trying to change the defaultfolder at will. I am certain my problem is glaringly obvious to most of you, but obviously not to me. I'm wondering it it is the fact that I am using a cp for part of the filepath.
What I am doing "seems" reasonable but I suppose it is not.
My intent is to set the defaultfolder to the folder where All of my music resides on openstack, list the folders into a field, then upon clicking on one of those lines of different music genres listed, setting the defaultfolder to that genre, and then putting the files of that genre into a field.


--in the stack script: --this all works

o

Code: Select all

n openstack
   set the defaultfolder to "C:\Users\Gandalf\Desktop\Stick Music/"  --where all music resides
set the callmusic of this stack to the defaultfolder
   set the backdrop to none -- I really wish I didn't have to keep dealing with that
   put the folders into fld "allofit" -- the folders being different genres of music
   delete line 1 of fld "allofit" --gets rid of the pesky "..." that gets put in line 1
   choose browse tool
end openstack--all good thus far

--in the script of fld "allofit"-- where the folders of the different genres are listed.

Code: Select all

on mouseup   
set the defaultfolder to the callmusic of this stack &"/"&& (the selectedtext of me)--my intent is to set a particular genre the defaultfolder--I feel sure this is wrong  the callmusic of this stack is the folderpath to wher all the music is kept.
put the files
end mouseup -- nothing happens.The debugger shows no errors and apparently the defautfolder does not change.Again,it "seems" reasonable to me.

Re: Setting the defaultfolder on the fly

Posted: Sat Jan 20, 2024 10:57 pm
by FourthWorld
The path mixes "\" and "/".

Re: Setting the defaultfolder on the fly

Posted: Sun Jan 21, 2024 12:22 am
by oldummy
Thank you. I tried replacing / with \ with no change. Finally I deleted one of the "&"s int the script and it worked..


set the defaultfolder to the callmusic of this stack &"/"&& (the selectedtext of me)did not work
set the defaultfolder to the callmusic of this stack &"/"& (the selectedtext of me)

Thanks for the reply.I need all of the help I can get.

Re: Setting the defaultfolder on the fly

Posted: Sun Jan 21, 2024 10:51 am
by Klaus
To be completley sure, use parenthesis when concatenating pathnames and objectnames!

Code: Select all

...
set the defaultfolder to (the callmusic of this stack &"/"& (the selectedtext of me))
...
One & will "glue" text together, two && do the same but with a SPACE!

Code: Select all

...
put "one word" & "another one" ## -> one wordanother one
put "one word" && "another one" ## -> one word another one
...

Re: Setting the defaultfolder on the fly

Posted: Sun Jan 21, 2024 2:36 pm
by stam
As a general debugging tip: When encountering errors constructing variable values this way it’s often more helpful putting the value inside an intermediate variable so you can view the value of what you create in the debugger.

In other words you would add a line before the set command where you set your variable to the path you’re constructing and then using that variable instead. If you interrupt the code by placing a red dot or simply typing breakpoint, you can see what the value of that variable is.
Or output it to the msgBox by inserting the line put <tempVariable>.

Then you would have seen there was an unseemly space in your file path because you used && instead of &.

In general if code that should work doesn’t, you need to look at what data is being processed and in the majority of cases that’s where the issue lies.


PS: why are you hiding the backdrop in your code and not setting that in your preferences?


PPS: horizontal ellipsis (“…”) is not inserted by default as far as I know. Maybe that’s something in your code?

Re: Setting the defaultfolder on the fly

Posted: Sun Jan 21, 2024 3:50 pm
by SparkOut
It won't be ellipsis, but the double dot "go back up one folder level" line in the list of folders returned.

Re: Setting the defaultfolder on the fly

Posted: Sun Jan 21, 2024 3:55 pm
by stam
Ah gotcha, yes.

Whenever I use the folders I filter it to remove the “..” - plus I always am concerned that files invisible on the Mac (starting with “.”) will be invluded with the Files, so with either I use the below to filter out anything that begins with a dot:

Code: Select all

Put the {folders | files} into myVar
Filter myVar without “.*”

Re: Setting the defaultfolder on the fly

Posted: Sun Jan 21, 2024 7:01 pm
by jacque
@olddummy: you can turn off the backdrop permanently in the View menu.
I kilter it
@stam: that's what happens when use LC for long enough. All your variables start wearing kilts. Just wait until they start playing bagpipes.

Re: Setting the defaultfolder on the fly

Posted: Sun Jan 21, 2024 11:31 pm
by stam
jacque wrote:
Sun Jan 21, 2024 7:01 pm
@olddummy: you can turn off the backdrop permanently in the View menu.
I kilter it
@stam: that's what happens when use LC for long enough. All your variables start wearing kilts. Just wait until they start playing bagpipes.
LOL :)
autocorrect corrected (although who knows why it felt 'kilter' was the word I was reaching for lol)... Mind you I kinda like the mental image of kilt-wearing variables ;)

Re: Setting the defaultfolder on the fly

Posted: Mon Jan 22, 2024 7:37 am
by jacque
Courtesy of NightCafe. I'm not very good at this yet.