read and write the local disk from a revlet

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

read and write the local disk from a revlet

Post by jmburnod » Sun Mar 21, 2010 12:33 pm

Hi All,

i need to read and write the local disk from a revlet
I select this option in the standalone setting
With revStudio i get the path of the stack and i build
a local folder path for read and write data

It work fine in a stack. glapilemaitre is a valid path
But not from a revlet, glapilemaitre = the short name of the stack

Code: Select all

on openstack
   global glapilemaitre
   put the  long name of this stack into glapilemaitre
   delete word 1 of glapilemaitre
   delete char 1 of glapilemaitre
   delete last char of glapilemaitre
end openstack
What i forget ?

Jean-Marc
https://alternatic.ch

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10057
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: read and write the local disk from a revlet

Post by FourthWorld » Sun Mar 21, 2010 3:30 pm

Is it absolutely necessary to write to the user's hard drive from the browser? Is there any way you could consider using remote storage for that as is more common on the web?

I've seen a surprising number of Revlets that request access to my local hard drive, and that can be fine for intranets but for the general public it may just scare people away from your Revlet or even the Rev plugin itself for the reasons I noted in the revJournal blog:
http://revjournal.com/blog.irv?pid=1262632837.378884

If you're in that rare circumstance in which you truly need to work with the site visitor's local hard drive, you may do better to use "ask file" to determine where the user wants to save the data. As I noted in another blog entry, Revlet stacks have no path because they exist only in memory, which is why your method of obtaining the path fails:
http://revjournal.com/blog.irv?pid=1253992718.569667

On your local disk it works fine because there actually is a stack file, but in a browser what the user has is a copy in memory of the file loaded from your server.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: read and write the local disk from a revlet

Post by jmburnod » Mon Mar 22, 2010 10:04 am

Thank for explanation and link

I need to write on hard disk to allow user save text or paint.

At this moment i build a painting tool for child with special needs there can't
use a dialogbox

Jean-Marc
https://alternatic.ch

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10057
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: read and write the local disk from a revlet

Post by FourthWorld » Mon Mar 22, 2010 11:40 am

For children it may be hard for them to find files within their hard drive -- any harm in writing it to the desktop?

If that'll work you can use the specialFolderPath function:

export snapshot from img 1 to file (specialFolderPath("desktop")&"/MyImage.jpg") as jpeg
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: read and write the local disk from a revlet

Post by jmburnod » Tue Mar 23, 2010 9:52 am

Hi FourthWorld,

Code: Select all

any harm in writing it to the desktop?
Yes, the revlet have a users registry and each user have a folder for text, paint
The preferences navigation mode can be different :

• one contact for a navigation by scrolling objects
• two contactors they send a keyboard message "9" = GoNextObject and "b" to confirm the selection

The navigation modes are like in "heure de pointe/ParkLot" : arrowkeyRight = GoNextObject and "b" confirm the selection

Thank one more for help

Jean-Marc
https://alternatic.ch

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10057
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: read and write the local disk from a revlet

Post by FourthWorld » Tue Mar 23, 2010 1:09 pm

Are you the one who made the Parking Lot game? Nice work - I've spent some good time with it.

If the users have a pre-arranged path, what challenge is involved in determining that path for the write?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: read and write the local disk from a revlet

Post by jmburnod » Tue Mar 23, 2010 2:49 pm

Code: Select all

Are you the one who made the Parking Lot game? Nice work - I've spent some good time with it.
If the users have a pre-arranged path, what challenge is involved in determining that path for the write?
Yes i made the Parking Lot game. If you are Richard Gaskin, you sent me a feed-back. Thank one more

The challenge is one folder with on subfolder for each users

Jean-Marc
https://alternatic.ch

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10057
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: read and write the local disk from a revlet

Post by FourthWorld » Tue Mar 23, 2010 4:39 pm

jmburnod wrote:Yes i made the Parking Lot game. If you are Richard Gaskin, you sent me a feed-back. Thank one more

The challenge is one folder with on subfolder for each users
Yep - I'm Richard. It seems signatures have recently been disabled here, which is a major drag since mine contains my contact info. You're welcome to write me at ambassador@fourthworld.com

On the user folders, do you expect to have multiple users accessing your site from one computer? Because of course if you support multiple computers and need to store info that can be shared with all of them you'll want to store that info on the server so everyone can access it.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Ron Zellner
Posts: 106
Joined: Wed May 31, 2006 9:56 pm
Contact:

Re: read and write the local disk from a revlet

Post by Ron Zellner » Tue Apr 06, 2010 2:13 am

OK, you've tweaked my interest, where can I see the Parking Lot game?

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: read and write the local disk from a revlet

Post by jmburnod » Tue Apr 06, 2010 10:30 am

Hi Ron,
You can read a small documentation here :

http://alternatic.ch/spip.php?article72

("Park lot" is "heure de pointe" in french)
It is a version for handicaped people with one or two contactors
but you can play with the mouse also without interface for special needs

Or dowload a standalone at :

Mac OSX version (2.7 Mo) : http://alternatic.ch/jmb/hdposx.zip
Windows version (1.4 Mo) : http://alternatic.ch/jmb/hdpwindows.zip

Regards

Jean-Marc
https://alternatic.ch

Post Reply