Day 002 - More controls and code completion
Yesterday I got part way through the Counter example in the tutorial, and one thing I noticed was that I wasn't getting my initial value of 12. I'd read too quickly and I'd put the text
EDT_Counter = 12
in the content field instead of simply
12
With that corrected, I'm now seeing the initial value both in design mode and when running the window.Â
To run the window I simply click on the Go button in the toolbar. But there are two Go buttons.Â
The Go button on the left runs just the current window; the one on the right runs the project. Or you can use the drop-list for other project launching options.
I tried running the project and I got this window:
This made me curious about my project settings. I know from earlier explorations that there's a project view that's much like the solution explorer in Clarion, but at first glance I didn't see it. And I couldn't find it in the menus. Eventually I located it on the toolbar:
This seems like an awfully cryptic way to get to something as important as a project explorer. But maybe I'm missing something, or maybe most devs prefer the dashboard. Anyway, here's the project explorer:
Right-clicking on the Project and choosing Project Description brings up the rapidly-becoming-familiar eight-tab properties window. And this is also where I can set the initial window (if I haven't already done so on running the project):
Back at my newly created window, the tutorial tells me to look at the spin control's code by right-clicking on the control and choosing Code.Â
This is fully editable source added along with the control. I can change it to something like this:
and now my counter increments by 5 and decrements by 2.
I now have two windows open - the code window and the designer window. There are buttons for those at the lower left corner of the editor pane.
Only when I switch batch to my WIN_Counter window, I discover a problem. Have I mentioned that I'm highly distractable? I'd forgotten that the last time I was looking at the window I discovered something called 3D mode.Â
I'm not entirely sure what it's good for, but it looks cool. Only how the heck do I get out of 3D mode? Esc doesn't work. But closing the window does, either via the button as above or via the window's close control.Â
Okay, back to the tutorial again! Which points out that being able to run the window with live code without having to run the entire program is a big advantage. And that makes me wonder how you handle situations where the window's code depends on some pre-existing data or passed parameters.Â
I resized the window and added a close button using a similar process to adding the spin control. Again, the control comes with some predetermined code, but this time bring up the code view shows something a little different:
Clicking on the Preset action link brings up this window:
Lots of interesting things to explore there. And this is emblematic of the WinDev way. If there's something you want to do, chances are it's built into the IDE already - there really isn't much of a third party market for WinDev because so much comes in the box. Available preset actions include everything from sending email and burning CDs to reading records.Â
Text controls
Next, a new window and a text control. There are a variety of input masks available:
I also changed the name of the control from "Text" to "First name" which meant the text didn't all fit. There's an automatic Resize on the context menu, or you can resize manually.Â
The tutorial then instructed me to add a button, which I'll use to pop up a messagebox with whatever I've typed into the entry field.Â
Previously I used the control drop-down to choose a specific kind of control. This time I clicked directly on the button itself.Â
There are rather a lot of controls available, and some like the calendar control don't have any options. You click on the toolbar button, then you click on the window to place the control. But even if there is a drop-down for specific kinds of that control, you can always just get the generic version as well.Â
Something I've noticed about WinDev controls. When you first drop them on the window there some things you can do only at first, but not after the control has been modified in some other way. For instance, the automatic renaming of variables as noted yesterday. Another is that if you click twice (not double, but twice) on the button after dropping it, and you change the text on the button, the button's label gets changed to BTN_thetextyoujusttyped. But after you've been in the button's properties, changing the text doesn't change the label (which is a good thing, as otherwise you'd break code every time you changed button text).Â
The next step was to add some code to the button. So I right-clicked, chose Code, and started typing under Click BTN_Display:
Code completion brings up a list of functions; pressing ( brings up the function wizard:
Â
And as I type I get code completion for the variable name:
This won't work until there's been at least one compile, which will happen if you save the window first.Â
That's it for today. Because of scheduling conflicts I don't anticipate an installment on Friday, but I'll be back on Monday.Â
Â
Â
Â