Save Page / Save Setting in Designer

Anything related to Hollywood Designer goes in here
Post Reply
leavereality
Posts: 38
Joined: Sat Sep 28, 2019 1:39 pm

Save Page / Save Setting in Designer

Post by leavereality »

So on my next update for Amilion, I would love it to be able to save which page its on, on exit, I guess I would put code on the exit button, and then code on start up, so it check which page to start on, trouble is I kind of not sure what the code would be. I thinking of creating a external txt file that would save a number 1 to 6 on exit depending on the page your on and hollywood on boot would check the number and go to that page, but I did read about User settings/Use preferences so how would I go about using that, I not found a tutorial. thanks
leavereality
Posts: 38
Joined: Sat Sep 28, 2019 1:39 pm

Re: Save Page / Save Setting in Designer

Post by leavereality »

This is where Im up to So far I have a Setting.txt file with just "1" in the file so to test Hollywood is reading it, I have txt field named pageset

OpenFile(1, "setting.txt")
pageset = ReadLine(1)
CloseFile(1)
SetLayerStyle("pagetxt",{text=pageset})


On text entry "pagetxt" it display the number 1

On exit I have this when exit page 1
OpenFile (1, "setting.txt", #MODE_WRITE)
WriteLine(1, "1")
Closefile(1)


Code for page 2
OpenFile (1, "setting.txt", #MODE_WRITE)
WriteLine(1, "2")
Closefile(1)


This works and changes the setting.txt number to 2 and on next load up of the app it displays the number 2
Now I just need to figure out how to get Hollywood to jump to Page 2 if pageset = 2
Bugala
Posts: 1168
Joined: Sun Feb 14, 2010 7:11 pm

Re: Save Page / Save Setting in Designer

Post by Bugala »

First of all. you better write TABLE instead of text to your save file, unless you are planning to alter the save file using text editor or something afterwords, since in that case saving and reading as TABLE wont work for the purpose.

Here an example (I didn't test this)

Code: Select all

SettingsTable = { PageTxt = 2, SoundVolume = 32 }

OpenFile(1, "settings.bin", #MODE_WRITE)
WriteTable(1, SettingsTable)
CloseFile(1)
To use this somewhere after it have been saved:

Code: Select all

OpenFile(1, "table.bin", #MODE_READ)
SettingsTable = ReadTable(1)
CloseFile(1)

Debugprint(settingstable.PageTxt)
You could naturally instead of Page Numbers use Page names, ie. SettingsTable.PageTxt = "My Third Page"


To use it for designer to automatically jump to that specific page would work so that You would add code to be executed as a first thing in your first designer page.

This piece of code would be about following:

Code: Select all

Switch SettingsTable.PageTxt
Case 1:
	%>1
Case 2:
	%>2
Case "My Third Page"
	%>"My Third Page"
EndSwitch
I am not sure this works like this, since I haven't tried this. I just know that this is the command that you can Use for Designer to jump to pages, but I am not sure this is the right syntax to use it this way. But this is anyway the idea.

That you make a very first page, that has nothing else but piece of code that loads the settingstable and then jumps to the page depending upon what is saved at settings.txt.

If something else is saved on the settings.txt, like you could make default settingstable that has "none" saved to pagetxt variable, then in that case it just continues to the next page in designer.

By other words, when people would run your designer presentation for the first time, they would end to the first page as intended (which would actually be the second page, since first page is actually not showing anything, just running those two pieces of code)
leavereality
Posts: 38
Joined: Sat Sep 28, 2019 1:39 pm

Re: Save Page / Save Setting in Designer

Post by leavereality »

Firstly thanks for you help and previous tutorials, they really helped me learn more about how Hollywood works!
hope you can follow this image
Image
new page 1 identify is page001

rectangle 250 is basically the button that would save the page the user on into the Table "page001"

On removing this code, the app works, so it got to be something here?, checking the syntex it says error on line 3,
Switch SettingsTable.PageTxt
Case "page001"
%>"page001"
Case "page002"
%>"page002"
EndSwitch


Running the app it says Syntex error in Object "B??o" no idea what Object that is as this is a very simple test app I made to see if I could get this to work.

Tried %>PAGEID "page001" but not sure if that how the code should work.

uploaded my very basic Designer app with this code
https://amigang.com/software/wite2.lha
Thanks for you help, or if anyone else can shed light on what Im doing wrong. cheers
Bugala
Posts: 1168
Joined: Sun Feb 14, 2010 7:11 pm

Re: Save Page / Save Setting in Designer

Post by Bugala »

That is about how I would imagine it should work. I guess you are using Hollywood 5, since I haven't noticed that "properties" thing before where you are running that settings loading part.

I myself have Designer 4. I did order Designer 5 this week along with Hollywood 9, but I ordered it through snail mail, so it might take a while still before I get it, but I might take a look at this when it arrives.

Based upon the error, it seems to be complaining about the "%>"page001"-part, which was exactly the one I am not sure how it actually works.

That the example shows %>PAGEID, but how exactly are you supposed to put that line I am not sure of.

However, in that picture in page manager I see pages name as "New Page 1", you could try changing name to this, or you could also try without " these. Basically I think you are supposed to have a name as "Page001", but it is possible that Designer could be using it simply as:
%>page001

But this is only guessing from my part.
leavereality
Posts: 38
Joined: Sat Sep 28, 2019 1:39 pm

Re: Save Page / Save Setting in Designer

Post by leavereality »

You know persistency pay off, after trying a number of different codes, this one works!!!! Plus renaming the Page Name page001

Code: Select all

Switch SettingsTable.PageTxt
Case "page001"
        %>page001
Case "page002"
        %>page002
EndSwitch    
:D, this is one of the very few time the manual let me down, as I could not even find the code to change page in the doc plus no example of how to use the code, so thanks for point out it was %> that gave me a fighting chance!!!!
Bugala
Posts: 1168
Joined: Sun Feb 14, 2010 7:11 pm

Re: Save Page / Save Setting in Designer

Post by Bugala »

It is actually strange that Andreas have chosen to use the PAGEID without " marks.

I wonder does this mean that you are limited into using PAGEID names that don't contain spaces. Like can you have "Page 001" and then use
%>page 001

to get it to work, or will it fail?

I also wonder can you use variables as PAGEID identifier at all, like:

Code: Select all

NextPage = "Page002"
%>NextPage
But good you got it working anyway.


And for the rest of Designer specific codes, check 12.1 (custom code / code dialog) from here: https://www.hollywood-mal.com/docs/html/designer/
User avatar
airsoftsoftwair
Posts: 5425
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Save Page / Save Setting in Designer

Post by airsoftsoftwair »

Bugala wrote: Thu Mar 25, 2021 12:11 pm I wonder does this mean that you are limited into using PAGEID names that don't contain spaces. Like can you have "Page 001" and then use
%>page 001

to get it to work, or will it fail?
Won't work. Page and object IDs must not contain spaces. Designer won't allow you to enter spaces in the object and page ID fields so this is safe.
Bugala wrote: Thu Mar 25, 2021 12:11 pm I also wonder can you use variables as PAGEID identifier at all, like:

Code: Select all

NextPage = "Page002"
%>NextPage
No, that's not possible either.
leavereality
Posts: 38
Joined: Sat Sep 28, 2019 1:39 pm

Re: Save Page / Save Setting in Designer

Post by leavereality »

thanks for the feedback, support and work on Hollywood airsoftsoftwair!!!
Post Reply