Page 1 of 1

PageChangeName variable

PostPosted: Thu Aug 06, 2015 8:29 am
by BRobinsonS
I want to prevent a user from leaving a page if a condition exists.
i.e. in the transactions of an accounting app if the entries do not balance then inform the user and stay on the page.

I have read the help file
Optionally, the page change can be redirected or canceled by altering the value of the global [PageChangeName] variable.

The change page would be done by a Button (example: to go to the 'Main' page)
The PageChangeName variable doesn't contain the 'Main' and therefore, leaves the page.
I even set the variable to 'Main' and my app still leaves the page.

Any ideas of what I am misunderstanding?

Re: PageChangeName variable

PostPosted: Thu Aug 06, 2015 9:09 am
by HPW
From the help:
This variable can be used to abort or redirect a page change by modifying it from within the Book Properties > Page Change Action. Upon entering the Page Change Action, this variable will contain the name of the page the reader wishes to navigate to. You can abort the page change by clearing the variable like this:

SetVar "[PageChangeName]" ""

The page change can be redirected by setting the variable to the name of another page:

SetVar "[PageChangeName]" "Error Page"


So you have to do this in the 'page Change action' in book properties Actions.

Regards

Re: PageChangeName variable

PostPosted: Thu Aug 06, 2015 9:44 am
by BRobinsonS
Thanks you for your response.

Then I am not sure how to use this.

I am trying it on the 'Page Exit' tab for the page.
.CHECK TO MAKE SURE ENTRY IS BALANCED
If "[SumDifference]" "<>" "0"
MessageBox "Entry Balance" "Transactions DO NOT balance.|Do you want to leave this page?" "No|Yes" "[LeavePage]"
If "[LeavePage]" "=" "1"
SetVar "[PageChangeName]" ""
EndIf

EndIf


How would I do this?
The page I am on is 'Transactions' and the button is taking me to 'Main' page, but I don't want to go there if the numbers don't balance.

Re: PageChangeName variable

PostPosted: Thu Aug 06, 2015 10:19 am
by Gaev
Brian:

1) Regarding the variable [PageChangeName] ... according to the Help file ...
Upon entering the Page Change Action, this variable will contain the name of the page the reader wishes to navigate to.

... so this variable is ONLY effective in the Page Change routine.

2)
I am trying it on the 'Page Exit' tab for the page.

Since the user is required to click on a button in order to request a "page change", you don't need to use the Page Change or PageExit routines ... just do the check within the button's click action code ...
Code: Select all
.CHECK TO MAKE SURE ENTRY IS BALANCED

... just for test purpose
AlertBox "SumDifference" "[SumDifference]"

If "[SumDifference]" "<>" "0"
   MessageBox "Entry Balance" "Transactions DO NOT balance.|Do you want to leave this page?" "No|Yes" "[LeavePage]"
   If "[LeavePage]" "<" "2"
      Return
   EndIf
EndIf
... SumDifference = 0 OR user chose Yes
GotoPage "Main"

Re: PageChangeName variable

PostPosted: Thu Aug 06, 2015 10:42 am
by BRobinsonS
Thank you Gaev.
To my rescue again.

The page change may occur through other menu options too.
I believe I just have to check if I am on the transactions page when I want to leave through the menu and that I check like I do with the Main Button.
Perhaps a subroutine would be appropriate.

Re: PageChangeName variable

PostPosted: Thu Aug 06, 2015 11:42 am
by Gaev
Brian:

The page change may occur through other menu options too.
Perhaps a subroutine would be appropriate.

Yes ...
Code: Select all
:ToLeaveOrNotToLeavePage
.CHECK TO MAKE SURE ENTRY IS BALANCED
If "[SumDifference]" "<>" "0"
   MessageBox "Entry Balance" "Transactions DO NOT balance.|Do you want to leave this page?" "No|Yes" "[LeavePage]"
   If "[LeavePage]" "<" "2"
      Return
   EndIf
EndIf
... SumDifference = 0 OR user chose Yes
GotoPage "Main"
Return


Then, do a GoSub "ToLeaveOrNotToLeavePage" where ever the user requests a change of page.

Re: PageChangeName variable

PostPosted: Thu Aug 06, 2015 11:51 am
by BRobinsonS
Thanks again.