Page 1 of 2

get name of flashdrive.

Posted: Fri Apr 12, 2024 9:46 am
by CAsba
Hi all,
Is it possible to get the name of the USB stick that a livecode stack is on and put it into a field within the stack ?

Re: get name of flashdrive.

Posted: Fri Apr 12, 2024 3:04 pm
by dunbarx
Casbah

There is a function, "the volumes" that returns all mounted, er, volumes. Identifying a particular volume that happens to contain the name of a certain liveCode stack is another task.

But if you are already looking for a stack with a certain name, then why do you need to find it somewhere? Why not just put that name into the field?

There is more here, eh?

Craig

Re: get name of flashdrive.

Posted: Fri Apr 12, 2024 5:03 pm
by CAsba
Hi,
I'm trying to make a security measure (of sorts). Basically, I have a stack on a USB stick. This can be copied, so, to try to stop that, I want the stack to run after checking a field, the contents of which match the name of the USB stick, and if there is no match, the stack won't run. So I have to find a way that the stack can check if the name of the USB stick it's copied to will match. For that to happen the stack must have some code that will get the name of the USB stick, if there is a name.

A simple task for you, surely ?? (being ironical here).

Re: get name of flashdrive.

Posted: Fri Apr 12, 2024 5:19 pm
by jacque
The filename of the stack should include the volume name.

Re: get name of flashdrive.

Posted: Fri Apr 12, 2024 6:41 pm
by CAsba
Hi Jacque,
Thanks, but - I'm a bit lost..What's a volume name? and how would it work (in simple logic terms, if that's possible..)

Re: get name of flashdrive.

Posted: Fri Apr 12, 2024 9:14 pm
by jacque
CAsba wrote:
Fri Apr 12, 2024 6:41 pm
Hi Jacque,
Thanks, but - I'm a bit lost..What's a volume name? and how would it work (in simple logic terms, if that's possible..)
Put this in a button or handler in your stack:

Code: Select all

put the filename of this stack
Then look at the response in the message box. The volume name is the disk name. If the name of the flash drive is in the response then it's your flash drive.

In the real script you'd get the filename and check if the right name is in there without using the message box of course.

Re: get name of flashdrive.

Posted: Fri Apr 12, 2024 10:45 pm
by CAsba
Many thanks, Jacque, It's a bit late now, but I'll try it tomorrow (if circumstances allow..).
Once again, many thanks.

Re: get name of flashdrive.

Posted: Sat Apr 13, 2024 7:06 am
by SparkOut
There is a very old thread on the topic of interrogating volumes on Windows.
I don't know whether any of it still applies.
viewtopic.php?t=2357&start=0

Re: get name of flashdrive.

Posted: Sat Apr 13, 2024 10:30 am
by CAsba
Hi Jacque,
I tried that - it's exactly what's needed, so my heartfelt thanks to you.
Thanks also to the other contributors for their kind concern.

Re: get name of flashdrive.

Posted: Sat Apr 13, 2024 7:36 pm
by FourthWorld
Does Windows now identify volumes by name rather than letter designation?

Re: get name of flashdrive.

Posted: Sun Apr 14, 2024 12:00 am
by SparkOut
Windows has always used volume names. Those volumes may or may not be assigned a drive letter.

Re: get name of flashdrive.

Posted: Mon Apr 15, 2024 12:01 am
by dunbarx
Jacque.

Always impressed by your LC knowledge.

The "filename of stack". Really. What will they think of next??

Craig

Re: get name of flashdrive.

Posted: Mon Apr 15, 2024 6:37 am
by FourthWorld
SparkOut wrote:
Sun Apr 14, 2024 12:00 am
Windows has always used volume names. Those volumes may or may not be assigned a drive letter.
In file paths, such as the value returned from "the long name of this stack"?

Re: get name of flashdrive.

Posted: Mon Apr 15, 2024 8:09 am
by SparkOut
That wasn't what I was answering. Windows uses volume names for drive referencing (by humans). LiveCode returns a resolved file path on Windows which invariably has a drive letter.

Re: get name of flashdrive.

Posted: Mon Apr 15, 2024 8:35 am
by FourthWorld
SparkOut wrote:
Mon Apr 15, 2024 8:09 am
That wasn't what I was answering. Windows uses volume names for drive referencing (by humans). LiveCode returns a resolved file path on Windows which invariably has a drive letter.
Yes, that was my concern about the solution the OP is considering.