gettingstarted
[Top] [All Lists]

Re: New to REALbasic -- very basic example

To: Getting Started <gettingstarted at lists dot realsoftware dot com>
Subject: Re: New to REALbasic -- very basic example
From: John Kubie <jkubie at mac dot com>
Date: Sun, 31 Aug 2003 18:44:03 -0400
Sorry for the statictext error. Yes, two statictext controls are needed.

What I meant by eliminating the two lines is that, if you eliminate the two lines, the following two lines could be modified to directly work on the text properties of the editfields. The modified lines would be:

        statictext1.text=str(val(editfield1.text)*val(editfield2.text))
        statictext2.text=str(val(editfield1.text)/val(editfield2.text))

(no, I didn't check these to see if they work)

This is compressed, and hard to read, but should make sense to a basic programmer.

By the way, I think a very good practice exercise is to write a calculator program. I think writing a calculator was the first I came up with and I was very pleased with the result.

John Kubie

On Sunday, August 31, 2003, at 01:30  PM, whaler wrote:

I know that others have said most of this, but I think, for basic transition, three simple things are needed:

1) A pushbutton control's "action" combined with editfield contols should replace basic "input" statements. The user should know that editfield values (editfield.text) are stored as text and, for numbers, must be converted using the val() operation.

2) A pushbutton control's "action" combined with a statictext (or editfield) control should replace the 'print' statement. Again, if the internal variables are numbers, they must be converted to text before display. This is done with the str() operation. Access to a statictext or editfield is through it's text property, as in "StaticText1.text".

----------------

the following example has the action of a pushbutton perform both the "input" and "print" operations.

The pushbutton action gets values from the editfields and places its ouputs onto the static text (or editfield) control.

Make a window with 2 edtifield, controls, 1 statictext control and a pushbutton. (note, you can change the names of the controls in the development environment; the ones I've used are standard defaults).

The "action" method of a pushbutton is what happens when the button is pushed, and is the basic means of getting things to happen. To access the method, while in the development environment, double click the pushbutton. You will be in the editor of the pushbutton's action event.

 The "action" event of the pushbutton could be:

sub action()
        dim string1, string2 as string
        dim value1, value2 as integer

string1=editfield1.text // these two lines are not needed - the next lines could operate directly on editfield1.text and editfield2.text
        string2=editfield2.text

        value1=val(string1)*val(string2)
        value2=val(string1)/val(string2)

        statictext1.text=str(value1)
        statictext2.text=str(value2)
end sub

----
As a modest elaboration, the output could be a multiline editfield (an editfield with its multiline property set.)

The "output" operation would then be

editfield1.text= editfield1.text + chr(13) + str(value1) {or whatever is to be "printed"}

This would produce a scrolling ouput field, retaining its prior values; more like the "print" statements in basic. >>

I tried the example, and wound up a little confused.
I left out the two lines which were said to be not needed, but found that they were needed after all. Also, there was a need for TWO statictext controls, rather than the one stated in the example. I sincerely appreciate the efforts by the folks who are generous with their time, and I am VERY grateful for the help, but I'd like to suggest that examples be carefully checked for errors, because it is doubly difficult for newbies like me to figure out why something wouldn't work. Again, this suggestion is made with the greatest of reticence, because I certainly do not wish to have any of the kind souls who offer the much needed help to think that they are "speaking" to ungrateful critics. This is NOT the case.
Thanks again!

---
Unsubscribe or switch delivery mode:
<http://support.realsoftware.com/listmanager/>


---
Unsubscribe or switch delivery mode:
<http://support.realsoftware.com/listmanager/>

<Prev in Thread] Current Thread [Next in Thread>