
RAPIDQ
Object orientated Programming Language
Created and Edited by Learron Ashton
Please check out http://rapidq.no-ip.org for FREE bannerless 150 MB Web hosting
Please note that Spelling mistake and omissions are NOT intentional and email me at the above address if there are any mistakes
Please also note that
ALL source code can be downloaded from the Tutorials Site and also can be
shipped for $
Let’s start of with a simple program, the famous
hello world application.
Enter this line into the
RapidQ Code Viewer
Go to the file menu and
choose save, save it as the filename helloworld.bas
From the run menu choose
run or simply hit F5 and you will see the following

Click on the OK button to
close the window
You will notice the Menu
bar of the top Program says helloworld, It will default to the Filename, we can
change this by adding the following line above the line we added before
application.title="Test Application" we see the following

We cannot see the whole
Title because it is too long for the Minimum size of a Form.
The only way to see the
whole title is to make the Test longer so change the following line
Showmessage “hello
world” to
Showmessage “ hello world
” notice how there are 10
blank spaces before and after the text hello world
Press F5 and you get the
following

The above is our first
application, save it and call it hello world app.bas
Go to the Window menu and
click Form1

and you will see the
following:

The above Window is what we
call a FORM, a FORM is something similar to a Piece of canvas, we can add
buttons and other controls to this form, of which we will do as we get along in
this book.
On the above form click the
Button button (I know I know) click on this
and click on the form somewhere like this

Click once on the button so
it looks like this ![]()
The left are the
properties of this Button, we will run through these on the Next page, each
property has an effect on the Button
On the Left hand side you
will see this

To change options click on the relevant option and you
will see of these The options are displayed in a list like above, to
select and option highlight it and left click it
these allow you to choose
from a list of options by clicking on the arrow like this:

If you select 4 –alright
you will see the following

As you can see the Button
has aligned itself to the right hand side and taken up the Whole height of the
form, of course you can resize any object by dragging the little black boxes as
shown below
![]()
Okay Now change the
property that says caption to say Hello world so it should look like the
Screen shot on the following page

Now before we proceed I
want to explain something.
On the right of the
Properties Tab is the Events Tab, (
)
events are actions that occurs when something is done, now different Objects
have different Events, for example the Button has the following Events:

If you select the Button
now, and click on the Events Tab

and click inside OnClick, a
appears, click on this and you will be
presented with the following:

The code inside here will
be executed when the button has an OnClick event, or a user Clicks on the
button
Inside this box enter the
following code
Click on the Code it button
![]()
and then save it as Hello
app2.bas
then Run the App (by
pressing F5), you should get, a screen like the one below

Click on the Button now and
you should get

This little dialog box came
up because we said in the box on the previous page Showmessage “Hello again
world” this told the program that when the button was pushed display this code.

ClS – this just clears the
screen in Console Applications, here I will briefly explain the two types of
applications RapidQ can do, GUI or Console, Console are DOS based applications,
they run in a window, 
Console Application
A GUI (Graphical user
Interface) Application is like the one(s) that you have been creating.
In a Console Application,
cls clears the screen and print displays text on the screen, Input allows a
user to input stuff, so let’s try out hand at a console application.
Click the new icon to open
up a new window, type the following
print "what is your sex"
Input sex$
if sex$="male" then
print "you are a male"
end if
if sex$="female" then
print "You are a female"
end if
sleep 5
I will explain the above
program:
The first line displays the
text “what is your sex”, the second line says wait for user input, and when
they do type something and press enter
it will be saved in the variable sex$, now I will explain variables.
Variables are like Post
boxes, they hold temporary information, so when you entered male the variable
sex$ also was male, the fact that it had a $ on the end means that Both text
and number can go into it, if it has a $ then it is called a String, a string is
anything that is encased in either “ marks or in NOT a number example
If we enter the following
lines
A$=”1+2”
Sleep 5
If we were to enter the
above, we would just get 1+2 on the screen, then a short delay of 5 seconds,
this can be good if you are wanting to display this equation, however if you
want to find the result we have to take it out of its string form,. Because
being a string it is NOT a number or equation t\for that matter.
Try this
a=1+2
print a
sleep 5
The above code displays 3,
this is Because a is NOT a string, it is still a variable though, and the print
a told RapidQ to print the result, so let’s recap about variables, pick the
strings from the below list:
Var1
Var$
Fish$
Rod$
Fumble
Trick$
The answer to the previous
Quiz was
Var$
Fish$
Rod$
Trick$
Because they ALL have the
$.
Back to the Program we ran
before
print "what is your sex"
Input sex$
if sex$="male" then
print "you are a male"
end if
if sex$="female" then
print "You are a female"
end if
sleep 5
The 3rd line
says if what the user enters and stores in the string variable sex$ equals male
(notice how male is in Quotation marks, this is so it is treated as a string)
then line 4 says print on the screen “you are male”.
Line 5 says end the if
statement, ALL if statements MUST be terminated, as soon as possible (with the
end if command) this is for two reasons:
1) – They can get VERY messy if you don’t
2) – You may actually end up ending the wrong if
statement
I will give you a demonstration
The following program
print "What’s your name (
input name$
if name$="
print "Thats good"
if name$<>"
end if
print "Not good"
end if
sleep 5

