open stack not working in openstack handler

Want to move your code and projects to LiveCode but don't know where to start?

Moderators: Klaus, FourthWorld, heatherlaine, robinmiller

Post Reply
Judson
Posts: 26
Joined: Fri May 07, 2010 9:15 pm

open stack not working in openstack handler

Post by Judson » Fri May 21, 2010 9:21 pm

Anyone know why the open stack "Edge Photographers" doesn't work below? The stack is in the same directory as all the others:

on openstack

set the itemDelimiter to slash
get the effective filename of this stack
set the defaultFolder to item 1 to -2 of it
put it & return into message
beep
start using stack "JGR Utilities Rev Unique"
start using stack "Utilities JGR"
start using stack "rvat"
start using stack "bikini science"
start using stack "WebsiteFunctions3" --contains term expander
--start using stack "Foobar"
put return & the stacksinuse after message

--initialize globals to What?
global PXV, PXE, readyFlag, initVersion
put "Paysite New" into PXV --probably not used
put ".html" into PXE

open stack "Edge Photographers"

end openstack


Following is the directory list:


Bikini Science.rev
Edge Photographers.rev
JGR Utilities Rev Unique.rev
JGR Utilities.rev
RVAT.rev
Utilities 01.rev
Utilities JGR
Website Functions
Website Functions Custom Site
Website Functions PAYC
Website Functions PAYC_Ads
Website Functions PAYC_Ads retired A71229
Website Functions PAYC_Only
Website Functions PAYC_Sky
Website Functions Paysite A803
Website Functions Paysite A803 copy
Website Functions Paysite A80326 BU
Website Functions Paysite New
Website Functions Paysite New retired A71229
Website Functions Promolib
Website Functions Tour Extras
WebsiteFunctions
WebsiteFunctions2
WebsiteFunctions3
WebsiteFunctions3.rev
WebsiteFunctions4
WebsiteFunctions4 copy

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5132
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: open stack not working in openstack handler

Post by Mark » Sat May 22, 2010 12:11 pm

Judson,

"Edge Photographers" seems to be the short name of a stack. The short name of a stack is only known if the stack is already in memory. To open a stack that isn't in memory yet, you need to use the (relative) path to the stack.

For example, use this script:

Code: Select all

set the itemDel to slash
put (item 1 to -2 of the effective filename of this stack) & "/Edge Photographers.rev" into myPath
open stack myPath in new window
Best regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Judson
Posts: 26
Joined: Fri May 07, 2010 9:15 pm

Re: open stack not working in openstack handler

Post by Judson » Sun May 23, 2010 4:24 am

Okay Mark, thank you for this, but...

In the opencard handler at hand I already do the first two lines of your code, and should not the setting of the defaultFolder in line 3 be the same thing as your line three where you spell out the pathname?

One thing I have also noticed fiddling around is that if I append the stack name with ".rev" it works:

open stack "Edge Photographers.rev"

Judson

ReindlWolfgang
Posts: 13
Joined: Thu Aug 26, 2010 11:36 am

Re: open stack not working in openstack handler

Post by ReindlWolfgang » Sun Sep 12, 2010 2:27 pm

I've tried it:

on mouse up
open stack teststack1
end mouse up

in a button of teststack2 - will open teststack1

BUT

on mouse up
open stack teststack1.rev
end mouse up

shows
"no such card" in teh message box

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5132
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: open stack not working in openstack handler

Post by Mark » Sun Sep 12, 2010 2:52 pm

ReindlWolfgang,

Everything that could be wrong is wrong in your script. I am not surprised at all that it doesn't work. Stack names should be surrounded by quotes. File names should contain the correct (relative) path to the file and should be in quotes too. Why would you expect your script to work?

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

ReindlWolfgang
Posts: 13
Joined: Thu Aug 26, 2010 11:36 am

Re: open stack not working in openstack handler

Post by ReindlWolfgang » Mon Sep 13, 2010 3:33 pm

Hello Mark
Mark wrote: Everything that could be wrong is wrong in your script.
Thanks for the flowers *grmbl*
Mark wrote: I am not surprised at all that it doesn't work.
The first script DOES work!
Mark wrote: Stack names should be surrounded by quotes.
Thanks, I didn't know. In HC it was not necessary to set quotes.
Mark wrote: File names should contain the correct (relative) path to the file and should be in quotes too.
Both stacks are within the same folder
Mark wrote: Why would you expect your script to work?
Mark
1) Scripts like (it is on teststack1)

