Setting the defaultfolder on the fly

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
oldummy
Posts: 78
Joined: Mon Jun 13, 2016 3:21 pm

Setting the defaultfolder on the fly

Post by oldummy » Sat Jan 20, 2024 7:50 pm

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.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9842
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Setting the defaultfolder on the fly

Post by FourthWorld » Sat Jan 20, 2024 10:57 pm

The path mixes "\" and "/".
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

oldummy
Posts: 78
Joined: Mon Jun 13, 2016 3:21 pm

Re: Setting the defaultfolder on the fly

Post by oldummy » Sun Jan 21, 2024 12:22 am

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.

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Setting the defaultfolder on the fly

Post by Klaus » Sun Jan 21, 2024 10:51 am

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
...

stam
Posts: 2686
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Setting the defaultfolder on the fly

Post by stam » Sun Jan 21, 2024 2:36 pm

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?

SparkOut
Posts: 2852
Joined: Sun Sep 23, 2007 4:58 pm

Re: Setting the defaultfolder on the fly

Post by SparkOut » Sun Jan 21, 2024 3:50 pm

It won't be ellipsis, but the double dot "go back up one folder level" line in the list of folders returned.

stam
Posts: 2686
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Setting the defaultfolder on the fly

Post by stam » Sun Jan 21, 2024 3:55 pm

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 “.*”
Last edited by stam on Sun Jan 21, 2024 11:30 pm, edited 1 time in total.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7238
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Setting the defaultfolder on the fly

Post by jacque » 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.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

stam
Posts: 2686
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Setting the defaultfolder on the fly

Post by stam » Sun Jan 21, 2024 11:31 pm

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 ;)

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7238
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Setting the defaultfolder on the fly

Post by jacque » Mon Jan 22, 2024 7:37 am

Courtesy of NightCafe. I'm not very good at this yet.
Attachments
XVariable.jpg
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”