Would ask you for your
Name, when you entered
That’s good
Not good
This is because of BAD if
statement termination.
The correct syntax should
be
print "What’s your name (
input name$
if name$="
print "Thats good"
end if
if name$<>"
print "Not good"
end if
sleep 5
Not the above code, but the
code above that was saying if what the user entered was gary then print That’s
good and Print Not good then END the IF statement
Back to the Program
print "what is your sex"
Input sex$
if sex$="male" then
print "you are a male"
end if
if sex$="female" then
print "You are a female"
end if
sleep 5
If the user enters female as the sex then print on the screen You are a female
End the IF statement
The Sleep 5 just pauses the
Application for 5 seconds so you can see the outcome
Check out the
RQDOCS\console.html file
Okay lets make a useful
Application, lets make a database that will allow you to store information
about contacts, sort of like your Windows Address book!
Okay now design your form
similar to the one shown below
Clicking on the Edit button
and then click on the form
![]()
Now in there properties
area change the text here
![]()
Change the Text so that it
displays nothing (empty the text property)
Change the location of the
edit box by changing the left property to 50 and the top property to 30
![]()
![]()
Now do the same, place 3
more on the form, align the ALL to left 50 and top multiples of 30, 60, 90, 120
Click on the Label button
and position that at left 180 top 35
and 3 more at left 180 and
top at multiples of 36, 65, 95, 125
it should look like this

Change the caption properties
of the Labels to read:
Label1=Surname
Label2=First Name
Label3=Address
Label4=Phone Number

As you can see the Labels
aren’t quite wide enough, simple solution
![]()
Change the width of each to
100
The Updated form should
look like this

Add three button as shown
below by clicking on the Buttons Button and then arranging them with what ever dimensions
you want

Change their text to:
Cancel
<Back
Next >
So that it looks like this

Now click on the Cancel
Button and then click on the Events Tab of the Properties Area and select
![]()
Click the … button and you
will get

This is called the Event
handle window, in here enter
End This simply Ends the program if this button is
Clicked.
Click on OK to apply the
settings (you must Always click on OK to apply code settings).
Click on Button 2 “The one
with < Back written on it” and go to the properties tab and change the
enabled property to
0 – false
![]()
So the form should look
like this