on mouse up
open stack teststack2
end mouse up

DID work pretty fine in HC (all the stacks within one folder), even when swithing between the 2 stacks twice or tirce during one schript and exchanging Information between the two stacks.
So I just had a guess it might work in rev as well.

2) the script I printed above DOES work in rev!
Why would you expect this script not to work?

3) the following script on teststack2 does NOT work (without error, both stacks within se same folder):

on mouseUp
open stack "teststack1.rev"
end mouseUp


On the other hand the following DOES work:

on mouseUp
open stack "teststack1"
end mouseUp

So my conclusion is:
1) putting ".rev" behind a stack's name is going to corrupt my scrips.
2) setting quotes around the stackName does neither help nor disturb.


Wolfgang

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5132
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: open stack not working in openstack handler

Post by Mark » Mon Sep 13, 2010 5:10 pm

Hi Wolfgang,

teststack1 could be a variable, while "teststack1" is a string for sure. Even in HyperCard, strings were supposed to be in quotes, regardless of whether they contained just one word or an entire phrase, but many people seem to have been unaware of that. In HyperCard, quoting your strings makes your scripts faster for instance. Also, unquoted strings may accidentally be defined as a local or global variable later on, which would break your scripts. It is only logical to use quotes, because stack filenames may contain spaces.

There are several reasons why RunRev might not find your stack. The stack may not exist at all, or appears to be corrupt, or is not in the current defaultfolder. There might be other reasons, e.g. that your stack isn't listed in the stackfiles property of the mainstack of your project (but this only applies if you meant to set the stackfiles property). Probably, it would be a good thing to start with checking the defaultFolder.

Btw, don't stick to the HyperCard syntax too much. There are many things that work differently in Revolution and there are hundreds of features that work in Rev but not in HC.

Best regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

ReindlWolfgang
Posts: 13
Joined: Thu Aug 26, 2010 11:36 am

Re: open stack not working in openstack handler

Post by ReindlWolfgang » Mon Sep 13, 2010 7:13 pm

Mark wrote: teststack1 could be a variable, while "teststack1" is a string for sure. Even in HyperCard, strings were supposed to be in quotes, regardless of whether they contained just one word or an entire phrase, but many people seem to have been unaware of that. In HyperCard, quoting your strings makes your scripts faster for instance. Also, unquoted strings may accidentally be defined as a local or global variable later on, which would break your scripts. It is only logical to use quotes, because stack filenames may contain spaces.
OK, I see that.

When I accidently will pass some
"open stack [StackName]"
during my conversion, I will quote it to
"open stack "[StackName]"
Mark wrote: There are several reasons why RunRev might not find your stack. ...
It's funny:

on mouse up
open stack teststack1
end mouse up

works. As soon as I write ".rev" behind "teststack1" it does NOTHING at all. Removing ".rev" reanimates the script

Mark wrote: The stack may not exist at all, or appears to be corrupt, or is not in the current defaultfolder. There might be other reasons, e.g. that your stack isn't listed in the stackfiles property of the mainstack of your project (but this only applies if you meant to set the stackfiles property). Probably, it would be a good thing to start with checking the defaultFolder.
That point stays mysterious for me at the moment.
Mark wrote: Btw, don't stick to the HyperCard syntax too much. There are many things that work differently in Revolution and there are hundreds of features that work in Rev but not in HC.
HyperTalk is the only programming language I ever did more than "Hello World" until now. (Exept a small program in some ancient MacBasic to recalculate geological structural data from an vintage format into modern Clar-type. A lot of IF - THEN - ELSE).

And now I try to convert my old HC project to rev. As HC did run within ClassicEnvironment it was not able to edit schripts or to create new ones. So I'm out of training for about 5 or 6 Years now.

Any time i face some problem with my old script from HC I place a copy of it into some testing-stack of rev and do my experiments in that "sandbox" until it works there.

Wolfgang

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5132
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: open stack not working in openstack handler

Post by Mark » Wed Sep 15, 2010 4:28 pm

Hi Wolfgang,

What's mysterious about the defaultFolder etc?

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

ReindlWolfgang
Posts: 13
Joined: Thu Aug 26, 2010 11:36 am

Re: open stack not working in openstack handler

Post by ReindlWolfgang » Fri Sep 17, 2010 8:35 pm

