Showing posts with label learn. Show all posts
Showing posts with label learn. Show all posts

Friday, January 2, 2009

Creating a Web Form - Lesson 2

Let's take the simple interactive hypotenuse calculator from the previous post and create a version of it that has a couple of fields and a button to do the computation:
[displayAll]
cls
print "Hypotenuse Calculator"
print
print "Length of side A: ";
textbox #sideA, a
print
print "Length of side B: ";
textbox #sideB, b
print
button #go, "Go!", [go]
print
if c > 0 then print "Length of side C: "; c
wait

[go]
a = #sideA value()
b = #sideB value()
c = sqr(a^2+b^2)
goto [displayAll]
The first part of the program clears the web page using the CLS statement. Then it adds labels and entry fields using the PRINT and TEXTBOX statements.

Then the BUTTON statement adds a button that will use the code at the [go] label to compute the length of the C side.

Notice the IF THEN statement after the BUTTON statment. If the length of C is greater than zero then that means we have computed at least once, so print the result on the web page.

Thursday, January 1, 2009

A Simple Interactive Web Application - Lesson 1

One thing that Run BASIC does better than most other web programming systems is interactive applications where a program asks the user for a piece of information at a time and produces answers as you go. This is the way a lot of non-web applications work but it is hard to create these kinds of apps using conventional web programming.

Here is Run BASIC source code for a simple web application that computes the length of a hypotenuse for a right triangle if the length of the other two sides are known.

[startHere]
print "Hypotenuse Calculator"
print

input "Length of side A"; a

input "Length of side B"; b

c = sqr(a^2+b^2)

print "Length of hypotenuse (side C) = "; c

print

input "Compute another (Y/N)"; yn$

if yn$ = "Y" or yn$ = "y" then

cls

goto [startHere]

end if

print "Goodbye."

end


If you're completely new to web programming you may not realize that the above code doesn't look like code for a web app. In fact it looks very much like code for a QBasic program. If you're an experienced web programmer you may be scratching your head because it looks too simplistic to be a web program, but it is a web program.

Run BASIC does its best to hide the hard stuff that most web programming systems force the programmer to deal with. If you really must use some special web development technique Run BASIC provides ways to do that too and we'll cover some of these in later posts. Most of the time it isn't necessary because Run BASIC does the heavy lifting for you.

Saturday, December 27, 2008

Web Programming without Web Programming

This blog will include short lessons that show how to do many different things in Run BASIC, a web programming so easy that it's fair to call it "Web Programming without Web Programming." I call it this because web programming is hard, but Run BASIC is not hard.