Registry Fields with Persistent Variables
-
Navigate to HSYCO Manager
-
Create a new project or open an existing one
- Go into the Home page
- Click "add"
- Add a "Field" object
- Go back to "edit" mode
- You can align the object by clicking "Align" and then "Center Horizontally" and "Center Vertically"
- Change the "ID" to "namefield"
9. Change the "Name" attribute to "$namefield!". "$namefield!" is a persistent variable that will contain the value of this field, so what the user enters as text Note that this variable is different from the ID as this two are two completely different things
10. Change the "Placeholder" to "Name". The Placeholder is a short hint that describes the expected value of the field
- Click "add"
- Add a second "Field"
- Click "edit"
- Move this field under the previous one
- Change the "ID" to "surnamefield"
- Change the "Name" attribute to "$surnamefield!"
- Change the "Placeholder" to "Surname"
- Click "add"
- Add the third "Field"
- Click "edit"
-
Move it under the other two fields
-
Change the "ID" to "datefield"
- Change the "Name" attribute to "$datefield!"
- Change the "Placeholder" to "Date of Birth"
- Change the "Type" to "date"
- The page should look like this:
- Click "Save" to save the project
Tip: Good! Now we need some code to retrieve the values in the three persistent values and show them in their respective fields every time we visit this page
- Go into the File Manager
- Navigate into the "events" folder
- Click "New File"
- Give it a name ("fields.txt" for example) and click "New File
**32. Copy the following EVENTS code and save the file:
INIT or $namefield! : UISET namefield.value = $namefield!
INIT or $surnamefield! : UISET surnamefield.value = $surnamefield!
INIT or $datefield! : UISET datefield.value = $datefield!
What this does is it sets the value of each of the field objects to the content of their corresponding persistent variable every time this changes**
- Go back to the Project Editor, click "Run" and "Default" to launch the application
- The page, at first, lets you insert some text
- Insert a Name in the first field
- Insert a Surname in the second field
- Select a date from the third field
- If you now try to reload the page or move to another page if your project has more pages, you should see that the fields will autocompile to the last value immetted, which is the value in the persistent variables