Hello Mark,
Mark wrote: What's mysterious about the defaultFolder etc?
What's 'the current defaultFolder'? I never set any folder to be defaultFolder activly.
So I guess the defaultFolder is the Folder the current stack is within.
And both stacks that are calling each other are within the same folder.
Mark wrote: e.g. that your stack isn't listed in the stackfiles property of the mainstack of your project
I don't understand anything.

I'm used to run any Mac-program without reading the documentation. Only if I need something verry special, I have a look into.
My HyperCard-project was made without reading documentation, exept: I printed the complete syntax on my nailprinter for a quick look.
I'm shure I'd done better coding with some 'learnig ahed' instead of 'learning by doing' - but my code did what I expected it to do.

Now I've printed the Revolution User Guide and squeezed it into an A5 Leitz ringbinder. Reading it instead of some novel when riding the train, on sofa listening music, before sleep ...
Nevertheless I don't understand (yet) what you're writing.

BUT: I discovered that there are SUBSTACKS! And making my NavigatingStack a substack of my DataStack solved a lot of "don'tworks" at one hit :D
That doesn't mean everyting's working now, but some of my old scripts do without further changes :-)

So I'm a litte more optimistic than I was last week.

           Wolfgang

WaltBrown
Posts: 466
Joined: Mon May 11, 2009 9:12 pm
Location: NE USA

Re: open stack not working in openstack handler

Post by WaltBrown » Sun Sep 19, 2010 6:00 am

Hi Wolfgang.

Enter "the defaultFolder" in the Message Box under the Tools menu and you will see what Rev currently thinks is the default folder. Mine says "C:/Program Files (x86)/Revolution Studio" at the moment. For many of the folder and file based functions, the defaultFolder is where Rev looks. My method is to do the following when I need to change folders (I never remember what I did in other modules, so I assume nothing :-):

Code: Select all

put the defaultFolder into tSomeVariable
set the defaultFolder to "C:/someotherfolder"
do stuff
set the defaultFolder to tSomeVariable
BR, Walt
Walt Brown
Omnis traductor traditor

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

Re: open stack not working in openstack handler

Post by Klaus » Sun Sep 19, 2010 12:17 pm

Hi all,

the "current defaultfolder", as Wolfgang mentioned, is the folder where your app resides!
This applies to Windows, Linux and Mac.

Code: Select all

...
A folder on the HD
   your app.exe
   your app.app
   your app  
   ## Linux does obviously not have an externsion for applications?

   A subfolder inside that folder
...
So after starting your app "the folder" = "A folder on the HD" in this example!

So a very good way to handle "the defaultfolder" (a term which is here for Hypercard compatibility,
the "correct" Rev syntax is "the directory" or simply "the folder") is as Walt described:

Code: Select all

...
put the folder into tSomeVariable
set the folder to "C:/someotherfolder"
## do stuff tot he files in this folder
set the folder to tSomeVariable
...
Best

Klaus

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5132
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: open stack not working in openstack handler

Post by Mark » Sun Sep 19, 2010 12:24 pm

Actually, the correct standard term is defaultFolder, according to the docs.

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

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

Re: open stack not working in openstack handler

Post by Klaus » Sun Sep 19, 2010 12:33 pm

Yes, you are right!

I had been looking in the MetaCard dictionary where it is listed under HyperCard compatibility.
So "in the beginning" this was not the correct term :)

Anyway, lazy moi prefers "the folder".

ReindlWolfgang
Posts: 13
Joined: Thu Aug 26, 2010 11:36 am

Re: open stack not working in openstack handler

Post by ReindlWolfgang » Mon Sep 20, 2010 7:08 pm

Thanks to Klaus, Walt and Mark
for explaining "the default folder".

Now I understand some of the oddities that occoured with ma two stacks calling each other.
e.g: when I opened both of them from the finder or from "Open"-Menue some of the ionteraction worked, when I closed one of the two stacks, it was possible to open it again with one of the interaction-scripts - but when I quit rev I had to open them again from the finder (I've learnd that stacks remain in the memory even when closed - until rev is quit or the stack is removed from memory).

BUT: There's no need at all to tell each of the stack's the location of the other, when one is made a substack of the other.

Learning by doing aided by learning by reading...

Now some functionality is returning into my project. And new errors occour.

Wolfgang

Post Reply

Return to “Converting to LiveCode”