Day 011 - Validating data and a new edit form
Someone asked me today if I was really spending an hour a day on this. And I suppose it may seem like a lot less than that, given that it takes rather less time to read each installment.Â
These are my hours, not yours. So yes, by the time I've taken the screen shots and written the text and poked around in the help and chased a variety of WinDev rabbits down their holes, the big hand has moved at least once around the clock.Â
Back at page 96 in the tutorial, I entered a Person record and two Movement records per the instructions.Â
In both forms I tried to save before fully completing the data entry. Here's the warning I got when I tried saving an empty Movement form:
And here are the details:
On closing this window and clicking Cancel on the previous window, I got this display:
Not overly helpful, but presumably there are ways to override these error messages for what would have to be a fairly common occurrence. It is, however, very nice to have the option to Debug, which returns focus to the relevant line of code in the application.Â
Locking the app
The tutorial explains how to set an automatic timeout for the application, via the Project Description. Just click the Lock option and set the timeout.Â
If the app times out, you'll have to reenter your Windows password to get access, or your application password if you have User Groupware (the security system) enabled.Â
The tutorial says to set the timeout for two minutes and then wait two minutes to see how the lockout works. I wonder if there's a key to lock the app on demand. I also wonder how secure this is - presumably it's a runtime feature and not open to programmer inspection, otherwise it would be an easy way to harvest passwords!Â
Edit windows
Starting on page 98 the tutorial begins explaining how to create a form window from scratch. I started by choosing File | New and then choosing one of the two indicated Window buttons:
Both bring up the following window:
I was curious about the R.I.D. tab, which looks just like the R.A.D tab except that the descriptive text says "The windows are created from the analysis of the project. The window must be programmed by the developer. The created windows mainly contain the controls as well as their file links."
More questions. But I have a tutorial to follow, so I created a blank window.Â
To populate fields onto the window I first opened the Analysis pane (Display | Toolbars | Panes | Analysis). I expanded the Persons file, selected all the fields...
... and dragged/dropped them onto the form.
There are two things I find interesting here. One is that as I'd entered one record in the Persons file prior to this step, that record shows up as data in my form. The other is that I discovered accidentally that I could also drag and drop fields into the work area around the form.Â
The link between the screen control and the data file is managed via the control's properties, on the Link tab:
This window mentions the ScreenToFile and FileToScreen library functions, which copy data between the file and the window.Â
But there's another option on this window that intrigues me - what is Multi-file binding?Â
If I choose that option I can add up to two more files in a linked list:
But how and when would I use this? I did a quick search but didn't find anything obviously helpful. Perhaps some reader can enlighten me.Â
In any case, at this point I was able to hit Go (for the window rather than the application) and see the window displayed. But I didn't yet have a way to save any data.Â
I created a new Add button and in its Click embed I wrote the following code:
ScreenToFile() HAdd(Person)
I hit the Go button again and got a pretty ugly form. Because I like to try to break things I decided to click on Add without entering any data, and got this window:
Apparently I already have one empty email address in my key. Still, it's interesting to see another of the standard error handling procedures.
Note that the PersonID has been incremented automatically. This is provisional; if I exit the program and attempt another add, the PersonID is still 2. So everything cleans up nicely on the database side.Â
Tomorrow, apparently, I'll start tidying up the form.Â
Â
Â
Â
Â