The Disabled < Back
button now cannot be clicked.
Click on the Next >
button and go to the events tab and enter an event at OnClick (click on the …
button) and enter into the Event handle Box the following code (of which I will
explain)
DIM data as qfilestream
data.open("c:\data.txt",
65535)
data.writeline(edit1.text+"|"+edit2.text+"|"+edit3.text+"|"+edit4.text)
The above text is only a
portion of it so I will explain this first.
The DIM data as qfilestream
means basically set up the variable data as a file handler (this means
everything the data refers to will be the file)
data.open("c:\data.txt",
65535)
The above line means (using
the file handler data) data.open means open then file that data handler refers
to in this case c:\data.txt
The filename quoted in “”s
means this is the file to open, note you NEED to use the Full Resource locater
(RL) the part of the file that says ,65535 means to Create the file, the modes
are as bellows:
To create a file = 65535
To open a file for reading
ONLY = 0
To open a file for Writing
ONLY = 1
To Open a file for Read and
Write = 2
So if you are writing to or
reading from use 2, IMPORTANT NOTE When you use
mode 65535 be careful, next time you use this and you ask the file to be
created again (by using 65535) and the file already exists then you are going
to run into problems, if in a program you have a file created all the time then
you must delete the file prior to creating it!
data.writeline(edit1.text+"|"+edit2.text+"|"+edit3.text+"|"+edit4.text
The above line says write a
line of something to c:\data.txt.
So the above line says to
write edit1.text+"|"+edit2.text+"|"+edit3.text+"|"+edit4.text
to the data.txt.
The above line is saying
what ever is held in the edit filed edit1.text, edit2.text, edit3.text and
edit4.text to the data file.
![]()
Note in the above screen
shot I have added the line data.close
The above line tells RapidQ
to close the file with the handle of data (in this case c:\data.txt).
This then means that the
file is closed, you can now use the handle data and you don’t have to declare
it because it has already been declared in the line that we discussed ages ago DIM
data as qfilestream.
Now that we have the form
designed and the basics on the Code written, we have to do a few more little
things, we have to enable the Back button when the Next > button is clicked.
Add the code into the event
handler box under the line data.close
button2.enabled = 1
so when the Next >
button is clicked the button2 will become active, in this example this is the
back button, now we must give the illusion that the < Back button actually
does go back, with this we must click OK to accept the code in the
button1.click event handler, and then click on the < Back button click on
the events tab and open up an onclick event handler for the < Back button.
To open up the event
handler click on the back button
![]()
and then click on the
![]()
Then click on the onclick
event tab
![]()
now click on the … button ![]()
you will get the following

In here erase the line
above (this is put in automatically) and put the following text in
edit1.text=""
edit2.text=""
edit3.text=""
edit4.text=""
button2.enabled=0
The above line(s) say in
the edit1.text filed put nothing (clear it) do the same with edit2.text,
edit3.text and edit4.text.
When the four fields are
cleared then disable the < Back button again, the reason why we have done
the above code, is to give the appearance that the Back button has gone back to
the previous screen, which of course we know hasn’t happened.
Be very careful when ding
this with your programs, you will need to initialize ALL variables, for example
if we had a variable called tt in the code somewhere and ran the program like
this, the tt variable will still hold what ever it was holding when it was last
called, this can be particularly dangerous in loops, for example if we had a
loop that ran 100 times, then when the back button was Clicked, and we were
using tt to count the number of times, so when tt was the value of 100 it would
stop, we would be in trouble because tt is already set to 100 so the loop would
NOT run, so here's the first EXTEREMELY important rule
Always
reset variables, and before
They are
used ALWAYS set them
to their
starting value.
You should have the
following code, it is also in the code\app1 directory on the CDROM
' Copy and paste into your
program
DECLARE SUB Button1Click (Sender AS QBUTTON)
DECLARE SUB Button2Click (Sender AS QBUTTON)
DECLARE SUB Button3Click (Sender AS QBUTTON)
CREATE
Caption = "Form1"
Width = 428
Height = 293
Center
CREATE Label1 AS QLABEL
Caption = "Surname"
Left = 180
Top = 35
Width = 42
END CREATE
CREATE Label2 AS QLABEL
Caption = "Firstname"
Left = 180
Top = 65
Width = 45
END CREATE
CREATE Label3 AS QLABEL
Caption = "Address"
Left = 180
Top = 95
Width = 38
END CREATE
CREATE Label4 AS QLABEL
Caption = "Phone Number"
Left = 180
Top = 125
Width = 71
END CREATE
CREATE Edit1 AS QEDIT
Text = ""
Left = 50
Top = 30
END CREATE
CREATE Edit2 AS QEDIT
Text = ""
Left = 50
Top = 60
TabOrder = 1
END CREATE
CREATE Edit3 AS QEDIT
Text = ""
Left = 50
Top = 90
TabOrder = 2
END CREATE
CREATE Edit4 AS QEDIT
Text = ""
Left = 50
Top = 120
TabOrder = 3
END CREATE
CREATE Button1 AS QBUTTON
Caption = "Next >"
Left = 322
Top = 223
TabOrder = 4
OnClick = Button1Click
END CREATE
CREATE Button2 AS QBUTTON
Caption = "< Back"
Left = 234
Top = 223
Enabled = 0
TabOrder = 5
OnClick = Button2Click
END CREATE
CREATE Button3 AS QBUTTON
Caption = "Cancel"
Left = 18
Top = 223
TabOrder = 6
OnClick = Button3Click
END CREATE
END CREATE
'Insert your initialization
code here
Form.ShowModal
'--------- Subroutines
---------
SUB Button1Click (Sender AS QBUTTON)
DIM data as qfilestream
data.open("c:\data.txt",
65535)
data.writeline(edit1.text+"|"+edit2.text+"|"+edit3.text+"|"+edit4.text)
data.close
button2.enabled = 1
END SUB
SUB Button2Click (Sender AS QBUTTON)
edit1.text=""
edit2.text=""
edit3.text=""
edit4.text=""
button2.enabled=0
END SUB
SUB Button3Click (Sender AS QBUTTON)
end
END SUB