In this series
this series of
series of short
of short videos
short videos, we
we will look
will look at
look at topics
at topics for
topics for the
for the Power
the Power Basic
Power Basic console
Basic console compiler
Today we will
will look again
look again at
again at commands
at commands for
commands for the
for the console
This was our
was our application
our application at
application at the
at the end
the end of
end of the
of the last
the last video
We have created
have created a
created a console
a console application
console application which
application which displays
which displays information
displays information to
information to the
to the user
the user on
user on the
on the console
the console screen
As you will
you will see
will see from
see from the
from the start
the start of
start of the
of the code
the code, we
we have two
have two lines
two lines of
lines of code
of code at
code at the
at the beginning
the beginning which
beginning which define
which define two
define two constants
two constants, one
one for rows
for rows and
rows and one
and one for
one for columns
In the pb_main()
the pb_main() function
pb_main() function, we
we make a
make a call
a call to
call to a
to a prep
a prep screen
prep screen function
This one here
This prepares our
prepares our console
our console for
console for use
will see in
see in here
in here, we
we have a
have a command
a command which
command which sets
which sets the
sets the size
the size of
size of the
of the screen
the screen using
screen using the
using the con
the con virtual
con virtual command
So currently we're
currently we're set
we're set for
set for 25
for 25 rows
25 rows and
rows and 80
and 80 columns
80 columns, which
which is the
is the standard
the standard console
standard console size
The first thing
first thing we're
thing we're going
we're going to
going to do
to do today
do today is
today is to
is to increase
to increase the
increase the size
size of our
of our console
our console, to
to go up
go up to
up to 50
to 50 rows
50 rows and
rows and 100
and 100 columns
If we run
we run the
run the application
the application now
application now without
now without any
without any further
any further changes
further changes, we
we will see
will see it
see it displays
it displays quite
displays quite happily
quite happily, but
but you will
you will also
will also see
also see we
see we now
we now have
now have horizontal
have horizontal and
horizontal and vertical
and vertical scroll
vertical scroll bars
scroll bars, which
which allow us
allow us to
us to move
to move up
move up, and
and down, and
and left and
left and right
and right on
right on the
This allows you
allows you to
you to set
to set a
set a console
a console up
console up that
up that better
that better suits
better suits your
suits your application
your application, giving
giving you more
you more flexibility
more flexibility for
flexibility for what
for what you
what you can
you can use
can use the
use the console
the console compiler
console compiler for
The next thing
next thing we're
going to change
to change today
change today is
today is the
is the section
the section of
section of code
of code that
code that displays
that displays information
displays information on
information on the
on the screen
the screen to
screen to the
We have this
have this at
this at the
at the moment
the moment inside
moment inside a
inside a Do
a Do loop
going to take
to take this
take this section
this section of
of code and
code and move
and move it
move it into
it into its
into its own
its own function
own function, and
and we're going
going to call
to call that
call that function
that function display
function display screen
Having these lines
these lines of
of code in
code in its
in its own
own function will
function will make
will make our
make our PB
our PB main
PB main function
main function much
function much tidier
And here is
here is the
is the new
the new function
new function with
function with the
with the code
the code just
code just pasted
just pasted in
we clear our
clear our console
our console screen
console screen, we
we display the
display the headers
the headers, and
and we jump
we jump into
jump into the
into the Do
the Do loop
Do loop to
loop to display
to display the
display the data
the data on
data on screen
application now, we
see it behaves
it behaves exactly
behaves exactly as
exactly as it
as it did
it did before
It runs through
runs through the
through the loop
the loop, and
and at the
of the loop
the loop, it
it will terminate
will terminate the
terminate the application
Since we have
we have removed
have removed that
removed that code
that code from
code from our
from our PB
main function, there
there are some
are some declares
some declares at
declares at the
the beginning of
beginning of the
of the function
the function that
function that we
that we no
we no longer
no longer need
longer need, so
so we will
we will just
will just take
just take those
take those out
going to make
to make use
make use of
use of one
of one of
one of the
of the features
the features of
features of the
of the console
the console within
console within Power
within Power Basic
Power Basic, you
you have not
have not one
not one, but
but eight consoles
eight consoles available
consoles available, and
and we can
we can switch
can switch quite
switch quite easily
quite easily between
easily between each
between each console
Only one console
one console can
console can display
can display to
display to the
user on screen
on screen at
screen at any
at any one
any one time
one time, but
but having these
having these eight
these eight separate
eight separate consoles
separate consoles gives
consoles gives us
gives us a
us a great
a great deal
great deal of
deal of flexibility
of flexibility for
flexibility for how
for how our
how our application
our application operates
In the display
the display screen
display screen section
screen section, there's
there's a call
to a underlying
a underlying function
underlying function called
function called display
called display headers
This displays basically
displays basically a
basically a template
a template on
template on screen
on screen, which
which we can
we can use
can use later
use later on
These are the
are the headings
Power Basic, the
console compiler keeps
compiler keeps track
keeps track of
track of both
of both the
both the active
the active console
active console page
console page and
page and the
and the visible
the visible console
visible console page
It's important to
important to differentiate
to differentiate between
differentiate between these
between these two
The active page
active page is
page is the
is the page
the page that
page that your
that your commands
your commands will
commands will write
will write to
write to and
to and read
and read from
The visible page
visible page is
page that is
that is visible
is visible to
visible to the
And as you
as you can
you can guess
can guess, the
visible page does
page does not
does not necessarily
not necessarily have
necessarily have to
have to be
to be the
be the same
the same as
same as the
as the active
So within this
within this function
this function, we're
going to set
to set up
set up two
up two local
two local variables
local variables, one
one to keep
to keep track
keep track of
track of the
of the active
active page and
page and one
and one to
of the visible
visible page for
page for our
for our console
And I'm going
I'm going to
going to add
to add another
add another local
another local variable
local variable called
variable called status
This is going
is going to
going to be
to be a
be a static
a static variable
I intend to
intend to use
to use one
use one of
the console pages
console pages as
pages as a
as a template
a template so
template so that
so that when
that when the
when the application
the application runs
application runs, it
it will create
will create a
create a template
template on the
on the eighth
the eighth console
eighth console page
That will be
will be used
be used as
used as a
a template to
template to copy
to copy into
copy into any
into any of
any of the
of the other
the other pages
other pages we
pages we wish
we wish to
wish to use
you only have
only have to
have to create
to create this
create this template
this template once
And a single
a single line
single line of
line of code
of code can
code can be
can be used
be used to
used to copy
to copy that
copy that eighth
that eighth console
console page to
page to any
to any other
any other page
other page of
page of the
And our status
our status variable
status variable is
variable is going
to be used
used to determine
to determine whether
determine whether we
whether we have
we have or
have or haven't
or haven't yet
haven't yet created
yet created that
created that template
So we're going
use of two
of two additional
two additional console
additional console commands
Con page active
page active, which
which can be
to determine what
determine what is
what is the
is the active
active page, and
and con page
con page visible
page visible to
visible to determine
to determine which
determine which is
These will populate
will populate these
populate these two
these two variables
two variables, which
we can then
can then test
Testing the value
the value within
value within our
within our status
status variable will
variable will determine
will determine whether
determine whether the
whether the template
the template has
template has already
has already been
already been created
been created or
created or not
If the template
been created, we're
going to use
to use a
use a con
a con pcopy
con pcopy command
This will copy
will copy from
copy from one
from one console
one console window
console window to
window to another
going to create
to create a
create a new
a new constant
new constant in
constant in a
in a moment
a moment to
moment to hold
to hold the
hold the value
the value 8
will be template
be template page
So with this
with this single
this single line
of code, we
we are copying
are copying the
copying the eighth
eighth console to
console to the
to the currently
the currently active
currently active console
And in order
in order to
order to determine
determine which console
which console page
console page we're
page we're actually
we're actually on
actually on, let's
let's print something
print something to
something to the
to the screen
the screen so
screen so the
so the user
the user can
user can quite
can quite easily
quite easily see
easily see which
see which console
console page is
page is in
is in use
we will set
will set the
set the location
the location to
location to print
to print to
print to row
to row 1
row 1, column
column 2, and
and we'll call
we'll call the
call the print
the print function
print function we
function we created
we created in
created in the
in the last
This to print
to print the
print the visible
visible page number
page number to
number to the
to the top
the top of
top of the
of the page
the page, in
in the cyan
the cyan colour
And once that
once that has
that has completed
has completed, we
can then exit
then exit the
exit the function
If the status
the status variable
variable is false
is false, it
it means our
means our template
our template has
template has not
has not yet
not yet been
yet been created
So we can
use the code
the code that's
code that's about
that's about to
about to follow
to follow this
follow this to
this to create
to create our
create our standard
our standard template
set the status
status variable to
variable to the
to the value
the value true
And all the
all the code
the code after
code after that
after that we
that we need
we need not
need not change
This will print
will print to
print to whatever
to whatever the
whatever the active
console page actually
page actually is
So at the
end of this
of this function
this function, we
we will copy
will copy the
copy the active
active page back
page back to
back to the
to the template
Before we run
we run an
run an application
an application, we'll
we'll need to
need to create
create this new
this new constant
new constant, this
this template page
template page constant
page constant at
constant at the
beginning of our
of our application
And we'll set
we'll set that
set that to
that to the
So we'll be
we'll be using
be using the
using the eighth
console page as
page as our
as our template
So with the
with the page
the page number
page number now
number now displayed
now displayed at
displayed at the
our console page
console page, we
we can now
can now try
now try running
try running an
running an application
an application to
application to see
to see how
see how it
how it performs
And there we
there we have
we have page
have page 1
page 1 at
1 at the
at the top
So now that
now that we
that we have
have this multiple
this multiple console
multiple console ability
console ability set
ability set up
set up within
up within our
within our application
our application, how
how can we
can we make
we make use
use of it?
of it? So
it? So let's
So let's go
let's go back
go back to
back to our
to our pb_main
our pb_main function
In our pb_main
pb_main function, we
we prepare the
prepare the screen
the screen and
screen and we
and we display
display the screen
what we're going
to do is
do is we're
is we're going
use of the
of the con
the con scroll
con scroll commands
you to scroll
to scroll up
scroll up, down
Scrolling up on
up on the
the console will
console will move
will move the
move the text
the text effectively
text effectively downwards
So I will
I will put
will put a
put a waitkey
a waitkey command
waitkey command after
command after that
after that so
that so we
we can still
can still see
still see it
see it on
it on the
the screen after
screen after the
after the application
the application completes
application completes that
completes that command
display the information
the information to
the user and
user and once
and once that's
once that's complete
that's complete, the
the console scrolls
console scrolls down
scrolls down by
down by 10
by 10 rows
you to move
to move information
move information around
information around on
around on the
the console, effectively
effectively creating a
creating a blank
a blank area
blank area to
area to which
to which you
which you can
you can then
can then write
Even if that
if that area
that area is
area is above
is above information
above information already
information already committed
already committed to
committed to the
to the console
going to get
to get a
get a little
a little interactive
little interactive with
interactive with the
with the console
the console here
to create three
create three new
three new local
new local variables
One for input
for input, one
one for page
for page, both
both string and
string and number
to be using
be using a
using a Do
Do loop here
we will first
will first position
first position the
position the cursor
the cursor at
cursor at row
at row 2
row 2, column
set the colour
the colour to
colour to black
to black with
black with a
with a white
a white background
And we will
we will use
will use the
use the con
the con input
con input command
input command to
command to prompt
to prompt the
prompt the user
the user for
user for a
for a response
So giving the
giving the text
the text, do
do you wish
you wish to
wish to exit
to exit yes
exit yes or
yes or no?
or no? And
no? And whatever
And whatever the
whatever the user
the user types
user types and
types and then
and then presses
then presses enter
presses enter, we
we will store
will store into
store into the
into the input
the input variable
you to get
to get interactive
get interactive with
interactive with your
with your user
then test the
test the value
the value of
value of that
of that input
that input variable
I'm forcing the
forcing the input
input variable to
variable to uppercase
to uppercase to
uppercase to test
to test to
test to see
to see if
see if the
if the word
the word yes
word yes has
yes has been
has been given
If it has
it has, we're
we're then exiting
then exiting our
exiting our loop
If we're not
we're not exiting
not exiting the
exiting the loop
the loop, I'm
going to ask
to ask the
ask the user
the user to
user to select
to select which
select which page
which page of
the console they
console they actually
they actually wish
And we'll limit
we'll limit the
limit the user
user to either
to either page
either page 1
page 1 or
1 or page
or page 2
Again using the
to prompt them
prompt them for
them for an
for an input
And we'll store
we'll store that
store that in
that in a
in a string
a string variable
string variable called
variable called page
can then transfer
then transfer the
transfer the value
the value in
value in that
in that string
that string variable
string variable to
variable to a
to a numeric
a numeric variable
numeric variable using
variable using the
using the VAL
the VAL command
And we're then
we're then testing
then testing the
of that page
that page variable
page variable to
variable to see
see if it's
if it's either
it's either value
either value 1
value 1 or
1 or 2
We're then setting
then setting the
setting the visible
the visible and
visible and the
and the active
the active pages
active pages using
pages using the
the con page
page visible and
visible and con
page active commands
While we're setting
we're setting both
setting both the
both the visible
the active consoles
active consoles to
consoles to the
to the same
the same value
same value, you
can use these
use these functions
these functions to
functions to set
to set them
set them to
them to different
to different values
different values if
values if you
if you have
you have different
have different functionality
different functionality in
functionality in mind
Now that we've
that we've prompted
we've prompted a
prompted a user
a user for
user for another
for another console
another console number
console number, we
can then re-display
then re-display the
re-display the screen
the user using
user using our
using our existing
our existing display
existing display screen
display screen function
We're resetting the
resetting the color
the color back
color back to
back to green
to green with
green with a
with a black
a black background
black background and
background and calling
and calling display
calling display screen
And then scrolling
then scrolling up
scrolling up 10
up 10 lines
10 lines, as
as we did
we did earlier
So once we
once we exit
we exit this
exit this loop
this loop, we
can then, for
for the purposes
the purposes of
purposes of this
of this application
this application, re-display
re-display each of
each of the
console pages to
pages to the
For example pages
example pages 1
pages 1 and
1 and pages
and pages 2
order to do
to do this
do this, all
all I need
I need to
need to do
do is to
is to use
to use the
page visible command
visible command to
command to set
to set it
set it to
it to the
to the page
the page I
page I wish
And then we're
then we're using
we're using a
using a waitkey
waitkey command to
command to allow
to allow it
allow it to
it to remain
to remain on
remain on screen
on screen so
screen so we
we can see
can see it
see it before
it before going
before going to
going to the
to the next
the next console
next console page
So let's try
let's try running
try running our
running our application
our application now
application now and
now and see
and see how
how it goes
So the application
application runs and
runs and we're
and we're displaying
we're displaying the
displaying the information
the information on
information on page
on page 1
page 1 to
1 to the
Once this is
this is completed
is completed, we
we scroll down
scroll down 10
down 10 lines
10 lines and
lines and we
and we prompt
we prompt the
user to see
to see whether
see whether they
whether they wish
they wish to
yes or no
So in this
in this case
this case, let's
let's put the
put the value
the value no
value no in
no in and
in and press
and press the
press the enter
the enter button
It's now asking
now asking which
asking which console
console page we
page we actually
we actually want
We know we're
know we're on
we're on console
on console page
console page 1
page 1, so
so let's pick
let's pick console
pick console page
console page 2
And it's now
it's now displaying
now displaying console
displaying console page
page 2 to
2 to the
And once this
once this has
this has completed
has completed, it
it will again
will again scroll
again scroll down
scroll down another
down another 10
another 10 lines
lines and ask
and ask if
ask if you
if you wish
this case, we'll
we'll say yes
What it has
it has now
has now done
now done is
done is it's
is it's re-displayed
it's re-displayed to
re-displayed to us
to us what
us what was
what was on
was on page
page 1, as
you can see
can see from
from the screen
The last data
last data appearing
data appearing on
appearing on page
page 1 is
1 is now
is now visible
now visible, including
including the two
the two prompts
two prompts at
prompts at the
the console page
We're now sitting
now sitting on
sitting on the
on the wait
the wait key
wait key command
If we press
we press the
enter button, it
it will now
will now show
now show us
show us what
what was in
was in page
in page 2
And if we
if we hit
we hit the
hit the enter
enter button once
button once more
once more, the
the application will
application will complete
So in summary
in summary, what
what we've done
we've done today
done today is
today is we
is we have
we have extended
have extended our
extended our console
our console beyond
console beyond the
beyond the allowing
the allowing us
allowing us to
us to have
to have scroll
have scroll bars
scroll bars, vertical
vertical and horizontal
we have taken
have taken information
taken information on
information on our
on our console
console screen and
screen and saved
and saved it
saved it to
it to a
to a template
a template console
template console screen
And as the
as the console
the console has
console has 8
has 8 screens
8 screens within
screens within Power
Power Basic, we
use these quite
these quite easily
quite easily to
easily to switch
to switch between
switch between them
between them, using
using the visible
visible and active
and active commands
We have displayed
have displayed information
displayed information on
on the first
the first page
first page to
page to the
user and asked
and asked them
asked them whether
them whether they
wish to continue
If they say
they say yes
say yes, we're
we're allowing them
allowing them to
them to pick
to pick another
pick another console
another console page
this has been
has been completed
been completed, when
when the user
the user decides
user decides they
decides they wish
to exit, then
then we're showing
we're showing each
showing each page
each page to
The ability to
ability to have
to have 8
have 8 console
8 console pages
console pages and
pages and to
and to allow
to allow the
allow the user
user to switch
between them, and
and also to
also to copy
to copy information
copy information from
information from one
from one to
one to the
to the other
the other, gives
gives you a
you a great
of flexibility in
flexibility in your
in your console
your console applications
Hopefully you'll find
you'll find this
find this useful
this useful in
useful in your
in your own
your own applications
own applications, but
but that's it
that's it for
it for today
Thank you for
you for watching.
Welcome! In this
series of videos
of videos we
videos we will
we will cover
will cover the
cover the design
the design and
design and implementation
and implementation of
implementation of a
of a project
a project, from
from initial design
initial design through
design through coding
through coding and
coding and development
and development to
development to testing
to testing, using
using the Power
Power Basic Windows
Basic Windows Compiler
we will continue
will continue our
continue our project
our project to
project to create
create our own
our own web
own web browser
web browser, by
by completing the
completing the work
the work on
work on text
on text hyperlinks
text hyperlinks and
hyperlinks and adding
and adding support
adding support for
support for the
for the underline
the underline tag
was our project
our project at
project at the
have a light
a light browser
light browser which
browser which allows
which allows us
allows us to
us to drag
to drag HTML
drag HTML pages
HTML pages onto
pages onto the
onto the browser
This then displays
then displays our
displays our HTML
our HTML page
HTML page to
the user, and
if we click
we click on
click on any
on any one
any one of
of the image
the image hyperlinks
image hyperlinks, it
it will take
will take us
take us in
us in to
in to the
the next page
next page, including
including the display
the display of
display of graphics
We also have
also have headers
have headers and
headers and text
and text which
text which is
which is paragraphed
is paragraphed, and
and we have
have a text
a text URL
text URL at
URL at the
at the bottom
the bottom of
bottom of our
of our index
our index page
the moment this
moment this text
this text URL
text URL is
URL is not
is not underlined
not underlined, which
which is more
is more or
more or less
or less the
less the standard
the standard for
standard for all
for all text
all text URLs
That's what we're
going to tackle
to tackle today
tackle today, is
is the underlining
the underlining of
underlining of text
of text hyperlinks
hyperlinks and the
and the use
the use of
of the underline
underline tag in
tag in HTML
in HTML can
HTML can be
used to mark
to mark a
mark a section
a section of
section of text
of text as
text as being
as being underlined
underline tag is
tag is usually
is usually discouraged
usually discouraged, as
as it can
it can confuse
can confuse users
confuse users to
users to think
to think that
think that a
that a piece
a piece of
piece of text
of text is
text is underlined
is underlined is
underlined is a
is a hyperlink
it's still supported
still supported within
supported within HTML
within HTML, so
let's go and
go and have
and have a
have a look
a look at
look at our
at our code
our code to
code to see
to see what
see what we
what we can
we can do
can do to
do to achieve
to achieve this
have two globals
two globals at
globals at the
of our code
our code, one
one for the
for the default
the default font
default font and
font and one
one to contain
to contain the
contain the handles
the handles for
handles for the
for the array
the array of
array of fonts
of fonts we
fonts we are
we are using
to add two
add two more
two more globals
more globals to
globals to this
to this list
this list, one
the default underline
default underline font
underline font and
one for an
for an array
an array of
array of underline
of underline fonts
This will allow
will allow us
us to maintain
to maintain an
maintain an array
underline fonts, which
can use at
use at any
at any point
any point in
point in the
in the application
you can probably
can probably guess
probably guess, we're
going to have
to have to
to create and
create and also
and also destroy
also destroy fonts
destroy fonts when
fonts when the
when the program
the program starts
program starts and
starts and when
and when the
the program ends
have two functions
two functions which
functions which perform
which perform these
perform these functions
these functions, one
one called create
called create fonts
create fonts and
fonts and one
and one called
one called unload
called unload fonts
let's go to
go to the
to the create
the create fonts
create fonts function
fonts function first
we are re-dimensioning
are re-dimensioning our
re-dimensioning our array
our array as
array as having
as having six
having six elements
to add a
add a command
a command to
command to do
to do the
do the same
the same for
same for our
for our underline
our underline fonts
It allows us
us to store
to store the
store the handles
handles for each
for each font
as we have
we have six
have six normal
six normal fonts
normal fonts, we're
to have six
have six fonts
six fonts of
fonts of the
of the same
the same size
same size, but
but set for
set for underline
we've added a
added a font
a font new
font new command
new command to
command to create
create our default
our default font
default font, which
which in this
this case is
case is set
is set for
set for option
for option five
option five, which
which will allow
to have bold
have bold underline
And in our
in our for
our for next
for next loop
next loop, where
where we created
we created the
created the six
the six fonts
six fonts, we're
we're creating six
creating six additional
six additional fonts
additional fonts, but
but this time
this time set
time set with
set with the
with the underline
the underline flag
that we've created
we've created our
created our fonts
our fonts, we
also have to
have to unload
to unload the
unload the fonts
the fonts when
if we have
look at the
at the unload
the unload fonts
unload fonts function
fonts function, it
it will quite
will quite simply
quite simply need
simply need two
need two font
two font end
font end commands
end commands, one
one to end
to end the
end the default
to end each
end each of
of the fonts
the fonts referenced
fonts referenced in
referenced in our
in our global
our global array
now we need
we need to
need to handle
to handle the
handle the underline
underline tag when
tag when we
when we get
we get to
get to the
to the render
the render the
render the HTML
the HTML tags
This is our
is our tagging
our tagging engine
go to that
to that function
that function and
function and make
and make the
make the necessary
the necessary changes
end of our
of our select
our select statement
select statement, we're
going to put
to put two
put two more
two more case
more case statements
case statements in
statements in, one
one to handle
handle the beginning
the beginning underline
beginning underline tag
underline tag and
tag and one
handle the end
if we are
we are starting
are starting an
starting an underline
an underline section
underline section of
section of the
of the HTML
the HTML document
HTML document, we
need to set
to set our
set our graphic
our graphic font
graphic font to
font to the
to the default
can do that
do that using
that using the
using the graphic
the graphic set
graphic set font
set font command
font command, using
using our global
our global variable
global variable for
variable for the
the underline bold
underline bold handle
we can pick
can pick up
pick up the
up the data
the data after
data after the
after the underline
underline tag by
tag by using
by using the
using the function
the function we
created in our
in our previous
our previous video
previous video, the
the get tag
get tag value
tag value, giving
giving the long
the long start
long start variable
start variable and
variable and the
and the underline
the underline end
underline end tag
And then we
then we can
we can go
can go to
to the print
the print data
print data statement
data statement, which
which will print
will print our
print our data
our data to
data to the
And with the
with the end
the end underline
end underline tag
underline tag, we
we can reset
can reset the
reset the font
the font back
font back to
to the global
the global handle
global handle of
handle of the
of the default
order to test
see how far
how far we've
far we've got
we've got with
got with the
need to make
to make a
make a change
a change to
change to one
to one of
one of our
of our web
our web pages
going to amend
to amend the
amend the index
the index to
index to HTML
to HTML document
beneath the section
the section which
section which is
which is going
to be hyperlinked
be hyperlinked, we
have a new
a new paragraph
new paragraph, which
which is a
is a test
a test for
test for our
we have the
have the word
the word 'test'
word 'test' and
'test' and a
and a piece
of text after
text after that
after that, which
which is not
is not going
not going to
to be underlined
let's run our
run our application
our application and
application and copy
and copy in
copy in this
in this HTML
this HTML document
we have partially
have partially achieved
partially achieved our
achieved our objective
We do have
do have the
word 'test' marked
'test' marked 'underlined'
the tag is
tag is still
is still visible
still visible on
visible on the
and we don't
we don't have
don't have the
have the words
the words 'and
words 'and not
'and not underlined'
not underlined' after
underlined' after the
after the underlined
the underlined 'test'
underlined 'test' text
there is more
is more to
more to do
We'll need now
need now to
now to have
to have a
at the print
print function, which
which prints data
prints data to
data to our
to our graphics
our graphics control
to the code
we handle all
handle all the
all the text
the text that
text that has
that has to
has to be
to be printed
be printed on
printed on the
on the HTML
the HTML page
HTML page for
page for the
for the user
and our underlined
our underlined tags
underlined tags are
tags are, in
in fact, embedded
have a section
section of this
of this code
this code which
code which currently
which currently handles
currently handles embedded
handles embedded links
need to expand
to expand on
expand on that
Here is a
is a section
code that tests
that tests for
tests for an
for an embedded
an embedded link
we're currently looking
currently looking for
looking for the
for the href
the href equals
href equals text
equals text to
text to determine
determine whether this
whether this is
this is a
is a URL
a URL, and
and if so
if so, we
we are setting
are setting positions
setting positions and
positions and exiting
and exiting the
exiting the function
the function, so
so we do
we do not
do not actually
not actually print
actually print that
print that data
And now, we're
we're also testing
also testing for
testing for the
for the underlined
the underlined tag
If it's an
it's an embedded
an embedded underlined
embedded underlined tag
underlined tag, we're
we're exiting the
do not print
try running it
running it again
it again and
again and see
and see what
what we get
we get this
get this time
And now it's
now it's looking
it's looking slightly
looking slightly better
We're getting the
getting the word
word 'test' underlined
'test' underlined, but
but we're missing
we're missing the
missing the text
the text after
there's a little
a little more
little more to
to do, but
but at least
at least we're
least we're no
we're no longer
no longer getting
longer getting the
getting the underlined
the underlined tags
underlined tags printed
tags printed on
on the dialog
So again, back
to our code
when you're developing
you're developing applications
developing applications, you'll
you'll find you
find you may
you may have
may have to
have to go
to go through
go through a
through a great
a great number
great number of
number of iterations
of iterations to
iterations to edge
to edge towards
edge towards the
towards the eventual
the eventual application
eventual application that
application that you
that you wish
This is quite
is quite normal
quite normal in
normal in development
in development when
development when you're
when you're working
you're working on
working on something
on something you've
something you've never
you've never done
never done before
while we're in
we're in this
in this function
to add the
add the color
the color and
color and the
the underline to
underline to our
to our hyperlinks
If the ref
the ref tag
ref tag is
tag is true
is true and
true and our
and our strDataViable
our strDataViable is
strDataViable is populated
is populated, then
then we know
we know this
know this is
is a hot
a hot zone
be a URL
all we really
we really need
really need to
is to add
to add color
add color to
color to the
to the foreground
the foreground and
foreground and background
and background of
background of our
of our font
our font and
font and set
and set the
set the font
the font to
font to be
with our simple
our simple two
simple two commands
two commands, we
we should have
should have now
have now handled
now handled the
handled the underlining
underlining of our
of our hyperlinks
and see if
see if we've
if we've achieved
we've achieved that
there we do
do have a
have a go-to
a go-to page
go-to page 5
page 5, which
which if we
click on it
on it, will
take us to
us to page
to page 5
we've achieved the
achieved the coloring
the coloring and
coloring and the
and the underlining
underlining of a
of a text
a text hyperlink
you can now
can now see
now see the
see the confusion
the confusion that
confusion that using
using the underline
underline tag can
tag can give
can give to
give to a
to a user
have two pieces
two pieces of
pieces of text
of text, one
one saying go
saying go to
go to page
which is indeed
is indeed a
indeed a hyperlink
As we can
can see, if
if we move
we move the
move the mouse
the mouse over
mouse over, it
it changes to
changes to the
to the hand
the hand symbol
But the word
word 'test', which
which is also
is also underlined
also underlined, is
is not a
not a hyperlink
But to a
a user, it
it could give
could give the
give the illusion
the illusion that
illusion that it
that it is
it is a
tag is now
is now discouraged
The one piece
one piece of
piece of functionality
of functionality we
functionality we still
we still have
still have to
have to have
to have on
have on the
the screen is
screen is to
is to have
to have the
have the text
text after the
after the ending
the ending of
ending of the
will see, we
not underlined', which
which follows the
follows the word
the code to
see if we
if we can
we can tidy
can tidy that
tidy that up
this function, there
there is a
is a piece
piece of code
of code which
code which handles
which handles where
handles where there
where there is
of text with
text with no
with no line
no line breaks
need to check
to check in
check in this
in this section
this section to
section to see
see whether this
is a reference
a reference tag
And if it
if it is
it is true
is true a
true a reference
reference tag, we
need to reset
to reset the
reset the default
font and color
This is done
is done quite
done quite easily
quite easily using
easily using these
using these two
these two commands
two commands again
The graphic color
graphic color command
color command to
to set the
set the foreground
the foreground back
foreground back to
back to black
to black and
black and the
and the background
the background to
background to white
And to set
there are a
are a couple
a couple more
couple more changes
more changes we'll
changes we'll need
to make to
make to this
to this code
this code to
code to fully
to fully support
fully support the
support the underline
to the end
the underline, we
to check to
check to see
see if we're
if we're actually
we're actually inside
actually inside a
inside a paragraph
a paragraph or
paragraph or not
can do this
do this by
this by testing
by testing the
testing the 'inParagraph'
the 'inParagraph' variable
If that's true
that's true, then
then we are
we are indeed
are indeed inside
indeed inside a
there may well
may well be
well be some
be some text
some text still
text still to
still to print
can pick that
pick that up
that up using
up using the
using the 'getTag'
the 'getTag' value
'getTag' value, looking
for the end
of the paragraph
the paragraph tag
And then calling
then calling the
calling the 'printData'
the 'printData' function
'printData' function to
function to print
to print that
print that out
try running that
running that now
that now to
now to see
if we've got
we've got our
got our extra
our extra text
extra text now
we're edging closer
We do actually
do actually have
actually have the
have the extra
the extra text
extra text, but
but it's on
it's on the
on the next
the next line
next line down
it's treating the
treating the text
the underline 'endingTag'
underline 'endingTag' as
'endingTag' as a
as a new
a new line
new line of
line of data
the code and
code and sort
and sort that
sort that out
at the 'printData'
'printData' function, we'll
we'll see there's
see there's a
there's a graphic
a graphic print
graphic print statement
print statement which
statement which is
which is doing
is doing two
doing two things
It's trimming the
trimming the data
the data, which
which will mean
will mean taking
mean taking the
taking the leading
the leading spaces
leading spaces off
spaces off the
off the end
of the string
the string, which
which we do
do not in
not in fact
in fact want
And it's also
it's also missing
also missing a
missing a semicolon
a semicolon in
semicolon in the
in the end
the end means
end means we
means we will
we will not
will not automatically
not automatically move
automatically move down
move down to
down to the
that should in
should in theory
in theory fix
theory fix this
fix this problem
it has fixed
has fixed one
fixed one problem
one problem, but
but it has
it has actually
has actually introduced
actually introduced another
introduced another one
It's not picking
not picking up
picking up the
up the start
start of paragraphs
need to go
to go back
code and fix
and fix that
a new function
new function which
function which we
we can call
can call from
call from different
from different parts
different parts of
parts of the
of the application
We'll call this
call this function
this function 'printBlankLine'
function 'printBlankLine' and
'printBlankLine' and its
and its job
its job will
job will be
will be to
be to move
to move the
the text down
text down to
the next available
next available line
here is our
is our new
our new 'printBlankData'
new 'printBlankData' function
It has always
has always three
always three commands
three commands –
commands – one
– one to
one to set
set the position
the position of
position of the
of the x
the x and
x and y
and y global
y global coordinates
global coordinates, one
one to print
to print a
print a line
a line with
line with nothing
with nothing in
nothing in it
in it, and
and a second
a second to
second to get
to get the
get the new
the new position
need to call
to call this
call this new
this new function
new function from
function from within
from within the
within the 'renderHTMLTags'
the 'renderHTMLTags' function
And we're now
we're now going
now going to
going to look
to look for
look for the
have the call
the call to
call to our
to our new
our new function
new function to
print a blank
a blank line
have we now
we now done
now done enough
done enough to
enough to make
to make our
make our HTML
our HTML document
HTML document properly
document properly shown
properly shown on
shown on screen?
on screen? If
screen? If we
If we bring
we bring in
bring in our
in our index2
our index2 document
index2 document, and
can see that
see that the
that the problem
the problem we
problem we had
we had with
had with the
underline tag has
tag has now
has now been
now been resolved
have the link
the link to
link to go
to go to
page 5, we
have the underline
the underline text
underline text which
which is 'test'
is 'test', and
and the remainder
the remainder of
remainder of the
of the line
the line is
line is showing
is showing as
showing as not
as not being
not being underlined
And we still
still have operational
have operational links
operational links to
links to each
to each of
of the pages
it's always a
always a good
a good idea
good idea to
idea to compare
to compare our
compare our browser
our browser with
browser with a
with a standard
a standard browser
if we double-click
we double-click on
double-click on our
on our index2
index2 document and
document and bring
and bring up
bring up a
up a Chrome
a Chrome browser
Chrome browser, and
if we compare
we compare that
compare that with
that with our
with our browser
our browser, we'll
we'll see we're
see we're fairly
we're fairly close
We're missing an
missing an extra
an extra line
extra line at
line at the
end of each
of each of
of the sections
the sections of
sections of text
of text where
text where the
where the paragraphs
the paragraphs are
paragraphs are, but
but apart from
apart from that
from that, we're
the solution for
solution for our
for our problem
our problem printing
problem printing seems
printing seems to
seems to have
to have been
have been caused
been caused by
caused by this
by this graphics
this graphics print
graphics print statement
While this is
this is actually
is actually putting
actually putting the
putting the cursor
the cursor down
cursor down to
available line, it's
it's not resetting
not resetting the
resetting the global
the global coordinates
global coordinates for
coordinates for X
for X and
take this line
this line of
of code out
code out completely
out completely, and
and I've put
I've put an
put an additional
an additional print-blind
additional print-blind line
print-blind line up
line up here
a section which
section which handles
which handles text
handles text which
is not an
not an image
if we try
we try running
an application now
application now, hopefully
hopefully this should
this should fix
should fix the
fix the problem
And indeed, we
have the paragraphs
the paragraphs quite
paragraphs quite correctly
quite correctly for
correctly for the
for the text
the text, and
and we appear
we appear to
appear to have
to have it
have it for
it for the
for the images
the images as
images as well
compare that against
that against a
against a standard
standard browser, we
can see our
see our text
our text is
text is appearing
is appearing more
appearing more or
or less exactly
less exactly where
exactly where it
where it should
We have each
have each of
of the images
the images which
images which have
which have embedded
have embedded links
have the URL
the URL, which
is a text
text URL, and
we have underline
have underline and
underline and non-underline
and non-underline text
non-underline text within
text within the
within the same
the same paragraph
we have added
have added support
added support for
we have amended
have amended the
amended the text
the text URLs
text URLs to
URLs to be
to be displayed
be displayed in
displayed in blue
in blue and
blue and with
and with an
with an underline
an underline, making
making it more
it more obvious
more obvious to
obvious to the
the user that
user that this
that this is
this is indeed
indeed a URL
obviously there is
is a great
great deal more
deal more to
to do in
do in our
in our browser
the purpose of
purpose of this
of this project
this project is
project is to
is to cover
to cover areas
cover areas of
areas of Power
of Power Basic
Power Basic that
Basic that we
that we may
we may never
may never have
never have covered
have covered before
covered before, allowing
us to pick
to pick up
pick up new
up new skills
Welcome to an
to an update
an update for
update for the
Power Basic for
Basic for Beginners
for Beginners YouTube
Beginners YouTube channel
We have recently
have recently gained
recently gained a
gained a few
a few new
few new subscribers
new subscribers to
subscribers to the
to the channel
the channel and
channel and as
and as it's
as it's some
it's some time
some time since
time since our
since our last
our last update
last update then
update then this
then this short
this short video
short video should
video should provide
should provide some
provide some useful
some useful information
useful information to
information to assist
to assist you
assist you in
you in getting
in getting the
getting the most
the most from
most from the
from the channel
can see we're
see we're now
we're now on
now on the
on the Power
There are currently
are currently 426
currently 426 videos
426 videos on
videos on this
on this channel
this channel, covering
covering many topics
many topics on
topics on both
on both the
both the Power
Basic Windows and
Windows and Console
and Console Compilers
click on the
on the More
the More section
More section here
section here, we
see that source
that source files
source files for
files for these
for these projects
these projects are
projects are available
are available on
available on an
on an external
an external website
external website, this
one here, the
the GSF Software
GSF Software website
If we go
we go to
to that link
that link, it
it takes us
takes us to
us to this
to this page
This site is
site is in
is in fact
in fact an
fact an index
an index to
index to the
to the YouTube
the YouTube channel
YouTube channel, indexing
indexing all the
all the videos
the videos which
videos which are
which are on
are on the
on the channel
On the Recently
the Recently Added
Recently Added page
Added page we
page we have
we have all
have all the
all the recent
the recent videos
recent videos that
videos that have
that have been
have been added
been added to
added to the
can see, each
each video is
video is listed
is listed separately
have a compiler
a compiler or
compiler or topic
or topic, which
which is an
is an icon
an icon to
icon to show
to show what
show what type
what type of
type of video
of video it
video it is
it is, in
this case a
case a podcast
a podcast and
podcast and the
and the next
the next one
next one down
one down is
down is a
is a video
a video on
video on the
This website also
website also charts
also charts the
charts the videos
the videos for
videos for my
for my Hardware
my Hardware channel
Hardware channel, which
which are shown
are shown by
shown by this
by this icon
this icon here
Videos on purely
on purely console
purely console applications
console applications are
applications are shown
are shown with
shown with this
with this icon
this icon, and
and videos which
videos which cover
which cover both
cover both the
both the console
the console and
console and the
and the Windows
the Windows Compilers
Windows Compilers are
Compilers are shown
are shown again
shown again with
again with a
with a different
a different icon
So apart from
apart from the
from the obvious
the obvious details
obvious details of
details of the
of the subject
the subject of
subject of the
of the video
the video and
video and the
and the date
the date on
date on which
on which it
which it was
it was uploaded
was uploaded to
uploaded to YouTube
to YouTube, we
also have a
have a short
a short description
the website goes
website goes further
goes further, it
it not only
not only gives
only gives you
you a link
a link to
link to the
the YouTube video
YouTube video itself
video itself, but
but it gives
it gives you
gives you keywords
If you are
you are interested
are interested in
interested in videos
in videos on
videos on a
on a similar
a similar subject
similar subject, you
you can click
can click on
click on a
on a keyword
This brings up
brings up a
up a separate
a separate page
separate page, in
this case all
case all the
the videos with
videos with the
with the podcast
the podcast keyword
on the intro
the intro keyword
intro keyword, we'll
we'll be taken
be taken to
taken to 47
to 47 videos
47 videos, which
which are all
are all introduction
all introduction to
introduction to Power
to Power Basic
Power Basic videos
if there is
there is any
is any source
any source code
source code associated
code associated with
associated with a
with a video
a video, then
then there will
there will be
will be an
be an icon
an icon in
icon in the
in the source
the source view
source view column
view column, and
and if you
if you click
you click on
click on that
on that, you
will see the
see the actual
the actual source
actual source code
source code of
code of the
of the core
the core Power
core Power Basic
Power Basic project
Basic project file
you to view
to view the
view the source
the source code
source code quite
code quite easily
quite easily from
easily from this
from this site
wish to download
to download all
download all the
all the files
the files for
files for this
for this particular
this particular project
particular project, there
is a zip
a zip files
zip files download
files download icon
Clicking on that
on that will
that will allow
will allow you
allow you to
you to download
to download the
download the zip
the zip file
The GitHub link
GitHub link will
link will take
will take you
take you to
you to GitHub
to GitHub, where
where you can
you can view
can view and
view and download
and download the
download the files
the files from
files from here
This page only
page only covers
only covers those
covers those videos
those videos which
videos which have
which have been
been added recently
in videos purely
videos purely for
purely for the
console compiler, if
you will get
will get a
get a list
a list of
list of all
of all the
the videos to
videos to do
to do with
do with the
with keywords and
keywords and the
and the ability
ability to download
to download or
download or view
or view the
source code for
code for each
for each of
each of these
of these files
are interested purely
interested purely in
purely in the
in the Windows
the Windows compiler
Windows compiler, you
you can do
can do the
same for it
a section for
section for videos
for videos which
cover both Windows
both Windows and
For third party
third party add-ons
party add-ons, we
section for that
for that too
And for third
third party videos
party videos that
videos that cover
that cover both
both the Windows
the Windows and
console compilers, there
there is again
is again a
again a separate
Again for Power
for Power Basic
Power Basic introductions
Basic introductions, Projects
Projects and Design
and Design, and
have added a
added a new
a new entry
new entry of
entry of podcasts
now have prepared
have prepared a
prepared a number
a number of
number of audio
of audio podcasts
audio podcasts, which
which link to
link to videos
to videos which
which have already
have already been
already been uploaded
These videos give
videos give you
give you the
you the opportunity
the opportunity to
opportunity to listen
to listen to
listen to an
to an audio
an audio discussion
audio discussion on
discussion on the
on the topic
the topic of
topic of a
of a particular
a particular video
particular video which
video which has
which has already
And the last
the last two
last two options
two options in
options in here
in here allow
here allow you
allow you a
you a bit
a bit more
bit more flexibility
interested in a
in a specific
a specific keyword
specific keyword, for
for example browser
example browser, you
on the browser
the browser keyword
And this will
this will give
will give you
give you a
you a list
which have that
have that keyword
And the library
the library files
library files allow
files allow you
code of libraries
of libraries used
libraries used within
used within the
within the projects
the projects, by
by clicking on
clicking on the
on the source
source view icon
allows you, regardless
regardless of where
of where you
where you are
you are in
are in the
in the world
the world, the
ability to look
to look at
look at source
at source code
code for Power
And as always
as always, this
this website does
website does not
does not use
not use cookies
use cookies or
cookies or any
or any similar
any similar tracking
similar tracking technologies
And should allow
should allow you
allow you an
you an easier
an easier method
easier method of
method of actually
of actually finding
actually finding YouTube
finding YouTube videos
YouTube videos to
videos to watch
find this website
this website of
website of use
of use in
use in your
in your Power
your Power Basic
Power Basic coding
for the PowerBasic
the PowerBasic Windows
PowerBasic Windows compiler
at the use
use of OpenGL
That's the Open
the Open Graphics
Open Graphics Library
Graphics Library within
Library within your
within your applications
Today we're going
to be looking
be looking at
looking at the
at the Open
OpenGL is a
is a cross-language
a cross-language, cross-platform
cross-platform API for
API for rendering
for rendering 2D
rendering 2D and
2D and 3D
and 3D vector
3D vector graphics
Although OpenGL is
OpenGL is no
is no longer
no longer in
longer in active
in active development
active development, there
there are extensions
are extensions which
extensions which can
which can provide
can provide additional
provide additional functionality
today we are
we are just
are just going
just going to
of the OpenGL32.dll
the OpenGL32.dll that
OpenGL32.dll that ships
that ships with
ships with Windows
with Windows 10
Windows 10 and
10 and 11
and 11, by
by looking at
looking at a
at a piece
piece of software
of software created
software created by
created by Gary
by Gary Beene
Gary Beene, to
to which I've
which I've added
I've added a
added a couple
a couple of
couple of small
of small additions
I'll put a
put a link
link to Gary's
to Gary's website
Gary's website in
website in the
in the description
the description below
This site contains
site contains lots
contains lots of
lots of useful
of useful examples
useful examples of
examples of PowerBasic
of PowerBasic code
can see on
see on screen
on screen, we're
to be demonstrating
be demonstrating the
demonstrating the 10
the 10 primitives
10 primitives that
primitives that OpenGL
that OpenGL supports
OpenGL supports, from
from points all
points all the
all the way
the way down
way down to
down to polygons
I have added
have added more
added more options
more options at
options at the
of the list
the list, which
which we'll cover
we'll cover later
cover later in
later in the
in the video
can see at
see at the
the moment is
moment is the
is the use
of the points
have six points
six points and
points and we're
and we're rotating
we're rotating around
rotating around these
If we switch
we switch to
switch to Lines
to Lines, we
can see we
see we have
two lines on
lines on the
the screen, one
one in red
in red and
red and one
and one using
one using a
using a gradient
a gradient fill
The next is
next is Line
is Line Strip
This allows us
us to display
to display a
display a longer
a longer and
longer and more
and more angular
more angular line
is Line Loop
Line Loop, which
which is showing
is showing a
showing a closed
a closed, four-sided
If we now
we now go
now go to
go to Triangles
to Triangles, we
we can demonstrate
can demonstrate the
demonstrate the use
use of gradient
of gradient fills
Each corner of
corner of the
of the triangle
the triangle has
triangle has a
has a base
a base RGB
base RGB colour
Triangle Strip allows
Strip allows us
us to add
to add triangles
add triangles together
next one is
one is Triangle
is Triangle Fan
can see, this
this takes the
takes the concept
the concept a
concept a little
a little further
with a gradient
Quads takes us
takes us into
us into the
into the realm
the realm of
realm of four-sided
of four-sided figures
Quads Strip allows
us to join
to join these
join these four-sided
these four-sided figures
four-sided figures together
figures together, again
again here with
here with a
Next is Polygons
you to specify
to specify the
specify the coordinates
the coordinates of
coordinates of each
of the vertices
the vertices of
vertices of the
of the polygon
The final four
final four elements
four elements are
elements are not
are not primitives
These are built
are built up
built up from
up from the
from the primitives
the primitives themselves
we will have
will have a
at the Wire
the Wire Sphere
us to specify
to specify quite
specify quite easily
quite easily on
easily on screen
on screen a
screen a sphere
a sphere with
sphere with a
with a number
number of longitude
of longitude and
longitude and latitude
and latitude lines
The sphere is
sphere is formed
is formed up
formed up of
up of quad
of quad strips
quad strips, except
except for the
for the north
the north and
north and south
and south poles
south poles, which
which are triangle
are triangle fans
We can specify
can specify a
specify a circle
a circle quite
circle quite easily
quite easily, and
and this one
this one has
one has a
has a nice
a nice gradient
nice gradient fill
one is Spheres
this case, it
it appears as
appears as if
as if it's
if it's a
it's a billiard
a billiard ball
We have incorporated
have incorporated lighting
incorporated lighting and
lighting and shading
and shading on
shading on this
on this one
this one, to
to give quite
give quite a
quite a realistic
a realistic rendition
realistic rendition of
rendition of a
of a sphere
And the final
the final one
final one is
one is Teapot
What would a
would a 3D
a 3D demonstration
3D demonstration be
demonstration be without
be without the
without the traditional
the traditional teapot
traditional teapot shape?
teapot shape? So
shape? So we
we will next
will next look
next look at
at the Power
Power Basic code
Basic code that's
code that's been
that's been used
been used to
used to generate
to generate these
generate these images
at the code
top of our
our code, we
we have listed
have listed the
listed the ten
the ten different
ten different primitives
different primitives that
Line Strips, Line
Line Loops, Triangle
Triangle Strips, Triangle
Triangle Fans and
Fans and finally
and finally, Quad
We're now including
now including four
including four libraries
four libraries with
libraries with this
with this code
this code –
code – the
– the standard
the standard Windows
standard Windows 32
Windows 32 API
32 API library
API library and
library and three
and three additional
three additional ones
additional ones, coming
coming from José
from José Roca
The GL include
GL include, the
the GLU include
GLU include and
include and the
and the AFX
the AFX GLUT
AFX GLUT include
I've added each
added each of
of these libraries
these libraries to
libraries to the
to the zip
zip file to
file to make
to make it
make it easy
it easy for
easy for you
for you to
you to test
to test out
test out this
out this program
And I've created
I've created an
created an enumeration
an enumeration for
enumeration for all
for all of
all of these
of these primitives
We've also used
also used a
used a macro
a macro to
macro to define
to define the
define the constant
the constant pi
The dialog is
dialog is quite
is quite straightforward
We're using option
using option buttons
And the graphics
the graphics are
graphics are displayed
are displayed actually
displayed actually on
actually on a
on a label
a label control
label control called
control called 'id_Label'
So the work
the work begins
work begins in
begins in the
in the callback
the callback function
callback function, the
the Event handler
In here, we're
we're doing a
doing a number
number of things
of things to
things to set
We're using two
using two subroutines
two subroutines, first
first of all
of all to
all to get
get the render
the render context
render context and
context and secondly
and secondly, to
to initialize the
initialize the scene
We'll cover these
cover these in
these in a
Then we're setting
we're setting up
setting up a
up a timer
a timer, triggering
triggering every 50
every 50 milliseconds
This is to
is to allow
to allow us
us to change
to change your
change your viewpoint
your viewpoint of
viewpoint of the
of the 3D
the 3D or
3D or 2D
or 2D object
And when any
when any of
of the option
the option buttons
option buttons are
buttons are selected
are selected, we
we are calling
are calling a
calling a routine
a routine called
routine called 'draw
called 'draw scene'
Draw scene is
scene is the
is the routine
the routine which
routine which will
which will draw
will draw the
draw the image
the image onto
image onto the
onto the screen
This is called
is called from
called from a
from a number
number of places
from the timer
the timer and
timer and from
and from the
from the paint
This takes a
takes a number
number of parameters
of parameters, either
either to have
to have rotation
have rotation or
rotation or no
or no rotation
So if we
if we look
we look first
look first of
of all at
all at the
at the get_render_context
the get_render_context subroutine
This is first
is first of
of all setting
all setting up
setting up the
up the pixel
the pixel format
pixel format properties
format properties for
properties for our
for our device
our device context
We're going for
going for 24-bit
for 24-bit for
24-bit for both
for both the
both the colour
the colour bits
colour bits and
bits and for
and for the
for the depth
And this command
this command here
command here, 'control
'control handle', gets
gets the handle
the handle of
handle of our
of our label
our label control
label control and
control and stores
and stores it
stores it in
it in hLabel
hLabel is a
is a global
a global variable
And we're using
we're using the
using the get_dc
the get_dc call
get_dc call to
call to get
get the device
the device context
And another Windows
another Windows API
Windows API call
API call, setPixelFormat
set our pixel
our pixel format
pixel format up
format up and
up and ready
and ready to
ready to render
is done, we're
we're into the
into the initialize
the initialize scene
And this is
this is where
is where we
where we start
we start using
start using some
using some of
some of the
of the OpenGL
the OpenGL functions
To clear the
clear the colour
the colour, to
set the depth
the depth, to
specify the depth
the depth function
depth function, to
to enable depth
enable depth test
depth test, to
to go for
go for smooth
for smooth shading
smooth shading and
shading and to
and to go
go for the
for the best
the best quality
best quality rendering
quality rendering we
rendering we can
we can on
can on our
on our device
at the routine
routine which does
which does all
does all the
all the work
The one called
one called draw
called draw scene
It takes in
takes in the
in the three
the three parameters
three parameters, the
the X, Y
Y and Z
and Z coordinates
And we're stepping
we're stepping through
stepping through each
through each of
of the possible
the possible selections
possible selections the
selections the user
the user has
user has made
So we're basically
we're basically checking
basically checking to
checking to see
to see which
see which option
which option button
option button has
button has been
has been clicked
been clicked on
clicked on the
We're then clearing
then clearing the
clearing the buffers
the buffers and
buffers and we're
we're going through
going through a
through a series
a series of
series of routines
of routines which
routines which I've
which I've done
I've done my
done my best
my best to
best to document
As these are
these are likely
are likely to
likely to be
to be routines
be routines you
routines you have
have not used
not used before
this is all
is all set
all set up
set up, we're
using a rotate
a rotate call
rotate call to
call to work
to work out
work out the
out the rotation
the rotation of
rotation of our
of our coordinates
our coordinates, both
both the X
Y and the
and the Z
the Z coordinates
And the main
the main work
main work begins
in the case
the case statement
This is testing
is testing the
testing the selection
the selection you
selection you have
you have made
have made from
made from the
from the options
If we're doing
we're doing points
doing points, it's
it's setting the
setting the vertex
the vertex of
vertex of each
of these points
And it's held
it's held within
held within a
within a begin
a begin and
begin and an
and an end
an end command
And we give
we give it
give it the
it the constant
the constant to
constant to see
see what kind
what kind of
kind of object
of object we're
object we're dealing
we're dealing with
dealing with, in
this case points
The same with
same with the
with the lines
the lines, the
the line strip
line strip and
strip and the
and the line
the line loop
The triangles are
triangles are slightly
are slightly different
slightly different, as
as in the
in the triangles
the triangles have
triangles have different
have different colours
So the first
the first corner
first corner is
corner is green
is green, the
the second is
second is red
is red and
red and the
one is blue
And the same
the same approach
same approach is
approach is taken
is taken with
taken with the
with the triangle
the triangle strip
using the glColor3ub
the glColor3ub function
glColor3ub function to
function to specify
specify the color
the color for
color for each
each of our
of our vertices
And again, a
a similar approach
similar approach taken
approach taken with
the triangle fan
With the quads
the quads, we're
we're setting the
setting the default
the default vertex
default vertex color
vertex color in
color in one
in one line
one line, as
for the quads
the quads strip
quads strip, the
same approach again
So when we
to the circle
the circle, this
this one is
one is slightly
is slightly different
using the triangle
triangle fan and
fan and we're
using a for
a for next
next loop, going
going from 0
from 0 to
0 to 360
So this allows
to specify all
specify all 360
all 360 degrees
using the glVertex2f
the glVertex2f with
glVertex2f with the
with the radius
the radius and
radius and pi
and pi to
pi to draw
to draw the
draw the circle
the circle on
circle on the
The change in
change in the
in the color
the color is
color is used
is used by
used by manipulating
by manipulating three
manipulating three constants
three constants, one
one for red
for red, one
one for green
for green and
green and one
one for blue
And using the
using the color3ub
the color3ub function
color3ub function to
function to set
to set these
For each degree
each degree, we
we go around
go around a
around a circle
The solid sphere
solid sphere is
sphere is slightly
solid sphere, we're
we're using one
using one of
of the functions
the functions within
functions within the
within the library
the library, which
which we've added
we've added at
added at the
using the translate
the translate with
translate with the
with the coordinates
the coordinates provided
And we're setting
setting the three
three parameters using
parameters using this
using this function
this function here
This single function
single function will
function will display
will display on
display on screen
screen a solid
a solid sphere
solid sphere of
sphere of this
of this radius
this radius and
radius and the
and the number
the number of
number of subdivisions
of subdivisions you
subdivisions you specify
And in this
this case, we're
we're using 64
using 64 to
64 to give
to give us
give us the
us the best
the best chance
best chance of
chance of having
of having a
having a smooth
a smooth looking
smooth looking sphere
The only additional
only additional things
additional things we're
things we're doing
we're doing in
doing in this
this function is
function is setting
is setting up
up the lighting
the lighting and
lighting and the
and the material
the material parameters
And once we
once we pop
we pop this
pop this matrix
this matrix, at
at the very
the very end
very end of
of this select
this select statement
select statement is
statement is the
is the command
the command to
command to swap
to swap the
swap the buffers
This will display
will display the
display the image
the image to
image to the
With the teapot
the teapot, we're
we're using exactly
using exactly the
exactly the same
same approach when
approach when we're
when we're calling
we're calling a
calling a different
a different function
different function in
function in the
in the FX
the FX library
FX library, the
the solid teapot
look at this
at this library
this library, you
can see in
see in the
in the function
the function list
function list there
list there are
are a number
number of functions
of functions you
functions you can
you can call
can call to
to get specific
get specific shapes
specific shapes very
shapes very easily
very easily, from
from wire spheres
wire spheres to
spheres to wire
to wire teapots
we look inside
look inside this
inside this teapot
this teapot function
teapot function, you'll
you'll see there's
there's a large
a large amount
large amount of
amount of code
of code to
code to define
define the coordinates
of the areas
the areas of
areas of the
of the teapot
And this saves
this saves you
saves you doing
you doing a
doing a great
deal of work
So if you're
if you're after
you're after a
after a slightly
a slightly more
slightly more enhanced
more enhanced primitive
enhanced primitive, you
use these together
And looking at
the code within
code within these
within these functions
these functions can
functions can give
can give you
give you ideas
you ideas of
ideas of how
of how to
how to create
to create other
create other types
other types of
types of objects
So feel free
feel free to
free to browse
to browse into
browse into this
into this code
So this has
has been a
been a short
a short dip
short dip into
dip into the
into the world
the world of
world of OpenGL
Hopefully you found
you found this
found this code
this code interesting
code interesting and
interesting and might
and might find
might find uses
find uses for
uses for it
for it within
it within your
within your own
short videos we
the PowerBasic console
PowerBasic console compiler
look at commands
the console itself
be looking specifically
looking specifically at
specifically at commands
at commands used
commands used within
within the PowerBasic
And the commands
the commands we're
commands we're going
looking at are
at are those
are those directly
those directly associated
directly associated with
associated with the
There may come
may come a
come a time
a time when
time when you
when you wish
wish to monitor
to monitor a
monitor a background
a background application
This would be
would be a
be a console
application which is
which is running
is running with
running with no
with no user
no user interaction
This process can
process can be
can be processing
be processing data
processing data into
data into a
into a database
a database, processing
processing many transactions
many transactions or
transactions or dealing
or dealing with
dealing with large
with large file
large file processing
As such you
such you may
you may want
may want a
want a quick
a quick and
quick and easy
and easy way
easy way to
way to monitor
to monitor what
monitor what the
what the application
the application is
application is doing
Something simpler than
simpler than monitoring
than monitoring log
monitoring log files
So let's have
let's have a
can do within
do within the
within the console
The Windows console
Windows console can
console can be
can be quite
be quite flexible
to do first
do first of
of all is
all is to
is to designate
to designate the
designate the number
number of rows
of rows and
rows and columns
and columns that
columns that are
that are going
are going to
be used within
So I'm going
up two constants
So in our
in our console
our console we're
console we're going
to have 25
have 25 rows
The console can
can be set
be set up
up within PowerBasic
within PowerBasic as
PowerBasic as a
as a virtual
a virtual console
Hence you can
you can have
can have more
have more rows
more rows and
rows and more
and more columns
more columns than
columns than console
than console would
console would normally
would normally show
Also within the
the console you
console you can
can have a
have a range
a range of
range of colours
There are only
are only 16
only 16 colours
16 colours available
colours available within
available within the
within the basic
the basic console
basic console and
console and each
and each of
each of those
of those colours
those colours is
colours is allocated
is allocated by
allocated by using
by using a
using a number
So to make
make our code
our code a
code a little
a little easier
little easier to
easier to read
to read, we're
set up a
up a global
a global string
global string which
string which will
which will contain
will contain the
contain the text
the text of
text of each
of these colours
For example red
example red, blue
blue or green
And when we
when we want
we want to
want to designate
to designate a
designate a colour
a colour we
colour we can
use the text
text of that
of that colour
that colour and
colour and the
and the program
the program will
program will convert
will convert this
convert this to
this to the
to the number
the number to
number to be
be used in
used in the
in the console
the console commands
call this global
this global array
global array 'colours'
So we need
to do some
do some preparatory
some preparatory work
preparatory work to
work to set
set up our
up our application
our application, to
to use these
use these colours
these colours and
colours and to
and to prep
to prep our
prep our screen
And as we're
as we're going
to be displaying
be displaying some
displaying some random
some random data
random data on
data on the
the screen, just
just for the
of this video
this video we're
video we're going
use the randomise
the randomise command
randomise command to
set up the
up the random
the random number
random number generator
So we have
we have dimensioned
have dimensioned our
dimensioned our global
global array of
array of colours
of colours to
colours to be
to be 15
be 15 elements
That's starting from
starting from 0
from 0 and
0 and going
and going to
going to 15
to 15, which
which will encapsulate
will encapsulate all
encapsulate all 16
all 16 colours
16 colours that
colours that we
that we can
can use in
use in the
in the basic
to be calling
be calling a
calling a function
a function called
function called 'prepcolours'
This will set
will set up
up our colours
our colours in
colours in the
in the array
we will prepare
will prepare that
prepare that function
that function now
is a very
a very simple
very simple function
simple function with
function with effectively
with effectively only
effectively only one
only one line
one line of
using the array's
the array's 'sign'
array's 'sign' command
'sign' command to
command to assign
to assign a
assign a value
a value to
value to each
of the elements
the elements of
elements of our
of our global
Ranging from black
from black all
black all the
the way through
way through to
through to intense
to intense white
So having prepared
having prepared our
prepared our array
our array with
array with colours
with colours, we
we now need
now need to
need to prepare
to prepare the
prepare the console
So we'll create
we'll create a
function to perform
to perform that
So we're passing
we're passing a
passing a single
a single parameter
single parameter to
parameter to this
to this new
this new 'prepscreen'
new 'prepscreen' function
this is the
is the name
the name we
name we want
we want on
want on the
the console window
console window itself
So let's create
let's create the
create the function
the function to
function to prepare
to prepare our
prepare our screen
is our 'prepscreen'
our 'prepscreen' function
'prepscreen' function taking
function taking its
taking its single
its single parameter
single parameter, which
which will be
will be the
be the console
the console name
console name of
name of the
of the window
Our first task
first task is
task is to
is to set
the location of
location of the
console window on
window on the
on the monitor
the monitor screen
Using pixel coordinates
pixel coordinates from
coordinates from the
from the top
the top left
top left hand
left hand corner
using the 'con.loc'
the 'con.loc' command
'con.loc' command to
set the x
and y coordinates
this case we're
case we're going
going for 50
for 50, 50
Next we're going
use the virtual
the virtual option
virtual option to
option to set
set the number
and columns on
columns on our
our console window
allows you, should
should you need
you need a
need a larger
a larger console
larger console window
console window, to
set it quite
it quite easily
easily using this
using this command
using the two
the two constants
two constants we
constants we created
we created earlier
created earlier for
earlier for rows
Next we can
we can set
can set the
set the title
the title quite
title quite easy
quite easy using
easy using the
using the 'caption'
the 'caption' command
This will put
put a caption
a caption on
caption on the
on the window
the window of
window of the
Next I'm going
use the 'color'
the 'color' command
'color' command to
set the default
the default foreground
default foreground and
and background colors
As you may
you may remember
may remember the
remember the colors
the colors use
colors use numbers
use numbers rather
numbers rather than
rather than names
Color 10 is
10 is green
There are two
are two parameters
two parameters on
parameters on this
on this command
The first parameter
first parameter is
parameter is the
is the foreground
the foreground color
foreground color, which
which we're setting
we're setting as
setting as green
The second parameter
second parameter is
is the background
the background color
If you use
you use a
use a -1
a -1 it
-1 it will
it will leave
will leave the
leave the value
the value to
value to whatever
to whatever it
whatever it is
it is currently
is currently set
currently set at
Console windows default
windows default to
default to a
to a black
if we put
we put a
put a 'wait'
a 'wait' command
'wait' command in
command in our
pb_main function to
function to allow
us to run
to run the
the application and
application and have
and have it
have it display
it display on
on screen long
screen long enough
long enough for
enough for us
for us to
us to actually
to actually see
actually see what
see what it
what it looks
it looks like
application now, we'll
we'll see our
see our console
console window appears
It's got 'monitor
got 'monitor display'
'monitor display' as
display' as the
as the title
the title of
title of the
the window and
window and if
press the button
the button on
button on the
on the keyboard
the keyboard, the
the screen will
screen will close
we have successfully
have successfully set
successfully set up
up our console
you need to
need to clear
clear the screen
the screen at
point in your
in your application
your application, you
use the 'cls'
the 'cls' command
'cls' command, which
which is one
is one of
console commands, to
clear the console
console window completely
As we want
want to use
to use this
use this application
this application to
application to display
to display some
display some information
some information to
information to a
a user, there
be some headers
some headers or
headers or default
or default data
default data to
data to appear
to appear on
appear on this
on this type
this type of
type of form
create a function
a function whose
function whose job
whose job it
job it will
it will be
be to display
to display these
display these headers
This will be
will be text
be text, which
which is non-changing
create a display
a display headers
display headers function
headers function to
us to do
So here is
is our function
I'm setting up
setting up three
up three local
three local variables
One for row
for row, one
one for column
for column, both
both numbers, as
as long, and
one for text
for text, which
be the text
the text we
text we want
want to print
to print onto
print onto the
onto the console
to be doing
be doing a
doing a fair
a fair bit
fair bit of
bit of printing
of printing to
printing to the
console window, so
create a common
a common function
common function whose
be to print
to print information
print information to
information to that
to that window
But first we
first we want
want to set
location to which
to which we
which we wish
wish to print
This is counted
is counted from
counted from the
hand corner of
corner of our
of our window
our window, so
so we're setting
we're setting to
setting to row
to row two
row two and
two and column
and column two
And I want
I want to
print to this
to this window
this window a
window a piece
of text that
text that says
that says 'Monitor
says 'Monitor System'
'Monitor System' and
System' and I
I want that
want that printed
that printed in
printed in red
we're passing information
passing information to
Via four parameters
four parameters, the
the row and
row and the
and the column
the column, the
text we wish
to print, and
and the colour
the colour we
colour we wish
to print it
So let's now
let's now go
now go and
go and create
and create this
create this print
this print to
print to console
to console function
will see we
have the four
the four parameters
four parameters being
parameters being passed
being passed to
passed to this
to this function
The last parameter
last parameter is
parameter is set
is set as
set as optional
My idea behind
idea behind this
behind this is
this is if
is if you
if you do
you do not
do not specify
not specify the
specify the colour
the colour, it
it will not
will not change
not change the
change the colour
to put a
put a piece
code in to
in to test
whether this optional
this optional parameter
optional parameter is
parameter is present
is present or
present or not
use the inbuilt
the inbuilt is
inbuilt is missing
is missing function
This tests whether
tests whether the
whether the optional
the optional parameter
optional parameter has
parameter has actually
has actually been
actually been given
been given or
given or not
So if is
if is missing
is missing is
missing is false
is false, then
we know that
know that a
that a colour
a colour parameter
colour parameter has
parameter has been
And we want
want to get
get the colour
the colour number
colour number associated
number associated with
associated with that
with that colour
that colour name
have a little
a little embedded
little embedded function
embedded function in
function in here
in here called
here called get
called get colour
this will return
will return the
return the colour
colour number that
number that the
that the colour
the colour command
colour command needs
command needs to
needs to use
to use for
use for our
for our foreground
our foreground colour
And we're leaving
we're leaving our
leaving our background
our background colour
background colour as
colour as minus
as minus one
this particular application
particular application I'm
application I'm leaving
I'm leaving the
leaving the background
the background colour
colour as black
We'll create the
create the get
the get colour
get colour function
colour function in
function in a
a moment, but
but let's push
let's push on
push on to
on to do
do the last
the last couple
last couple lines
couple lines of
code in this
Having set the
the colour should
colour should the
should the parameter
the parameter have
parameter have come
have come in
come in, we
we want next
want next to
next to do
do the setting
the setting of
setting of the
of the location
use the cell
the cell command
cell command for
command for that
for that, as
have the row
the column numbers
that we've set
we've set the
the location we
location we wish
print to, we
can then use
then use the
use the print
the print command
print command to
command to print
to print our
print our text
our text to
text to the
this case the
case the print
print command is
command is followed
is followed by
followed by the
by the variable
the variable containing
variable containing the
containing the text
the text you
text you wish
if you put
you put a
put a semicolon
a semicolon at
semicolon at the
the line, it
it means it
means it will
will not put
not put a
put a carriage
a carriage return
carriage return line
return line feed
line feed at
feed at the
of the text
Which would automatically
would automatically push
automatically push the
push the cursor
the next row
us to update
to update specific
update specific locations
specific locations on
locations on the
the screen without
screen without injecting
without injecting an
injecting an extra
create this embedded
this embedded get
embedded get colour
So this is
be a fairly
a fairly straightforward
fairly straightforward function
straightforward function whose
be to return
to return the
return the number
number of the
of the associated
the associated colour
associated colour name
So as we
have all of
of these colour
these colour names
colour names in
names in a
in a global
a global array
global array, we
we merely have
merely have to
have to do
to do a
do a for-next
a for-next loop
for-next loop to
loop to step
to step through
step through each
through each element
each element while
element while looking
while looking for
looking for a
for a match
going for the
for the zero
the zero element
zero element to
element to the
to the upper
the upper bounding
upper bounding of
bounding of the
of the array
The UBOUND command
UBOUND command will
command will quite
will quite easily
quite easily return
easily return the
return the maximum
the maximum number
maximum number of
number of elements
of elements in
elements in this
in this particular
this particular array
particular array, which
case is 15
And we're comparing
we're comparing the
comparing the colour
the colour that
colour that come
that come in
come in with
in with the
with the parameters
the parameters against
parameters against the
against the colour
the colour held
colour held in
held in the
using the U
the U CASE
U CASE command
CASE command to
command to force
to force both
force both of
both of these
of these strings
these strings to
strings to uppercase
This avoids having
avoids having a
having a problem
a problem where
problem where the
where the user
user has actually
has actually coded
actually coded this
coded this with
this with lowercase
with lowercase for
lowercase for the
for the name
the name of
of the colour
the colour and
colour and our
and our array
our array is
array is holding
is holding it
holding it in
it in mixcase
Should this comparison
this comparison return
comparison return true
return true, then
then we're returning
we're returning the
returning the element
the element number
element number of
the array, which
is the colour
colour number, and
we can exit
can exit the
the function at
function at that
at that point
application now to
if we get
we get the
get the first
the first line
first line of
line of text
And there is
there is our
is our first
our first piece
first piece of
of text on
text on our
The words monitor
words monitor system
monitor system and
system and it's
and it's printed
it's printed in
have the basic
the basic mechanics
basic mechanics in
mechanics in our
in our display
our display headers
function to operate
to operate, we
we can put
can put additional
put additional pieces
additional pieces of
pieces of information
of information in
information in to
in to put
to put text
put text on
text on the
These will be
will be additional
be additional pieces
of text which
text which will
which will not
not change during
change during the
during the run
the run of
run of the
the first of
first of these
of these is
these is the
is the word
the word polling
will be a
be a section
screen to indicate
to indicate whether
indicate whether polling
whether polling is
polling is active
is active or
active or inactive
setting the row
the row number
row number to
to be row
be row number
row number 4
number 4 and
4 and the
the column number
column number to
to be column
be column number
column number 2
we're displaying this
displaying this in
this in green
in green text
we put another
put another 2
another 2 in
2 in, the
the first saying
first saying server
saying server stats
server stats on
stats on row
on row 6
row 6 column
6 column 2
column 2 and
2 and the
the next set
next set of
set of text
of text we're
text we're putting
we're putting on
putting on is
on is going
to be 3
be 3 sections
3 sections all
sections all in
all in one
in one row
Displaying on row
on row 8
row 8 starting
8 starting at
starting at column
at column 2
we run our
application now we
now we can
can see how
see how this
how this looks
on screen we've
screen we've got
we've got monitor
got monitor system
monitor system, the
word polling and
polling and then
and then server
then server stats
server stats in
stats in a
in a different
a different color
different color and
color and then
and then CPU
then CPU load
CPU load, CPU
CPU response time
response time and
time and user
and user count
These are all
are all the
all the fixed
the fixed pieces
fixed pieces of
text that will
that will not
not change within
change within our
within our for
next loop which
loop which we're
which we're about
we're about to
about to do
So I'm adding
I'm adding a
adding a number
number of local
of local variables
local variables to
variables to keep
of the row
the row, the
the text and
text and a
and a count
a count variable
use the count
the count variable
count variable for
for the number
number of times
of times we
times we run
we run round
run round this
round this loop
Each time we
time we pass
we pass through
pass through this
through this loop
this loop we
loop we will
we will increment
will increment the
increment the count
Once the count
count variable reaches
variable reaches This
reaches This means
This means we
we will no
will no longer
longer need the
need the wait
wait key at
key at the
can now start
now start to
start to put
to put the
put the information
the screen that
screen that the
that the user
the user would
user would want
would want to
want to see
going to populate
to populate first
populate first of
all the system
the system polling
system polling and
polling and we'll
and we'll create
create a little
a little function
little function to
function to return
to return that
return that value
These functions of
functions of course
of course are
course are just
are just dummy
just dummy functions
If you were
you were writing
were writing this
writing this for
this for real
for real each
real each of
of these functions
these functions would
functions would perform
would perform whatever
perform whatever is
whatever is needed
is needed to
needed to get
get the information
the information that
information that you
wish to display
to display to
So this again
this again is
again is a
simple function just
function just to
just to demonstrate
to demonstrate different
demonstrate different text
different text appearing
text appearing on
appearing on the
using the random
number generator here
generator here to
here to generate
to generate a
generate a number
a number either
number either of
either of a
of a 1
a 1 or
1 or a
or a 2
it's a 1
a 1 we
1 we will
we will return
return the word
the word active
it's a 2
a 2 we
2 we will
the word inactive
It's important when
important when you're
when you're using
you're using this
using this on
this on the
the console that
console that the
that the strings
the strings you
strings you put
you put in
put in within
in within this
within this loop
this loop are
loop are of
are of the
the same length
we put the
put the word
word inactive in
inactive in first
in first and
first and then
and then in
then in the
in the next
the next loop
next loop we
loop we put
word active in
Since the string
the string active
string active is
active is shorter
is shorter than
shorter than inactive
than inactive it
inactive it would
it would not
would not overwrite
not overwrite the
overwrite the last
last two letters
two letters of
letters of inactive
But if we
if we make
we make them
make them all
them all the
all the same
same length that
length that will
will not be
not be a
be a problem
And to simulate
to simulate what
simulate what we'd
what we'd be
we'd be doing
be doing in
doing in a
in a live
a live situation
live situation we're
situation we're going
put a sleep
a sleep command
sleep command in
command in here
Otherwise the loop
the loop will
loop will run
will run so
run so fast
so fast you'll
fast you'll hardly
you'll hardly see
hardly see anything
see anything on
anything on the
So we're putting
we're putting a
putting a sleep
command in for
in for of
for of one
of one and
one and a
and a half
a half seconds
half seconds for
seconds for each
for each loop
application now we'll
now we'll see
we'll see it
it displays inactive
displays inactive and
inactive and active
and active randomly
And then after
then after 10
after 10 iterations
10 iterations of
iterations of the
the loop the
loop the program
program will terminate
So we go
we go back
to the pb_main
the pb_main function
pb_main function and
function and we
can put some
put some more
some more printing
more printing in
Again specifying the
specifying the row
the column that
column that the
that the text
the text is
text is to
is to go
to go into
And we'll reduce
we'll reduce the
reduce the delay
the delay down
delay down slightly
And run once
run once more
Now we're getting
getting the CPU
the CPU load
CPU load, again
again as a
as a random
a random number
random number, in
this case between
case between the
between the values
the values 60
values 60 and
60 and 85
as we're displaying
this in white
in white it's
white it's quite
it's quite easy
quite easy to
easy to discern
to discern on
discern on the
So we'll put
we'll put two
two more pieces
more pieces of
of information on
on our screen
And these are
are the additional
the additional bits
additional bits of
bits of information
of information also
information also appearing
also appearing on
appearing on row
row 8 but
8 but further
but further along
further along in
along in the
in the columns
number generator to
generator to go
to go from
go from a
a number between
number between 30
between 30 and
30 and 80
and 80 and
80 and displaying
and displaying this
displaying this on
As the numbers
the numbers here
numbers here are
here are both
are both going
both going to
to be two
be two characters
two characters it
characters it won't
it won't cause
won't cause a
cause a problem
But in this
in this bottom
this bottom one
bottom one where
one where we're
where we're doing
doing a random
random number between
number between 10
between 10 and
10 and 2250
and 2250 these
2250 these will
will be turned
be turned different
turned different lengths
different lengths in
lengths in the
in the string
So I'm using
I'm using the
using the RSET$
the RSET$ command
RSET$ command to
command to right
to right justify
right justify the
justify the text
text and it's
and it's going
it's going to
to be in
be in a
in a 5
a 5 character
5 character limit
So all the
the text will
text will be
will be pushed
be pushed to
pushed to the
to the right
the right hand
right hand side
Therefore nothing will
nothing will be
will be left
be left on
left on screen
on screen from
screen from the
from the previous
the previous iteration
try running the
running the application
now we will
will see we're
see we're getting
getting the polling
the polling, the
CPU load, the
the response time
time and the
and the user
the user count
user count quite
count quite successfully
quite successfully appearing
successfully appearing on
So you can
see we can
we can quite
quite easily build
easily build up
build up information
up information on
screen using only
using only a
only a very
a very few
very few console
few console commands
in summary what
summary what we've
today is we've
is we've used
we've used console
used console commands
console commands to
commands to set
up a console
a console of
console of a
of a fixed
a fixed size
fixed size, make
make it a
it a virtual
a virtual screen
virtual screen to
screen to allow
us to increase
to increase it
increase it should
it should we
should we wish
wish to do
to do so
We have prepared
have prepared our
prepared our screen
our screen, used
used the clear
the clear screen
clear screen command
screen command to
command to clear
created a function
a function to
function to display
to display static
display static headers
static headers and
headers and we've
and we've used
we've used a
used a loop
a loop to
to display information
display information using
information using a
using a delay
a delay on
delay on the
screen to our
to our user
our user in
user in different
in different colors
different colors using
colors using a
using a standard
a standard, generic
generic print to
to console command
specify the row
row and column
and column, the
text and the
and the color
the color of
color of the
the text to
text to display
With these few
these few commands
few commands you
commands you can
console compiler to
compiler to display
display information to
a user quite
user quite easily
easily to allow
to allow them
allow them to
them to monitor
to monitor some
monitor some background
some background process
find this code
this code useful
code useful in
in your applications
your applications but
applications but that's
to testing using
testing using the
using the PowerBasic
by adding support
support for hyperlinks
for hyperlinks on
hyperlinks on text
on text and
text and other
and other enhancements
other enhancements to
enhancements to the
to the existing
the existing code
We have our
have our experimental
our experimental browser
experimental browser set
browser set up
set up so
up so we
we can display
can display an
display an index
an index page
On our index
index page we
we have four
have four graphics
of these graphics
these graphics contains
graphics contains a
contains a hyperlink
a hyperlink, allowing
us to click
to click on
on the hyperlink
the hyperlink and
hyperlink and go
and go to
go to a
to a number
number of underlying
of underlying pages
to add today
add today is
is the ability
I've prepared a
prepared a second
a second index
second index page
index page to
page to demonstrate
to demonstrate how
demonstrate how this
how this is
So in order
order to see
see what we're
what we're aiming
we're aiming for
aiming for I'm
for I'm going
use a chrome
chrome browser and
browser and we're
going to drag
to drag this
drag this new
this new index
new index page
index page onto
page onto that
onto that browser
this is what
is what we're
what we're after
The four links
four links as
links as we
as we had
we had before
had before and
before and a
and a text
a text link
text link at
link at the
the bottom, allowing
us to go
to go on
go on to
on to a
to a fifth
a fifth page
Also as you'll
as you'll note
you'll note on
note on the
on the chrome
the chrome browser
chrome browser, when
when the mouse
the mouse moves
mouse moves over
moves over one
over one of
of the underlying
the underlying hyperlinks
underlying hyperlinks, the
the mouse cursor
mouse cursor changes
cursor changes from
changes from a
from a pointer
a pointer to
pointer to a
to a hand
Regardless of whether
of whether it's
whether it's a
it's a graphic
a graphic or
graphic or a
or a text
We're also going
also going to
going to implement
to implement that
implement that functionality
that functionality in
functionality in our
in our application
But before we
before we do
we do that
do that we're
that we're going
going to fix
to fix one
fix one bug
one bug I've
bug I've discovered
I've discovered in
discovered in the
in the existing
we go into
go into say
into say for
say for example
for example page
example page four
page four, page
page four contains
four contains text
contains text and
and a graphic
The graphic has
graphic has no
has no underlying
no underlying hyperlink
Yet when we
when we go
we go on
on to the
to the graphic
the graphic and
graphic and click
and click on
on it, it's
it's taking us
taking us to
to page one
The reason for
reason for this
for this, as
as we go
we go onto
go onto each
onto each page
each page, it's
it's automatically setting
automatically setting up
up the hot
the hot zones
hot zones for
zones for each
of these hyperlinks
Designating the x
y coordinates, which
which contain the
contain the zone
the zone, which
which when clicked
when clicked on
clicked on will
on will trigger
will trigger the
trigger the hyperlink
These hot zones
hot zones are
zones are not
are not being
not being cleared
being cleared out
cleared out when
out when we
when we move
we move from
move from one
from one page
one page to
to page two
page two and
two and we
and we click
we click up
click up near
up near the
near the top
It will go
will go back
back to page
So that's the
that's the first
the first bug
first bug we
bug we need
need to fix
is a function
function called render
called render the
HTML tags, which
which is triggered
is triggered each
triggered each time
time we load
we load a
load a new
a new page
is where we're
where we're going
to make the
make the one
the one line
one line code
line code change
code change to
change to fix
to fix this
fix this bug
So here we
here we are
we are now
are now in
now in the
in the render
HTML tags function
So before we
before we step
we step through
of the tags
the tags within
tags within the
within the HTML
the HTML, we'll
we'll want to
want to reset
reset the contents
the contents of
contents of the
of the global
the global array
global array, which
which contains the
contains the URLs
this by using
using the reset
the reset command
reset command, followed
by the name
the array we
array we wish
wish to reset
running our code
our code now
is our browser
if we drag
we drag our
drag our index
our index onto
index onto that
onto that and
that and click
click on page
on page four
on the image
the image it
image it is
it is now
is now no
now no longer
no longer linking
longer linking back
linking back to
we have cured
have cured the
cured the first
So let's drag
let's drag index
drag index number
index number two
number two onto
two onto this
onto this browser
this browser and
browser and see
how it looks
will see that
see that each
that each of
of the graphical
the graphical images
graphical images is
images is still
is still appearing
still appearing as
appearing as normal
the text link
bottom of the
the page going
page going to
going to a
to a new
new page five
page five is
five is only
is only appearing
only appearing as
appearing as text
This is because
is because we're
because we're not
we're not handling
not handling this
handling this particular
this particular type
particular type of
type of tag
of tag just
tag just yet
So we've now
we've now created
now created a
created a page
a page five
page five that
five that this
that this can
this can actually
can actually link
actually link to
link to when
to when we
get the link
the link working
code and make
make the changes
the changes to
changes to allow
us to handle
to handle this
handle this particular
type of text
of text hyperlink
tags function is
function is our
is our engine
our engine to
engine to handle
to handle all
handle all HTML
all HTML tagging
we look further
look further down
further down on
down on that
on that, we'll
we'll see these
see these are
all the tags
the tags that
tags that it
that it currently
it currently handles
We are handling
are handling the
handling the A
the A and
A and the
and the closing
the closing A
closing A tags
A tags at
tags at the
the moment, but
but we're going
have to add
to add some
add some extra
some extra functionality
extra functionality to
functionality to these
to these to
these to allow
it to perform
of all, we
need to get
get the data
the data inside
data inside the
inside the tag
from the index
to HTML file
HTML file, we
we have here
have here the
here the tag
the tag, which
which is referencing
is referencing page
referencing page five
The highlighted portion
highlighted portion is
portion is already
is already picked
already picked up
picked up and
up and populated
and populated into
populated into the
into the attributes
the attributes variable
the go to
to page five
five is not
is not currently
not currently picked
currently picked up
But we have
have a function
a function which
function which can
used to pull
to pull that
pull that information
that information back
information back called
back called get
called get tag
tag value, which
which is exactly
is exactly what
exactly what we're
So the return
the return from
return from this
from this function
this function will
function will return
return the text
want to display
to display on
here we need
need to differentiate
differentiate between the
between the graphical
the graphical image
graphical image, which
which is within
is within this
within this tag
this tag and
tag and the
and the text
the text which
One easy way
way to do
do this is
is to look
for the equals
the equals sign
If it contains
it contains an
contains an equals
an equals, then
then it is
is a graphical
a graphical image
graphical image we're
image we're attempting
we're attempting to
attempting to show
to show to
show to the
If it does
it does not
does not contain
not contain an
contain an equals
then it's not
it's not an
an image source
image source, but
but plain text
we can test
can test for
test for this
for this by
using the in
the in string
in string command
set a variable
a variable to
variable to say
to say image
say image is
image is false
This can be
can be tested
be tested elsewhere
tested elsewhere in
elsewhere in the
in the code
Next thing to
thing to do
is to reset
to reset our
reset our tag
our tag user
tag user defined
user defined type
So the reset
reset command can
command can reset
can reset this
reset this user
this user defined
We're incrementing the
incrementing the URL
the URL and
URL and we're
and we're storing
we're storing the
storing the URL
the URL itself
URL itself in
itself in our
in our user
our user defined
defined type, as
as the URL
the URL was
URL was picked
was picked up
picked up previously
up previously in
previously in the
So having got
having got this
got this far
this far, we
need to print
to print this
print this text
this text onto
text onto the
onto the graphical
the graphical canvas
function called print
called print data
print data whose
data whose job
job it is
it is to
is to perform
to perform this
perform this, we're
to change the
change the existing
the existing print
existing print data
print data command
data command to
command to accept
to accept additional
accept additional parameters
going to pass
to pass ref
pass ref tag
ref tag and
tag and we're
to pass our
pass our user
tag is either
is either going
either going to
to be true
be true or
true or false
the user defined
defined type is
type is going
used to store
store the hot
the hot zone
hot zone, which
is the URL
the URL, just
just as we
we did for
did for the
for the graphical
print data function
data function and
function and add
and add these
add these extra
these extra parameters
So here are
here are the
are the two
the two extra
two extra parameters
extra parameters for
parameters for this
for this function
this function, the
ref tag variable
tag variable and
Print data is
data is called
called from elsewhere
from elsewhere in
have to ensure
to ensure that
ensure that everywhere
that everywhere it's
everywhere it's called
it's called, these
these two additional
two additional parameters
additional parameters are
parameters are included
do that, I'm
to add on
add on a
on a couple
couple of extra
of extra local
extra local variables
These I'm going
to call image
call image width
image width and
width and image
and image height
We're creating these
creating these two
two variables to
variables to contain
contain the width
the width and
width and the
and the height
the height of
height of our
of our text
our text hyperlink
This information is
information is needed
is needed as
needed as we
as we need
need to store
to store this
store this information
this information in
information in the
in the global
the user clicks
user clicks on
clicks on the
on the graphics
the graphics control
graphics control, we
we know whether
know whether they've
whether they've clicked
they've clicked on
clicked on a
on a hot
which will trigger
will trigger a
trigger a call
to a hyperlink
to do that
do that, we'll
need to change
to change this
change this line
This is looking
is looking to
looking to see
see whether our
whether our string
our string coming
string coming in
coming in as
in as image
as image source
image source equals
source equals within
equals within it
change this so
this so it's
so it's looking
it's looking for
for a href
a href equals
To tell whether
tell whether it's
whether it's an
an embedded image
embedded image or
image or a
or a hyperlink
us to set
set the global
the global X
global X and
and Y positions
Y positions of
positions of the
But before this
before this section
need to determine
to determine the
determine the height
the height and
height and width
and width of
width of the
is done by
done by testing
by testing our
testing our ref
our ref tag
true and the
and the str
the str data
str data is
data is not
not an empty
an empty length
empty length string
length string, then
we know it's
know it's a
it's a text
we can work
can work out
out the height
do this quite
this quite easily
quite easily by
easily by using
using a new
a new command
new command called
command called graphics
called graphics cell
graphics cell size
This gives us
gives us the
us the height
width of a
of a standard
a standard character
standard character in
character in the
in the selected
the selected font
This saves us
saves us having
us having to
having to work
work out which
out which font
which font we're
font we're currently
we're currently using
currently using on
using on the
And having worked
having worked out
worked out the
out the width
width and height
and height of
height of a
standard character, we
can then multiply
then multiply the
multiply the width
the width by
width by the
by the number
number of characters
And adding a
adding a little
a little to
little to the
to the height
the height just
height just to
just to make
make it slightly
it slightly bigger
us the values
the values we
values we can
can now store
now store in
store in our
Using the global
and Y as
Y as the
as the top
the top X
top X and
X and top
and top Y
And adding on
adding on to
on to that
to that the
that the width
and height for
height for the
for the bottom
the bottom X
bottom X and
X and bottom
and bottom Y
we try compiling
try compiling that
compiling that now
we have one
have one local
one local variable
local variable we
variable we still
have to declare
to declare, at
of the render
the render HTML
render HTML tags
So while we're
while we're adding
we're adding this
adding this variable
this variable I'm
variable I'm going
add some more
We currently have
currently have a
a command variable
command variable that
variable that stores
that stores the
stores the current
the current command
As some of
some of these
of these tags
these tags are
tags are going
to be nested
be nested, we'll
need to work
work out what
out what the
what the previous
the previous command
previous command was
create a local
a local variable
local variable to
variable to keep
the last command
And we'll also
we'll also create
also create a
create a couple
couple more boolean
more boolean variables
of the fact
the fact is
fact is it
is it an
it an image
an image or
image or not?
or not? And
not? And one
the fact are
fact are we
are we inside
we inside a
paragraph or not?
or not? This
not? This will
will give us
give us more
us more flexibility
flexibility for the
for the work
the work we're
work we're doing
we're doing today
doing today and
today and for
and for future
for future changes
In this line
of code we're
code we're picking
we're picking up
up the current
Before we populate
we populate this
populate this we'll
this we'll want
want to populate
to populate the
populate the last
last command variable
command variable we
variable we have
we have just
have just created
Now that that
that that is
that is stored
is stored we
stored we can
can quite happily
quite happily go
happily go ahead
go ahead and
ahead and populate
and populate the
populate the command
the command variable
So as you
see we make
we make other
make other calls
other calls to
calls to the
we will need
will need to
need to amend
to amend each
amend each call
each call to
call to this
to this print
this print data
data function to
function to add
to add these
Additionally in the
in the paragraph
the paragraph section
paragraph section we're
section we're setting
setting the paragraph
the paragraph boolean
be true since
true since we
since we know
we know at
know at this
at this point
this point we
point we are
we are inside
are inside a
And here are
here are our
are our extra
our extra parameters
extra parameters to
parameters to the
data function call
And we've now
we've now added
now added the
added the population
the population of
population of the
of the in
the in paragraph
in paragraph variable
paragraph variable to
variable to false
to false when
false when we
when we close
we close off
close off our
off our paragraph
So our application
our application is
application is compiling
is compiling quite
compiling quite happily
quite happily now
running it and
it and see
see how good
how good it
good it looks
So we drag
we drag in
drag in index
in index 2
can see we've
see we've now
we've now got
now got go
got go to
page 5 at
5 at the
However is it
is it a
it a hyperlink?
a hyperlink? If
hyperlink? If we
on it it's
it it's indeed
it's indeed taking
indeed taking us
So we've achieved
achieved the ability
to have hyperlinks
have hyperlinks which
hyperlinks which go
which go directly
go directly to
directly to the
the page regardless
page regardless if
regardless if they
if they are
they are images
are images or
images or text
However what we
what we need
need to tackle
to tackle next
tackle next is
next is we
is we need
change the mouse
mouse cursor from
cursor from an
from an arrow
an arrow to
arrow to a
a hand when
hand when it
when it goes
it goes over
goes over a
over a hot
We already have
already have a
have a callback
a callback function
callback function which
function which handles
which handles the
handles the mouse
the mouse movement
mouse movement on
movement on the
screen to pick
up the left
the left and
and right mouse
right mouse clicks
is the graph
the graph proc
graph proc function
this function we
function we are
we are currently
are currently handling
currently handling two
handling two events
The left mouse
left mouse button
mouse button going
button going up
going up and
up and the
and the right
the right mouse
right mouse button
going to handle
to handle a
handle a new
a new event
new event in
event in here
to handle mouse
handle mouse move
This will trigger
will trigger every
trigger every time
every time the
time the mouse
the mouse is
mouse is actually
is actually moved
we will create
a new local
new local variable
variable to allow
store the handle
of the new
the new cursor
call this hand
is a new
a new mouse
new mouse move
mouse move event
This as we
we did with
did with the
with the previous
the previous events
previous events is
events is picking
is picking up
up the x
y coordinates of
coordinates of the
of the mouse
We're determining where
determining where the
where the location
the location on
location on the
on the graphical
the graphical screen
graphical screen because
screen because it
because it is
is a virtual
a virtual graphical
virtual graphical screen
graphical screen by
screen by adding
by adding on
adding on the
on the width
using the existing
the existing function
existing function is
function is link
is link to
link to determine
whether the zone
the zone under
zone under the
under the cursor
the cursor is
cursor is a
hot zone containing
zone containing a
containing a hyperlink
If that's the
that's the case
the case we
case we are
we are checking
are checking to
if the hand
the hand handle
hand handle is
handle is currently
is currently populated
If it's not
it's not populated
not populated we're
populated we're then
we're then using
then using the
using the Windows
the Windows API
API call load
call load cursor
load cursor to
cursor to load
to load our
load our hand
our hand cursor
And using set
using set cursor
set cursor which
cursor which is
which is another
is another Windows
API call to
call to set
set the cursor
the cursor to
cursor to that
to that particular
that particular one
So we're now
we're now displaying
now displaying index
displaying index two
the mouse around
mouse around the
around the screen
the screen it
screen it stays
it stays as
stays as the
as the ordinary
the ordinary arrowed
ordinary arrowed mouse
arrowed mouse pointer
we move it
move it over
it over one
of the zones
the zones it
zones it changes
changes to a
move it back
it back it
back it changes
it changes back
changes back to
back to an
to an arrow
you will guess
will guess we
guess we are
we are not
are not putting
not putting any
putting any code
any code in
in to change
mouse cursor back
Windows is doing
is doing this
doing this automatically
this automatically for
automatically for you
the mouse down
mouse down to
down to where
to where our
where our text
text hyperlink is
hyperlink is it
is it changes
a hand as
hand as soon
as soon as
soon as we
as we are
we are over
are over the
over the hyperlink
have successfully implemented
successfully implemented the
implemented the ability
ability to change
mouse cursor when
cursor when we're
when we're over
we're over a
hot zone that
zone that contains
that contains a
One thing that
thing that we
we have not
have not done
not done yet
done yet is
yet is to
is to change
change the text
the text on
on our text
text hyperlink to
hyperlink to a
to a different
color and mark
and mark it
mark it as
it as underlined
This would normally
would normally indicate
normally indicate to
indicate to the
We won't do
won't do that
do that in
that in this
in this video
this video we'll
video we'll do
we'll do that
in a future
a future video
One other thing
other thing I'd
thing I'd like
I'd like to
like to do
do today to
today to finish
to finish off
finish off with
off with is
with is to
change the location
location of our
of our graphical
our graphical hyperlinks
graphical hyperlinks on
hyperlinks on screen
the moment they
moment they are
they are appearing
are appearing one
appearing one after
one after the
after the other
the other vertically
go into our
into our index
our index HTML
index HTML and
HTML and make
and make a
make a minor
a minor change
minor change these
change these are
these are contained
are contained within
contained within paragraphs
So the page
the page one
page one and
one and page
and page two
page two links
two links appear
links appear below
appear below each
below each other
If we take
we take out
take out these
out these paragraph
these paragraph tags
paragraph tags so
tags so that
so that both
that both hyperlinks
both hyperlinks are
hyperlinks are embedded
are embedded in
embedded in the
in the same
If we save
we save this
save this and
this and copy
and copy this
copy this back
this back into
back into our
into our browser
our browser we'll
browser we'll see
we'll see that
see that it
that it does
it does no
does no longer
no longer appear
longer appear normally
If we looked
we looked at
looked at this
at this file
this file in
file in a
in a Chrome
Chrome browser we
browser we will
will see they
see they would
they would appear
would appear quite
appear quite normally
There is however
is however a
however a gap
a gap between
gap between each
between each of
of these images
these images which
images which is
which is quite
is quite odd
quite odd as
odd as it
as it has
it has what
has what appears
what appears to
appears to be
be a hyperlink
a hyperlink for
hyperlink for page
for page one
page one between
one between the
between the two
I would have
would have expected
have expected both
expected both of
these images to
images to appear
to appear side
appear side by
side by side
by side with
side with no
with no gap
our browser is
browser is to
to change it
change it so
it so they
so they do
they do indeed
do indeed appear
indeed appear side
need to obviously
to obviously handle
obviously handle the
handle the fact
the fact that
fact that it's
that it's possible
it's possible to
possible to have
to have these
have these graphical
these graphical images
graphical images horizontally
images horizontally on
horizontally on one
on one line
So back to
you will remember
will remember earlier
remember earlier on
earlier on we
on we made
we made some
made some changes
some changes to
to the paragraph
the paragraph start
paragraph start and
start and paragraph
and paragraph end
paragraph end tags
a variable called
variable called paragraph
called paragraph either
paragraph either to
either to be
can use this
use this to
this to determine
to determine when
determine when we
when we print
we print an
print an image
an image on
image on screen
on screen if
screen if we're
if we're still
we're still inside
still inside a
paragraph or if
or if the
if the paragraph
the paragraph has
paragraph has moved
has moved on
can test to
if the last
last command was
command was the
was the closing
closing a tag
a tag and
tag and if
and if it's
if it's true
it's true we're
true we're currently
we're currently working
currently working on
working on an
on an image
the case then
case then we
reset the global
global x coordinate
x coordinate to
coordinate to be
to be 0
be 0 and
0 and the
and the calculation
the calculation of
calculation of the
of the y
the y coordinate
y coordinate will
coordinate will involve
will involve the
involve the current
the current value
current value plus
value plus the
plus the bottom
the bottom y
bottom y minus
y minus the
minus the top
the top y
use the graphics
the graphics set
graphics set position
set position command
position command to
the location where
location where the
where the next
the next printing
next printing will
printing will take
will take place
So since we're
since we're now
we're now using
now using this
using this in
this in paragraph
paragraph variable we'll
variable we'll need
need to pass
to pass this
pass this to
to the function
the function which
function which displays
which displays the
displays the images
this is an
is an additional
an additional variable
additional variable we're
variable we're adding
we're adding on
to the list
And having passed
having passed this
passed this variable
this variable to
variable to this
function we can
can test it
test it within
it within the
within the function
the function itself
our function and
function and we'll
and we'll add
we'll add on
add on this
on this extra
this extra parameter
And further down
further down the
down the function
the function where
function where we're
where we're updating
we're updating the
updating the global
the global position
global position we
position we can
we can take
can take out
take out the
out the graphics
the graphics get
graphics get position
get position command
position command as
command as this
as this is
this is determined
is determined further
determined further up
further up anyway
So this line
of code is
code is no
no longer needed
can now test
now test the
test the in
in paragraph tag
If the in
paragraph tag is
is true then
true then we
we can add
can add on
add on the
the width of
width of our
our graphical image
graphical image to
to the x
the x coordinate
it is false
is false then
false then we're
then we're resetting
resetting the x
coordinate to 0
y coordinate can
coordinate can be
can be the
be the y
y coordinate plus
coordinate plus the
plus the height
of our image
So with that
with that logic
that logic in
logic in place
in place let's
place let's try
let's try recompiling
try recompiling which
recompiling which recompiles
which recompiles quite
recompiles quite cleanly
And we'll try
we'll try running
application and we'll
and we'll see
we'll see if
see if it
if it now
it now handles
now handles correctly
handles correctly the
correctly the new
the new index
have page one
page two appearing
two appearing side
appearing side by
our browser we
browser we have
we have no
have no space
no space between
space between the
the two images
two images which
images which to
which to be
to be honest
be honest I
honest I personally
I personally prefer
on page one
page one it
one it takes
on page two
page two it
two it will
Page three still
three still works
Page four and
four and the
and the link
the link which
link which is
is the text
the text URL
text URL to
URL to page
page five also
five also works
And our history
our history is
history is working
is working fine
done today we
today we have
we have enabled
have enabled our
enabled our browser
our browser to
browser to support
to support text
support text hyperlinks
We have also
have also allowed
also allowed the
allowed the cursor
the cursor on
cursor on the
on the mouse
the mouse to
mouse to change
to change to
change to a
when it moves
it moves over
moves over the
the hyperlink either
hyperlink either graphical
either graphical or
graphical or text
And additionally we
additionally we can
can now have
now have graphical
have graphical hyperlinks
graphical hyperlinks side
hyperlinks side by
by side on
side on the
on the same
the same line
There is of
is of course
of course a
course a great
to do but
do but we'll
but we'll leave
we'll leave that
leave that for
that for later
for later videos
at topics common
topics common to
common to both
to both the
both the PowerBasic
PowerBasic console and
console and Windows
and Windows Compilers
again at using
at using pointers
using pointers within
pointers within your
looking at pointers
at pointers in
pointers in PowerBasic
Pointers are variables
are variables that
variables that hold
that hold a
hold a 32-bit
a 32-bit address
32-bit address of
address of code
of code or
code or data
or data located
data located somewhere
located somewhere else
somewhere else in
else in memory
It's called a
called a pointer
a pointer because
pointer because it
because it literally
it literally points
literally points to
points to that
to that location
create a small
a small application
small application today
application today that
today that will
that will demonstrate
will demonstrate the
use of pointers
of pointers, what
what they are
they are and
are and how
and how you
how you can
can use them
Let's assume for
assume for this
for this application
this application that
application that we're
to be storing
be storing some
storing some data
some data on
data on stars
want to store
to store a
store a number
number of different
of different pieces
different pieces of
information on each
on each star
As the stars
the stars exist
stars exist in
exist in a
in a three-dimensional
a three-dimensional space
three-dimensional space, we
store the x
the x, the
the y and
Plus we'll also
we'll also want
also want to
store the star's
the star's mass
number of ways
of ways of
ways of actually
of actually storing
actually storing these
storing these kinds
these kinds of
kinds of information
of information, but
but today we're
using a user-defined
a user-defined type
This user-defined type
user-defined type we're
type we're going
to call stars
call stars, udt
We're prefixing the
prefixing the name
the name with
name with udt
with udt to
udt to indicate
to indicate that
indicate that it
it is indeed
indeed a user-defined
The four elements
four elements within
elements within this
within this type
this type are
type are all
are all single-type
all single-type variables
Single-type variables are
variables are single-precision
are single-precision floating-point
single-precision floating-point numbers
floating-point numbers, or
or to put
to put it
put it more
it more simply
more simply, single-precision
These are very
are very versatile
The values stored
values stored within
stored within one
within one of
one of these
of these variables
these variables can
variables can contain
can contain decimal
contain decimal points
This single-precision representation
single-precision representation comes
representation comes as
comes as close
as close as
close as it
it can in
can in six
in six digits
So if your
if your number
your number has
number has six
has six digits
six digits within
digits within it
within it, you
you can store
can store it
store it within
it within this
type of variable
This includes decimal
includes decimal places
purposes of what
of what we're
what we're doing
doing today, this
this will work
will work out
work out just
out just fine
have our user-defined
our user-defined type
user-defined type set
type set up
set up at
up at the
the application, within
within any of
the functions or
functions or subroutines
or subroutines, we
we can declare
can declare a
declare a local
local variable as
variable as that
as that user-defined
that user-defined type
we can populate
can populate it
we are declaring
are declaring a
declaring a local
variable called uStar
And we're declaring
we're declaring that
declaring that as
that as udt
as udt stars
So our local
our local variable
local variable uStar
variable uStar, is
is now a
now a user-defined
user-defined type containing
type containing the
containing the four
four elements we
elements we declared
we declared at
declared at the
can now populate
now populate these
populate these quite
using the prefix
the prefix command
prefix command here
command here to
here to make
make the code
the code look
code look a
look a little
a little tidier
All the prefix
prefix command does
command does is
does is it
is it takes
it takes the
takes the string
the string that's
string that's in
that's in the
in the double
the double quotes
double quotes and
quotes and it
and it starts
it starts each
starts each following
each following line
following line until
line until end
until end prefix
end prefix with
prefix with those
with those values
So it's uStar
sngX equals and
equals and then
and then the
then the value
the value for
value for the
for the first
And it does
it does the
does the same
same for the
for the next
the next three
next three lines
we're doing here
doing here is
here is we're
is we're setting
setting the value
value of our
of our x
our x coordinate
x coordinate of
coordinate of the
of the star
the star to
star to be
be a random
number between 1
between 1 and
1 and 1000
and 1000, and
and we're adding
adding on another
on another random
another random number
That's a number
number between 0
between 0 and
0 and 1
So this will
this will populate
will populate our
populate our user-defined
user-defined type with
type with the
with the values
the values randomly
If we're using
we're using random
using random numbers
random numbers, we'll
set the random
generator to a
to a random
a random seed
do this at
our application, by
using the randomise
randomise command with
command with a
with a seed
a seed number
To make this
make this fairly
this fairly unique
fairly unique, we're
use the timer
the timer as
timer as our
as our seed
our seed number
that we've populated
we've populated this
populated this local
this local variable
local variable, we'll
we'll now want
now want to
want to push
to push the
push the information
the information out
information out to
out to the
to the log
the log so
log so we
can see what
see what values
what values have
values have come
have come out
come out of
out of it
So we're using
using the format
the format command
format command to
command to turn
to turn these
turn these numbers
these numbers into
numbers into strings
into strings so
strings so we
can use our
use our logging
our logging command
logging command to
command to send
to send information
send information out
application now, it
it will display
screen a number
number of values
of values for
values for the
for the x
the y, the
the z and
z and the
and the mass
the mass of
mass of our
of our star
we've now stored
now stored random
stored random information
random information within
information within our
within our locally
our locally declared
locally declared user-defined
declared user-defined type
Of course, you
can have arrays
have arrays of
arrays of user-defined
of user-defined types
if we were
we were looking
were looking to
looking to store
to store information
store information on
information on a
on a multitude
a multitude of
multitude of stars
of stars, we
we could use
could use an
use an array
an array containing
array containing each
containing each element
each element being
element being this
being this user-defined
where we can
we can start
can start to
start to use
to use pointers
we do the
do the array
the array, let's
let's use pointers
use pointers with
pointers with what
with what we've
what we've got
we've got –
got – the
– the single
the single variable
So for the
for the moment
the moment, let's
let's comment out
comment out this
out this code
will create some
create some new
some new code
new code using
code using a
using a pointer
be storing information
storing information on
information on multiple
on multiple stars
multiple stars and
stars and printing
and printing out
printing out information
out information on
multiple stars, I'm
to create two
create two new
two new functions
new functions –
functions – one
one to store
store the information
on a star
a star and
star and one
one to output
to output the
output the information
So we start
we start off
start off as
off as we
we did before
want to create
variable as this
as this user-defined
this is exactly
is exactly the
same line of
of code as
code as we
as we used
we used before
used before to
before to declare
to declare our
declare our local
variable as the
as the user-defined
the user-defined type
user-defined type for
type for stars
going to prepare
to prepare a
prepare a pointer
pointer to be
be used for
used for that
And here, our
local variable is
variable is called
is called 'single
called 'single star'
that as the
user-defined type, but
but we're following
we're following that
following that with
that with the
with the word
the word 'pointer'
word 'pointer' –
'pointer' – to
– to say
to say that
say that this
as a pointer
a pointer variable
And now that
that we've declared
we've declared this
declared this pointer
this pointer variable
pointer variable, we
now populate it
And we're populating
we're populating this
populating this pointer
pointer variable by
variable by using
using the VARPRT
the VARPRT function
This returns the
returns the 32-bit
the 32-bit address
address of a
of a variable
And in brackets
in brackets, we
have the name
of the variable
the variable we're
variable we're returning
So we're populating
we're populating the
populating the 32-bit
32-bit address into
address into our
into our pointer
our pointer variable
pointer variable of
variable of where
of where the
where the information
the information is
information is stored
is stored for
stored for 'U
for 'U star'
And as I
as I said
I said earlier
said earlier, we're
to use two
use two new
one to prepare
prepare the star
star to populate
populate the values
the values within
values within the
within the user-defined
user-defined type, and
print the details
the details out
So we're calling
we're calling the
calling the first
the first function
first function 'prep
function 'prep star'
'prep star' and
star' and the
and the printing
the printing function
printing function 'print
function 'print star'
As you'll see
you'll see from
see from both
from both of
both of the
of the calls
the calls to
calls to these
to these functions
these functions, we're
we're passing the
passing the pointer
the pointer variable
pointer variable –
variable – the
the single star
single star variable
star variable –
variable – to
– to each
and create the
create the first
first of those
of those two
those two functions
is the skeleton
the skeleton of
skeleton of our
of our new
new function –
function – 'prep
– 'prep star'
in the brackets
the brackets, this
where we normally
we normally put
normally put the
put the name
variable we're passing
we're passing to
passing to this
this case, since
since we're passing
passing a pointer
a pointer, pointers
pointers have to
to be passed
be passed by
passed by value
have the 'by
the 'by value'
'by value' word
value' word at
word at the
variable we're bringing
we're bringing in
this case, it's
it's the pointer
the pointer for
pointer for 'star'
that as a
as a user-defined
user-defined type, which
which we declared
very end, we
This indicates this
indicates this variable
this variable is
variable is in
in fact a
fact a pointer
we have that
have that set
that set up
set up, how
how do we
do we populate
we populate the
the values using
values using this
using this pointer
this pointer variable?
pointer variable? So
variable? So the
So the lines
the lines of
code to populate
to populate this
populate this value
this value look
value look remarkably
look remarkably similar
remarkably similar to
similar to what
to what we
what we did
The only difference
only difference is
difference is the
is the prefix
the prefix line
We're using an
using an '@'
an '@' sign
'@' sign in
sign in front
in front of
front of the
of the 'p'
the 'p' star
'p' star variable
The '@' sign
'@' sign before
sign before the
before the 'p'
the 'p' indicates
'p' indicates to
indicates to Power
Basic that we're
that we're using
will populate the
the values in
values in our
in our user-defined
user-defined type quite
type quite nicely
So anytime you
anytime you see
you see the
see the '@'
front of a
a variable, you
you know that
know that it's
that it's a
it's a pointer
a pointer that's
pointer that's being
that's being used
we've populated the
populated the user-defined
user-defined type using
type using our
using our 'PrepStar'
our 'PrepStar' function
'PrepStar' function, how
can we print
we print it
print it out
it out so
out so the
user can see
can see it?
see it? So
it? So we'll
So we'll now
we'll now create
now create our
create our 'PrintStar'
our 'PrintStar' function
So again here
again here, you'll
you'll see we're
see we're taking
we're taking exactly
taking exactly the
We have 'byval'
have 'byval' before
'byval' before the
before the name
the variable, and
and it's a
it's a user-defined
user-defined type of
type of stars
And again at
again at the
the end we
end we have
we're passing exactly
passing exactly the
the same variable
same variable in
variable in exactly
in exactly the
the same way
same way to
way to this
to this printing
this printing function
And to print
the details of
details of our
of our stars
our stars out
stars out to
out to our
to our log
our log, we're
using the 'format'
the 'format' command
'format' command to
to turn the
turn the value
the value back
value back into
back into a
into a string
a string so
string so we
use the fun
the fun log
fun log function
And the variable
the variable name
variable name is
name is preceded
is preceded with
preceded with the
with the '@'
'@' sign to
sign to indicate
to indicate to
indicate to Power
Basic that it's
But the rest
the rest of
rest of the
the code looks
code looks exactly
looks exactly the
We're still using
still using the
using the dot
the dot and
dot and the
and the name
of the element
the element within
element within the
set up, our
our program should
program should function
should function in
function in exactly
So there our
there our program
our program has
program has run
has run, and
we have three
have three coordinates
three coordinates for
coordinates for our
for our star
our star, and
have the star's
have successfully used
successfully used a
used a pointer
a pointer with
pointer with a
with a locally
a locally defined
locally defined user-defined
defined user-defined type
So what are
what are the
are the advantages
the advantages of
advantages of using
of using this
pointer variable? Say
variable? Say for
for example we
example we wanted
we wanted to
wanted to store
to store multiple
store multiple stars
multiple stars in
stars in an
in an array
array of user-defined
So let's dimension
let's dimension an
dimension an array
array of 100
of 100 elements
to be an
be an array
array of our
of our user-defined
going to step
step through this
through this array
this array using
array using a
So as we've
as we've done
we've done before
done before, we'll
we'll need a
need a local
variable to act
to act as
act as a
pointer to our
to our user-defined
user-defined type, using
did before, declaring
declaring PStar as
PStar as a
of stars with
stars with the
word 'pointer' on
'pointer' on the
on the end
the end to
end to indicate
indicate that this
indeed a pointer
let's now do
now do the
do the For
the For next
So for each
for each star
each star, we're
populate the pointer
pointer for the
for the element
the element of
element of the
the array being
array being processed
we will populate
populate the PStar
the PStar variable
PStar variable again
variable again using
again using var
using var pointer
var pointer, but
this time pointing
time pointing to
pointing to the
to the element
And having got
having got that
got that value
that value into
value into PStar
into PStar, we
can now quite
now quite happily
quite happily call
happily call our
call our PrepStar
our PrepStar function
PrepStar function, exactly
same as we
So from the
from the point
the point of
point of view
of view of
view of the
of the PrepStar
the PrepStar function
PrepStar function, it's
it's receiving a
receiving a pointer
And it doesn't
it doesn't really
doesn't really matter
really matter whether
matter whether you're
whether you're passing
you're passing the
the pointer to
to a single
a single declared
single declared variable
declared variable or
variable or an
or an element
an element of
element of an
of an array
It will handle
will handle both
handle both quite
both quite happily
we have now
have now populated
now populated the
populated the value
value for each
each star, let's
let's print some
print some of
some of those
of those values
those values out
Let's go for
the first three
first three stars
So again, we'll
we'll do a
do a For
next loop, and
we will call
will call our
call our printStar
our printStar function
So again, we're
going for lngR
for lngR equals
lngR equals 1
equals 1 to
1 to 3
give us information
us information on
populating the PStar
the PStar pointer
PStar pointer again
pointer again using
var pointer just
pointer just as
did before, with
with the element
And we're calling
calling the printStar
the printStar function
printStar function with
function with PStar
with PStar as
PStar as the
as the variable
the variable being
variable being passed
being passed in
So let's run
let's run that
run that code
that code and
code and see
So there is
our function running
function running quite
running quite happily
have the information
the information coming
information coming out
coming out of
out of the
array of stars
of stars just
stars just as
we had the
had the information
coming out from
out from the
from the single
can see, we're
using the same
the same functions
same functions to
functions to handle
to handle both
handle both single
both single variable
single variable user-defined
variable user-defined types
user-defined types and
types and an
and an array
an array element
array element, all
all using pointers
So to prove
to prove the
prove the information
information is coming
is coming out
coming out quite
out quite correctly
quite correctly, let's
let's print out
print out the
out the third
the third star
third star without
star without using
without using pointers
To make sure
make sure the
sure the information
information is exactly
is the code
code to print
to print out
out the values
the values of
values of the
of the third
setting the element
element number to
to be number
be number 3
is the third
And we're printing
we're printing out
printing out the
out the x
z coordinates of
coordinates of that
of that star
that star, and
and also the
also the mass
mass of the
we run this
run this now
this now, it
it should show
should show exactly
show exactly the
the same values
same values coming
values coming out
the array as
array as it
as it is
it is for
is for this
for this last
this last piece
last piece of
have the value
the value coming
value coming out
the array using
array using the
using the pointer
the pointer functions
pointer functions and
functions and coming
and coming out
coming out directly
out directly without
directly without using
And the values
the values are
values are exactly
are exactly the
in summary, as
see from this
from this code
this code, this
is a simple
a simple way
simple way to
way to use
to use pointer
use pointer, giving
giving you a
you a lot
a lot of
lot of flexibility
flexibility in how
in how you
you can actually
can actually use
actually use information
use information which
information which you're
which you're manipulating
you're manipulating for
manipulating for users
your applications, but
web browser by
browser by adding
hyperlinks on images
Hypertext Marker Language
Marker Language (HTML)
Language (HTML) was
(HTML) was developed
was developed in
developed in 1989
in 1989 at
1989 at CERN
at CERN, the
the European organisation
European organisation of
organisation of nuclear
of nuclear research
Its purpose was
purpose was not
was not only
not only to
only to provide
to provide a
provide a common
a common file
common file format
file format to
format to share
to share knowledge
share knowledge, but
but also to
also to allow
to allow those
allow those files
those files to
files to have
have the ability
ability to link
to link to
link to other
to other files
This could be
could be on
be on distant
on distant servers
This was no
was no small
no small feat
small feat as
feat as they
as they also
they also needed
also needed to
needed to create
to create the
create the Hypertext
the Hypertext Transfer
Hypertext Transfer Protocol
Transfer Protocol (HTTP)
Protocol (HTTP) -
(HTTP) - this
- this to
this to standardise
to standardise communication
standardise communication between
communication between computers
between computers and
computers and the
and the world
the world wide
world wide web
wide web was
web was born
The work in
work in our
in our light
our light browser
light browser so
browser so far
so far has
far has been
has been to
been to support
to support a
support a number
number of tags
of tags within
Today we'll be
we'll be adding
be adding support
for the Anchor
the Anchor tag
Anchor tag to
tag to allow
to allow hypertext
allow hypertext linking
hypertext linking to
linking to other
to other documents
other documents by
documents by allowing
by allowing users
allowing users to
users to click
click on images
So what changes
what changes do
changes do we
do we need
make to a
to a code
a code to
code to support
to support this
support this new
this new Anchor
new Anchor tag?
Anchor tag? The
tag? The first
first thing we
thing we will
look at is
at is when
is when the
when the HTML
the HTML code
HTML code is
code is loaded
is loaded into
loaded into our
into our light
So what do
what do we
to do to
do to keep
track of these
of these new
these new Anchor
new Anchor tags?
Anchor tags? As
tags? As we're
to be clicking
be clicking on
clicking on images
on images, we
need to keep
track of how
of how much
how much space
much space these
space these images
these images take
images take up
take up on
up on screen
These zones need
zones need to
need to be
to be stored
be stored within
stored within the
within the application
the application so
application so that
user clicks with
clicks with the
with the left
mouse button anywhere
button anywhere on
anywhere on the
graphics control we
control we can
we can determine
can determine whether
whether the user
user has indeed
has indeed clicked
indeed clicked on
clicked on an
an image which
image which has
which has an
has an underlying
an underlying Anchor
underlying Anchor linking
Anchor linking it
linking it to
it to another
to another document
create a user
a user defined
defined type called
type called Image
called Image Tag
This will store
will store the
store the top
left hand and
hand and bottom
and bottom right
bottom right hand
right hand corners
hand corners of
corners of any
of any of
any of these
of these linked
these linked zones
linked zones and
zones and we
create a global
global array to
array to store
our new type
new type called
type called udt
called udt image
udt image tag
This has a
has a number
It stores an
stores an x
an x and
and y coordinate
y coordinate for
coordinate for the
for the top
It also stores
also stores the
stores the bottom
the bottom right
right hand corner
corner of that
of that image
us to define
define the area
the area of
area of our
of our clicking
our clicking zone
clicking zone and
zone and additionally
and additionally it
additionally it stores
it stores a
stores a URL
the URL that
URL that once
that once the
once the user
clicks on this
on this zone
this zone we
zone we will
we will link
will link to
link to and
to and we
have dimensioned a
dimensioned a global
global array called
array called URLs
is an array
array of this
of this user
So having this
having this global
global array our
array our next
our next question
next question is
question is how
is how many
how many elements
many elements are
elements are we
are we going
we going to
going to allow
to allow in
allow in this
in this array?
this array? How
array? How many
How many zones
many zones are
zones are we
user to click
to click on?
click on? So
on? So we've
So we've added
new constant called
constant called max
called max URLs
are currently setting
currently setting this
setting this as
this as 100
will allow up
allow up to
up to 100
to 100 links
100 links within
links within our
within our HTML
Should you find
you find 100
find 100 links
100 links is
links is too
is too small
too small you
small you can
you can always
can always increase
always increase the
increase the value
value of the
of the constant
the constant and
constant and within
and within our
within our pb_main
pb_main function we
we can dimension
can dimension this
dimension this array
So there we
have our global
array of URLs
of URLs dimensioned
URLs dimensioned for
dimensioned for the
for the maximum
we have somewhere
have somewhere to
somewhere to store
the information we
information we next
we next need
next need to
need to pick
to pick the
pick the information
the information up
information up from
from the HTML
the HTML file
to do let's
do let's launch
let's launch the
launch the browser
the browser as
browser as it
as it currently
it currently stands
currently stands and
stands and we're
to drag our
our index document
index document into
document into that
into that browser
that browser and
browser and as
the four images
four images quite
images quite happily
quite happily showing
happily showing and
showing and we're
and we're not
we're not currently
not currently handling
currently handling the
handling the anchor
So our first
is to handle
handle the anchor
anchor tag when
tag when the
when the document
the document is
document is read
change to the
tags function to
to add support
add support for
support for anchor
for anchor tags
is our render
our render HTML
is the heart
the heart of
heart of our
of our render
our render engine
render engine handling
engine handling each
handling each of
So the last
the last tag
last tag in
tag in our
in our list
our list currently
list currently is
currently is the
is the image
the image tag
image tag which
tag which is
which is testing
is testing to
testing to ensure
to ensure we're
ensure we're inside
we're inside the
inside the body
the body of
body of the
of the document
the document before
document before we
before we display
So let's first
let's first put
first put a
put a couple
couple of case
of case statements
statements in to
in to handle
the beginning and
beginning and the
and the end
of the anchor
the anchor tags
the two new
two new tags
new tags the
tags the beginning
anchor tag and
set a new
a new variable
new variable within
variable within here
within here called
here called ref
called ref tag
ref tag which
tag which will
will be true
be true at
true at the
beginning of a
of a tag
tag and false
and false at
false at the
This will let
will let our
let our code
our code know
code know that
know that we're
that we're inside
we're inside an
inside an anchor
an anchor tag
anchor tag group
tag group and
group and as
as we're handling
we're handling clicks
handling clicks on
clicks on images
on images today
images today we
today we can
can test that
test that within
that within the
within the image
image tag section
By testing this
testing this immediately
this immediately after
immediately after we
after we display
the image on
image on the
So since the
since the value
value of ref
of ref tag
is true we
true we know
know we're inside
we're inside a
inside a reference
We're within the
within the block
the block which
block which is
is the anchor
store the link
link which has
which has come
has come in
come in on
in on the
on the URL
So at this
point we need
need to have
to have already
have already stored
already stored the
stored the value
value in the
in the URL
the URL variable
URL variable and
variable and we
do that quite
that quite easily
quite easily at
easily at the
at the start
of the reference
the reference tag
reference tag because
tag because the
because the URL
the URL will
URL will be
will be within
be within the
within the attributes
So we're looking
we're looking specifically
looking specifically for
specifically for the
for the equal
the equal sign
equal sign and
sign and we're
and we're taking
we're taking the
taking the second
the second part
second part of
part of that
of that using
that using our
using our parse
our parse command
parse command and
command and trimming
and trimming off
trimming off any
off any double
any double quotes
moment this should
this should give
should give us
us the direct
the direct path
direct path, albeit
albeit in the
the same directory
same directory, to
to the file
the file we
file we wish
wish to link
So as the
as the anchor
anchor tag is
tag is processed
is processed before
processed before the
before the image
image tag then
tag then at
then at this
this point in
the code our
code our strURL
our strURL variable
strURL variable will
variable will be
will be populated
So where are
where are we
populate the details
details of this
of this image?
this image? The
image? The display
The display image
display image command
image command is
command is the
is the one
the one that
one that loads
that loads the
loads the image
the image up
image up from
up from file
to pass a
pass a user
defined type to
type to that
to that to
that to allow
us to pass
to pass back
pass back the
back the x
of the top
top left and
left and the
and the bottom
corners of the
of the rectangle
use a new
local variable which
variable which is
is a user
defined type we
type we declared
be a local
to the beginning
the function and
function and declare
and declare the
declare the local
the local variables
local variables we're
variables we're going
to be needing
be needing to
needing to do
to do all
do all this
are our new
our new variables
using the ref
ref tag as
tag as a
as a true
a true or
or false to
false to determine
determine whether we're
whether we're inside
anchor tag or
tag or not
or not and
not and we're
using a user
type to store
store the coordinates
the coordinates top
coordinates top left
left and bottom
bottom right of
right of the
We're using url
using url to
url to store
store the url
the url in
url in the
in the link
the link and
link and we're
we're using another
using another variable
another variable which
is a long
a long as
long as the
as the last
the last populated
last populated url
As the user
the user will
user will have
will have up
have up to
up to 10
to 10 tabs
10 tabs usable
tabs usable within
usable within the
within the browser
the browser and
browser and we
and we load
we load each
load each one
each one up
one up dynamically
up dynamically each
dynamically each time
each time the
time the user
clicks on a
on a tab
Therefore we need
track of a
of a number
number of these
of these URLs
these URLs as
URLs as the
user can step
can step back
step back and
back and forward
and forward through
forward through 10
through 10 history
10 history pages
history pages for
pages for a
for a tab
a tab only
tab only to
only to hold
to hold information
hold information for
information for each
So as well
as well as
well as resetting
as resetting this
resetting this tag
this tag we
tag we need
pass this value
this value to
value to our
to our display
our display image
display image as
image as it
as it will
it will populate
will populate this
populate this with
this with x
with x and
before we amend
we amend this
amend this display
this display image
display image function
image function let's
function let's push
push on and
on and put
and put the
put the rest
the code in
code in here
If ref tag
true then we're
then we're inside
inside a anchor
The url has
url has already
already been populated
been populated so
populated so we
need to increment
to increment the
increment the pointer
to our url
our url position
This will determine
will determine the
determine the place
the place in
place in the
in the urls
the urls array
can populate the
populate the link
the link from
link from the
from the url
Inside our user
defined type and
type and then
quite easily slot
easily slot this
slot this entire
this entire user
entire user defined
defined type into
type into the
into the array
array of user
of user defined
user defined types
defined types based
types based on
based on the
the url long
url long variable
So next we
next we need
to the display
we have changed
have changed the
changed the number
of parameters it's
parameters it's now
it's now accepting
Up until now
until now it's
now it's taken
it's taken only
taken only three
only three parameters
three parameters the
parameters the dialog
the dialog handle
dialog handle the
handle the attribute
the attribute string
attribute string and
string and the
and the tab
the tab that
tab that has
that has been
has been selected
Now we're passing
we're passing an
passing an additional
an additional value
additional value which
value which is
So further down
further down this
down this code
this code we
code we have
we have loaded
have loaded the
loaded the image
the image file
image file from
file from disk
from disk into
disk into memory
into memory and
memory and we
have the image
the image width
and the image
the image height
image height which
height which are
which are the
are the key
the key bits
key bits of
of information we
information we need
to store in
So after our
after our copy
our copy command
copy command we
command we can
we can store
can store the
store the location
prefix command to
command to prefix
to prefix the
prefix the name
name of our
of our user
defined type before
type before each
before each of
storing the x
x and the
and the y
the y coordinates
y coordinates using
coordinates using our
our global x
storing the bottom
hand corner by
corner by taking
by taking the
taking the global
the global and
global and adding
width of that
that image and
image and the
bottom y coordinate
y coordinate is
coordinate is the
is the global
the global y
global y coordinate
height of the
have now stored
now stored the
stored the x
and y location
y location of
location of both
both the top
the top and
top and left
corners of our
our image and
image and this
this is passed
is passed back
passed back to
to the calling
the calling routine
calling routine to
routine to be
be passed into
passed into the
into the global
that we've stored
we've stored that
stored that information
that information in
information in a
global array how
array how can
use of it
of it so
it so that
the user hovers
user hovers over
hovers over it
over it when
it when they
when they click
they click with
click with the
mouse button it
button it will
it will load
will load up
load up the
up the URL
the URL that's
URL that's been
that's been stored
been stored in
stored in the
Well we've already
we've already got
already got a
got a function
function which allows
us to right
to right click
right click on
control we merely
we merely need
merely need to
need to add
to add to
add to that
that the ability
ability to trap
to trap left
trap left clicks
left clicks as
clicks as well
as well and
well and that
and that is
that is within
is within the
within the graphic
the graphic proc
graphic proc function
is our graphic
our graphic proc
function which is
which is called
is called when
called when the
user clicks either
clicks either with
either with the
the left or
left or the
or the right
have a condition
a condition set
condition set up
set up to
up to handle
handle the right
mouse button at
button at the
add a condition
a condition for
condition for the
for the left
is the case
case statement to
statement to handle
to handle when
handle when the
When that button
that button is
button is released
is released we
released we will
we will pick
will pick up
y coordinates on
coordinates on screen
populate the URL
the URL with
URL with an
with an empty
length string and
string and at
the moment we
moment we will
we will display
will display a
display a message
a message box
message box on
box on the
screen to prove
to prove that
prove that we've
that we've actually
we've actually trapped
actually trapped the
trapped the left
now and if
if we left
we left mouse
left mouse click
mouse click someone
click someone on
someone on the
the screen we're
screen we're getting
getting the message
the message box
So we are
we are correctly
are correctly picking
correctly picking up
up the click
the click with
So we've proved
we've proved that
proved that works
that works quite
works quite successfully
next we have
we have to
new function called
function called isLink
This will take
will take three
take three parameters
parameters the x
the x the
x the y
y coordinate and
coordinate and the
and the URL
The URL is
URL is going
to be populated
be populated on
populated on return
on return from
return from that
from that function
that function if
function if the
if the zone
the zone we
zone we have
we have clicked
have clicked upon
clicked upon is
upon is one
one of those
of those which
those which has
has an embedded
So as I
I said this
said this function
function is going
to take the
take the three
and the return
the return value
return value which
value which will
use a for
next loop here
loop here to
here to step
each element of
the global URLs
global URLs array
is quite a
quite a simple
a simple function
for each element
element of this
of this global
global array we're
array we're testing
we're testing the
testing the x
y coordinates against
coordinates against the
against the values
If the x
x coordinate is
coordinate is greater
is greater than
greater than the
than the top
top x but
x but less
but less than
less than the
than the bottom
top y and
y and less
and less than
If this is
is all true
all true then
are indeed within
indeed within a
within a zone
a zone which
zone which holds
which holds a
holds a link
can then populate
then populate the
the URL from
URL from that
from that by
that by using
using the trim
the trim command
trim command to
command to trim
to trim it
trim it down
it down from
down from the
from the extra
the extra spaces
extra spaces at
spaces at the
can then return
then return the
return the value
value true and
true and exit
and exit the
the function immediately
If we find
we find no
find no entry
no entry within
entry within this
within this array
this array then
array then the
the value returned
value returned is
returned is false
give us a
us a mechanism
a mechanism by
mechanism by which
by which when
which when the
can determine if
determine if the
if the area
the area they
area they have
they have clicked
have clicked on
clicked on has
on has been
has been stored
been stored as
stored as an
as an anchor
an anchor hyperlink
So if this
if this does
this does return
does return true
return true what
true what do
do we do
we do next?
do next? Well
next? Well we
Well we need
need to link
to the new
the new URL
let's create a
which can do
do that for
that for us
for us and
us and we'll
we'll call that
that function process
function process a
process a URL
new function process
a URL taking
URL taking its
single parameter which
parameter which is
this function we're
function we're going
be using some
using some common
some common code
common code we
we have already
have already created
is to determine
determine the existing
the existing path
existing path of
path of the
of the URL
the URL we're
URL we're currently
we're currently on
We can get
can get that
get that from
that from the
the URL text
URL text box
text box which
box which is
which is on
is on screen
screen at the
of the dialog
Eventually we're going
have to support
to support documents
support documents which
documents which are
are on a
on a web
a web server
web server as
server as opposed
as opposed to
opposed to those
to those which
those which are
which are local
are local to
local to the
to the machine
the machine we
machine we are
are currently running
currently running on
So this code
this code will
code will go
will go through
through a number
of iterations as
iterations as we
as we move
we move down
move down that
down that path
that path but
path but for
but for the
the moment we're
moment we're going
take the value
the value that's
value that's in
the URL at
the dialog and
dialog and we're
going to work
work out is
out is the
is the path
the path relative
path relative to
relative to where
to where the
where the existing
the existing URL
existing URL actually
URL actually is
we're looking for
for the backslash
the backslash and
backslash and forward
and forward slash
forward slash within
slash within the
within the URL
can determine the
determine the delimiter
the delimiter either
delimiter either backslash
either backslash or
backslash or forward
or forward slash
forward slash depending
slash depending whether
depending whether we're
whether we're actually
we're actually pulling
actually pulling any
pulling any local
any local file
local file or
file or we're
or we're taking
we're taking this
taking this from
this from somewhere
from somewhere on
somewhere on the
on the world
wide web and
web and as
we're handling everything
handling everything locally
everything locally we're
locally we're taking
taking the last
the last element
last element of
of the end
of the path
the path replacing
path replacing that
replacing that with
with the file
the file we've
file we've just
we've just loaded
just loaded up
loaded up the
and we're launching
we're launching from
launching from there
using an inbuilt
an inbuilt function
inbuilt function in
function in our
in our file
our file handling
file handling routines
handling routines library
routines library which
library which is
is called start
called start range
start range parse
takes the path
the path the
path the delimiter
the delimiter and
delimiter and the
the end element
We have determined
have determined the
determined the end
end element using
element using the
using the parse
the parse count
parse count value
This counts the
counts the number
of elements using
elements using the
using the delimiter
delimiter and subtracts
and subtracts one
subtracts one and
one and we
and we end
we end up
end up with
up with a
with a path
a path which
path which is
the path to
path to the
to the folder
the folder but
folder but not
but not the
not the file
the file itself
We then add
then add on
on the file
file we've got
we've got from
got from the
URL and in
and in later
in later videos
later videos we'll
videos we'll put
we'll put code
put code in
to handle these
handle these new
these new paths
that we've got
we've got this
this far we
far we now
series of steps
of steps to
steps to actually
to actually set
actually set values
set values on
values on the
on the dialogue
the dialogue and
dialogue and to
and to handle
handle the population
population of our
of our graphics
we are first
are first going
first going to
to call the
call the clear
the clear graphics
clear graphics control
graphics control routine
control routine and
routine and then
and then set
then set the
set the text
the text at
text at the
of the dialogue
the dialogue to
dialogue to be
be the URL
URL we're about
about to link
can then store
then store the
URL in our
global array by
array by determining
by determining the
determining the tab
the tab the
tab the user
user has currently
has currently selected
currently selected and
selected and using
and using that
using that to
that to store
to store it
store it in
it in the
And our final
our final stage
final stage is
stage is to
is to increment
increment the latest
the latest slot
latest slot array
slot array and
array and then
and then store
the URL history
URL history and
history and then
and then finally
then finally render
finally render the
the HTML itself
HTML itself using
itself using our
our existing function
existing function setup
function setup to
setup to perform
perform that task
So these are
these are routines
are routines we've
routines we've created
we've created in
created in previous
in previous videos
this far how
far how close
how close is
close is our
is our code
code to completion?
to completion? Let's
completion? Let's try
Well there is
Let's try dragging
try dragging in
dragging in our
in our index
Well our index
index document is
document is showing
is showing but
showing but we've
but we've still
we've still got
still got the
got the text
the text for
text for the
the href on
href on the
we go over
go over page
over page one
one and click
on it we
it we are
are indeed getting
indeed getting a
getting a link
link to page
page two we're
two we're getting
we're getting page
getting page two
However we need
to get rid
get rid of
rid of this
of this text
this text on
code and have
look at what
at what prints
what prints on
prints on this
on this graphics
this graphics control
So printing to
to the graphics
graphics control of
control of plain
of plain text
plain text is
text is done
is done in
done in a
in a function
This determines the
determines the position
the position to
position to print
to print and
print and prints
and prints text
prints text using
text using the
using the graphics
the graphics print
graphics print command
And we are
we are storing
are storing the
storing the value
of the data
the data to
data to print
to print in
print in this
in this temporary
this temporary variable
However if this
if this temporary
temporary variable contains
variable contains an
contains an image
image source command
source command then
command then it's
then it's an
need to test
to test and
test and bypass
and bypass that
bypass that if
that if that's
is our test
our test for
test for the
for the embedded
the embedded link
string command to
command to look
look for image
for image source
As the value
value within temp
within temp data
temp data is
data is all
is all lowercase
all lowercase then
lowercase then this
then this will
will work quite
work quite successfully
And if the
if the value
the value is
value is greater
greater than zero
than zero then
zero then it's
up the position
the position we
position we are
we are on
are on screen
We can print
can print a
blank line and
line and we
can then repopulate
then repopulate the
repopulate the global
running that code
that code once
code once more
drag in our
index page and
page and we
are now missing
now missing the
text we had
But the links
the links will
links will still
will still work
we can have
at the history
the history and
history and we'll
we'll see we
have our index
page and page
So all appears
all appears to
to be working
be working quite
working quite well
Page one gives
one gives us
gives us page
us page one
page one, page
page two gives
two gives us
us page two
page two, and
and page three
page three gives
three gives us
us page three
If however we
however we scroll
scroll down the
down the virtual
the virtual graphics
virtual graphics control
graphics control and
control and click
page four it's
four it's not
it's not giving
not giving us
giving us a
us a page
Or is it?
is it? If
it? If we
If we scroll
we scroll back
scroll back up
back up we'll
up we'll see
we have indeed
have indeed got
indeed got page
got page one
So why have
why have we
have we got
we got page
page one when
one when we
when we actually
we actually clicked
actually clicked on
clicked on page
on page four?
page four? The
four? The reason
for this is
is the graphics
graphics control is
control is virtual
As we scroll
we scroll up
scroll up and
up and down
and down the
down the position
the position has
position has actually
has actually changed
So what has
what has returned
has returned when
returned when we
when we click?
we click? Are
click? Are they
Are they coordinates?
they coordinates? Is
coordinates? Is it
Is it are
it are the
are the coordinates
the coordinates on
coordinates on the
on the top
of the current
the current part
current part of
part of the
of the window?
the window? So
window? So if
page two it's
two it's going
going to give
give us page
page one because
one because that's
because that's where
that's where page
where page one
page one existed
need to find
to find a
find a way
a way of
way of handling
of handling when
handling when the
has actually scrolled
actually scrolled down
scrolled down to
down to a
to a lower
a lower part
lower part of
of the graphics
the graphics page
fix that problem
So when the
the user actually
user actually clicks
actually clicks on
on the left
mouse button we
button we need
In here we're
here we're picking
y coordinates but
coordinates but we're
but we're using
using a virtual
a virtual window
get the beginning
beginning of this
of this window
this window and
window and Power
and Power Basic
Power Basic provides
Basic provides a
provides a graphic
a graphic get
graphic get view
get view command
view command and
command and this
and this allows
pick up a
up a width
a width and
height of where
of where we
where we currently
we currently are
currently are and
are and we
can then add
then add that
add that on
that on to
we've now started
now started to
started to use
two new variables
new variables which
variables which we'll
which we'll need
to create at
create at the
of our function
our function as
function as we
have now done
So this should
this should allow
should allow us
us to correctly
to correctly pick
correctly pick up
pick up where
up where we
where we are
we are actually
are actually clicking
actually clicking on
clicking on and
on and get
and get coordinate
get coordinate system
coordinate system we
system we can
we can actually
actually use with
use with a
with a global
running the code
the code once
our index, we
we can click
page one, we
on page three
page three and
three and if
scroll down if
down if we
page four it
four it has
it has indeed
has indeed got
got page four
However the position
the position on
position on that
on that screen
that screen is
screen is further
is further down
further down so
down so we'll
so we'll need
the location back
location back to
So there's one
there's one more
one more change
more change we
change we have
have to make
However the ability
ability to click
click on each
on each of
the pages is
pages is working
is working quite
working quite nicely
So once more
once more back
more back to
So there are
there are several
are several places
several places within
places within the
within the code
the code we
code we could
we could probably
could probably put
probably put this
put this change
However the render
the html function
html function is
function is where
is where all
where all information
all information is
information is rendered
is rendered to
rendered to the
So it's the
it's the logical
the logical place
logical place to
place to put
to put this
put this single
where we set
we set up
set up details
up details for
details for the
for the graphics
We do a
do a clear
a clear command
clear command, we
we set the
set the colors
the colors, we
set the phone
the phone, we
going to enter
to enter a
enter a new
in here and
here and that's
and that's to
that's to use
use the graphic
graphic set view
set view command
set the view
the view to
view to 00
to 00 which
00 which is
is the top
left hand coordinates
hand coordinates of
coordinates of our
once more, bring
index page, scroll
scroll down, select
select page four
four and go
and go back
now going back
going back to
the page which
page which is
which is ideal
we can link
can link to
link to each
the pages quite
pages quite successfully
quite successfully regardless
successfully regardless of
regardless of the
of the size
of our browser
We can make
can make our
make our browser
our browser larger
browser larger to
larger to accommodate
to accommodate all
accommodate all four
all four links
four links and
links and we
can link quite
link quite easily
click on an
on an area
an area outside
area outside the
outside the click
the click zones
click zones, nothing
to be inside
be inside the
inside the zone
the zone which
zone which we
which we have
we have trapped
have trapped the
trapped the coordinates
coordinates of in
of in order
order to make
make the anchor
the anchor link
anchor link work
link work correctly
what we've achieved
we've achieved today
achieved today is
a new html
new html command
html command, the
us to wrap
to wrap around
wrap around the
around the image
image tag and
tag and make
make the image
the image a
image a clickable
a clickable link
The user when
user when they
they click on
click on this
on this image
this image can
image can then
can then link
then link to
to the image
the image and
image and then
and then link
link to another
So using this
using this technique
this technique we
technique we can
can actually connect
actually connect together
connect together a
together a large
a large number
large number of
number of documents
of documents and
documents and as
and as we
we are supporting
are supporting up
supporting up to
links within any
within any one
any one html
one html file
html file this
file this gives
this gives you
more to be
to be done
be done with
done with anchors
with anchors and
anchors and links
and links in
links in general
However we'll leave
that for a
for a later
a later video
for today, thank
Welcome in this
Windows compilers today
compilers today we
at the parameters
the parameters passed
parameters passed between
passed between functions
between functions and
functions and subroutines
It has been
has been some
been some time
time since we
since we did
we did a
did a video
on the parameters
So today we're
going to revisit
to revisit the
revisit the subject
the subject for
subject for those
for those of
those of you
of you who
you who are
who are just
are just using
just using Power
using Power Basic
console compiler and
compiler and the
Windows compiler can
compiler can be
be used with
used with the
with the source
code for this
for this project
have two include
two include files
include files at
files at the
for the Windows
Windows API and
API and one
one for our
for our common
our common display
common display library
display library, which
which allows the
allows the source
source code to
code to be
be used either
used either in
either in the
Windows compiler or
compiler or the
or the console
first function in
function in your
your application that
application that gets
that gets executed
gets executed is
executed is the
is the pb_main
function and in
this function you
function you can
you can include
can include code
include code and
code and call
and call other
call other functions
other functions and
going to start
to start this
start this demonstration
this demonstration by
demonstration by calling
by calling a
function called process
called process count
process count by
count by reference
passing a parameter
a parameter to
this function called
function called count
We have declared
have declared the
declared the count
the count as
count as a
as a long
a long and
long and we're
next loop to
loop to count
to count between
count between one
between one and
one and five
function will be
will be called
be called five
called five times
function process count
count by ref
the brackets we
brackets we have
have the parameter
the parameter list
parameter list, in
this case just
case just a
just a single
single parameter called
parameter called count
called count, which
which has been
has been defined
been defined as
defined as a
This is preceded
is preceded by
preceded by the
by the word
the word byref
word byref to
byref to indicate
that this parameter
this parameter has
has been passed
been passed by
passed by reference
a reference to
reference to where
Power basic by
basic by default
by default passes
default passes parameters
passes parameters by
parameters by reference
if we had
we had no
had no mention
no mention of
mention of the
of the word
the word by
word by ref
by ref it
ref it would
it would still
would still be
still be passed
function we're declaring
we're declaring a
variable called value
called value also
value also as
also as a
we're populating that
populating that local
that local variable
local variable with
variable with the
with the value
of the parameter
the parameter passed
parameter passed in
passed in count
in count and
count and we're
we're adding one
adding one to
one to it
to it and
it and we're
we're printing the
printing the value
the value out
value out to
see the values
the values put
values put out
put out to
out to a
to a log
a log are
log are two
are two, three
five and six
is because every
because every time
every time we
time we call
we call this
function we're taking
taking the values
the values one
values one to
one to five
to five and
five and adding
adding a one
a one to
to it, giving
giving us the
the values two
values two through
two through six
have successfully passed
successfully passed a
passed a parameter
a parameter from
parameter from one
from one function
one function to
function to another
One thing to
thing to note
to note when
note when you're
when you're calling
you're calling functions
calling functions is
functions is that
is that the
that the value
the value you're
value you're passing
you're passing in
passing in here
in here which
here which is
is called count
called count which
count which is
is the variable
the variable we
variable we could
we could have
could have this
have this called
this called something
called something entirely
something entirely different
If we call
this new count
new count and
count and changed
and changed the
changed the other
the other references
other references to
references to that
to that, the
the application would
application would work
would work just
work just as
just as well
this is that
is that you're
that you're passing
you're passing a
a parameter by
parameter by reference
by reference therefore
reference therefore the
therefore the name
the parameter from
parameter from this
from this point
this point of
of view is
view is irrelevant
is irrelevant it's
irrelevant it's the
it's the same
We can prove
can prove this
prove this quite
easily by adding
by adding an
adding an extra
extra line of
code to our
to our function
If we place
we place an
place an increment
an increment command
increment command in
command in as
in as the
as the bottom
the bottom line
bottom line of
line of this
this function which
function which would
which would increment
would increment the
increment the long
the long new
long new count
As this value
this value being
value being passed
passed in is
in is being
is being passed
passed in by
in by reference
by reference then
reference then if
then if you
if you increase
you increase this
increase this by
this by one
by one then
one then this
then this would
would be passed
be passed back
the calling function
the application once
application once more
once more we
more we will
values we get
we get out
get out are
out are quite
are quite different
is because each
because each time
through this function
we are incrementing
are incrementing the
incrementing the current
the current variable
current variable and
variable and this
this is being
being passed back
this is something
is something to
something to be
to be wary
be wary of
wary of when
of when you're
when you're passing
you're passing variables
passing variables from
variables from one
to another or
another or from
or from one
function to a
to a subroutine
If they're passed
they're passed by
reference then any
then any change
any change made
change made to
made to that
to that variable
that variable within
variable within the
within the subroutine
the subroutine or
subroutine or function
or function will
will be reflected
be reflected in
reflected in the
in the calling
you wish not
wish not to
not to pass
to pass them
pass them by
them by reference
by reference you
reference you can
you can pass
can pass it
pass it byval
it byval that's
byval that's by
that's by value
This way the
way the actual
the actual value
actual value of
the variable is
variable is passed
is passed and
passed and not
and not the
not the pointer
pointer to where
to where it
where it sits
it sits in
sits in memory
If we change
we change our
change our code
code to call
this function and
function and run
and run the
run the code
the code now
code now you
now you will
the values return
values return to
return to as
to as they
as they were
they were before
As any change
made to this
to this variable
variable is not
is not reflected
not reflected back
reflected back to
Normally you will
you will pass
will pass parameters
pass parameters by
by reference as
reference as it
it is more
is more efficient
Power basic will
basic will allow
you to pass
to pass up
pass up to
up to 32
to 32 parameters
32 parameters between
parameters between functions
So let's say
let's say we
say we wanted
wanted to pass
pass a parameter
parameter to a
a subroutine as
subroutine as opposed
opposed to a
to a function
How would we
would we do
we do that?
do that? We
that? We can
can call a
call a subroutine
a subroutine by
subroutine by using
using the word
the word call
word call followed
call followed by
of the subroutine
the subroutine and
subroutine and its
and its parameters
The command word
command word call
word call is
call is optional
If we emitted
we emitted call
emitted call and
call and just
and just put
just put the
the subroutine in
subroutine in it
in it would
would still function
still function perfectly
function perfectly well
Our subroutine would
subroutine would look
would look like
look like this
It would start
would start with
start with the
the word sub
word sub followed
sub followed by
by the subroutine
the subroutine name
subroutine name and
name and then
then the list
the list of
list of parameters
The main difference
main difference between
difference between a
between a function
a function and
function and a
and a subroutine
a subroutine is
subroutine is that
is that a
that a function
a function will
will return a
return a value
As we see
we see here
see here the
here the function
the function has
function has declared
has declared that
declared that it's
that it's going
going to return
to return a
return a long
a long number
The difference between
a function can
function can return
can return a
Functions are very
are very useful
very useful as
useful as you
you can embed
can embed them
embed them in
them in your
in your code
Subroutines on the
on the other
the other hand
other hand do
hand do not
do not return
not return values
that now we
will see our
see our subroutine
our subroutine is
subroutine is returning
is returning this
returning this value
this value here
value here 6
here 6 which
6 which was
which was the
was the last
the last value
last value of
As with functions
with functions if
functions if the
if the parameter
parameter passed is
passed is not
is not defined
not defined as
defined as by
as by val
by val or
val or by
or by ref
ref it will
it will always
will always be
always be passed
be passed as
passed as by
as by reference
To demonstrate using
demonstrate using your
using your function
your function within
function within your
within your code
your code we're
code we're going
to call a
call a new
function to determine
determine whether a
whether a value
a value is
value is odd
is odd or
odd or even
of all we
all we will
up a variable
a variable which
variable which we're
which we're going
going to test
test and we're
value of this
of this variable
the value 9
to test the
value coming back
coming back from
back from this
Is it true
it true or
true or is
or is it
is it false?
it false? Power
false? Power basic
Power basic has
basic has an
has an is
an is true
is true command
true command word
command word which
word which tests
which tests the
tests the value
value returned from
returned from this
And we're passing
we're passing our
passing our parameter
our parameter value
parameter value to
value to the
can determine what
determine what to
what to do
to do based
do based on
on the return
It's always an
always an advantage
an advantage to
advantage to name
to name your
name your functions
your functions for
functions for the
for the purpose
the purpose they
purpose they perform
this case 'is
case 'is value
'is value even'
If that returns
that returns true
returns true then
true then the
value is even
If it returns
it returns false
returns false then
false then the
value is false
This makes your
makes your code
your code much
code much easier
much easier to
to read and
read and understand
let's now create
now create this
new function is
function is value
is value even
value even passing
even passing the
passing the single
the single parameter
single parameter of
parameter of value
of value defined
value defined as
And our return
our return from
function is also
is also defined
also defined as
using the modulus
the modulus command
modulus command to
command to take
the value, divide
divide it by
it by 2
by 2 and
2 and if
if the remainder
the remainder from
remainder from that
from that division
that division is
division is 0
is 0 then
0 then the
value is divisible
is divisible by
divisible by 2
Therefore the value
will return true
return true to
true to the
the function calling
function calling this
calling this function
Otherwise there is
there is some
is some remainder
some remainder and
remainder and we
and we return
we return the
the value false
we run that
that code now
code now it
now it would
it would tell
would tell us
tell us that
us that the
that the number
the number 9
number 9 is
9 is odd
we change that
change that to
that to an
to an even
an even number
So for example
for example 12
example 12 and
12 and run
the code again
code again it
again it would
tell us the
us the value
So we've passed
we've passed a
passed a variable
function and returned
and returned a
returned a value
a value which
which is either
is either true
either true or
Another thing you
thing you can
can do with
do with parameters
with parameters is
parameters is make
is make one
make one or
one or more
or more of
more of the
of the parameters
the parameters optional
example we declared
we declared another
declared another value
another value variable
value variable called
variable called special
called special value
special value and
value and we've
and we've populated
we've populated that
populated that variable
that variable with
the value function
value function passing
function passing it
passing it two
it two parameters
soon as you
as you do
you do this
do this if
this if we
we make no
make no change
no change to
the function is
value even then
even then the
then the program
program will no
no longer compile
As you're attempting
you're attempting to
attempting to call
call a function
a function with
function with two
with two parameters
two parameters and
parameters and the
and the function
the function only
function only has
only has declarations
has declarations for
declarations for one
for one parameter
Therefore it will
will not compile
So what you
do to the
it to accept
to accept either
accept either one
either one or
one or two
or two parameters
two parameters is
parameters is to
is to put
the word optional
word optional before
optional before the
before the second
If you're passing
you're passing say
passing say for
for example five
example five parameters
five parameters to
parameters to a
a function then
function then every
then every parameter
every parameter after
parameter after the
after the first
the first declaration
first declaration of
declaration of optional
of optional will
optional will be
will be optional
So the optional
the optional parameters
optional parameters need
parameters need to
to be at
be at the
the parameters list
we have an
have an optional
an optional parameter
optional parameter in
parameter in how
in how does
how does our
does our function
our function know
function know that
that a parameter
a parameter has
been passed or
passed or not
Well you can
you can test
test for it
There is an
is an inbuilt
an inbuilt command
inbuilt command called
command called is
called is missing
is missing returns
missing returns true
true then there
then there is
there is no
is no optional
no optional parameter
If if missing
if missing returns
missing returns false
then the optional
parameter has indeed
has indeed been
indeed been passed
You can place
can place this
place this at
beginning of your
of your function
your function to
function to work
work out whether
out whether the
the optional or
optional or optional
or optional parameters
optional parameters have
parameters have been
have been passed
It's important not
important not to
not to reference
to reference the
reference the special
the special value
special value variable
value variable if
variable if the
the parameter has
parameter has not
has not been
not been passed
Using this construct
this construct allows
construct allows you
to set your
set your code
your code to
code to handle
to handle missing
handle missing parameters
the parameter is
parameter is missing
is missing then
missing then you
then you should
you should have
should have no
have no reference
no reference to
reference to the
to the named
the named parameter
For example special
example special value
parameter is not
is not missing
not missing then
then you can
you can reference
can reference the
reference the value
And if you're
if you're going
you're going to
use this for
this for the
for the on
the on in
on in the
the code you
code you can
you can populate
can populate a
populate a locally
a locally declared
locally declared variable
declared variable with
variable with that
with that value
application now it
now it will
it will print
will print out
print out that
out that the
that the optional
optional parameter equals
parameter equals 13
we change it
it so there
optional parameter the
parameter the code
the code will
code will still
will still compile
still compile and
compile and run
and run and
run and it
and it will
it will tell
will tell us
tell us there
us there is
So using optional
using optional parameters
optional parameters gives
parameters gives you
of flexibility within
flexibility within your
within your function
So what happens
what happens if
happens if we
if we want
want to pass
to pass more
pass more information
more information than
information than just
than just numbers?
just numbers? Let's
numbers? Let's declare
Let's declare a
declare a user
We've now declared
now declared a
declared a user
called udt car
udt car and
car and it
and it has
it has four
has four elements
four elements make
elements make model
make model type
model type and
type and color
these is set
is set up
set up as
up as a
as a 20
a 20 character
20 character string
Within a user
defined type all
type all the
all the strings
the strings are
strings are not
are not dynamic
not dynamic they
dynamic they have
they have to
to be fixed
be fixed length
fixed length so
length so it's
so it's important
important to set
set them up
them up to
up to be
to be large
be large enough
large enough for
enough for the
for the data
the data you're
data you're going
to be populating
be populating it
populating it with
can now declare
now declare a
as that user
that user defined
is called ucar
called ucar and
ucar and it's
and it's been
it's been declared
been declared as
declared as a
as a udt
a udt car
udt car which
car which is
is the type
the type we
we declared a
declared a moment
a moment ago
then populate that
populate that by
that by the
by the construct
the construct of
construct of ucar
of ucar dot
ucar dot and
dot and then
then the element
the element name
here to save
to save a
save a little
a little bit
little bit of
bit of typing
of typing and
typing and to
and to make
prefix command takes
command takes the
the string which
string which appears
which appears immediately
appears immediately after
immediately after it
after it and
it and adds
and adds it
adds it to
beginning of each
of each line
each line of
code that follows
that follows until
follows until we
until we get
get to end
to end prefix
saves you in
you in some
in some cases
some cases a
cases a great
deal of typing
typing and makes
and makes the
makes the code
code look nice
look nice and
nice and tidy
populated this user
defined type how
type how do
do we pass
we pass that
pass that to
that to a
to a function?
a function? Actually
function? Actually quite
Actually quite simply
quite simply as
simply as we
as we would
we would pass
would pass any
pass any other
any other variable
other variable just
variable just by
just by mentioning
by mentioning it
mentioning it in
in the list
the list within
list within the
within the brackets
let's create this
this new show
new show car
show car details
car details function
in the parameters
parameters list we've
list we've declared
we've declared a
declared a local
local variable in
variable in this
this case ucar
case ucar as
ucar as the
as the udt
the udt car
udt car type
car type in
type in the
same way as
way as you
as you declare
you declare any
declare any other
other variable passed
variable passed on
passed on the
So all we're
all we're doing
we're doing within
doing within this
function is we're
is we're displaying
displaying the details
of the car
the car out
car out to
By printing out
out the local
the local name
local name ucar
name ucar dot
ucar dot then
dot then the
element name in
name in this
case the string
the string make
string make followed
make followed by
followed by a
by a carriage
So that each
that each element
type is printed
is printed out
printed out on
out on a
on a separate
a separate line
code now we
see we get
get the Ford
the Ford Capri
Ford Capri electric
Capri electric silver
electric silver printed
silver printed out
printed out to
So we've successfully
we've successfully passed
passed a user
defined type from
type from one
However we can
can go further
go further with
further with this
What if we
we had multiple
had multiple car
multiple car details
car details to
details to pass
to pass to
pass to our
can set up
set up an
up an array
So we're dimensioning
we're dimensioning an
dimensioning an array
an array as
array as udt
as udt car
car and the
of elements we
elements we have
we have specified
have specified as
specified as two
we can step
can step through
step through a
through a little
a little for
little for next
loop to populate
populate this information
So we're doing
we're doing between
doing between one
one and two
and two and
two and we're
the prefix which
prefix which is
of the user
type and in
in brackets the
brackets the element
element number and
number and then
then the details
The make the
make the model
the model the
model the type
the type and
type and the
on the number
the word just
word just so
just so we
we can distinguish
can distinguish which
distinguish which is
which is number
is number one
number one and
one and which
and which is
is number two
it is an
an array we
array we need
need to put
put the two
the two brackets
two brackets at
brackets at the
As in a
in a ucars
a ucars open
ucars open then
open then close
then close brackets
This tells Power
tells Power Basic
that we're passing
passing an array
an array by
array by reference
So on our
on our function
our function to
function to actually
to actually display
actually display these
display these to
these to the
the user we're
user we're calling
calling the function
the function showAllCarDetails
The array is
array is defined
is defined as
as a u
a u cars
u cars open
cars open and
open and close
and close bracket
that it's an
it's an incoming
an incoming array
incoming array which
array which has
by reference and
reference and we're
and we're specifying
we're specifying that
specifying that the
that the type
the type of
type of this
of this array
this array is
array is a
defined type car
And we're putting
putting a for
next loop in
loop in here
in here again
here again to
again to display
to display each
display each element
each element within
within the array
determine the number
of elements within
elements within the
the array by
array by using
using the ubound
value in this
this case two
printing the details
details out to
the log using
log using ucars
using ucars and
ucars and then
and then within
then within brackets
within brackets the
by the type
the type from
type from the
from the user
defined type as
type as in
as in make
in make, model
get the details
the details for
details for number
for number one
one and the
and the details
for number two
can pass a
pass a great
deal of data
of data using
data using the
using the array
array as one
as one of
But it's important
important to note
to note that
note that you're
that you're always
you're always passing
always passing this
passing this by
this by reference
of data between
data between one
between one function
one function and
function and another
and another function
another function or
function or subroutine
or subroutine by
by using an
using an array
The arrays are
arrays are always
are always passed
always passed by
As in you're
in you're not
you're not passing
not passing the
passing the data
the data within
data within the
the array but
array but you're
but you're passing
you're passing details
passing details which
details which Power
which Power Basic
Power Basic can
Basic can use
can use to
use to determine
to determine where
determine where the
where the data
the data actually
data actually sits
made to data
to data within
the array will
array will of
will of course
of course be
course be reflected
calling routine as
routine as they're
as they're both
they're both pointing
both pointing at
pointing at the
at the same
the same place
Even if the
if the name
the name you're
name you're using
you're using in
using in the
parameters list is
list is different
So what other
what other kind
other kind of
kind of parameters
of parameters can
parameters can we
can we possibly
we possibly use?
possibly use? Well
use? Well say
Well say for
example we want
want to run
to run a
run a process
A simple arithmetic
simple arithmetic process
arithmetic process that's
process that's going
that's going to
to be called
be called many
called many times
set up some
up some local
some local variables
A counter variable
counter variable, a
a total variable
total variable, a
a loop variable
loop variable and
variable and a
and a quad
a quad timer
We'll set the
set the values
the values for
for the counter
the counter to
counter to 10
to 10 and
10 and the
and the total
the total to
total to be
next loop from
loop from 1
from 1 to
1 to 1000
be calling this
calling this new
function process 1000
process 1000 times
to determine how
determine how long
how long this
long this actually
this actually takes
actually takes for
takes for the
for the processor
the processor to
processor to process
to process I'm
process I'm going
using the tix
the tix command
tix command takes
command takes a
takes a single
case a quad
a quad value
This picks up
picks up the
up the cycle
the cycle count
cycle count of
count of the
of the CPU
And after the
after the processing
the processing I'm
processing I'm calling
I'm calling tix
calling tix end
Which picks up
up the value
the value again
value again and
again and subtracts
and subtracts the
subtracts the first
the first value
first value from
value from the
from the second
the second value
us the number
number of CPU
of CPU cycles
CPU cycles used
cycles used between
used between the
between the tix
the tix and
tix and the
and the tix
the tix end
tix end command
This is useful
is useful to
useful to determine
to determine just
determine just how
just how efficient
how efficient one
efficient one routine
one routine is
routine is to
is to another
going to print
out the total
total to the
the log with
log with the
with the number
create this fun
this fun process
fun process function
a very straightforward
very straightforward process
straightforward process which
process which takes
which takes the
takes the two
the two parameters
two parameters coming
parameters coming in
coming in the
in the total
the total and
total and the
and the counter
And it adds
it adds to
adds to the
to the total
the total what's
total what's already
what's already in
already in total
in total plus
total plus the
plus the counter
And then returns
then returns to
returns to the
calling function the
function the value
of the total
the total variable
see it gives
it gives us
us a value
a value 10,000
value 10,000 and
10,000 and it
it has taken
has taken 20,787
taken 20,787 CPU
20,787 CPU cycles
CPU cycles to
cycles to perform
to perform these
perform these 1000
these 1000 iterations
So that is
that is our
is our baseline
a function that
function that performs
that performs something
performs something purely
something purely arithmetic
purely arithmetic can
arithmetic can we
can we do
we do this
do this faster?
this faster? Is
faster? Is there
Is there a
there a faster
a faster way
faster way of
way of executing
of executing this
executing this process?
this process? Power
process? Power basic
basic has a
has a different
a different type
different type of
type of function
of function called
function called fast
called fast proc
created a fast
a fast proc
fast proc function
It's taking in
taking in exactly
the same parameters
However it's taking
it's taking them
taking them in
them in by
in by value
In fast proc
fast proc you
proc you have
you have to
have to use
to use by
use by value
The arithmetic calculation
arithmetic calculation within
calculation within the
within the routine
the routine is
routine is exactly
as the previous
the previous one
taking the value
value in total
in total and
total and adding
on the counter
of the fast
the fast proc
fast proc we're
proc we're returning
we're returning that
returning that total
that total to
So we now
now go back
function and call
and call this
is the call
call to the
resetting the counter
the counter and
counter and the
total to 10
10 and zero
We're starting the
starting the tix
doing a look
a look from
look from 1
to 1000 as
1000 as we
But we're calling
calling the new
the new fast
new fast proc
fast proc process
And we're ending
we're ending the
ending the tix
tix command and
command and printing
out the details
the details to
details to the
we get a
get a different
a different value
different value coming
get the same
same value for
for the total
the total 10
total 10 000
But the number
cpu cycles is
cycles is considerably
is considerably less
It's only 7371
So running this
running this as
this as a
as a fast
fast proc means
proc means our
means our process
our process runs
process runs in
runs in almost
in almost a
almost a third
a third of
third of the
of the time
So just in
just in case
in case the
case the position
the position in
position in the
the code is
code is actually
is actually giving
actually giving the
giving the fast
fast proc an
proc an advantage
We'll move that
move that code
that code to
code to before
to before the
before the normal
the normal process
We'll cut that
cut that code
that code out
code out of
out of here
of here and
here and we'll
and we'll put
we'll put it
put it in
it in before
in before the
before the other
the other one
calling the fast
the fast process
fast process first
process first and
first and we're
calling the normal
normal process second
that code again
code again we're
again we're still
we're still getting
still getting the
getting the same
the same 10
same 10 000
10 000 values
But the fast
fast proc is
proc is still
is still running
still running considerably
running considerably faster
considerably faster than
faster than the
than the normal
the normal function
are some disadvantages
some disadvantages in
disadvantages in using
in using fast
using fast proc
You can't use
can't use local
use local variables
local variables within
variables within the
But if you
you have something
have something that
something that is
that is computationally
is computationally intensive
computationally intensive and
intensive and you're
and you're calling
you're calling it
calling it a
it a great
a great many
great many times
many times it
times it can
it can speed
can speed up
speed up your
up your processing
your processing as
processing as you
So this completes
this completes our
completes our short
our short look
short look at
look at parameters
at parameters being
being passed between

















































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































