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
we will give
will give an
give an introduction
an introduction to
introduction to those
to those who
those who have
who have never
have never used
never used Power
used Power Basic
Power Basic before
Basic before or
before or even
or even considered
even considered taking
considered taking up
taking up programming
 Today we
look at classes
at classes and
classes and objects
What are they
are they and
they and how
and how can
can we use
we use them
use them within
them within Power
within Power Basic?
 So what
So what is
what is an
is an object
an object in
object in programming
in programming terms?
programming terms? How
terms? How can
How can I
can I use
I use it
use it and
it and what
and what is
what is it
is it for?
it for? There
for? There have
There have been
have been many
been many different
many different coding
different coding languages
coding languages created
languages created over
created over the
over the years
the years which
years which have
which have used
have used a
used a wide
a wide variety
wide variety of
variety of approaches
of approaches in
approaches in allowing
in allowing you
allowing you, the
the programmer, to
to create applications
 One of
of these approaches
these approaches was
approaches was to
was to encapsulate
to encapsulate both
encapsulate both code
both code and
code and data
and data into
data into something
into something referred
something referred to
referred to as
to as an
as an object
 This can
can be manipulated
be manipulated, called
called and updated
and updated to
updated to perform
to perform actions
perform actions you
actions you wish
wish to carry
to carry out
carry out within
out within your
within your application
 The idea
The idea behind
behind this encapsulation
this encapsulation is
encapsulation is that
that the object
the object is
object is reusable
is reusable in
reusable in future
in future applications
future applications that
applications that would
that would need
would need that
need that functionality
 This should
This should save
should save you
save you time
you time developing
time developing new
developing new applications
new applications as
applications as they
as they will
they will be
will be built
be built using
built using a
using a series
series of pre-built
of pre-built objects
pre-built objects with
objects with a
with a smaller
a smaller amount
smaller amount of
of code specifically
code specifically written
specifically written just
written just for
just for that
for that application
 An object
An object is
object is a
is a complete
a complete little
complete little programming
little programming package
programming package containing
package containing both
containing both code
and data, all
in one tightly
one tightly contained
tightly contained place
 They can
They can be
be used by
used by other
by other developers
other developers who
developers who only
who only need
only need to
need to know
to know the
know the interface
the interface to
interface to the
to the object
And need no
need no deep
no deep understanding
deep understanding of
understanding of what's
of what's happening
what's happening inside
happening inside the
inside the object
 More on
More on that
on that later
In object terminology
object terminology, a
a class is
class is used
is used to
used to define
to define an
define an object
an object like
object like a
like a blueprint
a blueprint, a
a description of
description of the
of the variables
the variables and
variables and routines
and routines that
routines that make
that make up
make up the
up the object
 When in
When in your
your code you
code you create
you create a
a new instance
new instance of
instance of an
of an object
an object, the
the definitions in
definitions in the
in the class
the class are
class are used
are used to
used to create
create the new
the new instance
instance of that
of that object
 As such
such you can
you can create
can create multiple
create multiple separate
multiple separate instances
separate instances of
instances of the
the same object
same object and
object and each
and each will
each will have
will have its
have its own
its own distinct
own distinct copy
distinct copy of
copy of the
the variables defined
variables defined within
defined within the
within the class
 In Power
In Power Basic
use of objects
of objects is
objects is optional
In fact, you
you can freely
can freely continue
freely continue to
continue to use
to use subroutines
use subroutines and
subroutines and functions
and functions even
functions even along
even along with
along with classes
with classes and
 It has
has been said
been said that
said that computer
that computer CPUs
computer CPUs do
CPUs do not
do not run
not run classes
run classes natively
classes natively and
natively and that
and that any
that any use
any use of
use of them
of them, while
while beneficial to
beneficial to the
to the programmer
the programmer, is
is bound to
bound to bloat
to bloat the
bloat the code
the code or
code or slow
or slow down
slow down the
down the processing
 While this
While this may
this may be
may be true
be true of
true of other
of other languages
other languages, Power
Basic has gone
has gone a
gone a long
a long way
long way to
way to make
make the use
of objects practical
objects practical, fast
fast and with
and with little
with little overhead
 Each time
Each time you
time you wish
wish to make
use of an
an object, you
instance of it
you instantiate it
 This creates
This creates the
creates the object
the object which
object which encapsulates
which encapsulates both
encapsulates both the
both the code
code and the
and the variables
the variables within
variables within it
 These variables
These variables are
variables are referred
are referred to
to as instance
as instance variables
This data is
data is hidden
is hidden within
hidden within the
within the object
the object and
object and cannot
and cannot be
cannot be accessed
be accessed directly
accessed directly as
directly as these
as these variables
variables are invisible
are invisible to
invisible to the
the code outside
code outside the
outside the object
They can only
can only be
only be read
be read or
read or updated
or updated by
updated by using
using the subroutines
the subroutines within
subroutines within the
the object, by
by use of
use of a
of a method
a method or
method or property
So what terminology
what terminology do
terminology do I
do I need
need to learn
to learn in
learn in order
order to use
to use objects?
use objects? -
objects? - Class
- Class is
Class is a
is a definition
a definition of
definition of a
of a complete
a complete object
complete object which
object which may
which may include
may include one
include one or
or more interfaces
 - Interface
- Interface is
Interface is a
of a set
a set of
set of methods
of methods and
methods and properties
and properties which
properties which are
which are implemented
are implemented on
implemented on an
on an object
 - Method
- Method is
Method is a
is a subroutine
a subroutine very
subroutine very similar
very similar to
similar to a
a function or
or subroutine in
subroutine in traditional
in traditional code
 - Property
- Property is
Property is a
is a method
a method used
method used to
used to read
to read or
read or write
or write data
write data to
to the internal
the internal variables
internal variables within
 - Class
- Class method
Class method is
a subroutine but
subroutine but private
but private to
private to the
This cannot be
cannot be called
be called from
called from the
from the outside
the outside code
 - Instance
- Instance data
Instance data, these
these are variables
are variables within
the object set
object set up
set up when
up when the
when the object
object is created
 - Constructor
- Constructor, this
is an optional
an optional class
optional class method
class method run
method run when
run when the
 - Destructor
- Destructor, this
object is destroyed
 So when
So when should
when should you
should you use
you use objects?
use objects? Creation
objects? Creation of
Creation of an
an object requires
object requires a
requires a degree
a degree of
degree of planning
of planning as
planning as you
as you need
need to decide
to decide what
decide what information
what information it
information it should
it should store
should store, how
how it should
it should manipulate
should manipulate information
manipulate information given
information given to
given to it
it and how
and how it
it should interface
should interface with
interface with applications
with applications making
applications making use
making use of
 You may
may have a
have a review
a review stage
review stage after
stage after an
after an application
an application has
application has been
been completed and
completed and as
and as part
as part of
of that review
that review you
review you may
you may look
may look at
look at how
at how you
you can improve
can improve your
improve your skills
your skills and
skills and development
and development time
development time for
time for the
the next piece
next piece of
piece of work
 You could
You could identify
could identify that
identify that some
that some code
some code that
code that you
that you created
you created using
created using traditional
using traditional functions
traditional functions and
and subroutines is
subroutines is very
is very likely
very likely to
to be reused
be reused either
reused either by
either by yourself
by yourself or
yourself or another
or another team
another team in
team in a
a future development
 This would
This would raise
would raise the
raise the option
the option of
option of redeveloping
of redeveloping this
redeveloping this useful
this useful code
useful code in
code in the
in the form
the form of
form of an
an object that
object that can
that can be
can be easily
be easily be
easily be used
used in future
future applications needing
applications needing that
needing that functionality
 Power Basic
Power Basic does
Basic does give
does give you
you the flexibility
the flexibility of
flexibility of having
of having your
having your entire
your entire application
entire application using
application using objects
using objects or
objects or a
or a mix
a mix of
mix of traditional
of traditional functions
and subroutines with
subroutines with only
with only some
only some objects
 I'll put
a link in
link in the
description below to
below to a
to a simple
a simple example
simple example of
example of a
of a Power
a Power Basic
Power Basic class
you for watching!
for watching! 
a project from
project from initial
using both the
we will start
will start the
start the Cluster
the Cluster Processing
Cluster Processing Project
 It can
It can take
can take a
take a long
a long time
long time to
time to complete
to complete processing
complete processing tasks
processing tasks dealing
tasks dealing with
dealing with very
with very large
very large datasets
order to reduce
to reduce this
reduce this processing
this processing time
processing time we
time we have
we have looked
have looked at
looked at using
at using parallel
using parallel processing
parallel processing and
processing and multi
and multi threading
multi threading on
threading on a
on a single
a single computer
 Another approach
Another approach is
approach is to
is to spread
to spread the
spread the processing
the processing load
processing load over
load over many
over many computers
many computers where
computers where each
where each of
of those computers
those computers deals
computers deals with
deals with a
with a section
of the large
the large dataset
large dataset and
dataset and submits
and submits its
submits its results
its results on
results on completion
 of the
of the processing
 The aim
The aim of
aim of this
this project today
project today is
is to create
create a requirement
a requirement for
requirement for the
 software that
software that will
that will enable
will enable processing
enable processing tasks
processing tasks to
tasks to be
to be assigned
be assigned to
assigned to and
to and completed
and completed by
completed by a
by a number
number of networked
of networked computers
 The number
number of computers
of computers in
computers in this
in this cluster
this cluster may
cluster may vary
may vary over
vary over time
over time, as
as we may
we may start
may start with
start with just
with just a
just a couple
couple of computers
of computers and
computers and add
and add more
add more later
will allow the
allow the Cluster
the Cluster to
Cluster to be
to be scalable
be scalable depending
scalable depending on
depending on the
 processing task
 Any computer
Any computer or
computer or server
or server can
server can be
can be added
be added to
to the cluster
the cluster as
cluster as long
as long as
long as it
it is on
is on the
the same network
 As each
As each of
of the computers
the computers in
computers in a
in a cluster
a cluster will
cluster will be
will be working
be working on
working on what
on what is
what is likely
is likely to
be large datasets
large datasets, there
there will need
to be somewhere
be somewhere for
somewhere for those
for those datasets
those datasets, and
and any results
any results, to
 All the
All the computers
the computers should
computers should have
should have full
have full access
full access to
access to this
to this common
this common data
common data store
 Now we
Now we have
we have got
have got to
got to the
to the point
the point where
point where we
where we need
need to start
to start naming
start naming things
will have one
have one computer
one computer that
computer that will
that will monitor
will monitor the
monitor the rest
of the cluster
the cluster and
cluster and assign
and assign tasks
will call that
call that computer
that computer the
computer the 'Task
the 'Task Leader'
And the computers
the computers which
computers which are
which are doing
are doing the
doing the processing
the processing, we
will call the
call the 'Task
the 'Task Workers'
 The 'Task
'Task Leader' needs
Leader' needs to
needs to be
to be able
be able to
able to monitor
to monitor which
monitor which 'task
which 'task workers'
'task workers' are
workers' are available
are available to
available to accept
to accept tasks
accept tasks, and
and also which
also which task
which task workers
task workers are
workers are not
 This will
This will cater
will cater for
cater for the
for the task
the task workers
task workers that
workers that while
that while they
while they may
they may have
may have been
have been known
been known to
known to the
to the Task
the Task Leader
Task Leader at
Leader at some
at some point
some point in
in the past
the past, they
they are not
are not currently
not currently available
 And finally
And finally, those
those task workers
workers that have
have been assigned
been assigned and
assigned and accepted
and accepted tasks
accepted tasks to
tasks to run
of the task
the task worker
task worker computers
worker computers will
computers will have
will have multiple
have multiple processor
multiple processor cores
processor cores, then
then each of
of those cores
those cores should
cores should be
should be able
able to support
support a separate
a separate task
This will considerably
will considerably increase
considerably increase the
increase the number
number of tasks
of tasks that
tasks that the
that the cluster
the cluster can
cluster can process
So the Task
Task Leader will
Leader will need
need to track
to track tasks
track tasks at
tasks at the
at the processor
the processor core
processor core level
core level for
level for each
 So to
So to summarise
to summarise what
summarise what the
what the requirement
the requirement is
requirement is, albeit
albeit at a
at a high
a high level
What the Task
Task Leader needs
Leader needs to
needs to do
to do, is
 - Monitor
- Monitor the
Monitor the status
the status of
status of each
of each task
each task worker
task worker and
worker and assign
assign tasks to
tasks to the
to the selected
the selected task
selected task worker
 -Monitor results
-Monitor results coming
results coming from
coming from each
from each of
-Activate and deactivate
and deactivate task
deactivate task applications
 These are
are the applications
the applications which
applications which will
which will actually
will actually conduct
actually conduct the
conduct the processing
task worker needs
worker needs to
needs to report
to report status
report status back
status back to
 It also
It also needs
also needs to
needs to accept
to accept and
accept and run
and run selected
run selected tasks
 Once each
Once each task
each task has
task has been
been completed, it
it needs to
needs to save
to save the
save the results
the results to
results to a
to a common
a common storage
common storage area
 So this
a short summary
short summary of
summary of the
of the requirement
the requirement for
requirement for this
for this cluster
this cluster processor
What we'll cover
we'll cover in
cover in the
in the following
the following videos
following videos is
videos is the
is the specific
the specific code
specific code needed
code needed to
needed to achieve
to achieve each
achieve each of
of these requirements
you for watching
of videos, we
Power Basic Compilers
will start a
start a new
a new project
new project, to
use of blockchains
of blockchains within
blockchains within Power
what is blockchain
is blockchain, and
and what can
what can we
we use it
use it for?
it for? A
for? A blockchain
A blockchain is
blockchain is a
is a digital
a digital record
digital record of
record of transactions
This digital record
digital record is
record is duplicated
is duplicated and
duplicated and distributed
and distributed across
distributed across the
across the entire
the entire network
entire network of
network of computers
of computers associated
computers associated with
with that blockchain
It relies on
relies on a
on a method
a method of
method of recording
of recording information
recording information that
information that makes
that makes it
makes it almost
it almost impossible
almost impossible to
impossible to change
to change what
change what has
what has been
has been recorded
been recorded, without
without it becoming
it becoming obvious
becoming obvious that
obvious that an
that an attempt
an attempt to
attempt to amend
to amend it
amend it has
has actually happened
blockchain is basically
is basically a
basically a decentralized
a decentralized database
decentralized database, that
that is shared
is shared among
shared among computer
among computer network
computer network nodes
Transactional data from
data from many
from many sources
many sources may
sources may be
may be collected
be collected, integrated
integrated and shared
and shared using
shared using a
using a blockchain
a blockchain cloud
blockchain cloud service
Individual data records
data records are
records are held
are held as
held as blocks
as blocks within
blocks within the
within the blockchain
the blockchain, linked
linked together using
together using cryptographic
using cryptographic hashes
cryptographic hashes as
hashes as unique
as unique identifiers
Data integrity is
integrity is ensured
is ensured using
ensured using the
using the blockchain
the blockchain, which
which uses a
uses a single
a single source
single source of
source of truth
of truth to
truth to eliminate
to eliminate data
eliminate data duplication
data duplication and
duplication and increase
and increase security
Attempting to change
to change data
change data within
data within a
within a blockchain
blockchain is prevented
is prevented as
prevented as data
as data can't
data can't be
can't be changed
be changed without
changed without approval
So if blockchain
if blockchain is
blockchain is the
is the solution
the solution, what
is the problem
the problem it
problem it can
it can be
used to solve?
to solve? Let
solve? Let us
Let us assume
us assume we
assume we have
have four entities
really matter what
matter what they
they are, they
they could be
could be individual
be individual computers
individual computers or
computers or even
or even whole
even whole systems
Lets call them
call them North
them North, South
East and West
of these entities
these entities carries
entities carries out
carries out transactions
out transactions with
transactions with the
with the other
the other three
And each site
each site keeps
site keeps track
of the transactions
the transactions it
transactions it has
has actually made
But there is
there is at
is at the
the moment no
moment no central
no central authority
central authority with
authority with the
with the list
of all transactions
And each entity
each entity is
entity is unaware
is unaware of
unaware of transactions
of transactions that
transactions that did
that did not
did not affect
not affect them
So let's add
let's add a
add a central
a central entity
central entity, which
which we want
want to hold
to hold a
hold a list
all transactions made
transactions made in
made in the
in the order
the order they
order they occurred
we want some
want some unique
some unique transaction
unique transaction number
transaction number on
number on each
on each transaction
each transaction, to
them to be
to be identified
be identified in
identified in the
the order that
order that they
that they occurred
This works fine
works fine for
fine for the
for the central
the central entity
central entity, as
as they have
they have a
have a record
a record of
record of every
of every transaction
every transaction, and
and any reporting
any reporting can
reporting can be
can be done
be done from
done from its
from its data
It does rely
does rely on
rely on the
on the central
central entity always
entity always being
always being there
being there, and
and as such
as such it's
such it's a
it's a single
a single point
single point of
point of failure
So how could
how could a
could a blockchain
a blockchain approach
blockchain approach help
approach help here?
help here? If
here? If all
If all the
all the entities
the entities had
entities had a
had a copy
a copy of
the transactions, then
then the database
the database would
database would be
would be distributed
be distributed across
distributed across all
across all of
all of them
And no single
no single failure
single failure could
failure could stop
could stop the
stop the system
the system from
system from working
Should one of
of the entities
the entities go
entities go offline
go offline for
offline for a
for a while
a while, and
and the others
the others continued
others continued working
continued working, then
then it would
it would miss
would miss out
miss out on
out on one
on one or
or more transactions
So before carrying
before carrying out
carrying out a
out a transaction
a transaction, an
an entity would
entity would need
would need to
to check with
check with the
with the others
the others to
others to ensure
ensure that it
that it had
it had an
had an up-to-date
an up-to-date record
up-to-date record of
record of the
of the transaction
the transaction history
transaction history, before
before doing any
doing any new
any new transaction
Thereby allowing it
allowing it to
it to pick
pick up any
up any missing
any missing data
So what types
what types of
types of blockchain
of blockchain are
blockchain are there?
A public blockchain
public blockchain is
is a permissionless
a permissionless distributed
permissionless distributed database
distributed database, to
to which anybody
which anybody can
anybody can join
can join and
join and conduct
and conduct transactions
Crypto currencies are
currencies are an
are an example
an example of
example of this
The private blockchain
You need permission
need permission to
permission to join
to join this
join this network
could be used
used within a
within a company
a company or
company or organisation
A combination of
combination of public
of public and
public and private
Some parts could
parts could be
could be open
be open to
open to everyone
to everyone, and
and some parts
could be restricted
A consortium blockchain
consortium blockchain can
blockchain can be
can be controlled
be controlled by
controlled by a
by a group
a group of
group of identities
of identities, as
as a private
a private blockchain
 So which
So which is
which is best?
is best? There
best? There is
is no simple
no simple answer
simple answer to
answer to this
to this question
It depends entirely
depends entirely on
entirely on what
on what you
what you need
to do within
do within your
your own system
own system, as
as each type
each type of
type of blockchain
of blockchain has
blockchain has its
has its advantages
its advantages and
advantages and disadvantages
 What we
What we will
we will do
will do in
do in the
the next video
next video in
video in this
this series is
series is to
look at creating
at creating a
creating a blockchain
a blockchain solution
blockchain solution in
solution in Power
support for tables
have the beginnings
the beginnings of
beginnings of a
of a web
a web browser
We have on
have on screen
on screen an
screen an index
index page, and
and on there
on there we
have a number
number of images
Each image links
image links to
links to a
to a separate
we have achieved
have achieved the
an image and
image and use
and use it
use it as
it as a
as a hyperlink
also have standard
have standard text
standard text hyperlinks
text hyperlinks linking
hyperlinks linking us
linking us to
us to another
to another page
purpose of the
of the World
Web was to
was to allow
it to display
information to users
to users and
users and to
and to hyperlink
to hyperlink to
hyperlink to other
data on these
on these pages
these pages would
pages would be
would be in
be in tabular
in tabular format
And HTML used
HTML used the
used the table
the table tag
table tag to
tag to control
to control this
control this information
So that's what
to work on
work on today
going to extend
to extend our
extend our browser
to support table
support table tags
before we look
we look at
our code, let's
let's look at
look at a
at a webpage
a webpage which
webpage which we're
I've opened this
opened this webpage
this webpage in
webpage in Chrome
in Chrome, and
of the webpage
the webpage we
webpage we have
have a table
have a title
a title for
title for the
for the table
the table, and
have a couple
couple of columns
of columns and
columns and one
and one data
one data row
at the source
the source of
source of this
of this, we'll
we'll see here
see here is
is our table
our table construct
Starting with a
with a table
a table tag
table tag, followed
by a caption
a caption which
caption which contains
contains the title
title of our
of our table
our table, followed
followed by two
by two rows
two rows of
rows of data
The first row
first row is
row is using
is using the
using the th
the th tag
These are column
are column headers
The second row
second row is
row is a
is a data
a data row
data row using
row using the
using the td
the td tag
extend our code
support this construct
deal of functionality
of functionality embedded
functionality embedded in
in the table
the table tags
However today we're
today we're just
we're just going
to start with
with the absolute
the absolute basics
first thing we'll
thing we'll do
we'll do in
in our code
our code is
code is look
is look at
at the render
is our rendering
our rendering engine
Inside here we
here we have
is a select
a select case
select case block
In here we
we have case
have case statements
case statements for
statements for each
of the different
the different types
different types of
types of tag
to add table
add table to
table to the
of this list
As the table
table tag can
tag can contain
can contain many
contain many nested
many nested tags
nested tags, we're
going to operate
to operate within
operate within a
within a function
a function here
Once we reach
we reach the
reach the table
table tag, we're
we're then going
then going to
going to read
to read forward
read forward to
forward to the
of the table
table tag, and
do all that
all that in
in a new
function which we're
to call build
call build table
is the start
the start variable
This variable indicates
variable indicates where
indicates where in
where in the
in the HTML
the HTML we're
HTML we're actually
we're actually reading
new function build
function build table
I'm creating two
creating two local
one for data
for data and
data and one
one for lower
for lower case
lower case data
The data variable
data variable is
going to contain
to contain all
contain all the
all the information
the information between
information between the
between the beginning
the beginning table
beginning table tag
table tag and
the end table
end table tag
And the LC
the LC data
LC data variable
data variable will
be the lower
the lower case
lower case version
case version of
version of that
We'll be stepping
be stepping through
stepping through the
through the data
the data string
data string one
string one character
one character at
character at a
at a time
need a variable
track of our
of our character
our character, and
and we'll need
to know what
know what our
what our last
our last command
last command and
command and our
and our next
our next command
next command are
command are for
are for other
for other nested
other nested ones
nested ones in
ones in the
in the future
create a number
number of variables
of variables, much
much along the
along the same
the same lines
same lines as
lines as we
we did in
did in the
in the previous
the previous function
These variables will
variables will allow
us to keep
track of where
we are and
are and to
and to have
have a construct
a construct which
construct which is
which is very
is very similar
similar to the
to the previous
previous function, the
the render engine
The approach I'm
approach I'm going
to take within
take within this
function is to
is to build
to build up
build up an
array of data
will be all
be all the
all the string
the string data
string data that's
data that's held
that's held within
held within the
within the table
the table construct
As we don't
we don't know
don't know how
know how wide
how wide each
wide each of
of the columns
the columns are
columns are to
are to be
to be within
the table, we'll
to work that
work that out
work out how
out how many
how many header
many header columns
header columns we
columns we have
we have, how
how many data
many data columns
data columns, how
how many rows
many rows and
rows and how
and how many
how many columns
to create some
create some more
some more variables
we are when
are when we're
when we're building
we're building up
building up our
up our table
our table array
first task within
task within this
is to get
get the actual
the actual data
actual data between
data between the
And then populate
populate the lower
case data variable
data variable with
with the lower
So to do
do that we
can make use
the function we've
function we've created
previous videos, the
tag value variable
will return all
return all the
all the data
the data we
data we require
we require between
require between the
table tag non-exclusive
And we'll turn
we'll turn that
turn that into
that into a
into a lower
a lower case
case version by
version by using
using the L
the L case
L case dollar
case dollar command
Next we'll need
many columns are
columns are held
are held within
held within that
within that table
to populate three
populate three variables
three variables here
variables here, the
the header columns
header columns should
columns should there
should there be
there be any
be any th
any th tags
th tags and
tags and the
and the data
the data columns
data columns should
be any td
any td tags
work out our
out our row
our row count
row count by
count by counting
by counting the
counting the number
number of tr
of tr tags
has a command
a command called
command called tally
called tally, which
used to count
to count these
count these very
these very easily
we're looking inside
looking inside the
inside the lower
data variable to
variable to look
for the th
th tag and
and the value
value returned will
returned will be
will be stored
be stored in
in the header
header columns variable
is taken for
taken for the
data columns and
columns and the
and the row
the row count
It's always possible
always possible that
possible that some
that some of
the columns may
columns may not
may not have
not have headers
out which is
is the largest
the largest of
largest of the
of the header
header columns and
columns and we
use the max
the max command
max command to
command to work
work that one
that one out
And we'll populate
we'll populate that
populate that in
that in our
in our column
our column count
column count variable
So if the
if the header
header columns is
columns is actually
is actually greater
actually greater than
than zero and
zero and the
row count is
count is greater
greater than two
than two, then
then we'll need
out the column
the column count
column count based
count based on
As the td
the td tags
td tags will
tags will be
will be multiplied
be multiplied for
multiplied for each
for each row
us a true
a true column
true column count
Now we know
we know the
know the number
rows and number
and number of
number of columns
of columns we
columns we can
we can prepare
can prepare our
prepare our string
our string array
string array to
array to hold
hold the data
the data that's
we're dimensioning from
dimensioning from one
to the row
row count and
count and from
and from one
to the column
column count in
count in a
in a two
a two dimensional
two dimensional array
So now we
need to populate
to populate that
populate that array
that array by
array by stepping
by stepping through
stepping through our
through our data
our data variable
data variable one
variable one character
the render array
So we're picking
picking up one
up one character
a time and
time and we're
populating the command
So just as
the render function
render function, we're
we're actually testing
actually testing the
of our char
our char variable
it's an opening
an opening tag
opening tag, then
then we're picking
up the command
storing the last
command and we're
and we're moving
we're moving on
moving on to
on to work
what the end
the end data
end data is
data is and
is and storing
and storing all
storing all of
all of that
of that in
in our command
our command variable
code is just
is just cut
just cut and
cut and pasted
and pasted from
pasted from the
the next section
next section will
section will be
be to capture
to capture attributes
We're not in
not in this
this video going
video going to
to handle attributes
handle attributes of
attributes of the
of the th
the th and
th and td
and td commands
td commands or
commands or the
or the tr
the tr command
tr command for
for that matter
But we need
to be ready
be ready to
ready to do
in a later
going to capture
to capture the
capture the attributes
And this code
this code is
code is taken
is taken again
taken again straight
again straight from
straight from the
storing the attributes
the attributes in
attributes in an
in an attributes
an attributes variable
attributes variable and
variable and we're
and we're trimming
we're trimming them
trimming them from
them from the
from the command
we're setting two
setting two booleans
One for in
for in command
in command and
command and one
one for exit
for exit command
We'll be making
be making use
use of these
of these in
if the character
the character we
character we picked
we picked up
picked up is
up is a
is a right
a right angle
right angle bracket
angle bracket, then
then we're at
we're at the
end of a
And now we
we can decide
can decide what
decide what to
with the data
the data we've
data we've picked
we've picked up
where we test
we test the
test the command
the first sub
first sub tag
sub tag within
tag within the
table tag we're
tag we're going
at is caption
Not all tables
all tables will
tables will have
have a caption
a caption tag
case we're putting
we're putting it
putting it in
it in anyway
in anyway because
anyway because it
it is supposed
is supposed to
supposed to be
to be supported
order to pick
to pick that
that up we're
up we're going
use a function
to the get
tag value function
value function we
call this one
this one get
one get table
get table tag
table tag value
to take four
take four parameters
The character position
character position we're
position we're at
we're at, in
case the t
the t variable
The end tag
end tag we're
tag we're looking
looking for, in
case the end
of the caption
the caption tag
The data containing
data containing the
containing the data
inside the table
And the lowercase
the lowercase data
lowercase data version
data version of
will create that
create that new
that new function
new function and
and we'll come
we'll come back
come back to
back to this
this function in
is the existing
the existing get
existing get tag
returns the content
the content of
content of a
tag value taking
value taking the
taking the four
four parameters we
parameters we have
have just specified
It looks for
looks for the
for the start
the start position
start position, the
the ending position
ending position and
position and returns
and returns the
returns the data
the data in
data in our
in our midstring
our midstring command
we've created the
created the get
the get table
value function, let's
let's now add
now add support
support for other
for other tags
other tags within
table tag construct
to put something
put something in
something in that
in that handles
that handles the
handles the TR
the TR tag
TR tag and
the closing TR
closing TR tag
These indicate the
indicate the beginning
of a row
For the TR
TR tag which
is the beginning
a row, we're
we're incrementing our
incrementing our row
our row number
for the ending
the row, we're
setting the column
the column back
column back to
back to zero
have two other
two other types
of tag to
tag to support
start of a
of a header
a header column
header column, we
increment the column
our next task
next task is
the data for
data for that
for that column
going to reuse
to reuse our
reuse our get
our get table
value function here
function here to
here to populate
to populate our
populate our column
our column data
column data variable
us the information
information that we
need to insert
to insert into
insert into the
have that data
that data, we
we can insert
can insert it
insert it quite
quite easily in
easily in our
in our table
table array by
using the row
the column elements
we'll set our
set our header
our header flag
header flag to
flag to true
to true to
true to indicate
indicate that we're
inside a header
to do exactly
do exactly the
the same in
same in the
in the TD
TD tag where
tag where we
where we have
we have data
have to increment
the column and
column and populate
populate the table
the table array
moment we don't
don't have to
to do anything
do anything at
anything at the
But we do
do have to
to do it
do it for
for the TD
we're doing exactly
doing exactly the
same for that
for that, incrementing
incrementing the column
column number, getting
getting the data
the data and
data and storing
and storing it
storing it in
So by the
by the end
of this For
this For Next
Next Loop, we
will have gathered
have gathered all
gathered all the
information that needs
that needs to
needs to go
to go in
go in to
to the table
So our next
next task would
task would be
would be to
to display this
display this table
this table information
table information onto
information onto the
onto the graphics
graphics control so
control so the
user can actually
can actually see
actually see it
create a separate
a separate function
separate function whose
is to display
display the table
call that new
new function display
function display table
display table taking
table taking three
taking three parameters
The first being
first being a
being a pointer
pointer to the
table array, followed
by the value
the caption variable
caption variable and
variable and then
and then followed
then followed by
by the header
The header flag
header flag is
flag is used
used to tell
to tell this
tell this function
this function that
function that there
that there is
there is indeed
indeed a header
a header in
header in the
in the data
It's quite possible
quite possible that
that some tables
some tables will
tables will not
will not have
now have to
this new display
new display table
display table function
is the header
the header of
header of our
our new display
table function with
with the three
three parameters we
As we enter
we enter this
enter this new
new function we
function we have
we have at
have at the
moment no idea
no idea how
idea how big
how big the
big the table
the table is
table is going
to be on
be on the
This will depend
will depend entirely
depend entirely on
entirely on the
on the data
the data held
data held within
held within our
within our array
of the character
the character based
character based on
on the font
the font we're
font we're using
the caption, the
of the entire
the entire table
entire table, the
of columns in
columns in the
we'll need an
need an offset
an offset to
offset to position
to position the
position the caption
Captions are generally
are generally justified
generally justified in
justified in the
in the centre
the centre of
centre of the
step through our
through our array
our array using
using a column
a column and
column and a
and a row
a row variable
out the number
using the U-bound
the U-bound command
U-bound command on
command on the
on the table
Since this is
is a two
dimensional array we're
array we're looking
for the second
the second dimension
This tells us
tells us how
us how many
many columns there
columns there are
can then prepare
then prepare a
prepare a new
a new long
new long table
long table columns
table columns array
This will contain
contain the number
of elements matching
elements matching the
matching the number
going to store
to store how
store how wide
wide each column
each column actually
column actually is
This is so
is so we
can display them
display them to
them to the
the user without
user without them
without them overwriting
them overwriting each
overwriting each other
the graphics cell
cell size command
size command again
This works out
works out how
out how wide
how wide and
wide and how
and how high
how high our
high our single
our single character
single character will
character will be
will be based
be based on
the table will
table will be
based on how
on how many
how many characters
many characters are
characters are in
are in each
in each column
need a small
a small spacing
small spacing buffer
spacing buffer between
buffer between each
between each column
each column so
column so that
so that the
that the characters
the characters don't
characters don't run
don't run into
run into each
into each other
new function four
function four variables
The table data
table data itself
data itself, the
standard character and
character and what
and what we're
what we're expecting
we're expecting back
expecting back is
back is a
is a populated
a populated long
populated long table
columns array containing
array containing the
containing the width
width of each
of each column
will create this
new function in
a moment but
moment but let's
push on with
on with the
with the logic
the logic within
logic within this
We next have
next have to
have to test
see whether we
a caption or
caption or not
If the caption
the caption string
caption string is
string is zero
is zero length
zero length then
length then there
is no caption
So this section
code is entirely
is entirely devoted
entirely devoted to
devoted to captions
a caption then
caption then we
then we will
we will work
out the caption
the caption width
caption width based
width based on
on the standard
the standard width
standard width of
of a character
We will multiply
will multiply that
multiply that by
of characters in
characters in the
in the caption
caption width is
width is less
is less than
than the table
the table width
table width then
width then that
then that means
that means it's
means it's smaller
it's smaller than
smaller than the
the table and
table and we
can then calculate
then calculate our
calculate our offset
our offset, adjust
adjust our global
our global positioning
global positioning of
positioning of where
of where we're
print to next
to next by
next by that
by that offset
that offset, and
then we're going
to set that
set that position
that position, print
print out our
out our caption
our caption and
caption and then
and then get
then get our
get our current
our current position
current position at
position at that
that point in
point in time
this should handle
should handle printing
handle printing captions
printing captions where
captions where captions
where captions exist
that we've determined
we've determined the
determined the width
each column we
column we can
can now print
now print the
print the data
And again this
again this is
be a for
First we will
we will determine
determine the current
the current printing
current printing position
printing position on
position on the
on the global
through each record
each record, each
each row within
row within the
are on row
on row 1
row 1 and
1 and the
and the header
the header variable
header variable is
variable is true
know that the
that the first
first row in
row in our
our table is
table is a
is a header
a header row
A browser would
browser would print
would print these
print these header
these header rows
header rows in
rows in bold
font to Bold
to Bold Font
have an array
of fonts already
fonts already set
already set up
set up which
up which are
which are bold
So the fifth
the fifth font
fifth font is
font is going
be the standard
the standard one
standard one we're
one we're going
create the bold
the bold font
bold font value
font value at
value at the
to be 12
be 12 point
12 point bold
So within the
within the for
next loop for
loop for the
for the row
the row we'll
row we'll need
next loop nested
loop nested for
nested for our
for our columns
will first set
first set the
set the coordinates
the coordinates for
and Y on
Y on our
on our graphics
if we're on
we're on column
on column 1
are on column
column 1 we're
1 we're going
to put some
put some padding
some padding before
padding before the
before the first
the first column
So the table
the table does
table does not
does not appear
not appear right
appear right at
right at the
at the left
the left hand
left hand edge
hand edge of
edge of our
add on one
on one character
one character width
character width to
width to the
the position there
For the remainder
the columns we'll
columns we'll need
the previous columns
previous columns width
columns width was
going to need
to need a
need a new
function to do
call that Get
that Get Previous
Get Previous Columns
And we'll pass
we'll pass that
pass that a
that a couple
couple of parameters
the Table Columns
Columns Array and
Array and one
for the column
the column we're
column we're currently
We'll double back
double back and
back and create
And once we've
once we've done
we've done that
done that we
that we will
set the new
new position to
position to be
to be our
be our X
our X and
that we set
the position for
position for where
for where the
where the column
the column is
column is to
is to begin
to begin we
begin we can
can then print
then print out
print out from
out from our
from our Table
Table Array the
Array the actual
actual data held
held within it
within it based
it based on
on the row
our graphics print
print statement is
statement is a
is a semicolon
a semicolon which
semicolon which will
which will tell
will tell Power
tell Power Basic
Power Basic not
Basic not to
not to go
next line because
line because we
because we may
we may have
may have more
have more columns
more columns to
columns to actually
to actually print
once we get
to the last
the last column
last column in
column in a
in a row
a row we
row we then
we then have
then have to
to test for
the header being
header being true
being true or
a header then
header then we
then we want
font to normal
to normal using
normal using our
our global handle
global handle for
handle for the
And then to
then to finish
to finish up
finish up we're
up we're using
using a graphics
a graphics print
command to ensure
to ensure we
ensure we go
next line and
line and then
and then pick
then pick up
up the next
the next X
next X and
that we've finished
we've finished the
finished the function
to display our
display our table
our table onto
table onto our
onto our graphics
control we have
couple of functions
of functions we
functions we have
we have referred
have referred to
referred to which
which we still
for the Get
the Get Previous
Columns Width and
Width and one
for the width
So let's do
let's do the
do the Previous
Columns Width first
one is going
taking in the
in the two
two parameters we
parameters we specified
we specified, the
array of table
of table columns
table columns and
is going through
through a simple
a simple for
simple for next
loop from the
from the first
first column to
column to the
the column before
column before the
before the one
the one we're
one we're currently
And it's adding
it's adding up
adding up the
up the width
of these table
these table columns
this will tell
tell us where
us where the
the column should
column should now
should now begin
So our final
our final function
final function is
function is the
is the width
width of table
of table function
one that works
that works out
works out the
of a table
a table for
table for each
And again we
again we will
will need some
need some local
of the column
of columns, the
rows and the
the total width
total width we're
width we're going
to return to
return to the
up the number
of rows basedon
rows basedon the
basedon the array
the array we've
array we've been
we've been passed.Next
been passed.Next we're
passed.Next we're going
do a nestedfor
a nestedfor next
nestedfor next loop
next loop, looking
looking through eachcolumn
through eachcolumn and
eachcolumn and each
and each row.This
each row.This function
row.This function makes
function makes good
makes good use
good use of
of the maxcommand
the maxcommand to
maxcommand to work
to work outwhich
work outwhich is
outwhich is actually
is actually larger.The
actually larger.The column
larger.The column in
column in the
in the current
the current row
current row or
row or thecolumn
or thecolumn in
thecolumn in the
the previous row.And
previous row.And then
row.And then in
columns array we'realso
array we'realso going
we'realso going to
to be addingtwo
be addingtwo extra
addingtwo extra character
extra character spaces.This
character spaces.This will
spaces.This will allow
allow us more
us more room.So
more room.So that
room.So that the
that the data
data in one
in one column
one column does
column does notrun
does notrun into
notrun into the
into the data
data in the
the next column.So
next column.So now
column.So now that
have this final
this final functionfinished
final functionfinished let's
functionfinished let's try
let's try and
try and compile
and compile to
compile to makesure
to makesure we
makesure we haven't
we haven't missed
haven't missed anything.So
missed anything.So our
anything.So our application
our application compiles
application compiles cleanly.So
compiles cleanly.So let's
cleanly.So let's try
let's try runningit
try runningit and
runningit and see
what we get.So
we get.So we
get.So we have
have our browser
our browser on
browser on screen
Let'sjust drag in
drag in some
in some datafrom
some datafrom one
datafrom one of
the HTML pages.And
HTML pages.And there
pages.And there we
on screen our
screen our table
our table atthe
table atthe bottom
atthe bottom of
of the page.We
the page.We have
page.We have the
have the caption
have the titlecolumns
the titlecolumns column
titlecolumns column one
column one column
one column two
column two and
and we havethe
we havethe data
havethe data underneath
data underneath it.Let's
underneath it.Let's try
it.Let's try it
try it with
it with anotherpage
with anotherpage with
anotherpage with some
with some more
some more data.Now
more data.Now we
data.Now we have
we have another
have another page
another page which
page which has
which has oneheader
has oneheader and
oneheader and two
and two data
two data lines.And
data lines.And again
lines.And again we
again we can
can see a
see a caption
a caption isactually
caption isactually positioned
isactually positioned inthe
positioned inthe middle
inthe middle of
middle of the
of the table.And
the table.And we
table.And we have
have data one
data one data
one data two
data two a
two a largerdata
a largerdata column
largerdata column and
and a smaller
a smaller data
smaller data column.So
data column.So in
column.So in summary
we've achieved todayis
achieved todayis we
todayis we have
support for table
for table tags.Within
table tags.Within the
tags.Within the table
tag we're supporting
we're supporting thecaption
supporting thecaption tag
thecaption tag which
tag which allows
us to put
to put acaption
put acaption above
acaption above the
above the table.We
the table.We have
table.We have support
have support for
th tag to
tag to allowus
to allowus to
allowus to put
to put column
put column headersin
column headersin which
headersin which are
are shown in
shown in bold.The
in bold.The width
bold.The width of
column is driven
is driven by
driven by thedata
by thedata within
thedata within that
within that table.If
that table.If the
table.If the column
the column header
column header is
header is wider
is wider then
wider then thatis
then thatis the
thatis the width
of that column.If
that column.If the
column.If the data
the data tag
data tag is
tag is actually
is actually wider
actually wider thenthat
wider thenthat will
thenthat will be
be the width.So
the width.So this
width.So this is
is the very
the very basics
very basics of
basics of thebeginnings
of thebeginnings of
thebeginnings of table
of table support.There's
table support.There's a
support.There's a great
deal more in
more in attributesyou
in attributesyou can
attributesyou can do
do with tables.However
with tables.However we
tables.However we will
we will leavethat
will leavethat for
leavethat for a
a later video.That's
later video.That's it
video.That's it for
it for today.Thank
for today.Thank you
today.Thank you for
project to look
use of software
of software auto
software auto forms
auto forms by
forms by adding
by adding conditional
adding conditional controls
In this project
this project we
project we have
have created two
created two generic
two generic applications
purpose of these
of these applications
these applications is
applications is to
to allow a
allow a user
a user to
user to enter
to enter data
enter data into
into a form
the controls that
controls that exist
that exist within
exist within this
within this form
this form are
form are configured
are configured from
configured from within
from within an
within an external
an external file
first of the
of the two
the two applications
two applications is
applications is FormRunner
When FormRunner is
FormRunner is executed
is executed, it
it displays a
displays a list
list of forms
of forms the
forms the user
user can interact
can interact with
details of these
of these forms
these forms are
forms are held
are held in
held in configuration
in configuration files
go into the
into the forms
the forms folder
forms folder and
folder and into
and into the
into the configs
the configs folder
configs folder, we
see that there
that there are
there are three
are three CSV
three CSV files
CSV files –
files – TestDemo
– TestDemo, TestDemo2
TestDemo2 and TestDemo3
If we open
we open up
open up TestDemo3
up TestDemo3, we
will see a
see a list
list of controls
of controls that
controls that are
that are to
are to appear
on this particular
this particular form
The title gives
title gives us
us the title
of the form
the form and
form and its
and its width
its width and
and height, and
and the fact
fact that it
it is centred
is centred on
centred on the
number of other
of other objects
other objects have
objects have actually
have actually supported
actually supported, for
for example buttons
example buttons, labels
texts and so
and so on
of these objects
these objects, the
Y coordinates are
coordinates are specified
are specified, the
of the object
the object, and
and the unique
the unique identifier
Now I have
I have additional
have additional columns
additional columns to
columns to control
to control other
control other aspects
other aspects of
aspects of these
these objects, including
including a field
a field name
field name which
name which is
which is used
used to specify
to specify which
specify which of
which of the
of the fields
the fields are
fields are output
are output to
output to an
to an external
external file when
file when the
user clicks the
clicks the submit
the submit button
to be adding
be adding two
adding two new
two new columns
new columns to
columns to this
to this configuration
this configuration file
of these two
these two columns
two columns is
columns is to
is to mark
to mark which
mark which fields
which fields are
fields are conditional
When you're designing
you're designing forms
designing forms, there
there may be
may be times
be times in
times in your
in your form
your form when
form when you
when you do
do not want
not want some
want some fields
some fields to
fields to appear
to appear until
appear until something
until something else
something else has
else has occurred
For example, when
on a checkbox
a checkbox, you
you wish another
wish another label
another label and
label and text
and text box
text box to
box to appear
to appear to
appear to elicit
to elicit more
elicit more information
more information from
information from the
Up until the
until the clicking
the clicking of
clicking of that
of that checkbox
that checkbox, these
these two objects
two objects are
objects are invisible
are invisible and
invisible and non-accessible
and non-accessible by
non-accessible by the
by the user
So that's our
that's our task
our task for
task for today
for today, to
to configure the
configure the application
the application to
application to allow
to allow these
allow these to
these to exist
to exist in
exist in the
in the configuration
the configuration file
The application we're
application we're going
to make changes
make changes to
changes to is
to is the
is the autoform.bas
the autoform.bas file
Before we go
we go ahead
ahead and make
and make changes
to the functionality
the functionality of
functionality of this
application to support
to support these
support these new
these new pieces
new pieces of
pieces of functionality
of functionality, there's
there's one little
one little feature
little feature I
feature I want
want to fix
if the application
runs and the
the user picks
user picks one
picks one of
of the forms
the forms, if
if the output
the output for
output for that
for that form
that form does
form does not
does not exist
not exist, the
the application has
application has issues
Normally for the
for the very
the very first
very first time
first time the
time the application
application runs, you
you may not
may not actually
not actually have
actually have an
have an output
an output file
output file, so
to amend our
amend our pb_main
function to cater
to cater for
cater for that
And when no
when no output
no output file
output file has
file has been
has been created
been created, it
it has the
has the job
the job of
job of creating
of creating the
creating the output
the output file
at the pb_main
In this pb_main
this pb_main function
pb_main function, this
is where the
where the configuration
configuration file is
file is loaded
is loaded up
loaded into a
into a global
global array, and
then we populate
populate the form
the form data
form data array
data array, based
on the information
the information held
information held within
within that configuration
that configuration file
output file does
file does not
the populate the
the form array
form array will
array will return
value false, and
there is nothing
is nothing in
nothing in code
in code here
code here to
here to handle
to handle that
handle that condition
function called createOutputFormData
This will have
will have the
have the task
the task of
task of creating
creating the headers
the headers for
headers for the
for the output
new function, createOutputFormData
which takes no
takes no parameters
This will create
create a blank
a blank output
blank output form
output form, containing
containing only the
only the headers
The first part
first part of
code is to
get the output
output file name
function which returns
which returns this
returns this called
this called returnSaveFileValue
So we're making
we're making use
use of that
of that function
that function to
to return and
return and populate
populate the output
the output variable
And we also
which returns all
returns all the
all the column
the column names
of that one
that one as
one as well
as well, to
populate the headers
the headers variable
These column names
column names do
names do include
do include the
include the very
very first column
first column, which
which is displayed
is displayed to
displayed to the
is the ID
the ID column
ID column containing
column containing the
containing the form
the form number
We don't need
don't need this
need this in
this in our
in our output
our output file
is to trim
to trim that
trim that off
So we're re-dimensioning
we're re-dimensioning the
re-dimensioning the form
data array, which
which is global
is global, to
to contain two
contain two rows
A zero row
zero row, which
are the headers
and a first
a first row
first row, which
which is blank
populating the zero
the zero row
zero row with
row with the
with the result
the result of
result of the
the end range
end range parse
This is taking
is taking all
taking all the
the information in
in the headers
the headers from
headers from the
the second element
second element onwards
Having populated this
populated this array
this array, we're
existing function in
in our common
our common file
common file handling
handling routines to
routines to dump
to dump the
dump the array
the array to
array to disk
order to prove
to prove this
prove this change
this change is
change is functional
is functional, we
need to run
the application with
application with the
with the new
the new config
new config file
So we're creating
we're creating a
creating a new
a new file
new file called
file called testdemo4
called testdemo4, again
as a CSV
a CSV file
in this CSV
this CSV file
CSV file, we're
add two new
add a column
a column called
column called conditional
called conditional and
conditional and a
and a column
column called selection
of these will
these will become
will become apparent
become apparent very
apparent very soon
if we create
we create a
create a few
a few objects
few objects on
objects on this
on this just
this just to
just to test
to test it
test it out
with this in
this in place
in place, we
we should now
should now be
now be able
able to test
look inside the
inside the forms
the forms data
forms data folder
data folder, we
see the user
the user data
user data dot
data dot CSV
dot CSV file
The CSV file
CSV file that
file that will
will be created
be created in
created in here
in here when
here when we
when we run
application is configured
is configured in
configured in our
in our config
our config file
be called leave
called leave data
leave data dot
this does not
does not currently
not currently exist
currently exist as
exist as an
as an output
get the form
the form displayed
form displayed on
displayed on the
the screen with
screen with its
with its single
its single editable
single editable field
If we exit
we exit the
exit the application
a look back
look back in
back in our
in our forms
our forms data
now have a
have a leave
a leave data
dot CSV, which
which has a
has a single
a single name
single name field
name field in
field in it
in it, which
which is what
is what is
what is configured
configured in the
have successfully created
successfully created an
created an output
output file where
file where one
where one did
one did not
did not exist
not exist before
a few more
few more objects
more objects within
objects within our
within our configuration
our configuration file
we save these
save these additional
these additional configuration
additional configuration items
configuration items, and
and we go
go back and
back and run
once more, we'll
we're getting now
getting now more
now more objects
more objects on
objects on the
have a special
a special leave
special leave type
leave type, which
be a drop
a drop down
drop down list
at our configuration
configuration file, we
can see the
see the drop
the drop down
down list is
list is being
is being populated
being populated from
populated from a
from a text
a text file
text file called
file called leave
called leave type
leave type dot
type dot text
And our leave
our leave type
dot text has
text has a
has a short
a short list
short list of
list of leave
of leave types
have a list
leave types appearing
types appearing in
appearing in the
in the drop
What we want
we want the
want the application
application to do
to do now
do now is
now is that
is that when
that when one
when one specific
one specific item
specific item on
item on this
on this list
this list is
list is picked
is picked, for
for example, jury
jury duty, we
we want two
want two additional
two additional objects
additional objects to
objects to appear
appear on the
One being a
being a label
a label and
label and one
and one being
one being an
being an additional
an additional text
additional text box
When any other
any other item
other item is
item is picked
is picked from
picked from this
from this drop
this drop down
down list, these
these two new
two new objects
new objects are
objects are to
are to remain
to remain invisible
So how can
that in the
in the code?
the code? First
code? First of
of all, in
in the config
the config file
config file we're
file we're going
some more objects
And the two
new objects we're
objects we're going
to add are
add are a
are a label
a label to
label to say
to say court
say court ref
court ref and
ref and a
a text field
text field to
field to allow
enter a reference
a reference value
the application as
application as it
as it stands
it stands, we
see that this
that this field
this field appears
field appears automatically
as nothing has
nothing has been
been selected for
selected for the
for the leave
the leave type
leave type yet
type yet, we
want the court
the court reference
court reference label
reference label and
box to be
to be invisible
be invisible until
invisible until such
until such times
such times as
times as a
as a user
a user clicks
user clicks jury
clicks jury duty
go and make
and make some
make some changes
some changes in
changes in the
code to make
make this invisible
have two scenarios
two scenarios to
scenarios to look
look at here
The first scenario
first scenario is
scenario is when
when the form
the form first
form first loads
first loads and
loads and the
user has selected
has selected nothing
The second scenario
second scenario is
scenario is where
the user is
user is actually
is actually interacting
actually interacting with
interacting with the
with the form
let's first do
first do the
do the initial
the initial loading
initial loading of
loading of the
This takes place
takes place in
in the populate
the populate form
populate form function
we go through
go through all
through all the
all the entries
the entries that
entries that came
that came from
came from the
from the config
config file, currently
currently loaded into
loaded into the
the global configuration
global configuration array
After all of
these objects have
objects have been
have been created
been created, we
want to check
to check our
check our configuration
our configuration array
configuration array to
array to see
see if any
if any of
of the objects
the objects are
objects are dependent
are dependent on
dependent on any
on any other
any other object
the function, before
before we set
we set focus
set focus to
focus to the
to the start
the form, we're
that function 'HideObjects'
As before, we
need to step
through each row
each row in
row in the
have a quick
a quick look
quick look at
at the configuration
configuration file itself
in here these
here these are
two new entries
new entries –
entries – one
– one label
one label and
and one text
These have their
have their own
their own unique
own unique identifier
unique identifier numbers
now using these
new columns we
columns we added
we added to
added to our
to our config
config file conditional
file conditional and
conditional and selection
is to indicate
indicate that both
that both of
these objects are
dependent on object
on object 2005
object 2005, which
case is the
is the drop-down
the drop-down list
And the selection
the selection column
selection column holds
column holds the
holds the value
the value we're
value we're searching
we're searching for
in the drop-down
drop-down list is
list is 'jury
is 'jury duty'
'jury duty', then
then these two
two objects will
objects will become
will become visible
In all other
all other scenarios
other scenarios, these
these objects should
objects should be
should be invisible
to look through
look through here
through here to
here to find
to find those
find those objects
those objects which
objects which have
which have a
have a conditional
a conditional entry
we will then
will then check
then check the
check the default
the default values
default values to
values to see
see if that
if that matches
So if that
that matches that
matches that, then
then the object
the object should
object should be
should be visible
it should be
should be made
be made invisible
will first create
first create some
create some local
variables to allow
And then next
then next it
next it will
be a standard
a standard for
standard for next
We're first checking
first checking to
see whether the
whether the entry
the entry in
entry in the
the configuration array
configuration array is
array is blank
If that is
that is so
is so, then
then we iterate
we iterate to
iterate to the
We're then populating
then populating the
populating the data
in the row
pick up three
up three pieces
three pieces of
pieces of key
of key information
The reference ID
reference ID, which
is the handle
of the control
the control, the
the conditional control
conditional control value
control value, and
the selection value
Here we're referring
we're referring to
referring to constants
These constants we
constants we have
have not yet
not yet created
yet created, so
so we'll double
double back in
back in a
a moment and
moment and create
and create them
create them at
them at the
the code, in
in the enumeration
the enumeration section
If the conditional
conditional control is
control is actually
is actually a
actually a number
a number greater
number greater than
than zero, then
then this object
this object is
object is conditionally
is conditionally visible
We can check
can check the
check the value
the default selected
default selected by
selected by using
existing function to
return the field
the field value
field value from
from the default
the default column
And if these
if these two
these two values
two values do
values do not
do not match
not match, if
if the selection
the selection doesn't
selection doesn't match
doesn't match the
match the default
the default selection
default selection, then
then we hide
we hide the
hide the control
So in the
the code previous
code previous, we
created the object
and here we
here we decide
we decide whether
decide whether the
whether the object
object is to
is to be
to be hidden
be hidden or
hidden or not
code and create
and create these
create these two
two new constants
have the ref
the ref conditional
ref conditional and
conditional and ref
and ref selection
ref selection added
selection added to
list of enumerations
So this logic
this logic is
logic is followed
is followed for
followed for each
for each entry
each entry in
In our configuration
configuration file, I've
I've set the
set the dropdown
the dropdown list
dropdown list to
list to have
to have no
have no default
we should see
should see that
that the two
two extra fields
extra fields are
fields are initially
are initially invisible
first scenario we
scenario we have
have now catered
now catered for
have to cater
cater for when
for when a
when a user
a user makes
user makes a
makes a change
for example, if
if the user
the user selects
user selects jury
selects jury duty
we want these
want these two
these two fields
two fields to
So there needs
there needs to
to be some
be some handling
some handling of
handling of the
of the changes
changes to this
to this dropdown
this dropdown list
And this would
this would take
would take place
take place in
in the run
the run control
run control process
control process, our
our equivalent of
equivalent of an
of an event
an event handler
at the run
control process, I'm
two new local
one called strData
called strData and
strData and one
one called longResult
we handle each
handle each of
of the types
the types of
types of object
of object on
object on which
on which some
which some event
some event has
event has occurred
the moment only
moment only events
only events occurring
events occurring to
occurring to buttons
The save button
save button and
button and the
and the exit
the exit button
to add three
add three new
three new types
new types of
of all, dropdown
user picks from
picks from the
from the dropdown
dropdown list and
list and picks
and picks jury
picks jury duty
want the objects
the objects to
objects to be
to be visible
if they pick
they pick anything
pick anything else
anything else, we
want the two
new objects to
objects to disappear
We'll also need
also need to
to put an
put an event
an event in
event in for
in for a
for a text
a text box
text box and
box and also
and also for
also for the
for the checkbox
We'll handle the
handle the dropdown
dropdown list first
list first of
Our dropdown lists
dropdown lists in
lists in this
in this application
this application are
application are for
are for single
for single selects
single selects only
selects only, as
want to take
of the user's
the user's pick
user's pick and
pick and to
and to push
to push it
push it out
it out to
to the output
So we're trapping
we're trapping the
trapping the button
the button click
button click message
click message, and
and we know
this point that
point that the
has made some
made some selection
So as these
these are single
are single select
single select, we
we know we
know we can
use the control
the control gate
control gate text
gate text command
text command to
command to pull
to pull back
pull back from
back from the
from the control
the control the
control the value
the value and
value and put
and put it
put it into
it into the
So once we've
done that, we
out whether there's
whether there's a
there's a dependent
a dependent control
Has the user
the user changed
user changed something
changed something that
something that needs
needs to make
to make something
make something invisible
something invisible or
invisible or visible?
or visible? So
visible? So we're
work out if
out if this
if this object
this object has
object has a
has a dependent
And this new
new function can
function can be
used for each
the other object
other object types
object types we
types we want
want to do
to do events
do events on
we're passing two
passing two parameters
two parameters to
parameters to this
new function, the
first being the
being the control
the control handle
is a control
a control handle
control handle of
the object that
object that the
has actually clicked
clicked on, and
and the strData
the strData, the
the second variable
second variable, is
is the value
the value we've
value we've taken
we've taken out
taken out of
out of that
new function Has
function Has dependent
Has dependent control
So here's the
here's the skeleton
our new control
We're using four
using four local
four local variables
local variables here
variables here to
here to keep
track of what
doing within the
within the configuration
configuration file, as
as again this
again this will
will be another
be another for
another for next
want to pick
pick up from
up from our
from our configuration
configuration file some
file some key
some key pieces
key pieces of
of information, the
reference ID, the
the conditional value
conditional value and
value and the
and the object
we find a
find a match
a match, we
can then pick
up the selection
the selection from
selection from the
from the selection
And if that
if that match
that match is
match is the
is the data
the data being
data being passed
passed in for
in for this
this function, then
we can show
can show the
show the control
the control on
control on screen
on screen by
screen by using
using the control
the control normalize
control normalize command
And then move
then move it
move it on
on the value
we will hide
will hide the
the control using
control using the
the control hide
control hide command
Since the user
the user may
user may move
may move around
move around the
around the form
the form quite
form quite dynamically
quite dynamically, it
it may well
may well have
well have been
have been populated
been populated in
populated in a
in a previous
a previous selection
if the form
the form is
form is to
is to hide
to hide the
the control, we'll
we'll also blank
also blank out
blank out the
out the value
in the control
we know there
know there are
there are going
to be three
be three different
three different types
types of control
of control here
There could well
could well be
well be a
be a text
a text control
text control, a
a checkbox or
checkbox or a
or a dropdown
a dropdown list
And there need
there need to
to be different
be different commands
different commands to
commands to blank
to blank out
blank out each
out each of
common function to
function to blank
to blank a
blank a control
So we'll call
new function blank
function blank control
blank control, giving
giving it three
it three variables
the dialog, the
object and the
and the type
type of the
it a text
a text box?
text box? Is
box? Is it
it a dropdown
a dropdown list?
dropdown list? Or
list? Or is
it a checkbox
checkbox or tickbox?
or tickbox? And
tickbox? And this
And this function
to be very
be very straightforward
very straightforward indeed
doing a select
select case statement
case statement on
statement on the
on the type
type of object
If for text
for text, we're
doing a control
a control set
control set text
set text command
for the tickbox
the tickbox, we're
control set check
set check command
for the dropdown
dropdown list, we're
doing a combo
a combo unselect
our application once
Initially the new
the new objects
If we pick
we pick jury
pick jury duty
jury duty, then
then the two
the two objects
two objects have
objects have now
have now appeared
now appeared and
appeared and can
and can be
can be populated
change our mind
our mind and
mind and go
back and pick
and pick a
pick a different
different value, they
they will disappear
will disappear again
back to jury
to jury duty
jury duty, they
they will reappear
will reappear, but
is no data
no data within
within the field
So the data
data we keyed
we keyed in
keyed in has
in has been
has been automatically
been automatically wiped
So we've succeeded
we've succeeded in
succeeded in allowing
in allowing our
allowing our two
our two new
to be controlled
by a parent
a parent control
in that parent
that parent control
parent control defines
control defines whether
defines whether the
whether the objects
objects are visible
are visible to
the user or
user or not
more objects to
objects to our
do a checkbox
or a tickbox
a tickbox to
tickbox to mark
to mark whether
mark whether the
user is working
is working at
working at home
at home or
home or not
And then an
then an additional
box to allow
the user, when
when that is
that is ticked
is ticked, to
enter a number
number of hours
of hours per
hours per day
we save that
save that now
at our config
config file now
file now, we'll
number of new
of new objects
have a label
a label saying
label saying 'working
saying 'working at
'working at home'
at home' and
home' and a
and a tickbox
Underneath that, we
label saying 'enter
saying 'enter hours
'enter hours per
hours per day'
per day' and
day' and another
and another text
another text box
text box, allowing
allowing the user
to enter daily
enter daily hours
These daily hours
daily hours entries
hours entries have
entries have a
a conditional of
conditional of 2013
of 2013, which
is the 'working
the 'working at
at home' tickbox
So as before
want these extra
these extra fields
extra fields only
fields only to
only to appear
to appear when
appear when the
when the tickbox
the tickbox has
tickbox has been
has been ticked
We made a
made a change
a change for
change for the
dropdown list in
list in the
equivalent of a
of a callback
go back in
back in there
in there and
there and put
and put in
put in some
in some additional
some additional code
additional code to
handle these two
As we've got
we've got an
got an entry
an entry for
entry for the
dropdown list, we
we need one
need one for
the text box
This time we're
time we're looking
for the enChange
the enChange event
enChange event, in
in which case
which case we're
case we're picking
value in our
in our text
our text box
box and putting
and putting it
putting it into
data variable and
variable and recalling
and recalling the
recalling the function
created earlier as
earlier as dependent
as dependent control
dependent control, passing
passing it the
it the same
the same two
same two parameters
And we've created
we've created a
created a new
a new section
new section for
section for tickboxes
these are basically
are basically buttons
basically buttons, we're
using the bnCollect
the bnCollect event
We're using Ctrl
using Ctrl Get
Ctrl Get Check
Get Check to
Check to get
get the value
the value, and
we're calling again
calling again the'hasDependentControl'
the application again
application again, we
will see all
see all our
all our fields
our fields are
fields are now
are now displaying
now displaying on
displaying on screen
'Jury duty' is
duty' is already
already picked because
picked because that's
because that's form
that's form number
form number one
if we select
we select a
select a different
different value, it
it will disappear
if we tick
we tick on
tick on our
on our working
our working at
at home, we
we will get
will get the
get the entry
the entry of
entry of hours
that is unticked
is unticked, the
the value will
value will disappear
And as before
as before, if
we put an
put an entry
an entry in
entry in place
in place, if
if we untick
we untick it
untick it and
it and then
and then tick
then tick it
tick it again
it again, the
the entry is
entry is blank
There is one
is one additional
one additional change
additional change we
change we need
make to our
to our application
our application to
application to hide
to hide these
hide these conditional
these conditional objects
conditional objects, and
that is in
is in the
in the 'resetForm'
the 'resetForm' function
the user enters
user enters some
enters some values
...and saves them
saves them, is
that the 'resetForm'
'resetForm' function will
function will reset
will reset the
reset the form
the form completely
So as working
as working at
at home is
home is not
is not ticked
not ticked, the
the enter hours
enter hours per
per day label
day label and
text box should
box should disappear
to the 'resetForm'
'resetForm' function and
function and put
and put a
put a call
a call in
call in to
in to our
function to hide
to hide objects
So the change
the change we'll
change we'll have
we'll have to
to make will
make will be
will be right
be right at
After the loop
the loop has
loop has completed
is our 'Hide
our 'Hide objects'
'Hide objects' function
So to finish
finish off our
off our testing
our testing, I've
I've amended the
amended the default
the default for
default for the
leave type to
type to be
to be 'holiday'
the form initially
form initially loads
initially loads, the
the two fields
two fields for
fields for jury
for jury duty
jury duty should
duty should be
should be hidden
application and see
if that tests
that tests out
is our application
application now loaded
We have 'holiday'
have 'holiday' preselected
can put the
put the entry
can click 'OK'
So that should
that should show
should show at
show at the
of our form
our form without
form without any
without any of
the new fields
new fields being
fields being populated
can now put
now put a
put a new
new entry in
We will now
will now pick
now pick jury
jury duty, which
which should make
should make our
make our new
our new fields
new fields appear
can put our
put our date
our date in
date in place
we can mark
can mark it
mark it 'working
it 'working from
'working from home'
from home' for
home' for one
for one hour
one hour per
hour per day
we can hit
can hit the
hit the 'OK'
the 'OK' button
This should now
should now have
now have populated
have populated our
populated our working
our working and
working and one
one for daily
for daily hours
we exit out
exit out of
of that and
that and have
at our output
in our data
our data folder
have a 'weave
a 'weave data.csv'
And it is
is now showing
now showing 'home
showing 'home working
'home working 1'
working 1' and
1' and 'daily
and 'daily hours
'daily hours 1'
'1' in 'home
in 'home working'
'home working', which
is a checkbox
a checkbox, indicates
indicates that this
that this has
So what we've
have taken our
taken our application
application and we
have added conditional
added conditional controls
These are controls
are controls that
controls that only
that only appear
only appear when
appear when other
when other selections
other selections have
selections have already
already been made
And when those
when those other
those other selections
other selections are
selections are unselected
are unselected, our
our extra controls
extra controls will
controls will become
will become invisible
become invisible to
Giving us more
more flexibility of
flexibility of what
of what we
can actually do
actually do on
do on forms
this code, useful
look at software
at software add-ons
software add-ons for
add-ons for the
look at UPX
at UPX, a
a utility to
utility to compress
to compress your
compress your executables
This is UPX
is UPX, which
which describes itself
describes itself as
itself as the
as the ultimate
the ultimate packer
ultimate packer for
packer for executables
UPX is a
is a free
a free, secure
high-performance executable packer
executable packer for
packer for several
for several executable
several executable formats
looking at today
at today is
is the compression
the compression of
compression of both
of both executables
both executables and
executables and DLL
and DLL files
So why would
why would you
would you want
you want to
want to pack
to pack and
pack and compress
and compress your
compress your executable?
your executable? One
executable? One of
of the reasons
the reasons for
reasons for this
is that if
that if you're
if you're running
you're running in
running in a
in a networked
a networked environment
networked environment, you
may want to
want to place
to place your
place your executables
your executables in
executables in a
in a shared
a shared network
shared network folder
Users can then
can then have
then have read-only
have read-only access
read-only access to
access to that
to that folder
That way your
way your executable
your executable only
executable only needs
only needs to
to be delivered
be delivered to
delivered to one
to one location
one location, and
and the users
the users can
users can run
can run it
run it from
it from there
from there quite
there quite happily
is a shared
a shared folder
shared folder, every
every time a
time a user
a user wishes
user wishes to
wishes to execute
to execute the
execute the binary
the binary, it
will be dragging
be dragging all
dragging all bytes
all bytes across
bytes across the
across the network
So the smaller
the smaller the
smaller the file
the file, the
of other executable
other executable packers
executable packers out
packers out there
of these are
these are free
are free, and
and some of
these are commercial
are commercial applications
to be concentrating
be concentrating and
concentrating and looking
looking at UPX
I'll put links
put links in
links in the
below to this
to this website
When you click
on the Download
the Download latest
Download latest release
latest release, it
it takes you
takes you to
you to a
to a section
section of GitHub
of GitHub, where
you can download
can download the
download the version
the version suitable
version suitable for
suitable for your
for your operating
your operating system
I've downloaded the
downloaded the Windows
the Windows 64-bit
Windows 64-bit version
This comes as
comes as a
as a zip
a zip file
zip file, and
and once unzipped
once unzipped, these
are the files
the files that
files that we
that we get
get out of
have a HTML
a HTML file
HTML file, which
which has details
has details of
details of all
all the commands
the commands you
And you get
you get the
get the executable
the executable command-line
executable command-line utility
command-line utility itself
order to demonstrate
to demonstrate the
use of this
this application, we're
look at one
at one of
of our projects
is the AutoForms
the AutoForms Runner
AutoForms Runner application
It is comprised
is comprised of
comprised of two
of two binaries
two binaries, two
two executables –
executables – the
– the FormRunner
the FormRunner EXE
FormRunner EXE and
EXE and an
and an underlying
an underlying EXE
underlying EXE, which
is called by
called by the
by the first
the first executable
FormRunner is around
is around 71K
around 71K in
71K in size
in size, and
and once it
once it runs
it runs, it
it will bring
will bring up
up a single
a single dialog
single dialog, allowing
user to pick
to pick which
pick which form
which form to
form to load
to load into
load into the
into the next
the next executable
run the form
the form, we
get a new
a new dialog
new dialog coming
dialog coming up
coming up on
on screen, and
and from here
from here, the
user can fill
can fill in
fill in form
in form details
And also look
also look at
at what forms
what forms have
forms have been
have been keyed
been keyed in
keyed in so
in so far
We covered this
covered this in
this in detail
in detail in
detail in about
in about 10
about 10 videos
we look in
look in the
in the forms
forms folder, we
see the AutoForms
the AutoForms EXE
AutoForms EXE is
EXE is around
is around 448K
around 448K in
448K in size
Now this is
this is by
is by no
by no means
no means a
means a large
a large executable
But as you
as you saw
you saw a
saw a moment
moment ago when
ago when I
when I showed
I showed you
showed you the
you the application
the application running
application running, it
it has a
number of embedded
of embedded icons
Each icon or
icon or bitmap
or bitmap you
bitmap you add
you add to
add to your
to your application
your application increases
application increases the
increases the size
of the executable
now is to
to use UPX
use UPX to
UPX to compress
to compress both
compress both of
of these executables
these executables, to
see if this
if this affects
this affects the
affects the way
the way the
way the application
the application works
at the documentation
the documentation for
documentation for UPX
for UPX, its
its purpose is
purpose is to
is to compress
to compress the
compress the executable
the executable and
executable and give
and give you
give you what
you what appears
be an executable
an executable but
executable but smaller
the user runs
user runs this
runs this executable
this executable, it
will load into
load into memory
into memory, decompress
decompress automatically and
automatically and perform
and perform as
perform as it
as it would
it would as
would as if
as if it
if it was
it was uncompressed
user is an
is an non
an non the
non the wiser
the wiser that
wiser that you
that you have
you have in
have in fact
in fact compressed
fact compressed your
compressed your executable
it easy to
easy to run
to run UPX
run UPX, I'm
a small Windows
small Windows batch
Windows batch file
put the commands
the commands within
commands within this
within this batch
this batch file
batch file to
to run compressions
of all, I
I will enter
will enter the
enter the path
path to UPX
number of options
of options you
options you can
can actually put
actually put in
put in to
change the way
the way UPX
way UPX works
to be just
be just using
just using the
using the defaults
And the default
the default means
default means we're
means we're only
we're only going
only going to
have to put
to put in
put in one
in one parameter
that is the
the path and
path and the
of the binary
the binary executable
binary executable that
executable that we
that we wish
wish to compress
And the first
the first one
first one we're
going to try
to try is
try is autoform.exe
put a little
a little timeout
little timeout at
timeout at the
of the batch
the batch file
batch file so
file so that
that the console
console window will
window will stay
will stay on
stay on screen
on screen for
screen for around
for around six
around six seconds
actually see the
see the result
result of what's
of what's coming
what's coming up
if we briefly
we briefly have
briefly have a
look at autoform.exe
There is its
is its size
its size at
size at the
we will take
will take a
take a copy
copy of that
of that file
we can compare
can compare it
compare it to
it to what
to what it
what it is
it is going
to look like
look like after
like after compression
is our copy
if we double
we double click
double click on
click on our
on our batch
our batch file
will see there
see there is
there is the
is the exudal
the exudal having
exudal having been
having been compressed
It's gone down
gone down from
down from 458K
from 458K down
458K down to
to a much
a much smaller
much smaller size
smaller size of
size of 120K
So we appear
to have successfully
have successfully compressed
successfully compressed our
compressed our executable
is it still
it still usable?
still usable? Can
usable? Can it
Can it still
it still be
still be run?
be run? Well
run? Well, let's
let's go up
go up a
up a folder
a folder and
folder and run
run the formrunner
the formrunner application
formrunner application again
we pick our
pick our form
our form, hit
hit the Run
the Run Form
Run Form button
Form button and
button and our
and our autoforms
our autoforms executable
autoforms executable runs
executable runs quite
runs quite happily
It lets us
lets us display
us display all
display all the
all the detail
the detail that's
detail that's been
And lets us
lets us step
us step through
the forms in
forms in turn
now have an
have an executable
an executable that
executable that is
that is half
is half the
half the size
of the original
Let's try it
it with the
with the initial
the initial file
initial file as
file as well
have now amended
now amended the
amended the batch
file to do
to do two
do two compressions
One for autoform
for autoform which
autoform which we
have already compressed
one for formrunner
for formrunner which
formrunner which we
not yet compressed
So we save
save that and
that and we'll
and we'll run
we'll run that
run that there
And double click
And it tells
it tells us
tells us that
first executable has
executable has already
already been packaged
has now compressed
now compressed the
compressed the second
the second executable
Going down from
down from 72K
from 72K to
72K to 35K
is our executable
our executable now
executable now half
now half the
on that, the
the executable runs
executable runs just
runs just fine
is our second
our second executable
second executable still
executable still functional
we've achieved is
achieved is the
compression of two
of two separate
two separate executables
separate executables in
executables in one
in one batch
one batch file
So can we
can we compress
we compress a
compress a dynamic
a dynamic link
dynamic link library?
link library? We
library? We have
We have down
have down at
down at the
the screen here
screen here a
here a DLL
a DLL -
DLL - Win
- Win Resources
This is currently
is currently only
currently only 15K
only 15K in
15K in size
we compress that
compress that as
that as well?
as well? Let's
well? Let's have
at our batch
batch file again
we will put
will put another
put another entry
another entry in
entry in to
in to compress
to compress that
compress that DLL
run this it
this it should
it should give
give us errors
us errors for
errors for the
the first two
first two because
two because they
because they have
they have already
Which it does
it does indeed
is our DLL
our DLL now
DLL now being
now being compressed
gone down to
to a mere
a mere 9K
mere 9K in
9K in size
So even if
even if your
if your executable
your executable is
executable is quite
is quite small
quite small you
you can still
can still get
still get a
get a good
a good ratio
good ratio of
ratio of compression
what we've seen
we've seen today
seen today is
today is that
is that UPX
that UPX is
is a workable
a workable and
workable and free
and free executable
free executable compressor
Compressing both DLLs
both DLLs and
DLLs and executables
So if you
you have a
have a large
large executable with
executable with many
with many bitmaps
many bitmaps, icons
icons and images
and images embedded
images embedded in
embedded in it
in it, you
you can compress
can compress it
compress it down
it down to
Reducing your time
your time taken
time taken to
taken to download
to download it
download it from
it from a
from a network
a network folder
you'll find UPX
find UPX a
UPX a useful
a useful addition
useful addition to
addition to your
to your tools
at the WinLift
the WinLift SkinEngine
WinLift SkinEngine add-on
SkinEngine add-on from
add-on from Zap
from Zap Solution
Zap Solution to
Solution to enhance
to enhance the
enhance the look
the look of
look of your
of your applications
We have previously
have previously looked
previously looked at
looked at a
at a version
a version of
version of WinLift
there is now
now a new
a new version
new version out
version out which
out which has
which has changed
has changed its
changed its license
its license model
WinLift version 7
version 7 is
7 is now
is now available
now available in
available in either
in either 32-bit
either 32-bit or
32-bit or 64-bit
or 64-bit versions
As a PayPal
a PayPal, donate-ware
donate-ware Win32DLL add-on
This 32-bit will
32-bit will allow
you to use
to use it
use it within
it within PowerBasic
within PowerBasic, and
and that's what
look at today
going to apply
to apply WinLift
apply WinLift to
WinLift to one
is the Form
the Form Runner
Form Runner project
Runner project consists
project consists of
consists of three
of three screens
three screens, and
we are primarily
are primarily going
primarily going to
at the first
the first screen
first screen today
This small application
small application is
application is a
is a fairly
a fairly bland
fairly bland form
bland form, and
to use WinLift
use WinLift to
WinLift to enhance
look of the
the form while
form while maintaining
while maintaining its
maintaining its current
its current functionality
So let's delve
let's delve into
delve into the
into the code
see what WinLift
what WinLift can
WinLift can do
can do for
do for us
is a folder
a folder containing
folder containing the
containing the code
the code for
code for our
for our Form
our Form Runner
Form Runner application
add two DLLs
two DLLs to
DLLs to this
to this folder
are the DLLs
the DLLs we're
DLLs we're going
be using for
using for WinLift
is the WinLift32.DLL
the WinLift32.DLL and
WinLift32.DLL and the
and the ZTrace32.DLL
In addition, we're
to add an
add an include
an include file
include file, which
which we'll reference
we'll reference within
reference within our
within our code
is the WinLift32.include
the WinLift32.include file
As the purpose
purpose of WinLift
of WinLift is
WinLift is to
use a series
series of skins
of skins to
skins to enhance
to enhance your
enhance your application
your application, we're
have to copy
to copy these
copy these in
these in as
in as well
These are held
held in two
in two folders
name of this
of this particular
this particular skin
particular skin is
skin is Sony
is Sony, and
have a resource
a resource folder
resource folder which
folder which can
which can contain
can contain some
contain some images
In addition, we
need one more
one more definition
more definition file
is the SKS
the SKS file
is a flat
a flat text
flat text file
text file that
file that specifies
that specifies the
specifies the definition
the definition of
definition of how
of how our
how our skinning
our skinning is
skinning is going
to work, by
by referencing a
referencing a series
series of either
of either JPEGs
either JPEGs or
JPEGs or PNG
or PNG files
These describe how
describe how each
how each part
each part of
part of your
of your window
your window is
window is going
are all inside
all inside this
inside this Sony
this Sony folder
what we have
do to change
change the look
look of our
I'm additionally going
additionally going to
add an icon
an icon for
icon for the
for the application
the application itself
application itself as
itself as it
it currently does
currently does not
does not have
not have one
So in here
going to define
define the ZTraceDLL
the ZTraceDLL and
ZTraceDLL and also
and also include
also include the
include the WinLift32.encode
the WinLift32.encode file
have to look
at the definition
definition of our
function that defines
that defines all
defines all the
all the parts
the parts within
parts within our
within our form
we display our
display our form
our form to
form to the
the user, we
need to define
to define which
define which skin
which skin of
skin of WinLift
of WinLift we're
WinLift we're going
up a few
a few local
few local variables
local variables in
variables in order
order to populate
WinLift uses Unicode
So all of
these strings we're
strings we're going
to be setting
be setting up
setting up as
up as WStringZ
Now comes the
comes the point
where we actually
we actually define
actually define and
define and initialize
and initialize the
initialize the skin
the skin engine
we define the
define the resource
the resource which
resource which is
is the skin
the skin itself
is the Sony
the Sony skin
need to turn
to turn on
turn on and
on and initialize
initialize the engine
the engine itself
this should be
should be the
be the basics
the basics of
basics of skinning
of skinning our
skinning our window
see what difference
what difference this
difference this has
this has made
can see, we've
we've made quite
made quite a
quite a radical
a radical difference
radical difference to
difference to our
to our form
The form look
form look has
look has changed
has changed completely
still have the
have the existing
the existing buttons
existing buttons for
buttons for exit
for exit and
exit and run
and run form
run form and
form and we
have the list
the list box
list box on
the form has
form has changed
has changed quite
changed quite radically
quite radically from
radically from what
from what it
what it was
it was before
before we change
we change this
change this application
this application any
application any further
any further, let's
of the demo
the demo applications
demo applications that
applications that ships
ships with WinLift
at this buttons32.exe
this buttons32.exe variable
This shows you
shows you what
you what WinLift
WinLift can actually
can actually achieve
have a clock
a clock running
clock running at
running at the
the screen in
screen in real
in real time
number of buttons
are all custom
all custom buttons
custom buttons to
buttons to WinLift
to WinLift itself
And the screen
screen is resizable
And one of
of the buttons
the buttons has
buttons has a
has a font
a font embedded
font embedded on
embedded on it
So what else
what else can
else can we
can we actually
we actually do
actually do to
do to our
to our original
our original form?
original form? As
form? As the
As the form
the form stands
form stands, it
it would be
would be fully
be fully functional
let's add one
add one or
or two more
two more items
more items to
items to it
After having skinned
having skinned the
skinned the form
can now attempt
now attempt to
attempt to add
add the WinLift
the WinLift clock
We're setting a
setting a variable
a variable for
for the resource
the resource folder
a folder we
folder we looked
looked at which
at which contains
which contains our
contains our resources
this case, the
the clock image
We're specifying the
specifying the png
the .png file
a function within
function within the
within the WinLift
the WinLift library
WinLift library called
library called clock_control
to define this
define this clock
this clock constant
clock constant at
the code, which
which we'll do
do in a
setting the anchor
the anchor of
anchor of the
of the clock
the clock to
clock to the
to the bottom
This means when
means when your
when your form
your form is
form is resizable
is resizable, the
the clock will
clock will stay
will stay at
stay at the
the form when
form when this
when this form
this form is
form is resized
So let's define
let's define this
define this constant
this constant at
can see with
see with that
with that one
that one line
added a clock
a clock to
to add any
add any timers
add any special
any special code
special code to
code to redraw
to redraw the
redraw the clock
The clock is
clock is just
is just there
can we enhance
we enhance these
enhance these buttons
these buttons on
buttons on the
on the form?
the form? Let's
form? Let's look
look at that
at that next
moment we have
have two buttons
two buttons defined
buttons defined on
defined on the
on the form
An exit button
exit button and
button and a
and a run
a run form
going to comment
to comment those
comment those two
those two out
two out in
out in the
add a couple
couple of the
of the custom
the custom buttons
custom buttons that
buttons that WinLift
that WinLift supports
of all, the
This uses another
uses another function
another function within
WinLift library, the
the push button
push button image
if we do
for our run
our run form
form button, this
this will not
will not only
not only add
only add the
add the button
the button to
button to the
to the form
the form, it
it will place
will place an
place an image
on the button
And you can
use the constants
the constants to
constants to decide
to decide whether
decide whether you
whether you want
you want the
want the buttons
the buttons centred
buttons centred or
centred or left
or left or
left or right
or right justified
run our code
code now, we'll
now have two
have two new
two new buttons
As I kept
I kept the
kept the same
the same constant
same constant for
constant for the
for the buttons
the buttons, the
the buttons are
buttons are still
are still functional
still functional using
functional using your
using your existing
your existing code
All we've done
we've done is
done is added
is added the
added the button
Now if we
if we turn
we turn our
turn our eyes
our eyes to
eyes to the
list box, what
what I'd like
is to make
make the text
on the list
list box slightly
box slightly larger
And perhaps change
perhaps change the
the colour on
colour on the
on the text
Now these commands
these commands do
commands do not
do not appear
not appear to
to have actually
have actually changed
actually changed the
changed the form
the form colours
is because they
because they are
they are being
are being controlled
being controlled from
controlled from the
from the skin
skin engine itself
engine itself using
itself using the
using the definition
the definition file
So what I'm
what I'm going
to try now
try now is
the way that
way that works
that works by
works by creating
by creating a
a new skin
new skin definition
skin definition file
We will clone
will clone the
clone the existing
the existing one
existing one and
one and we'll
and we'll make
we'll make some
make some minor
some minor changes
So I have
I have copied
have copied the
copied the Sony
the Sony SKS
Sony SKS file
SKS file and
file and created
and created a
created a Sony
a Sony EX
Sony EX file
of these SKS
these SKS files
SKS files is
files is to
is to define
to define both
define both the
both the images
the images and
images and certain
and certain items
certain items of
items of each
For example, the
of the status
the status bar
status bar and
bar and the
and the offset
the offset for
offset for buttons
we also can
also can control
can control the
control the colours
the colours of
colours of caption
of caption text
caption text and
text and also
and also button
also button text
to make some
make some very
some very slight
very slight changes
slight changes to
changes to these
to these colours
these colours within
colours within this
within this Sony
this Sony EX
Sony EX SKS
EX SKS file
And I've also
I've also created
also created a
Sony EX folder
EX folder to
folder to contain
to contain my
contain my images
I've also changed
also changed the
changed the control
the control background
control background image
So all we
all we need
to change our
change our form
our form so
form so it's
so it's using
it's using the
using the new
the new SKS
new SKS file
code now, we
that the look
our form has
has changed again
The background image
background image is
image is actually
is actually now
actually now sitting
now sitting within
sitting within the
within the form
So we still
make this text
this text a
text a little
a little bigger
we have managed
have managed to
managed to change
change the colours
colours of the
the dialogue title
dialogue title and
title and the
and the plain
the plain text
plain text on
text on a
So our video
our video form
video form is
form is looking
is looking much
looking much better
if we add
we add a
add a control
control set font
font command after
command after the
after the form
form has been
has been skinned
the text in
text in our
our list box
list box is
box is now
is now larger
when we click
on it, it
it gets small
gets small again
So we're heading
we're heading in
heading in the
in the right
the right direction
try is, rather
rather than creating
than creating the
creating the list
list box within
box within the
the form definition
form definition, we're
to try creating
try creating it
creating it within
within the initialised
the initialised dialogue
initialised dialogue section
dialogue section of
of the callback
will just amend
just amend the
amend the code
code to take
to take out
take out reference
out reference to
reference to our
to our list
we will also
will also declare
also declare the
declare the font
the font globally
And having done
having done that
we will define
will define our
define our font
our font in
font in the
in the PB_Maine
the PB_Maine function
Now we've done
we will attempt
will attempt to
attempt to populate
populate our list
list box from
box from within
initialised dialogue function
setting the style
the style and
style and the
and the extended
the extended style
extended style of
style of our
of our list
function to get
the form list
form list to
list to populate
to populate an
populate an array
using a control
a control add
control add statement
add statement to
statement to add
to add this
add this array
this array to
array to our
the font of
font of the
list box itself
code now, we're
we're now getting
now getting a
getting a list
a list box
list box which
box which looks
which looks slightly
looks slightly better
on it, we're
we're not getting
not getting the
getting the reduced
the reduced font
reduced font size
So I think
I think we
think we have
have successfully transformed
successfully transformed our
transformed our project
project to use
The functionality is
functionality is still
is still within
still within the
application to run
the form, which
have not changed
not changed yet
have taken a
taken a fairly
we compare this
compare this to
the existing form
existing form, you
see it looks
it looks a
looks a great
great deal better
We have done
have done this
done this with
this with only
with only very
only very minor
very minor modifications
minor modifications to
modifications to our
our original code
original code, while
while retaining the
retaining the existing
the existing functionality
have also added
also added a
a new control
new control to
control to the
the form, the
the clock control
We have replaced
have replaced both
replaced both of
of the existing
existing buttons with
buttons with WinLift's
with WinLift's own
WinLift's own custom
own custom buttons
custom buttons, which
which give you
you the ability
ability to put
to put graphics
put graphics on
graphics on the
on the buttons
the buttons themselves
Plus we now
have a background
a background to
background to the
next video, we'll
we'll move on
move on to
on to cover
to cover the
cover the rest
rest of our
Can WinLift handle
WinLift handle dynamic
handle dynamic forms?
dynamic forms? I'll
forms? I'll put
below to where
to where you
can actually apply
actually apply and
apply and donate
and donate to
donate to get
to get WinLift
again at Graphics
at Graphics Windows
In our last
our last video
last video on
video on Graphics
on Graphics Windows
Graphics Windows we
Windows we had
we had created
had created an
created an application
an application which
application which could
which could be
could be compiled
be compiled either
compiled either using
either using the
using the console
console compiler or
or the PowerBasic
the application, we
see it launches
it launches three
launches three graphics
three graphics windows
graphics windows, the
first of which
of which is
is a sample
a sample graphics
sample graphics progress
graphics progress bar
Once that completes
that completes, it
will load a
load a JPEG
a JPEG graphic
JPEG graphic up
graphic up from
from the directory
the directory and
directory and deposit
and deposit it
deposit it in
in the first
the first graphics
first graphics window
It will put
will put text
text on that
on that window
that window and
window and text
and text on
on a second
a second graphics
second graphics window
Before we make
we make any
make any changes
any changes to
this code, I'm
change the JPEG
the JPEG slightly
JPEG slightly to
slightly to trim
to trim off
trim off the
off the excess
the excess round
excess round the
round the side
the side of
side of the
double-click on the
on the map
the map JPEG
map JPEG, we're
a minor edit
minor edit to
edit to this
to this graphic
this graphic, just
just to crop
to crop it
crop it slightly
it slightly, like
like so, and
will then save
then save that
save that one
that's what our
what our graphic
our graphic is
graphic is going
look like now
So let's look
see how we
how we can
can make some
make some more
some more changes
more changes to
changes to our
it stands, we're
we're using three
using three libraries
three libraries, the
API library which
library which comes
which comes with
comes with PowerBasic
with PowerBasic and
PowerBasic and two
and two additional
two additional libraries
The first is
first is the
the Graphics Splash
Graphics Splash Progress
Splash Progress library
Progress library, which
used to display
display the progress
the progress bar
progress bar in
bar in a
in a graphics
a graphics window
The next library
next library is
library is PB-Load-JPEG
is PB-Load-JPEG as
PB-Load-JPEG as Bitmap
As graphics controls
graphics controls in
controls in graphics
in graphics windows
graphics windows require
windows require bitmaps
require bitmaps to
bitmaps to load
load into them
into them, this
this library allows
library allows you
you to take
to take a
take a JPEG
a JPEG file
JPEG file, convert
convert it to
to a bitmap
a bitmap and
bitmap and allow
and allow you
you to load
to load that
load that directly
that directly into
directly into your
into your control
your control or
control or graphics
or graphics window
What you will
see in this
in this part
this part of
code is this
is this is
where we clear
we clear the
clear the graphics
the graphics window
graphics window, and
setting the background
background to a
to a light
a light grey
light grey colour
We're then changing
then changing the
changing the graphics
the graphics colour
graphics colour so
colour so that
so that any
that any text
any text that
text that appears
that appears on
appears on that
on that background
that background is
background is black
is black in
black in text
in text with
text with a
with a light
light grey background
is the part
the part we're
part we're going
So we'll comment
we'll comment out
comment out these
out these two
these two lines
of code for
code for the
with the background
the background is
background is make
is make it
it a gradient
gradient fill, so
so that it
is a smooth
a smooth gradient
smooth gradient between
gradient between two
between two colours
application to paint
to paint the
paint the background
this function PaintBackground
function PaintBackground, which
which will take
take a single
graphics window we
window we wish
wish to paint
the background of
new function PaintBackground
function PaintBackground, taking
up our local
our local variables
variables in here
first is going
array of a
of a user-defined
user-defined type called
type called TriVertex
next is going
to be another
be another variable
another variable of
variable of a
type for the
for the gradient
the gradient rectangle
The next variable
next variable is
variable is another
is another handle
another handle for
handle for our
the final variables
final variables are
variables are the
are the width
as the graphics
graphics window can
window can vary
can vary, the
first thing I
thing I want
use a graphics
a graphics attach
graphics attach command
attach command to
command to make
make sure I'm
sure I'm pointing
I'm pointing towards
pointing towards the
towards the correct
the correct window
use the hwin
the hwin variable
hwin variable, which
been passed in
passed in on
parameters list, to
to point it
point it towards
it towards that
towards that window
Next we want
want to determine
determine the size
window and populate
populate the w1
the w1 and
w1 and h1
and h1 variables
h1 variables –
variables – the
– the width
use the graphics_get_size
the graphics_get_size command
graphics_get_size command to
command to obtain
to obtain those
obtain those values
want to obtain
to obtain the
obtain the device
device context of
context of our
of our current
our current graphics
current graphics window
populate the hdc
the hdc variable
hdc variable with
populate the TriVertex
the TriVertex array
We're putting two
putting two sets
two sets of
sets of information
information in here
in here –
here – first
– first of
all the width
and height in
height in pixels
in pixels of
pixels of the
the window itself
Secondly we're putting
we're putting in
putting in the
in the colour
the colour –
colour – the
– the red
the red, green
green and blue
and blue colour
blue colour –
colour – for
– for each
of the sides
the sides of
sides of our
of our gradient
here we're making
we're making it
making it 230
it 230 for
230 for red
for red and
red and 150
and 150 for
150 for red
for red on
red on the
the other side
to the gradient_full_windows
the gradient_full_windows API
gradient_full_windows API function
This will perform
will perform the
perform the gradient
the gradient fill
gradient fill for
fill for us
for us filling
us filling the
filling the window
the window with
window with a
with a colour
a colour of
colour of our
of our choice
And finally we're
finally we're using
the graphics redraw
graphics redraw command
redraw command to
command to redraw
redraw the graphics
graphics window so
window so the
actually see what's
see what's on
what's on it
And there you
there you will
see the background
background of the
of the sample
the sample graphics
sample graphics window
graphics window is
window is now
now showing a
showing a gradient
gradient fill of
fill of red
Going from a
from a lighter
a lighter red
lighter red on
left hand side
hand side to
side to a
to a darker
a darker red
darker red on
on the right
We can amend
can amend the
amend the colour
the colour of
colour of this
of this gradient
this gradient fill
gradient fill quite
fill quite easily
easily by amending
by amending the
amending the values
values in the
in the paint_background
the paint_background function
we put some
put some values
some values in
values in for
in for the
for the green
the green element
green element of
element of our
of our colour
our colour and
colour and run
application again now
again now, we
will get quite
get quite a
quite a different
a different colour
see the text
text that is
that is being
is being printed
being printed on
printed on this
this graphics window
window is overwriting
is overwriting the
overwriting the background
the background fill
As the background
background fill colour
fill colour is
colour is a
is a gradient
a gradient, we
we can't set
can't set the
set the background
background colour of
our text command
But can we
we make it
make it transparent
it transparent so
transparent so that
that the background
background colour will
colour will show
will show through?
show through? Let's
through? Let's have
back to where
where the text
text is actually
is actually written
the text being
text being written
being written to
written to the
So we'll want
want to put
put a graphics_colour
a graphics_colour command
graphics_colour command in
command in to
in to override
to override the
override the standard
the standard colours
Before we'd use
we'd use the
graphics colour with
colour with its
with its two
its two parameters
two parameters -
parameters - the
- the black
the black for
black for the
for the foreground
foreground and the
and the light
the light grey
light grey for
grey for the
for the background
If we remove
we remove the
remove the light
light grey and
grey and we
and we put
we put in
put in -2
in -2, this
background to be
to be transparent
be transparent and
transparent and allow
and allow the
allow the background
our gradient fill
gradient fill to
fill to show
to show through
text is now
is now successfully
now successfully displayed
successfully displayed and
displayed and the
background colour is
colour is showing
is showing through
So having populated
having populated our
populated our graphics
our graphics window
graphics window, can
can we copy
we copy data
copy data from
data from it
from it and
it and on
and on to
to the second
the second graphics
second graphics window?
graphics window? Let's
window? Let's go
So after the
after the JPEG
the JPEG is
JPEG is rendered
to the first
graphics window, we
want to copy
to copy a
copy a section
of this first
this first graphics
graphics window to
window to the
thing we need
use a graphics_attach
a graphics_attach command
graphics_attach command to
command to reference
reference the second
This instructs Power
instructs Power Basic
Basic that the
that the graphics
graphics window we're
window we're going
going to write
to write to
write to is
is the second
the second one
use the graphic_copy
the graphic_copy command
graphic_copy command, referencing
referencing the first
the first window
first window and
window and the
and the area
area of that
of that window
that window we
window we want
to copy and
copy and where
and where on
where on the
on the second
the second window
second window we're
going to copy
to copy to
So the graphics_copy
the graphics_copy command
graphics_copy command will
command will take
take a number
of parameters, the
which is where
where we're actually
we're actually copying
actually copying from
And since we're
since we're copying
we're copying from
copying from a
from a graphics
graphics window, the
the next parameter
next parameter needs
parameter needs to
to be zero
Next are the
of the area
the area we
area we wish
wish to copy
Note these are
these are not
are not widths
not widths and
widths and heights
and heights, but
but the actual
the actual pixel
actual pixel coordinates
To finish the
finish the command
the command, we
need to tell
to tell it
tell it where
it where we're
where we're copying
we're copying to
copying to on
to on the
we're moving to
moving to 100
to 100 by
100 by 100
by 100 pixels
100 pixels and
pixels and we're
using the mix_copy
the mix_copy source
And after using
after using the
using the graphics_copy
graphics_copy command, we
will use graphics_redraw
use graphics_redraw to
graphics_redraw to instruct
to instruct Power
instruct Power Basic
Power Basic to
Basic to redraw
graphics window and
window and make
and make it
make it visible
it visible to
will get our
get our progress
our progress bar
Once it completes
it completes, the
the JPEG will
JPEG will be
will be displayed
be displayed on
window and a
and a section
section of that
of that graphics
that graphics window
graphics window has
window has now
now been copied
been copied to
copied to the
you can quite
quite easily copy
easily copy from
from one window
one window to
to another with
another with one
with one command
we copy something
copy something from
something from the
window to somewhere
to somewhere else
somewhere else on
else on the
first graphics window?
graphics window? We
window? We can
can take exactly
take exactly the
same approach as
approach as we
did a moment
we use the
use the graphics_attach
the graphics_attach command
command to instruct
Basic that what
that what we're
to be writing
be writing to
writing to is
is the first
use the graphics_copy
graphics_copy command to
command to say
say that we
that we are
are copying to
copying to the
are copying from
copying from this
from this location
this location to
location to this
to this location
This is defining
is defining the
defining the size
the rectangle we
rectangle we wish
copy and this
this is saying
is saying we
saying we were
we were copying
were copying to
use the graphics_redraw
the graphics_redraw command
graphics_redraw command to
Basic to display
display this to
that now, we
get the progress
progress bar as
bar as before
JPEG will then
will then be
then be copied
be copied to
to the primary
the primary window
And we now
now have the
have the secondary
the secondary window
secondary window populated
window populated as
populated as before
as before and
before and we
also have an
have an image
an image copied
image copied to
copied to a
a separate area
separate area of
area of the
of the first
is we've added
added a gradient
fill to our
to our primary
our primary graphics
primary graphics window
We've amended the
the text so
text so that
when the text
text is written
is written to
written to that
to that graphics
graphics window, it
it allows the
allows the background
the background screen
background screen to
screen to show
In other words
other words, we
we have written
have written the
written the text
the text with
with a transparent
a transparent background
We've also copied
also copied a
copied a section
And we've also
window to a
a separate location
separate location on
location on that
on that first
that first graphics
We can probably
can probably do
probably do more
do more to
more to the
to the paint
the paint background
paint background function
background function to
function to make
make it more
it more generic
more generic so
generic so that
so that you
that you can
you can specify
can specify the
specify the colours
the colours in
at the creation
the creation of
creation of clickable
of clickable buttons
clickable buttons on
buttons on a
on a graphics
created a number
number of videos
of videos which
which cover the
cover the creation
creation of dialogues
of dialogues in
dialogues in the
in the PowerBasic
These dialogues allow
dialogues allow you
you to create
to create objects
create objects on
objects on screen
on screen that
screen that users
that users can
users can click
And additionally the
additionally the Windows
Windows Compiler provides
Compiler provides you
provides you with
you with an
with an Event
Event Handler, a
series of callback
of callback functions
callback functions, in
in which you
you can handle
can handle the
handle the events
the events that
events that have
that have occurred
have occurred when
occurred when users
when users interact
users interact with
interact with this
with this dialog
This functionality is
functionality is not
is not available
not available within
Mainly because the
because the console
console compiler is
compiler is designed
is designed to
designed to operate
to operate with
operate with console
with console applications
console applications, which
which do not
do not require
not require dialogues
happens if all
if all you
all you have
you have is
have is the
is the console
compiler and you
and you need
need to provide
to provide some
provide some kind
some kind of
kind of user
of user feedback
user feedback or
feedback or user
or user interaction
user interaction with
interaction with a
with a pseudo-dialogue
a pseudo-dialogue on
pseudo-dialogue on screen?
on screen? Say
screen? Say for
example we had
we had set
had set ourselves
set ourselves the
ourselves the task
task of providing
of providing to
providing to the
the user a
user a button
a button to
button to click
click on from
on from within
we do this?
do this? Well
this? Well today
Well today we're
This application can
application can run
can run either
run either within
either within the
within the Windows
window and on
and on that
on that graphics
going to provide
provide a clickable
a clickable button
And the code
the code behind
code behind is
behind is going
going to detect
to detect that
detect that the
that the button
the button has
task within the
application is to
create our graphics
the graphic window
graphic window command
window command, setting
setting the title
the title to
title to mouse
to mouse click
mouse click and
click and setting
and setting its
setting its coordinates
its coordinates its
coordinates its width
and height on
height on the
The output from
output from this
from this call
this call is
call is to
is to populate
to populate a
populate a variable
a variable, in
case a D-word
This being the
being the handle
graphics window itself
need to declare
to declare a
variable to hold
to hold that
hold that information
want to tell
to tell PowerBasic
tell PowerBasic that
PowerBasic that this
the active graphics
active graphics window
use the redraw
the redraw option
redraw option to
option to ensure
ensure that the
graphics are only
are only redrawn
only redrawn to
redrawn to the
screen at a
at a point
a point in
the code where
code where we
where we wish
use the handle
the handle we've
handle we've just
we've just populated
just populated, hWin
can mark that
mark that as
that as graphic_attach
as graphic_attach with
graphic_attach with the
with the redraw
We may want
want to send
to send some
send some text
some text to
screen so we're
up a font
a font to
font to do
So we'll use
we'll use the
use the font
the font new
new command and
command and we'll
and we'll pick
we'll pick Courier
pick Courier New
Courier New as
New as the
as the font
font of our
using a 24
a 24 point
24 point font
point font so
font so it's
so it's quite
it's quite visible
quite visible on
visible on screen
And that gets
that gets populated
gets populated to
populated to a
to a DW
a DW font
DW font variable
font variable which
variable which we've
which we've also
we've also declared
We now want
want to instruct
to instruct PowerBasic
instruct PowerBasic to
PowerBasic to set
set that font
that font as
font as the
as the current
the current graphics
current graphics font
graphics font so
font so that
any text automatically
text automatically picks
automatically picks that
picks that up
use the graphic_clear
the graphic_clear command
graphic_clear command to
window and give
and give it
give it a
it a background
a background of
background of light
of light grey
So to complete
to complete this
complete this section
this section we
section we will
we will print
will print the
print the words
the words 'Click
words 'Click button
'Click button when
button when ready'
when ready' to
ready' to the
we will execute
will execute the
execute the redraw
the redraw command
to redraw that
redraw that to
have two windows
two windows on
windows on the
A standard console
standard console window
console window which
window which we're
be using to
using to display
display information and
information and a
and a graphics
graphics window which
window which has
which has the
has the words
when ready' at
ready' at the
So to terminate
to terminate the
the application we
application we will
we will close
will close the
close the graphics
window and then
we will exit
will exit the
exit the console
now that our
that our graphics
window is prepared
is prepared how
prepared how can
can we display
we display a
display a button
a button on
on the screen?
the screen? One
screen? One of
of the things
the things you
things you can
do within a
within a graphics
window is you
is you can
you can render
can render graphics
render graphics to
graphics to it
create a bitmap
a bitmap which
bitmap which is
be the image
the image of
image of our
of our button
our button and
button and we're
going to render
to render that
render that on
that on the
created a bitmap
a bitmap graphic
bitmap graphic called
graphic called 'Click
called 'Click me
'Click me dot
me dot bmp'
at that it's
it's a simple
a simple rectangle
simple rectangle with
rectangle with the
with the words
words 'Click me
'Click me on
me on it'
the image we
image we will
we will render
will render onto
render onto our
window which will
which will become
will become our
become our button
So how do
do we render
we render that
render that onto
that onto the
onto the screen?
the screen? Well
screen? Well we'll
Well we'll need
to define in
define in a
in a variable
a variable a
variable a path
a path to
path to and
to and the
of our bitmap
So we declared
variable called 'bmp_name'
called 'bmp_name' and
'bmp_name' and we're
populating that with
with the 'Click
the 'Click me
dot bmp' which
bmp' which exists
which exists within
exists within our
within our current
our current folder
As the bitmap
the bitmap you're
bitmap you're going
to be rendering
be rendering may
rendering may be
may be of
be of different
of different sizes
different sizes you
sizes you want
of the bitmap
the bitmap at
bitmap at runtime
Therefore we can
we can open
can open the
open the bitmap
the bitmap for
bitmap for binary
for binary handling
binary handling and
handling and we
can get the
the information for
information for the
and height out
height out of
the bitmap file
bitmap file itself
We've used this
used this technique
this technique in
technique in previous
So we're assigning
we're assigning the
assigning the long
the long file
long file variable
file variable to
variable to be
be the next
next available free
available free file
We're then opening
then opening our
opening our bitmap
our bitmap for
binary handling as
handling as that
as that file
that file handle
using two get
two get commands
First way to
way to get
get the width
width and secondly
and secondly to
secondly to get
get the height
our bitmap we
bitmap we can
can then close
then close down
close down the
down the file
we will declare
will declare those
declare those variables
those variables we've
variables we've now
The width, the
height and the
and the handle
the handle for
for the bitmap
determined the size
bitmap we now
have to decide
to decide where
decide where we
where we want
want to position
to position it
position it on
it on screen
position of our
will create two
One called X
called X graphic
X graphic and
graphic and one
one called Y
called Y graphic
So we want
position the button
the button 100
button 100 pixels
100 pixels in
pixels in from
in from the
from the left
hand side and
side and 100
and 100 pixels
100 pixels down
pixels down from
will define both
define both of
both of those
of those variables
those variables at
variables at the
now we come
we come to
come to the
can actually load
actually load our
load our graphic
our graphic up
graphic up and
up and render
and render it
render it to
So having determined
having determined the
our bitmap and
bitmap and where
and where we
to place it
place it on
do we actually
we actually render
actually render that
render that straight
that straight to
straight to the
to the screen?
screen? Well we
Well we use
the graphic render
graphic render command
render command takes
being the name
the name and
name and the
and the path
to the bitmap
bitmap file on
file on disk
Then the next
set of parameters
of parameters are
parameters are in
are in brackets
Y coordinates we
coordinates we want
want to start
to start the
start the bitmap
bitmap at and
at and the
and the X
want to end
end the bitmap
This is why
is why we
why we picked
picked up the
have the button
button on our
Let's see if
we can detect
can detect mouse
detect mouse clicks
mouse clicks on
Because we'll need
to know that
that the mouse
the mouse has
mouse has been
been clicked in
clicked in order
order to know
to know whether
know whether the
whether the button
code you realise
you realise just
realise just how
just how much
how much work
much work the
work the dynamic
the dynamic dialog
dynamic dialog tools
dialog tools are
tools are doing
are doing for
doing for you
for you in
you in the
create the basics
basics of an
This is basically
basically a loop
loop to capture
to capture mouse
capture mouse clicks
going to run
to run render's
run render's loop
render's loop and
loop and try
and try and
try and detect
and detect the
detect the mouse
the mouse having
mouse having been
having been clicked
do this every
this every 100
every 100 milliseconds
And we need
need to detect
to detect whether
detect whether the
whether the graphics
window is actually
is actually still
actually still open
still open or
open or has
or has it
has it been
it been closed
been closed by
closed by the
can use a
use a straightforward
a straightforward is
straightforward is window
is window command
window command to
command to determine
whether the window
the window handle
Which we determined
we determined earlier
determined earlier when
earlier when we
when we created
we created a
created a graphics
window is still
is still active
still active or
active or not
it is no
no longer active
longer active then
active then we
can exit this
if the return
return from the
from the isWindow
the isWindow function
isWindow function is
function is false
then the graphics
window has been
has been closed
been closed and
closed and we
exit the loop
if the graphics
is still open
still open we
open we need
whether the mouse
been clicked or
clicked or not
And there's a
a graphic window
graphic window click
window click command
click command we
to determine that
So we're giving
we're giving it
giving it the
it the hWindow
the hWindow handle
hWindow handle and
handle and we're
and we're giving
it three additional
three additional variables
A click variable
click variable and
variable and an
and an x
x and a
and a y
a y coordinate
If the click
the click variable
click variable returns
variable returns zero
returns zero then
zero then there
then there has
there has been
has been no
been no mouse
no mouse click
it returns one
returns one then
one then the
then the left
mouse button has
been clicked once
it returns two
returns two then
two then the
been clicked twice
a y coordinates
y coordinates and
coordinates and pixels
and pixels on
pixels on the
the graphics screen
graphics screen are
screen are returned
are returned in
returned in the
in the long
the long x
long x and
and the long
the long y
long y variables
to declare these
declare these new
these new variables
new variables at
that we've done
of our click
value of long
of long click
long click is
click is greater
zero then the
then the mouse
mouse has indeed
indeed been clicked
So for information
for information purposes
information purposes let's
purposes let's pick
let's pick up
to print those
print those out
those out to
to our console
let's run the
code now and
see what happens
is our graphics
the mouse somewhere
mouse somewhere inside
somewhere inside the
inside the graphics
window and click
and click we
click we can
see the coordinates
the coordinates are
coordinates are now
are now appearing
determine the x
y coordinates that
coordinates that have
have been clicked
clicked on it
on it should
it should now
now be fairly
be fairly easy
fairly easy to
easy to work
work out have
out have we
have we clicked
we clicked on
the button or
button or not
After all we
all we know
know the location
of the button
the button, we
we know its
know its width
width and we
know its height
So it's a
a simple matter
simple matter of
matter of arithmetic
of arithmetic to
arithmetic to work
whether the x
coordinates are within
are within that
within that boundary
So we're testing
we're testing if
testing if long
if long x
long x is
x is greater
is greater or
greater or equal
or equal to
equal to the
to the original
the original position
original position of
the bitmap and
bitmap and less
less than or
than or equal
x coordinate plus
plus the width
And also with
also with its
with its within
its within the
within the boundings
the boundings of
boundings of the
print out to
our console log
console log button
log button click
button click if
click if we've
if we've detected
we've detected a
detected a click
a click on
can click anywhere
click anywhere on
graphics screen and
screen and the
and the coordinates
coordinates are returned
we click somewhere
click somewhere on
the button it
button it is
is indeed picking
indeed picking up
up the fact
the fact it's
fact it's a
it's a button
a button click
So although we
although we are
are now picking
now picking up
fact that the
mouse has clicked
has clicked over
clicked over the
over the button
the button there
button there is
is no visual
no visual feedback
visual feedback from
feedback from the
from the button
the button that
button that you
that you would
you would normally
would normally get
When a button
a button is
button is pushed
is pushed it
pushed it generally
it generally moves
need to animate
to animate our
animate our button
our button slightly
button slightly to
slightly to give
to give the
the illusion to
illusion to the
user that they've
that they've actually
they've actually clicked
on an actual
an actual button
can we simulate
we simulate a
simulate a button
a button push?
button push? So
push? So what
up the graphic
the graphic line
graphic line width
it slightly thicker
slightly thicker so
thicker so we
actually put a
put a simulated
a simulated shadow
simulated shadow in
shadow in place
in place to
place to indicate
to indicate the
indicate the fact
the fact the
fact the button
button has actually
actually been depressed
will declare this
declare this new
this new line
new line width
line width variable
to set its
set its value
its value to
value to 2
to 2 pixels
Now I'm going
going to draw
to draw two
draw two lines
two lines, one
one along the
along the top
the top edge
top edge of
edge of the
the button and
button and one
and one down
one down the
down the left
hand side of
And to do
do this we're
this we're going
graphic line command
Graphic line will
line will draw
will draw a
draw a line
a line between
line between two
between two points
We've designated the
designated the first
the first point
first point as
point as being
as being the
being the top
And the ending
the ending point
ending point is
point is the
is the x
setting the color
the color to
color to be
to be dim
be dim grey
And the second
the second line
second line is
line is a
is a vertical
a vertical line
end we will
will do a
do a graphic
a graphic redraw
graphic redraw to
redraw to display
So having drawn
having drawn this
drawn this vertical
this vertical and
vertical and this
and this horizontal
this horizontal line
horizontal line, we
want to re-render
to re-render the
re-render the bitmap
the bitmap to
bitmap to appear
to appear as
appear as if
if it's slightly
it's slightly to
slightly to the
the right and
right and slightly
and slightly down
As if the
if the button
button has changed
has changed aspect
changed aspect by
aspect by being
by being pushed
being pushed in
we can re-render
can re-render the
re-render the button
the button graphic
button graphic to
graphic to our
to our graphic
our graphic window
Moving it two
it two pixels
two pixels to
pixels to the
right and two
and two pixels
two pixels down
And making it
making it slightly
it slightly smaller
slightly smaller than
smaller than it
than it was
was before by
before by the
by the same
the same margin
will see when
see when we
button it appears
it appears to
to be depressed
However it's not
it's not returning
not returning back
returning back up
back up again
up again like
again like a
like a button
a button would
button would normally
would normally do
So we'll have
have to simulate
to simulate that
simulate that again
do that by
that by simply
by simply re-rendering
simply re-rendering the
re-rendering the graphic
the graphic in
graphic in its
in its original
its original location
However we don't
we don't want
don't want to
do it instantaneously
be a slight
a slight delay
going to wait
to wait one
wait one or
or two hundred
two hundred milliseconds
hundred milliseconds before
milliseconds before we
before we redraw
So the redraw
redraw command is
command is in
is in for
for the depression
the depression of
depression of the
to wait 100
wait 100 milliseconds
100 milliseconds and
milliseconds and then
and then re-render
then re-render the
re-render the graphic
Going back up
back up two
up two pixels
And then using
the graphic redraw
graphic redraw command
redraw command once
command once more
once more to
more to redraw
redraw that graphic
that graphic to
graphic to the
the user so
user so they
so they may
they may see
may see it
We get our
get our graphics
window which is
which is still
is still detecting
still detecting the
detecting the clicking
clicking of the
it will briefly
will briefly depress
briefly depress as
depress as if
And after each
after each depression
each depression 100
depression 100 milliseconds
100 milliseconds later
milliseconds later the
later the button
the button will
button will return
will return to
to the upright
the upright position
window we have
we have rendered
have rendered a
rendered a button
a button from
button from a
from a bitmap
a bitmap file
We're detecting mouse
detecting mouse clicks
And we're determining
we're determining if
determining if the
if the mouse
the mouse click
mouse click is
click is over
is over the
it is over
the button we
button we are
we are moving
are moving the
moving the graphics
the graphics slightly
graphics slightly to
right and down
and down to
down to simulate
to simulate the
simulate the button
button click image
And then 100
then 100 milliseconds
milliseconds later we're
later we're returning
returning the button
button to its
to its original
its original position
By redrawing the
redrawing the graphic
the graphic on
graphic on the
This to a
a user will
user will give
will give the
illusion that the
the button is
button is in
in fact interactive
this technique you
technique you can
you can display
can display buttons
display buttons on
And then once
then once the
user has clicked
has clicked on
on it once
it once you've
once you've done
you've done the
done the redrawing
can then call
then call any
call any function
any function within
that you need
So it would
would be quite
be quite possible
quite possible although
possible although a
although a bit
a bit of
bit of work
of work to
work to create
create a graphics
graphics window with
window with interactive
with interactive controls
However if you're
doing a lot
lot of dialogue
of dialogue work
dialogue work I
work I would
I would recommend
would recommend doing
recommend doing as
doing as much
as much as
much as you
you can in
can in the
if you really
you really need
need to you
to you can
can do some
do some within
some within the
creation of arrays
your applications, arrays
arrays can be
can be a
be a very
a very useful
very useful way
useful way of
way of storing
of storing, accessing
accessing and manipulating
and manipulating your
manipulating your data
have done a
done a number
of videos on
videos on creation
on creation of
of arrays and
arrays and accessing
and accessing their
accessing their data
going to cover
to cover today
cover today is
today is some
is some areas
some areas of
areas of array
of array accessing
array accessing and
accessing and creating
and creating that
creating that we
that we haven't
we haven't covered
haven't covered before
look at some
at some code
Since we're going
to be making
use of some
of some random
random data generation
data generation in
generation in this
use the Randomize
the Randomize command
Randomize command using
command using its
using its single
parameter of timer
To seed the
seed the random
number generator with
generator with the
with the current
the current date
current date and
date and time
So firstly, we're
create a one-dimensional
a one-dimensional string
one-dimensional string array
string array with
array with five
with five elements
And having created
having created this
created this array
populate the array
the array with
array with some
with some data
some data using
the array Assign
array Assign command
Assign command takes
takes the name
array as the
as the first
first parameter, followed
followed by an
by an equals
an equals sign
equals sign and
sign and then
and then a
then a comma
a comma delimited
comma delimited list
delimited list of
list of the
of the values
the values you
values you wish
wish to put
to put into
put into the
we're putting five
putting five values
five values into
values into the
Let's now display
now display this
display this array
this array on
array on our
on our log
our log to
log to see
see if they
if they have
they have arrived
next loop, stepping
the elements within
elements within our
will see, although
although we have
we have five
have five lines
five lines of
lines of data
of data appearing
the screen, only
only four of
four of them
of them are
them are actually
are actually populated
So what's gone
what's gone wrong
gone wrong with
wrong with our
with our code?
our code? One
code? One thing
thing that might
that might not
might not be
not be immediately
be immediately obvious
immediately obvious is
obvious is when
is when we
when we dimensioned
we dimensioned the
dimensioned the array
the array, we
we gave it
gave it the
it the name
array with the
the number five
number five in
five in brackets
in brackets, intending
intending to have
to have five
have five elements
what this has
this has actually
has actually achieved
actually achieved is
achieved is it
is it has
it has created
has created an
created an array
an array with
array with six
with six elements
six elements, starting
starting with the
the element zero
element zero, then
then one, two
four and finally
and finally five
when we use
use the array
Assign command, we
we were going
were going to
the value apple
value apple into
apple into the
into the first
the first element
first element of
is the zero
And because our
because our for
next loop is
loop is going
is going from
going from one
to five, it
it will only
will only display
only display those
display those five
those five elements
will not display
not display the
display the zero
zero element, which
which is why
is why one
why one of
one of them
of them was
them was missing
not require the
require the zero
zero element of
the array, you
you can dimension
can dimension the
dimension the string
the string slightly
string slightly differently
So putting just
putting just five
just five within
five within the
the brackets is
brackets is the
is the equivalent
the equivalent to
equivalent to dimensioning
to dimensioning it
dimensioning it from
it from elements
from elements zero
elements zero to
zero to five
If you only
you only want
only want elements
want elements one
elements one to
to five, you
dimension the array
the array and
array and in
in brackets put
brackets put one
put one to
In this array
this array, there
will be no
be no zero
no zero element
see all five
all five elements
five elements are
elements are now
are now correctly
now correctly populated
Whether you have
have a zero
a zero element
zero element or
element or not
or not in
not in your
in your arrays
your arrays is
arrays is entirely
is entirely up
entirely up to
up to yourself
Sometimes having a
having a zero
zero element can
element can be
can be useful
For example, holding
holding a column
a column header
column header name
The other thing
other thing that
thing that it's
that it's useful
it's useful to
useful to do
to do when
do when accessing
when accessing your
accessing your array
your array is
array is not
is not to
not to assume
to assume the
assume the element
the element size
At some points
some points in
points in your
you may well
may well redimension
well redimension an
redimension an array
an array to
array to change
to change its
change its size
have a nice
a nice dynamic
nice dynamic way
dynamic way of
way of working
of working out
working out what
what the lower
the lower bounding
lower bounding and
bounding and the
and the upper
the array actually
array actually is
Power basic supplies
basic supplies two
supplies two commands
two commands to
commands to achieve
L bound for
bound for lower
for lower bounding
bounding and U
and U bound
U bound for
bound for upper
for upper bounding
we can replace
can replace the
replace the for
the for lngR
lngR equals one
equals one to
to five with
five with a
with a new
of code will
code will work
out the lower
lower bounding value
bounding value and
upper bounding value
bounding value of
the array dynamically
This way your
way your code
your code does
code does not
does not need
not need to
to change in
in the event
the event of
event of the
array being redimensioned
So we run
code again, it
it will give
give us exactly
us exactly the
this time the
time the for
loop is dynamically
is dynamically working
dynamically working out
working out how
out how big
big the array
The dimensional aspects
dimensional aspects of
aspects of your
of your array
your array can
array can sometimes
can sometimes depend
sometimes depend on
depend on the
the data that
data that you
for example, we
wanted to hold
hold information based
information based on
on the year
We're looking at
looking at storing
at storing information
storing information for
for the last
the last 10
last 10 years
Perhaps the number
number of staff
of staff that
staff that have
that have worked
have worked from
worked from your
from your organization
your organization for
organization for each
of those years
While we can
can dimension an
an array from
array from elements
from elements one
one to 10
10 and put
put the values
values in, having
having something even
something even more
even more dynamic
more dynamic is
dynamic is quite
is quite useful
create a one
a one dimensional
one dimensional array
dimensional array with
array with an
with an element
an element for
element for each
for each year
each year and
year and store
and store the
store the numbers
the numbers of
numbers of staff
of staff working
staff working for
working for each
So what we
have done here
done here is
here is create
is create two
create two local
One to specify
specify the start
the start year
start year and
year and one
specify the end
the end year
populating the start
start year with
year with So
with So we're
going to dimension
to dimension an
hold the information
the information we're
information we're going
And we're dimensioning
we're dimensioning the
dimensioning the array
array using these
two variables from
variables from the
start year to
year to the
array will not
not be 0
be 0 or
0 or 1
or 1, it
will be 2013
array will be
will be 2023
This way we
way we can
using the year
the year number
year number as
number as the
as the element
This makes the
the code even
code even more
even more readable
the value we
value we have
we have which
have which specifies
which specifies the
specifies the element
the element could
element could in
could in itself
in itself be
itself be stored
stored within another
within another variable
we've stored these
stored these two
two values against
values against these
against these two
these two years
two years, how
would we print
we print that
that out to
to a log?
a log? How
log? How would
would we access
we access it
access it from
it from the
from the array?
the array? So
array? So using
So using the
using the approach
the approach we
approach we used
we used a
used a moment
moment ago, we're
to use L
use L bound
L bound and
bound and U
U bound to
bound to work
from the L
the L bound
L bound function
bound function in
function in this
this case for
case for that
for that particular
that particular array
particular array, the
the staff count
staff count array
count array, will
a value of
value of 2013
upper bounding will
bounding will return
value of 2023
get the year
the year coming
year coming out
coming out and
out and each
of the year
the year numbers
And we're also
we're also getting
also getting out
getting out the
of staff for
staff for each
as we populated
we populated the
populated the years
the years 2022
years 2022 and
2022 and values
and values coming
coming out for
out for those
So this shows
this shows that
shows that when
that when you
when you dimension
you dimension array
dimension array, you
you have quite
have quite a
quite a bit
bit of flexibility
of flexibility of
flexibility of the
of the lower
upper bounding elements
can we go
we go further
go further than
further than just
than just positive
just positive numbers?
positive numbers? Let's
numbers? Let's say
wanted to create
to create another
create another one-dimensional
another one-dimensional array
one-dimensional array, but
this time with
time with an
an element number
element number for
number for each
for each temperature
each temperature, holding
holding the number
number of days
of days at
days at that
at that temperature
would we go
we go about
go about doing
about doing that?
doing that? Let's
that? Let's say
Let's say, for
for example, we're
we're interested in
interested in the
in the temperatures
the temperatures of
temperatures of -10
of -10 to
-10 to plus
to plus 5
the array from
array from -10
from -10 to
-10 to 5
And that will
that will create
will create one
create one element
one element for
of these values
can then assign
then assign to
assign to that
to that array
that array some
array some values
can now use
now use the
assign command to
command to populate
to populate some
populate some values
some values into
populating the first
the first seven
first seven elements
seven elements of
elements of this
populated that, let's
let's use the
use the same
the same construct
same construct, the
next loop, using
using the lower
upper bounding, to
our log the
log the temperature
the temperature and
temperature and the
code now to
see what comes
what comes out
there are our
are our temperatures
our temperatures from
temperatures from -10
first seven have
seven have appearing
have appearing on
appearing on screen
on screen, from
have not populated
not populated the
populated the values
for the other
the other temperature
other temperature values
temperature values, they're
they're all coming
all coming out
coming out as
out as 0
can see, the
the numbers we
numbers we use
we use for
use for the
for the beginning
beginning and ending
and ending elements
ending elements of
elements of an
an array when
array when you
you dimension them
dimension them do
them do not
do not necessarily
to be positive
But they do
they do have
to be whole
be whole numbers
we've actually handled
actually handled one
handled one dimension
one dimension arrays
dimension arrays, can
the same thing
same thing with
thing with multi-dimension
with multi-dimension arrays?
multi-dimension arrays? Arrays
arrays? Arrays of
Arrays of dimensions
of dimensions of
dimensions of two
of two or
two or more
Let's assume we're
assume we're going
create a two-dimensional
a two-dimensional array
two-dimensional array, holding
holding a day
a day number
day number in
number in the
first element and
element and the
and the rainfall
the rainfall in
rainfall in the
in the second
So this new
this new array
new array, the
the average rainfall
average rainfall array
rainfall array, is
to contain seven
contain seven rows
seven rows, from
from rows 1
rows 1 to
1 to row
to row 7
contain two columns
two columns, from
from column 1
column 1 to
1 to column
to column 2
populate that using
that using a
store in the
first column the
column the day
the day number
be a number
0 and 6
the second column
second column, we're
to be generating
be generating a
generating a random
0 and 200
be the number
number of millimeters
of millimeters of
millimeters of rainfall
we can report
can report on
report on each
of the seven
the seven days
seven days how
days how much
how much rainfall
much rainfall occurred
display on our
log the data
data that's sitting
that's sitting in
sitting in the
the array, using
using the L-bound
the L-bound and
L-bound and U-bound
and U-bound commands
U-bound commands we've
commands we've used
we've used earlier
So the for
loop is for
is for the
for the L-bound
the L-bound of
L-bound of the
case is 1
is 1, and
case is 7
will see, the
U-bound commands have
commands have an
have an extra
an extra parameter
optional parameter designates
parameter designates which
designates which dimension
which dimension we
dimension we are
we are querying
Our array has
array has two
has two dimensions
The first dimension
first dimension is
dimension is basically
is basically the
basically the number
second dimension is
dimension is the
is the number
we are interested
in the upper
of the number
of rows, hence
hence the comma
the comma 1
Having determined that
determined that, we
we are printing
are printing out
printing out using
out using the
using the inbuilt
the inbuilt dayname
inbuilt dayname command
we have stored
have stored a
stored a value
a value between
value between 0
and 6 in
6 in the
first row, first
first element, we
want to actually
actually print out
print out what
out what dayname
what dayname that
dayname that is
The dayname$ function
dayname$ function will
return the actual
the actual name
actual name of
of the day
the day, starting
starting with Sunday
with Sunday for
Sunday for the
for the value
the value 0
And our second
our second column
second column is
column is the
is the rainfall
the rainfall itself
So we try
see we are
we are getting
are getting the
getting the 7
the 7 days
7 days printing
days printing out
printing out on
out on the
on the log
the log, and
and a random
random number generated
number generated for
generated for the
for the amount
the amount of
amount of rainfall
easier to follow
little more readable
more readable, and
and therefore maintainable
It's not immediately
not immediately obvious
immediately obvious that
obvious that the
first column is
column is actually
is actually the
actually the day
day number, or
or that the
that the second
column is in
in fact rainfall
can set these
set these up
these up in
up in constants
in constants at
constants at the
up a simple
a simple enumeration
this particular enumeration
particular enumeration, we
are setting up
setting up constants
are using the
using the singular
the singular command
singular command, so
so it means
it means that
means that the
that the following
the following line
following line, in
this case dayname
case dayname, is
with the %
the % sign
% sign in
sign in your
are setting its
setting its value
value to 1
the next constant
next constant, in
this case rainfall
case rainfall, we
have not given
not given a
given a value
Therefore the code
code will automatically
will automatically populate
automatically populate that
populate that with
the value 2
This saves having
saves having to
having to put
to put them
put them all
them all in
all in specifically
So how would
would we put
we put that
put that in
in our code?
our code? If
code? If we
If we comment
we comment out
comment out the
out the two
the two lines
two lines where
lines where we
we have hardcoded
have hardcoded the
hardcoded the column
And substitute the
substitute the two
new constants, one
for the dayname
the dayname, and
for the rainfall
code now becomes
now becomes more
becomes more readable
It's more obvious
more obvious that
obvious that we're
that we're storing
storing the dayname
storing the rainfall
long as we
as we use
we use these
use these constants
these constants through
constants through the
through the rest
we don't really
don't really need
to know which
know which column
which column number
column number that
number that data
that data is
data is stored
is stored in
It's all handled
all handled by
handled by the
by the constant
So we'll make
we'll make the
make the same
the same change
same change for
change for displaying
for displaying the
displaying the data
out the original
the original piece
original piece of
of code, and
we'll put a
a new piece
new piece of
code in, which
specifies the dayname
the dayname and
dayname and the
the rainfall constants
We've merely substituted
merely substituted dayname
substituted dayname where
dayname where we've
where we've had
we've had the
had the one
the one for
we get exactly
get exactly the
the same result
get the 7
7 days worth
days worth of
worth of rainfall
you'll find these
find these techniques
these techniques useful
techniques useful in
at the concept
the concept of
concept of associative
of associative arrays
associative arrays within
arrays within your
what are associative
are associative arrays
associative arrays and
arrays and what
use them for?
them for? An
for? An associative
An associative array
associative array, map
symbol table or
table or dictionary
or dictionary is
dictionary is an
is an abstract
an abstract data
abstract data type
data type that
type that stores
that stores a
stores a collection
a collection of
collection of pairs
of pairs of
pairs of keys
of keys and
keys and values
Each possible key
possible key appears
key appears no
appears no more
no more than
more than once
than once in
once in the
in the collection
store a list
list of countries
could have a
have a three-letter
a three-letter key
three-letter key for
key for each
for each country
each country and
country and store
store the full
the full name
full name of
of the country
the country associated
country associated with
with that key
By entering the
entering the key
the key our
key our application
our application could
application could return
could return the
Many types of
types of data
of data are
data are structured
are structured in
structured in this
in this way
this way, for
for example bank
example bank accounts
bank accounts where
accounts where the
where the account
the account number
account number links
number links to
links to the
to the data
the data value
data value or
value or values
or values associated
values associated with
associated with it
As the key
the key is
key is unique
is unique you
unique you should
you should be
able to return
return that information
that information very
information very quickly
do we use
we use associative
use associative arrays
associative arrays in
arrays in Power
in Power Basic?
Power Basic? We
Basic? We would
We would need
would need a
need a way
a way to
way to add
to add, find
update and remove
and remove entries
remove entries from
entries from the
from the associative
the associative array
So do we
need to access
to access new
access new libraries
new libraries or
libraries or DLLs?
or DLLs? No
DLLs? No, this
functionality is inbuilt
is inbuilt to
inbuilt to Power
Power Basic and
Basic and it's
and it's called
it's called Power
called Power Collections
some code to
code to illustrate
to illustrate this
you who have
who have been
have been watching
been watching these
watching these videos
these videos for
videos for a
a while, you
you will know
will know that
know that we've
we've done several
done several videos
several videos on
videos on Power
on Power Collections
Power Collections before
to revisit them
we can concentrate
can concentrate in
concentrate in a
in a little
little more detail
more detail on
detail on how
on how they
how they actually
they actually work
now see on
screen a list
list of users
of users with
users with their
with their names
their names, their
their addresses, their
their telephone numbers
telephone numbers and
numbers and an
and an account
an account number
If you look
you look closely
look closely at
closely at the
at the data
the data, you
see there were
there were in
were in fact
in fact two
fact two John
two John Smiths
So since we
since we need
store a unique
a unique identifier
unique identifier for
identifier for each
of these users
these users, we're
going to pick
pick the account
As you would
you would expect
would expect, in
in banking systems
banking systems, the
account number is
number is a
is a unique
identifier for the
for the customer
you have the
have the account
account number, you
able to pull
to pull any
pull any of
of the information
the customer out
customer out of
of the banking
the banking system
This data at
data at the
moment is held
is held in
held in a
in a plain
a plain CSV
plain CSV file
first task in
task in the
is to pull
to pull this
pull this information
this information into
information into the
into the application
application and store
and store it
it in a
in a format
a format which
format which we
can put into
put into our
into our Power
our Power Collection
defined type for
type for this
for this customer's
this customer's information
call this Customers
this Customers and
Customers and it
it will store
store the account
account number as
number as a
as a string
a string of
string of 8
of 8 characters
store the first
the first name
first name and
name and surname
and surname as
surname as strings
as strings of
strings of fixed
of fixed length
fixed length 50
length 50 characters
The address as
address as 100
as 100 characters
100 characters and
characters and the
and the telephone
the telephone number
telephone number as
string of 14
of 14 characters
The advantage of
advantage of using
of using a
type is that
is that you
that you could
you could extend
could extend this
extend this to
this to include
to include additional
include additional information
additional information, should
should the need
the need arise
Since our unique
our unique identifier
unique identifier is
identifier is going
be the account
account number, we're
put a prefix
a prefix on
prefix on the
on the front
the front of
of the account
can use an
use an account
account number for
number for two
for two different
two different purposes
More will become
will become clearer
become clearer when
clearer when we
get to that
to that point
up a constant
a constant or
constant or the
or the user
the user prefix
user prefix, which
will be for
be for our
for our user
our user account
So $user prefix
$user prefix in
prefix in this
case is going
the text user
So as we're
using a Power
a Power Collection
Power Collection, we
have to define
to define that
define that collection
global variable called
variable called Customers
called Customers as
Customers as an
as an iPowerCollection
We're then making
then making Customers
making Customers equal
Customers equal to
to the class
the class PowerCollection
This completes the
completes the setting
the setting up
setting up of
up of the
of the PowerCollection
the PowerCollection and
PowerCollection and we
can now look
now look at
look at putting
at putting some
putting some data
some data into
data into it
will now declare
type as our
as our type
we're creating udtCustomers
creating udtCustomers as
udtCustomers as uCustomers
as you'll remember
you'll remember, is
is the user
type we set
as we intend
we intend holding
intend holding two
holding two different
two different types
types of information
of information for
information for our
for our customers
our customers, we're
create another local
us to tell
to tell the
tell the difference
difference between them
call that RecordType
start to set
up some variables
some variables which
variables which are
which are going
used to get
to get data
get data into
data into our
into our PowerCollection
our PowerCollection and
PowerCollection and to
and to get
get data out
data out of
We'll start with
with the key
The key we
key we are
as a local
variable as a
as a wString
A wString or
wString or wideString
or wideString is
wideString is a
is a UnicodeString
type of string
of string is
string is slightly
slightly different from
different from our
from our ANSI
our ANSI standard
ANSI standard strings
The Unicode string
Unicode string stores
string stores the
stores the data
data for each
for each character
each character as
character as two
as two bytes
This allows the
allows the first
first part to
part to contain
to contain information
contain information on
information on what
on what character
what character set
character set we're
set we're actually
we're actually talking
actually talking about
allows the storage
the storage of
storage of international
of international character
international character sets
character sets and
sets and is
and is widely
is widely used
widely used within
the Windows subsystems
Next we're creating
creating a local
variable called longR
be using this
using this to
this to read
to read through
read through our
Next we're declaring
declaring a VData
a VData variable
is the variant
the variant that's
variant that's going
stored in a
in a PowerCollection
finally we're storing
we're storing an
storing an item
an item number
is the record
the record number
record number in
the collection itself
So having set
having set these
these up, how
do we get
data that's in
that's in our
in our CSV
our CSV file
CSV file into
file into the
into the PowerCollection?
the PowerCollection? Well
PowerCollection? Well we're
Well we're going
be to load
to load this
load this raw
this raw CSV
raw CSV file
into the collection
call that loadRawFile
If this new
new function returns
function returns true
true then our
then our CSV
CSV file has
has been loaded
been loaded into
false then we'll
then we'll report
we'll report that
report that we
that we could
we could not
could not load
not load the
load the CSV
We're taking a
taking a single
of the file
wish to load
As we will
see the MyUserData
the MyUserData exists
MyUserData exists in
exists in the
the same folder
same folder as
folder as our
as our application
let's create that
have the beginning
Taking in its
in its single
single parameter, to
to load the
load the collection
the collection from
collection from a
from a CSV
a local array
local array, a
a longR counter
longR counter and
counter and also
and also we're
also we're declaring
we're declaring our
declaring our UDT
our UDT customers
UDT customers as
customers as a
as a UCustomers
a UCustomers user
UCustomers user defined
we're also declaring
also declaring a
local variable for
for the key
to call one
call one of
the functions in
functions in our
File Handling Library
This is read
is read the
read the file
the file into
file into an
into an array
This useful function
useful function takes
function takes two
takes two parameters
two parameters, the
the file you're
file you're reading
you're reading and
reading and the
and the array
the array into
array into which
into which you
which you want
put the data
use of such
of such library
such library functions
library functions saves
functions saves you
saves you quite
you quite a
quite a lot
lot of coding
of coding because
coding because quite
because quite often
quite often you'll
often you'll be
you'll be loading
be loading files
loading files into
files into arrays
So this populates
this populates a
populates a one
And then for
then for each
row in that
in that array
that array we're
array we're going
read through it
through it one
it one row
one row at
row at a
And next we're
next we're using
to define each
define each of
within our user
we're adding to
adding to each
of these elements
these elements a
elements a piece
piece of data
case we're taking
taking the user
text user, and
we're adding onto
adding onto that
onto that the
that the fifth
the fifth column
fifth column from
column from our
from our CSV
CSV file, the
the parse command
And we're doing
we're doing the
doing the same
same for each
the other elements
other elements of
The name, the
the surname, the
the address and
address and the
populated our user
The next task
is to place
to place that
place that within
within the customer's
the customer's power
customer's power collection
we're setting first
setting first of
all the key
the key to
key to be
using the add
the add method
add method in
method in the
in the power
the power collection
power collection to
collection to add
to add our
add our data
to the collection
It takes two
being the key
the key, the
the second being
second being the
being the user
value of object
of object result
object result is
result is SOK
is SOK, then
then the operation
the operation has
operation has been
has been successful
been successful and
successful and we
have stored that
that information within
information within the
within the power
that returns a
returns a value
a value other
value other than
other than SOK
than SOK, then
then either there
either there has
has been an
been an error
an error inserting
error inserting or
inserting or that
or that data
that data has
data has already
already been stored
With your power
your power collection
power collection, the
the key value
key value must
value must be
must be unique
So this would
this would prevent
would prevent putting
prevent putting a
putting a duplicate
a duplicate key
duplicate key into
key into the
into the system
we get that
get that far
that far, we're
we're returning true
returning true to
get this far
this far, then
then the data
the data will
data will have
will have been
have been loaded
into the power
So if that's
the case, can
can we also
we also pull
also pull the
pull the data
the data out
of the collection
the collection and
collection and put
put it out
out to another
to another file
another file just
file just to
just to prove
to prove we
prove we have
we have been
have been successful
been successful in
successful in storing
in storing the
storing the data
to call another
call another new
another new function
new function, save
wish to create
to create with
create with the
data that's currently
that's currently within
currently within the
within the collection
new function now
new function taking
the file to
file to actually
to actually create
We're creating some
creating some local
us to pull
to pull the
pull the information
information out of
And we're opening
we're opening our
opening our file
our file to
file to which
to which we're
to be saving
use the equivalent
the equivalent of
of a for
next loop on
loop on the
power collection itself
collection itself using
itself using for
using for each
for each V
each V data
V data in
data in customers
Customers is the
of the power
And V data
V data is
data is a
is a variant
And we're converting
we're converting the
converting the data
data within V
within V data
V data to
data to a
to a string
we're storing that
storing that within
within the record
the record type
record type variable
And we're looking
the first four
first four characters
four characters that
characters that determine
that determine whether
a user user
user user defined
defined type or
type or it's
or it's the
it's the account
the account one
account one we
one we have
not yet used
We'll cover the
cover the current
the current one
current one in
one in more
in more detail
more detail later
as the data
within a collection
a collection is
collection is all
is all user
all user data
user data, this
this piece of
code is the
the one that's
one that's going
going to execute
using the type
the type set
type set command
This is populating
is populating this
populating this user
defined type customer
type customer out
And it's taking
it's taking the
taking the information
the information that's
information that's coming
that's coming out
out of our
of our variant
quite easily populates
easily populates this
populates this user
defined type using
type using a
using a single
we're printing that
printing that data
that data out
data out to
wish to output
to output to
to be handling
be handling account
handling account data
account data separately
data separately later
separately later on
later on, we're
going to declare
to declare another
declare another user
another user defined
type before we
before we try
try running this
well as the
as the customers
the customers user
customers user defined
defined type, we're
set up another
up another user
type to hold
to hold account
hold account information
this case an
case an account
account number with
number with balance
with balance and
balance and transactions
And we'll define
we'll define a
define a new
a new prefix
new prefix for
prefix for this
for this account
this account data
account data using
data using ACCT
using ACCT, which
which will appear
will appear before
appear before the
before the key
the key in
key in the
how far we
far we get
getting the information
information coming up
coming up to
up to say
to say we
say we have
number of entries
of entries stored
entries stored in
stored in our
in our power
And additionally, we're
we're getting a
getting a message
a message to
message to say
have successfully saved
successfully saved the
saved the collection
the collection to
collection to disk
look at what's
at what's come
what's come out
In our folder
our folder, we
we know how
know how a
how a customers
a customers dot
customers dot text
dot text file
we open that
open that up
that up, we
that it stores
it stores information
stores information from
from the power
power collection in
collection in a
in a flat
number with its
with its prefix
its prefix, the
the person's name
person's name as
name as a
as a 50
a 50 character
50 character wide
character wide string
wide string, the
the person's surname
person's surname similarly
surname similarly stored
similarly stored and
stored and all
all the other
the other data
easily see we
see we pulled
we pulled the
pulled the information
information in from
from the CSV
CSV file and
file and we've
and we've output
we've output it
output it to
to the text
the text file
we've actually saved
actually saved information
saved information into
information into this
into this customers
this customers dot
text file, that's
that's the content
content of our
of our power
to comment out
these two functions
two functions we
have created, which
which pull it
pull it in
it in from
from the law
the law CSV
law CSV file
CSV file as
file as we
as we won't
we won't need
won't need these
need these at
these at the
in the customers
the customers dot
text file, we
can then load
then load it
load it directly
it directly from
directly from there
to use yet
use yet another
yet another new
function called load
called load collection
populate the power
power collection directly
collection directly from
directly from the
from the customers
we are in
in the new
new function, taking
single parameter, specifying
specifying the file
the file we're
to be loading
be loading the
loading the collection
collection from disk
did before, we're
up a number
A file handle
file handle, a
a customer string
customer string, the
defined type we're
storing information into
information into and
into and one
for the accounts
the accounts, which
which we haven't
we haven't created
haven't created yet
created yet, but
but we will
we will be
will be doing
be doing shortly
using a W
a W key
W key as
key as a
as a W
a W string
W string variable
string variable, which
which is our
is our unique
unique identifier in
identifier in the
we're opening up
opening up a
up a file
We're running a
running a while
a while loop
while loop to
loop to handle
to handle every
handle every record
every record within
record within that
within that file
set command to
populate the user
type for each
of the records
did before, we
quite easily define
easily define our
define our key
our key, which
which is coming
using the customers
the customers add
customers add method
add method again
method again to
again to add
to the power
when we create
we create the
create the account
the account data
account data, we'll
we'll be doing
be doing exactly
if the object
the object result
result is S
is S OK
S OK, then
then we have
have successfully stored
successfully stored the
stored the information
us a message
to say it's
say it's already
it's already been
been stored or
stored or there
or there has
the function will
return true if
true if all
if all has
all has gone
has gone well
So having loaded
having loaded the
loaded the collection
the collection, can
can we tell
we tell how
tell how many
how many records
many records are
records are actually
are actually sitting
actually sitting within
within the customers
the customers power
customers power collection?
power collection? We
collection? We can
We can using
can using customers
using customers dot
customers dot count
out our log
our log, the
number of records
of records we
records we find
we find within
find within the
customers power collection
successfully stored nine
stored nine records
nine records from
records from the
from the data
data and we're
and we're reporting
we're reporting nine
reporting nine records
nine records found
records found in
found in the
So we've loaded
we've loaded up
up the text
text file, put
collection and reported
and reported on
reported on a
on a number
have a power
power collection running
collection running, how
do we add
add a new
a new record
new record to
record to the
to the collection?
the collection? One
collection? One that
One that did
not exist in
in the original
the original CSV
original CSV file
use our prefix
our prefix command
prefix command again
command again to
again to make
easy to add
add to each
the elements in
elements in the
in the user
So we're adding
adding on a
on a new
a new account
new account number
account number of
number of thirteen
of thirteen hundred
the data, there
there is not
not currently an
currently an entry
entry for thirteen
for thirteen hundred
So we should
have no problems
no problems storing
problems storing this
storing this information
We're putting the
putting the name
the name in
name in as
in as Fred
as Fred Smith
Fred Smith, we're
putting the address
the address in
address in and
in and we're
we're putting their
putting their telephone
their telephone number
telephone number in
number in as
populating the key
the key with
key with the
with the account
we're using customers
customers dot add
dot add to
add to add
add this piece
piece of information
of information to
information to our
to our power
use of user
defined types is
types is quite
quite useful as
useful as it
as it gives
you a little
a little packet
little packet of
packet of data
of data you
data you can
you can add
can add quite
add quite easily
easily to power
to power collections
that we've added
we've added this
added this extra
this extra piece
extra piece of
of information, can
we display how
display how many
many records we've
records we've gotten
we've gotten, which
which should now
should now show
now show ten
show ten rather
ten rather than
rather than nine
than nine as
nine as we've
as we've added
we've added one
added one additional
one additional record
So we'll push
we'll push out
push out the
out the customer's
the customer's current
customer's current back
current back to
will see it's
see it's gone
it's gone from
gone from nine
from nine records
records found up
found up to
up to ten
we've successfully stored
successfully stored an
stored an additional
an additional record
So our power
power collection at
collection at the
the moment holds
moment holds information
holds information on
information on all
on all the
all the accounts
the accounts that
accounts that we
we have for
have for our
for our users
to store some
store some different
some different type
type of information
of information within
the same power
same power collection
to use our
use our user
type for accounts
for accounts now
prefix command, but
time with the
with the accounts
the accounts user
accounts user defined
defined type, add
add information to
information to each
using the account
the account prefix
account prefix and
prefix and 1300
this new user
new user Fred
user Fred Smith
Fred Smith is
Smith is going
to have two
have two records
two records within
records within the
power collection, a
a customer's record
customer's record and
record and an
an account record
And just as
use the customer's
the customer's add
customer's add command
add command and
and this data
this data to
to our collection
And just to
just to be
to be sure
be sure that
sure that this
that this particular
this particular record
particular record has
record has been
has been added
been added successfully
added successfully, we
can test the
object result to
result to see
has been successfully
been successfully stored
successfully stored or
stored or pushing
or pushing two
pushing two messages
two messages out
messages out to
the log, the
the key and
key and the
and the word
the word stored
word stored and
stored and also
and also a
also a count
a count of
records we have
we have in
have in the
the collection, which
which should have
should have gone
have gone up
gone up by
up by another
by another one
run that, I'm
to declare two
declare two additional
two additional user
additional user defined
defined types, one
one called customer
called customer out
customer out, which
which is again
is again going
again going to
to be based
on the customers
the customers type
customers type, and
one called accounts
called accounts, which
on the accounts
We need the
need the accounts
the accounts one
accounts one because
one because we're
because we're going
be using it
using it to
it to put
to put account
put account data
account data in
data in for
in for our
for our new
our new 1300
new 1300 account
that the account
the account 1300
account 1300 has
1300 has been
successfully stored and
stored and we're
we're now up
now up to
up to 11
to 11 records
11 records within
records within our
within our power
well as adding
as adding data
adding data to
power collection, there
there will become
will become a
become a time
wish to remove
to remove data
remove data from
data from the
to remove a
remove a customer's
the moment an
moment an account
account number So
number So we're
going to remove
to remove that
remove that record
that record from
record from the
easily by specifying
by specifying the
specifying the key
the key, which
is our user
our user prefix
user prefix and
prefix and 1200
use the remove
the remove method
remove method to
method to remove
remove that key
that key and
the data from
from the collection
We can again
can again test
again test to
test to make
make sure that
has been removed
putting two messages
the log, one
one to see
see what we've
what we've removed
we've removed and
removed and another
and another to
another to count
to count how
count how many
records are now
are now left
we're now down
now down to
down to 10
to 10 records
10 records again
So account user
account user 1200
user 1200 has
1200 has been
been successfully removed
successfully removed from
removed from the
have added and
added and removed
and removed records
Can we update
we update an
update an existing
an existing record?
existing record? We
record? We have
have an entry
entry for account
for account number
account number 600
to make an
make an update
an update to
update to that
to that one
that one to
one to change
change its value
So first of
of all, we'll
we'll test to
sure the record
the record exists
record exists in
We will specify
will specify the
specify the key
will then use
the customer's contains
customer's contains command
contains command to
pull back the
back the item
the item number
that returns zero
returns zero, then
then no record
no record has
has been found
it returns a
returns a number
a number other
number other than
other than zero
than zero, you
can use that
use that item
that item number
item number to
number to pull
back the actual
actual data using
using the customer's
the customer's entry
customer's entry command
This entry command
entry command populates
command populates the
populates the variable
the variable V
variable V data
V data with
data with the
data that's within
that's within the
we can pull
can pull back
back the record
the record into
record into V
into V data
V data using
data using a
have the unique
unique identifier, the
the key, we
use that to
that to pull
the information back
And assuming object
assuming object result
result is OK
is OK, we
then populate our
populate our user
defined type with
data from V
from V data
using the variant
the variant dollar
variant dollar command
dollar command again
customer out will
out will be
will be fully
be fully populated
So we said
we said we
said we wanted
wanted to update
to update the
update the data
data for this
for this customer
quite easily use
easily use the
use the prefix
prefix command and
command and update
and update the
data within this
within this user
So we're changing
we're changing this
changing this case
this case, both
both the phone
the phone number
phone number and
number and the
and the address
the address of
address of this
of this customer
So having updated
having updated the
updated the user
defined type, we
can now replace
now replace the
replace the data
in the customer's
power collection with
collection with our
with our new
our new data
the customer's replace
customer's replace command
As with the
with the add
the add command
add command, it
takes the same
takes the key
defined type containing
data we wish
wish to push
to push into
push into the
the collection, replacing
replacing what was
what was already
was already there
And again, we
can test our
test our object
our object result
result to ensure
to ensure the
ensure the account's
the account's been
account's been updated
if it gives
us the result
the result we
result we expect
is a message
to say the
say the data
the data was
data was found
was found at
found at record
at record number
record number three
number three and
three and the
the user 600
user 600 account
600 account has
account has been
has been updated
what other commands
other commands can
commands can we
we actually use
actually use on
use on our
on our power
our power collection?
power collection? Over
collection? Over time
Over time, the
data being added
being added to
added to this
to this collection
this collection would
collection would not
would not necessarily
not necessarily be
necessarily be in
be in any
in any order
any order, but
is a sort
a sort command
sort command you
command you can
can use on
use on the
collection to sort
to sort it
sort it into
into the order
the order of
order of the
of the key
We can perform
can perform this
perform this with
this with a
with a single
a single command
single command using
command using customers
customers dot sort
The sort command
sort command is
is followed in
followed in brackets
in brackets with
brackets with a
value is zero
is zero, then
the data items
data items are
items are sorted
are sorted in
sorted in ascending
in ascending sequence
If you change
you change this
change this to
this to one
to one, the
the items will
items will be
will be sorted
be sorted in
sorted in a
in a descending
a descending sequence
So what if
want to move
to move through
move through each
each record in
record in our
in our collection
our collection and
collection and display
and display it
display it on
it on screen?
on screen? Again
screen? Again, we
can do a
loop for each
the customer's collection
The V data
data is, of
of course, the
going to hold
data that comes
that comes out
comes out of
out of each
of each record
And we're picking
up the record
record type as
type as we
did before, and
a user record
user record or
record or whether
or whether this
is an account
As they're using
they're using different
using different user
different user defined
this will handle
will handle our
handle our user
our user records
set command, pull
the information from
information from our
from our variant
our variant variable
variant variable into
variable into our
into our user
details of each
of each element
the customers out
customers out user
out user defined
for the account
the account records
account records, we're
we're doing something
doing something very
something very similar
We're using type
using type set
type set to
set to pull
the information into
into the account's
the account's user
account's user defined
And we're pulling
we're pulling information
pulling information from
information from that
from that user
type using the
turn the currency
the currency data
currency data back
data back into
back into strings
into strings, which
which we need
need to display
then in next
in next command
next command to
command to get
get the next
the next record
And before we
before we finish
we finish off
finish off, we're
going to save
save the collection
the collection back
collection back to
back to disk
to disk, overriding
overriding the customers
this now contains
now contains all
contains all the
all the updated
the updated data
updated data and
data and will
and will allow
code now, you
we have updated
have updated the
updated the customers
And you will
also see that
that the keys
the keys are
keys are now
are now sorted
now sorted in
in ascending order
we have saved
have saved the
to disk, you'll
you'll see that
see that account
that account number
account number the
number the power
application again, it
will be unable
be unable to
unable to delete
to delete that
delete that record
that record because
record because it
because it no
it no longer
no longer exists
more to ensure
ensure we get
get that message
there we are
Record 1300 is
1300 is already
is already stored
already stored, so
we can no
can no longer
no longer add
longer add it
add it to
the collection because
collection because it's
because it's already
it's already there
And record 1200
record 1200 has
1200 has not
not been removed
been removed because
removed because it
because it doesn't
it doesn't exist
doesn't exist within
exist within the
created a power
collection to do
to do an
do an associated
an associated array
We stored two
stored two different
of data within
within this collection
this collection, data
data on accounts
on accounts and
accounts and data
and data on
data on customers
as we're using
we're using variants
using variants to
variants to pull
information back from
from this power
this power collection
determine what we
on the prefix
the prefix of
prefix of our
of our key
If it's user
it's user, we
know it's user
it's user data
if it's account
it's account, we
know it's account
it's account data
we can handle
can handle that
handle that data
that data independently
using this method
this method, you
you can get
can get quite
get quite flexible
quite flexible data
flexible data sets
data sets stored
sets stored within
stored within a
within a power
can be then
be then manipulated
then manipulated, added
added to, removed
updated and even
and even sorted
look at coding
at coding tips
coding tips for
tips for your
for your applications
When you are
in the business
the business of
business of developing
of developing applications
developing applications, you
well have a
number of applications
of applications which
applications which are
which are very
are very similar
So when you're
when you're starting
you're starting off
starting off developing
off developing a
developing a new
a new application
new application which
which is similar
is similar to
similar to applications
to applications you've
applications you've built
you've built before
built before, it's
it's good to
good to build
to build your
build your application
your application from
application from a
from a template
Templates can be
can be accessed
be accessed from
accessed from the
from the drop-down
the drop-down menu
drop-down menu in
menu in the
in the toolbar
is a list
list of templates
of templates currently
templates currently available
of the templates
the templates ship
templates ship with
ship with PowerBasic
with PowerBasic itself
PowerBasic itself, both
both in the
compiler and in
and in the
can add your
add your own
your own templates
I've created a
created a video
a video some
video some time
some time ago
time ago on
ago on template
on template creation
you can find
can find that
find that on
that on YouTube
advantage of course
of course in
course in using
in using templates
using templates is
templates is that
is that it
that it speeds
it speeds up
speeds up your
up your development
With any development
any development, you
you will start
will start off
start off with
off with a
with a basic
a basic requirement
This requirement may
requirement may well
may well give
well give you
give you most
you most of
most of the
the information you
information you need
to start coding
when you start
you start your
start your coding
your coding, it
it never does
never does any
does any harm
any harm to
harm to map
to map out
map out what
application is going
to do, even
even just in
just in comments
You can of
can of course
of course use
course use professional
use professional or
professional or free
or free packages
free packages to
packages to do
to do mind
do mind mapping
mind mapping or
mapping or Visio
or Visio type
Visio type diagrams
type diagrams, which
are all good
you could design
could design your
design your application
your application using
application using pen
using pen and
pen and paper
As you become
you become more
become more experienced
more experienced with
experienced with developing
with developing in
developing in your
in your language
your language of
language of choice
of choice, you
probably do most
do most of
most of this
of this design
this design in
design in your
in your head
once you start
you start programming
start programming, it
it doesn't do
doesn't do any
do any harm
harm to sketch
to sketch out
sketch out in
in the program
the program code
program code what
code what it
it is you're
is you're planning
you're planning on
planning on doing
For example, at
of your application
to check any
check any preconditions
any preconditions for
preconditions for the
application to be
to be allowed
be allowed to
allowed to run
For example, you
you may wish
may wish to
wish to check
application is already
is already running
Or there may
be some preconditions
some preconditions by
preconditions by which
by which you
which you wish
you wish the
wish the application
the application only
application only to
only to run
to run on
run on a
on a particular
a particular day
particular day of
day of the
of the week
We'll take this
take this as
this as an
as an example
If we're going
to set this
set this application
this application up
application up, only
the week, we
to check the
check the current
the current day
we can create
can create a
create a very
simple function to
determine which day
which day we're
day we're actually
We're looking to
looking to check
if the day
the day is
day is Saturday
it's not a
not a Saturday
a Saturday, then
then we'll send
we'll send a
send a message
message to our
our log and
log and we
the application immediately
is a Saturday
then we wish
wish to log
to log that
log that we
we have started
have started processing
started processing and
processing and then
and then continue
then continue on
continue on with
with the rest
in this new
this new CheckDay
new CheckDay function
CheckDay function, we're
passing a string
a string which
string which is
And we wish
whether the current
current day in
day in your
in your computer
your computer matches
computer matches that
matches that or
that or not
easily in PowerBasic
in PowerBasic by
PowerBasic by using
using the PowerTime
the PowerTime class
can prepare a
prepare a local
which we're calling
we're calling IPDate
calling IPDate as
IPDate as an
as an I
an I PowerTime
I PowerTime variable
can set IPDate
set IPDate to
IPDate to be
to be equal
be equal to
the class PowerTime
can populate this
populate this variable
this variable with
the current or
current or local
or local date
local date and
and time by
time by using
by using ipdate.now
the value held
value held within
held within this
within this variable
if it matches
it matches the
matches the string
the string we've
string we've passed
we've passed in
for the day
the day name
using the ipdate.dayOfWeek
the ipdate.dayOfWeek string
ipdate.dayOfWeek string, which
which will return
return the name
the day of
I'm forcing these
forcing these two
these two lowercase
two lowercase to
lowercase to make
sure that there's
that there's no
there's no issues
no issues with
issues with the
with the comparison
the comparison of
comparison of the
of the strings
day name matches
name matches, we
we can return
can return true
return true, otherwise
otherwise we can
can return false
running that application
that application now
see that matches
that matches and
matches and processing
and processing has
processing has started
have successfully checked
successfully checked the
checked the current
current day against
day against the
against the day
the day the
day the application
application is looking
is looking for
Another thing to
thing to take
to take into
take into consideration
into consideration with
consideration with your
with your application
your application is
is to work
out what data
what data will
data will flow
will flow into
flow into the
the application, how
how it is
it is stored
is stored and
stored and manipulated
and manipulated and
manipulated and then
and then sent
then sent back
sent back out
back out to
out to where
where it came
it came from
store information in
information in an
an array within
array within our
There are, of
of course, a
of actually declaring
actually declaring an
declaring an array
can declare it
declare it as
it as global
as global to
global to the
to the whole
the whole application
whole application, in
which case it
case it is
it is functionally
is functionally accessible
functionally accessible within
accessible within any
within any part
any part of
Or we could
we could create
could create an
create an array
an array which
array which is
which is local
is local only
local only to
only to the
to the current
the current function
current function or
There are advantages
are advantages and
and disadvantages of
disadvantages of doing
of doing it
doing it either
it either way
So let's assume
assume for the
the moment that
moment that we're
going to go
to go down
go down the
down the route
the route of
route of having
having a global
have declared this
declared this array
this array at
array at the
our code, and
calling the array
array by a
by a single
a single letter
single letter, the
the letter A
While this will
will work within
work within your
your application, it's
idea to name
name your arrays
your arrays to
arrays to give
to give some
give some indication
some indication of
indication of what
of what they
are and what
and what they're
what they're for
So I would
I would suggest
would suggest that
suggest that you
that you establish
you establish a
establish a naming
a naming convention
naming convention for
convention for your
for your variables
this case, I
I have named
have named this
named this particular
particular array as
array as GA_STR_STAFF_DATA
I've prefixed the
prefixed the name
variable with GA
That's G for
G for global
for global and
global and A
and A for
A for array
The STR further
STR further indicates
further indicates that
indicates that it's
it's a string
Staff data is
data is the
is the indication
the indication to
indication to our
to our programmers
our programmers that
programmers that this
that this array
this array contains
array contains staff
contains staff data
staff data information
So anytime we
anytime we see
we see this
see this referenced
this referenced in
referenced in the
that it's global
it's global, we
it's an array
an array, it
indeed a string
a string array
string array containing
array containing staff
containing staff data
Taking an approach
an approach like
approach like this
like this, having
having a naming
naming convention, means
means that your
that your code
your code is
code is partially
is partially self-documenting
Having defined that
defined that we're
to have this
have this global
have to dimension
to dimension it
dimension it to
it to see
see how many
many elements it
elements it actually
it actually has
actually has, and
how many dimensions
The REDIM command
REDIM command we've
command we've given
we've given here
given here has
here has dimensioned
has dimensioned this
dimensioned this array
this array having
array having 1000
having 1000 elements
So effectively, we've
we've hardcoded the
hardcoded the value
value We may
want to reference
to reference this
reference this at
this at some
at some other
some other point
other point in
the code, so
so sometimes it's
sometimes it's quite
it's quite useful
quite useful to
useful to re-dimension
to re-dimension it
re-dimension it using
it using a
using a constant
For example, %MAX_STAFF
We can define
can define this
And anytime in
anytime in the
in the rest
the application you
application you need
need to reference
reference this the
this the constant
the constant %MAX_STAFF
And should at
should at some
the future your
future your application
your application requires
application requires to
requires to change
change the value
value of 1000
of 1000 to
1000 to some
to some other
some other value
other value, there
there is only
is only one
the application that
application that needs
needs to change
you could actually
could actually store
actually store this
store this 1000
this 1000 value
1000 value in
value in an
in an external
an external configuration
external configuration file
configuration file, or
or even in
even in a
in a database
This of course
of course would
course would give
would give you
you the advantage
advantage of being
of being able
being able to
able to change
change the functionality
functionality of the
the application without
application without changing
without changing the
changing the application
the re-dimensioning of
re-dimensioning of your
array can be
can be performed
be performed by
performed by calling
case we're calling
we're calling it
calling it get_MAX_STAFF
So I've created
created a small
a small stub
small stub function
stub function called
function called get_MAX_STAFF
called get_MAX_STAFF, which
which is returning
is returning the
returning the value
The function of
function of course
of course could
course could get
could get that
that from a
from a database
a database or
database or from
or from anywhere
from anywhere else
anywhere else in
else in the
in the system
the system that
system that had
that had that
had that information
Having set up
up the global
global array which
be storing the
the data, we
get the staff
the staff data
staff data from
data from somewhere
pb_main function we're
function we're calling
calling a new
function called get_staff_data
This segmented approach
segmented approach to
approach to coding
to coding allows
coding allows you
you to break
to break up
break up the
up the functionality
the application into
application into smaller
into smaller code
smaller code, functions
And since a
since a function
a value, you
use this return
this return value
return value to
value to determine
whether the function
function has been
been successful or
successful or not
So if we're
if we're returning
true to say
say the function
successful and false
and false to
false to say
function is not
is not successful
not successful, we
can report to
report to our
our log that
log that the
that the attempt
the attempt to
attempt to load
load the staff
staff data has
data has been
has been unsuccessful
application immediately and
immediately and not
and not continue
in this prototype
this prototype we
prototype we can
create a stub
a stub function
stub function whose
is to return
When you're fleshing
you're fleshing out
fleshing out this
out this function
function you would
you would of
would of course
of course populate
course populate the
populate the global
of this prototype
this prototype, where
where we're just
we're just looking
just looking to
see what the
to do, this
this stub function
stub function will
function will do
will do nicely
we are continuing
are continuing in
continuing in that
in that mode
that mode by
mode by creating
creating a stub
stub function to
function to adjust
to adjust the
adjust the staff
the staff of
staff of A
function will perform
will perform whatever
perform whatever manipulation
whatever manipulation you
manipulation you wish
to do on
do on the
on the staff
returns false, then
then this manipulation
this manipulation has
manipulation has not
not been successful
successful and you
you can exit
it returns true
returns true, you
can then continue
continue on to
And your final
your final section
final section of
code will be
be to do
to do something
do something to
something to save
save the data
be the data
the data you
data you have
you have just
have just finished
just finished amending
And again we're
again we're taking
function called save
called save data
save data, which
return a true
true or a
or a false
If true, then
saved the data
the data successfully
data successfully and
successfully and we
we can finish
can finish off
finish off the
off the application
Should it return
it return false
return false, then
then some error
some error has
error has occurred
you can save
can save this
save this error
this error to
error to the
what we've looked
we've looked at
looked at today
today is a
is a mechanism
can actually submit
actually submit your
submit your application
your application into
application into different
into different sections
different sections, each
each section performing
section performing a
performing a particular
a particular task
And each section
each section returning
section returning a
returning a true
a false, indicating
indicating whether that
whether that section
that section has
section has been
that the next
the next part
next part of
of your code
your code can
code can actually
can actually determine
actually determine whether
determine whether it's
whether it's worth
it's worth continuing
worth continuing or
continuing or not
This combined with
combined with a
with a good
a good naming
good naming convention
your variables and
variables and arrays
and arrays, and
and a good
for your functions
your functions, will
will stand you
stand you in
you in good
in good stead
After all, while
while the application
application will be
will be quite
be quite clear
quite clear in
clear in your
in your mind
your mind once
mind once you've
once you've finished
you've finished coding
finished coding it
coding it, it
it may not
may not be
not be so
be so clear
so clear in
clear in six
in six months
six months time
months time when
when you have
have to come
to come back
come back and
back and fix
and fix something
fix something in
something in it
in it which
it which has
which has broken
this self-documenting in
self-documenting in the
code is also
is also useful
also useful for
useful for other
for other developers
developers who have
who have not
yet been involved
been involved in
involved in the
the application, and
and may at
may at some
the future have
future have to
have to pick
to pick it
pick it up
it up to
up to do
to do support
find this helpful
this helpful in
helpful in your
in your developments
your applications and
applications and the
use of libraries
the previous video
previous video, we
we had looked
had looked at
looked at some
at some coding
some coding tips
coding tips, mostly
mostly to do
do with naming
with naming conventions
naming conventions and
conventions and setting
and setting prerequisites
setting prerequisites up
prerequisites up for
up for your
for your application
your application to
looking at libraries
they and why
and why you
why you should
should be using
be using them?
using them? First
them? First of
we'll look at
at the console
compiler is often
is often used
often used to
used to write
to write applications
write applications which
applications which have
which have little
have little or
little or no
or no user
These can be
can be background
be background programs
background programs which
programs which calculate
which calculate information
calculate information based
based on data
on data coming
data coming in
coming in and
in and create
and create data
create data going
data going out
One common use
common use is
use is the
is the processing
the processing of
processing of files
the console application
console application we
application we have
the moment, you'll
see that I've
that I've highlighted
I've highlighted a
highlighted a line
a line of
code which starts
which starts with
starts with the
the word 'include'
This include command
include command instructs
command instructs PowerBasic
instructs PowerBasic to
PowerBasic to add
to add in
add in another
in another code
another code library
code library to
library to the
to the application
the application at
application at compile
at compile time
This include file
include file can
file can contain
can contain a
contain a great
deal of code
It can even
can even nest
even nest into
nest into additional
into additional libraries
The library we
library we have
we have highlighted
have highlighted here
highlighted here is
is the Win32
the Win32 API
Win32 API include
API include file
is a file
a file that
file that ships
ships with PowerBasic
PowerBasic and gives
and gives you
gives you access
you access to
access to the
to the full
the full Windows32
full Windows32 application
Windows32 application programming
application programming interface
When PowerBasic compiles
PowerBasic compiles your
compiles your application
your application, it
it will look
will look inside
look inside each
inside each referenced
each referenced library
referenced library to
library to see
the functions, code
code or statements
or statements are
statements are referenced
are referenced in
referenced in your
they are then
are then this
then this code
will be compiled
be compiled and
compiled and linked
and linked into
linked into your
into your application
your application executable
If there are
there are functions
are functions and
and subroutines within
subroutines within these
within these included
these included files
included files that
files that are
that are not
are not referenced
not referenced within
referenced within your
your own code
own code, then
then that code
that code will
code will not
not be included
be included in
included in your
in your eventual
your eventual compiled
eventual compiled application
This is known
is known as
known as dead
as dead code
dead code removal
This means the
means the size
size of your
of your executable
your executable will
executable will be
will be as
be as small
as small as
small as possible
So why should
why should you
should you consider
you consider using
consider using libraries?
using libraries? If
libraries? If within
If within this
within this application
this application we're
be doing lots
doing lots of
lots of file
of file handling
file handling, reading
reading data from
data from files
from files into
into arrays, saving
saving data from
data from arrays
from arrays into
arrays into files
into files and
files and generally
and generally doing
generally doing a
lot of file
These types of
types of functions
of functions and
and subroutines will
subroutines will be
will be common
be common to
common to many
to many applications
many applications and
applications and to
and to save
to save you
save you having
you having to
having to rewrite
to rewrite them
rewrite them or
them or paste
or paste them
paste them in
them in every
in every time
every time you
wish to write
to write a
write a new
If you include
you include this
include this code
this code in
code in an
in an include
include file, you
can reference it
reference it in
in a single
code and bring
and bring all
bring all this
all this useful
this useful functionality
useful functionality into
functionality into your
have now added
added the pb
the pb file
pb file handling
handling routines include
routines include file
include file to
file to our
our application with
application with one
with one line
a look to
look to see
see what that
what that particular
that particular library
particular library has
library has in
has in it
in it, we
we can drag
can drag that
drag that into
that into our
into our compiler
is the include
the include file
include file for
file for pb
for pb file
It contains a
contains a number
of functions, which
which I've documented
I've documented at
documented at the
So by adding
by adding this
adding this include
our application, we
can now reference
now reference all
reference all the
all the functions
functions within this
within this file
This means a
means a lot
lot of common
of common functionality
common functionality can
functionality can be
can be included
be included on
included on all
on all of
all of your
your applications by
applications by setting
by setting up
of these library
these library files
you are working
are working in
working in a
in a team
a team, it
it means code
means code that
you have written
have written can
written can be
by other members
other members of
members of the
of the team
of course saves
course saves time
saves time because
time because they
are not reinventing
not reinventing the
reinventing the wheel
the wheel every
wheel every time
every time they
time they want
they want to
do something that
something that you
that you or
you or another
or another programmer
another programmer has
programmer has already
has already coded
So the use
of libraries will
libraries will speed
will speed up
speed up the
up the development
the development that
development that you
from the explorer
the explorer window
explorer window we
window we now
now have on
on screen, these
library files, the
the include files
include files, are
folder as are
as are executable
But this does
be the case
have a path
a path in
path in the
in the include
include file statement
What I've done
I've done with
done with these
with these include
these include file
include file paths
file paths is
paths is I
is I put
I put two
put two dots
two dots at
dots at the
the path, which
which instructs Power
Basic and Windows
and Windows to
Windows to go
go up one
up one directory
one directory and
directory and then
and then down
then down into
down into the
into the libraries
the libraries folder
then the name
of the include
include file is
file is stated
is stated after
stated after that
at that in
in the explorer
the explorer, we'll
have a libraries
a libraries folder
libraries folder which
folder which contains
contains the four
the four files
four files we
files we wish
wish to bring
to bring in
If we attempt
we attempt to
attempt to compile
to compile this
compile this application
this application now
it will compile
will compile quite
compile quite cleanly
to see just
see just what's
just what's being
what's being included
being included in
included in an
in an application
an application, we
we can change
can change one
change one of
of the options
to the menu
the menu at
menu at the
the screen, pick
pick Options, go
go to Compiler
to Compiler, we
click on Detailed
on Detailed Results
we hit OK
hit OK on
OK on that
on that and
that and then
and then do
then do another
do another compilation
another compilation, we
can see all
see all the
all the component
the component files
component files that
files that Power
that Power Basic
Basic has considered
has considered for
considered for compilation
will see, this
is a significant
a significant number
significant number of
number of files
Most of these
these are coming
are coming from
coming from the
from the Windows
Windows API we
API we included
we included at
included at the
the beginning, plus
plus our own
our own library
own library files
library files at
see the code
the code that
code that has
has been extracted
the functions which
functions which have
have been pulled
been pulled out
pulled out of
out of these
library files and
files and included
and included in
Many of these
of these, as
I said, are
So what's the
what's the advantage
advantage of keeping
of keeping your
keeping your include
your include files
include files in
files in a
in a library
a library folder?
library folder? If
folder? If you
you have your
have your include
include files copied
files copied in
copied in to
the folder containing
folder containing your
containing your own
your own executable
own executable, there's
there's always a
always a danger
a danger that
danger that you
that you will
you will make
will make some
make some change
some change to
to a library
a library file
library file and
file and not
and not copy
not copy it
copy it back
it back to
to the common
the common area
The whole point
whole point of
point of library
of library files
library files is
files is that
is that all
that all members
all members of
of the development
the development team
development team will
team will be
will be able
able to access
to access the
access the most
the most recent
most recent version
So keeping them
keeping them in
them in a
in a common
a common location
common location that
location that everyone
that everyone can
everyone can have
can have access
have access to
access to, and
and is where
is where you
where you compile
you compile from
compile from, is
is always an
way your application
your application can
application can be
can be built
be built up
up from a
from a common
a common set
common set of
set of component
of component libraries
So when starting
when starting a
starting a brand
a brand new
brand new application
new application, one
one thing you
thing you will
you will want
will want to
to do at
do at the
the beginning is
beginning is to
is to decide
decide what libraries
what libraries are
libraries are going
to be needed
be needed within
needed within this
And once you
start your development
your development, you
you will probably
will probably have
probably have to
of new functions
new functions which
functions which do
do not exist
not exist within
exist within these
within these libraries
If you find
you find these
find these functions
these functions could
functions could have
have a use
a use later
use later in
later in future
future applications, you
of course create
course create a
a new library
new library, thereby
thereby saving yourself
saving yourself time
yourself time in
time in the
the future and
future and the
and the time
the time of
time of your
of your fellow
your fellow developers
These libraries of
libraries of course
of course can
course can be
can be passed
be passed to
passed to anyone
to anyone who
anyone who codes
who codes in
codes in Power
that we've looked
looked at the
console compiler, let's
let's now look
at the Windows
As far as
far as libraries
as libraries are
libraries are concerned
are concerned, you
can do exactly
thing with the
with the Windows
console compiler, you
can have your
have your libraries
your libraries in
libraries in the
folder as your
as your main
your main application
Or they could
could be in
in a nested
a nested folder
nested folder underneath
folder underneath your
underneath your application
your application, or
or in the
in the folder
the folder above
folder above, or
in a hard-coded
a hard-coded network
hard-coded network location
there is something
is something else
something else with
else with libraries
with libraries we're
libraries we're going
look at now
have four libraries
four libraries here
libraries here, the
the file handling
handling routines, the
the macro library
macro library, a
a button plus
button plus library
plus library, and
and a library
a library to
library to load
to load JPEGs
load JPEGs as
JPEGs as bitmaps
this application, it
give us an
us an error
The error that's
error that's coming
that's coming up
coming up for
up for this
this particular compile
particular compile is
compile is that
is that there
function within one
within one library
one library which
which is already
is already referenced
already referenced in
the previous library
have a name
a name conflict
name conflict here
Power Basic doesn't
Basic doesn't know
doesn't know which
know which one
which one to
one to include
Basic will not
will not allow
not allow you
you to pull
to pull in
pull in two
in two functions
two functions or
or subroutines of
subroutines of the
the same name
same name from
name from different
from different libraries
can we handle
we handle this?
handle this? Well
this? Well, we
in here the
the function it's
function it's complaining
it's complaining about
complaining about is
about is a
function called gdi
called gdi plus
gdi plus shutdown
This is in
in the button
the button plus
button plus include
plus include file
include file and
file and is
and is also
is also in
also in the
in the pbload.jpg
the pbload.jpg as
pbload.jpg as bitmap
as bitmap file
when we find
we find there
find there is
is a common
set of functions
of functions in
functions in two
in two other
two other libraries
other libraries which
libraries which may
which may well
may well need
well need to
to be loaded
be loaded within
loaded within your
your application, we
way of taking
of taking this
taking this common
this common code
common code out
code out and
out and putting
it into a
into a new
There are four
are four things
four things within
things within this
within this library
this library which
library which we
need to strip
to strip out
strip out and
out and put
and put into
put into its
its own library
The two types
two types and
types and the
and the startup
the startup and
startup and the
and the shutdown
we select all
select all these
all these and
these and put
and put them
put them in
to save this
save this into
this into a
into a file
a file called
file called pbgdi
called pbgdi plus
pbgdi plus common
plus common dot
common dot include
we will want
want to remove
to remove these
remove these or
these or for
or for the
the moment we'll
moment we'll just
we'll just comment
just comment them
comment them out
them out in
out in here
we'll also load
also load up
up the other
the other file
other file which
file which it
it was complaining
was complaining about
And within the
within the button
include file we
file we will
we will comment
will comment out
out this section
this section as
section as well
will also comment
also comment out
types and having
and having updated
having updated these
updated these two
these two existing
two existing libraries
new library in
library in at
in at the
that now it
However you may
may not want
not want to
want to include
to include gdi
include gdi plus
gdi plus inside
plus inside your
inside your application
So one option
one option we
option we have
we have is
have is to
is to include
to include this
include this in
this in the
plus library and
library and the
and the load
the load jpeg
load jpeg library
So another safety
another safety tip
safety tip for
tip for including
for including these
including these is
these is to
use the once
the once option
look inside these
inside these two
these two libraries
two libraries we
libraries we can
the word once
word once after
once after the
after the word
the word include
What this does
this does is
does is Power
is Power Basic
Basic will only
will only attempt
only attempt to
attempt to include
to include it
include it if
it if it
it has not
not been included
been included already
And your application
your application will
application will compile
This is very
is very useful
for example our
example our load
our load jpeg
load jpeg is
jpeg is bitmap
is bitmap also
bitmap also needed
needed to include
to include the
include the pb
Well if we
put the once
the once after
once after each
after each of
of these then
these then Power
then Power Basic
Power Basic would
Basic would work
would work out
work out this
out this for
this for you
And would only
would only include
only include each
include each library
each library once
saves you a
deal of coding
In previous versions
previous versions of
versions of Power
Power Basic you
Basic you had
you had to
had to include
to include some
include some constant
some constant within
constant within your
within your libraries
your libraries and
libraries and then
and then test
then test for
test for that
for that at
that at compilation
at compilation time
Now adding the
adding the simple
the simple once
simple once word
once word after
word after include
after include means
include means you
means you don't
you don't have
do that anymore
So now any
now any complex
any complex nesting
complex nesting of
nesting of libraries
of libraries and
libraries and dependencies
and dependencies is
dependencies is handled
is handled for
handled for you
As with everything
with everything in
everything in development
in development a
development a lot
lot of this
of this comes
this comes down
comes down to
down to documentation
Documenting what your
what your libraries
your libraries do
libraries do will
do will be
will be advantageous
be advantageous if
advantageous if you're
if you're working
you're working in
Because the new
the new team
new team member
team member who
member who joins
who joins your
joins your team
your team will
team will need
know which libraries
which libraries are
libraries are available
are available for
available for use
for use and
use and what
and what they
what they all
they all do
And taking this
taking this component
this component approach
component approach of
approach of building
of building your
building your applications
your applications will
applications will speed
your development significantly
And ideally when
ideally when one
when one of
these libraries needs
libraries needs to
to be amended
be amended either
amended either to
to have new
have new functions
new functions in
functions in it
in it or
it or perhaps
or perhaps changing
perhaps changing the
changing the parameters
the parameters of
parameters of existing
of existing functions
do a continuous
a continuous integration
continuous integration approach
integration approach by
approach by which
by which all
which all your
all your applications
your applications can
applications can be
can be automatically
be automatically recompiled
automatically recompiled to
recompiled to ensure
ensure that they
that they still
they still compile
still compile cleanly
We've covered this
this in a
a previous video
the description to
description to that
to that video
that video so
video so you
look at continuous
at continuous integration
find these approaches
these approaches useful
approaches useful in
use of constants
of constants within
constants within your
We have, in
previous videos, covered
covered the concept
concept of variables
looking at constants
at constants, and
and covering the
covering the difference
difference between the
between the use
of a constant
a constant and
constant and the
will declare a
I have declared
declared this local
as a single
single letter name
Now there is
is nothing intrinsically
nothing intrinsically wrong
intrinsically wrong with
wrong with declaring
with declaring your
declaring your variable
your variable as
Basic will compile
will compile it
compile it and
it and it
it will run
will run just
run just fine
creating variables with
variables with names
with names that
names that do
that do not
do not reflect
not reflect what
reflect what is
what is contained
is contained within
contained within the
within the variable
the variable can
variable can lead
can lead to
lead to confusion
to confusion later
confusion later on
later on, especially
especially if another
if another programmer
programmer has to
has to pick
pick up your
up your code
from this line
code that we
we are multiplying
are multiplying 42
multiplying 42 by
42 by 20
by 20 by
20 by 40
Turning that into
a string and
string and populating
and populating the
populating the t
can then output
then output the
output the value
of that variable
that variable to
variable to our
And we're getting
getting a value
value of 33,600
From the text
text on screen
on screen, we
we can assume
can assume that
assume that this
that this value
this value in
value in t
in t is
t is the
is the total
the total number
total number of
can make the
the code a
to follow by
follow by putting
by putting each
putting each of
these values into
values into a
into a variable
a variable of
variable of its
of its own
But again, as
as they are
they are single
are single character
single character variable
character variable names
variable names, it's
it's not particularly
not particularly obvious
particularly obvious what
obvious what they
what they actually
they actually represent
to make life
make life easier
life easier for
easier for yourself
for yourself and
yourself and for
for the programmers
the programmers who
programmers who follow
who follow you
follow you, it's
it's best to
best to replace
to replace these
replace these with
these with more
with more descriptive
more descriptive names
we have named
have named our
named our variables
our variables 'staff'
variables 'staff', 'departments'
'departments' and 'hours'
And we've put
we've put a
a little comment
little comment in
comment in against
in against the
against the population
population of each
these variables to
variables to explain
to explain what
explain what it
what it means
now see that
that the staff
the staff is
staff is the
of staff per
staff per department
number of departments
of departments is
departments is set
is set and
set and the
of hours worked
hours worked for
worked for each
for each person
each person within
person within that
within that department
we can output
can output that
output that to
that to our
our log by
log by simply
by simply multiplying
simply multiplying each
multiplying each of
these variables together
variables together and
together and populating
and populating our
populating our string
our string variable
But the code
code is now
is now more
now more readable
more readable and
readable and therefore
So where do
where do constants
do constants come
constants come in?
come in? Let's
in? Let's assume
moment that the
departments is not
going to vary
point of putting
of putting a
putting a value
a value into
value into a
a variable is
variable is that
within that variable
that variable can
variable can change
can change during
point of a
a constant is
constant is that
the value input
value input to
input to it
to it will
not change while
change while the
application is running
It's set at
set at compile
So let's set
let's set the
of departments as
departments as a
as a constant
have declared a
declared a constant
a constant called
constant called 'total
called 'total departments'
'total departments' and
departments' and made
and made it
made it equal
it equal to
the value 20
The percentage sign
percentage sign at
sign at the
of the name
the name indicates
name indicates to
indicates to PowerBasic
to PowerBasic that
is an integer
an integer constant
It will accept
will accept whole
accept whole numbers
can now substitute
now substitute this
substitute this for
this for anywhere
for anywhere else
the application where
application where the
where the department
the department value
department value is
value is required
So here you
here you will
that the department
the department variable
department variable has
variable has been
has been replaced
been replaced with
replaced with the
with the total
the total department's
total department's constant
When you define
you define a
define a constant
a constant at
your application, when
when your application
application is compiled
is compiled, it
it will replace
will replace any
replace any reference
any reference to
reference to total
to total departments
total departments with
departments with the
value held at
held at the
the application, in
this case 20
This ensures that
ensures that it
that it will
run the program
the program again
program again now
we're getting exactly
getting exactly the
also used the
used the format
command to put
put a comma
a comma in
comma in after
in after thousands
who are coming
are coming to
coming to PowerBasic
to PowerBasic from
PowerBasic from other
from other applications
other applications, you
you may be
may be used
used to using
to using a
a constant keyword
PowerBasic does not
not have a
have a constant
we can emulate
can emulate it
emulate it by
it by using
by using macros
on screen, we've
we've used the
used the 'macro
the 'macro constant
'macro constant equals
constant equals macro'
your application compiles
application compiles, it
will replace the
replace the string
the string constant
string constant with
constant with the
the word 'macro'
This will mean
will mean our
mean our declared
our declared constant
declared constant, as
as in C
in C underline
C underline 'long
underline 'long total
'long total departments
total departments equal
departments equal to
equal to 20'
to 20', is
is then a
then a constant
be used like
used like any
like any other
any other constant
If we're replacing
we're replacing our
replacing our 'total
our 'total departments'
'total departments' constant
departments' constant with
constant with this
with this new
this new VB
new VB style
VB style constant
style constant, we
have to replace
to replace the
replace the 'total
the 'total departments'
departments' constant string
constant string with
string with the
with the 'total
'total departments' VB
departments' VB style
VB style macro
the same output
can see, you
use the 'macro'
the 'macro' keyword
'macro' keyword to
keyword to effectively
to effectively extend
effectively extend the
extend the language
So far, we
have replaced the
replaced the 'total
'total departments' with
departments' with 'constants'
of hours done
hours done per
done per week
per week in
week in the
in the moment
the moment has
moment has a
has a value
value of 40
That would be
be quite easy
easy to replace
to replace with
replace with a
with a constant
a constant, setting
value to 40
what if the
if the number
hours done by
done by staff
by staff on
staff on a
on a weekly
a weekly basis
weekly basis was
basis was not
was not a
not a whole
a whole number
this case, you
you couldn't use
couldn't use an
use an integer
integer constant, because
because integer constants
integer constants don't
constants don't have
don't have decimal
have decimal places
for this, the
the macro again
macro again comes
again comes to
comes to the
to the rescue
If we follow
we follow the
follow the macro
the macro with
macro with the
with the name
the name that
name that we
to use, in
this case, C
C for constant
for constant, SGL
SGL for single
for single, and
and hours for
hours for the
I tend to
tend to keep
to keep this
keep this naming
this naming convention
naming convention so
convention so that
so that regardless
that regardless of
regardless of how
of how large
how large your
large your application
application is, it's
it's easy to
easy to see
see what everything
what everything actually
everything actually is
can see this
see this one
this one in
one in the
the code as
code as being
as being a
being a constant
a constant, and
and what it
what it contains
it contains is
contains is going
be a single
a single, something
something with a
with a decimal
a decimal place
And we're making
making it equal
equal to 375
to 375 divided
375 divided by
divided by 10
application compiles, will
will slot in
slot in the
in the 'value'
the 'value' here
'value' here into
here into your
into your code
your code, so
so that this
that this will
will be calculated
be calculated at
calculated at runtime
to get exactly
get exactly 37.5
set the hours
the hours to
hours to be
to be 37.5
be 37.5 rather
37.5 rather than
rather than 40
than 40, we
we should get
should get a
get a reduced
a reduced number
reduced number of
hours per week
per week, which
we do indeed
So this handles
this handles numeric
handles numeric constants
numeric constants, either
using the standard
the standard percentage
standard percentage at
percentage at the
the name, or
or using the
using the VB-style
the VB-style construct
VB-style construct, or
or using a
using a macro
macro to calculate
to calculate values
calculate values which
values which are
which are not
are not whole
not whole numbers
create another constant
another constant, in
this case, TotalRecords
we're setting its
value to be
be the value
the value 5
If you're performing
you're performing a
performing a for
next loop, from
from the value
value of 1
of 1 to
1 to 5
to 5, we
replace the 5
the 5 with
5 with our
with our integer
our integer constant
a large application
large application, this
this TotalRecords constant
TotalRecords constant may
constant may appear
may appear many
appear many times
many times within
times within your
And should the
should the value
the value have
value have to
have to change
to change, you
you merely have
to change one
change one line
have to hunt
to hunt through
hunt through the
through the whole
whole application to
application to find
to find out
find out everywhere
out everywhere the
everywhere the number
the number 5
number 5 is
5 is used
can output the
output the word
the word 'record'
word 'record' followed
'record' followed by
by the string
the string version
string version of
version of our
of our record
our record number
can now run
now run the
application to get
to get 'record'
get 'record' and
'record' and the
well as numeric
as numeric constants
numeric constants, we
we can also
can also have
also have string
have string constants
wanted to replace
to replace this
replace this hard-coded
this hard-coded word
hard-coded word 'record'
word 'record' with
'record' with a
with a string
a string constant
to call it
call it 'record
it 'record label'
can set this
set this up
this up at
String constants preceded
constants preceded by
preceded by a
a single dollar
single dollar sign
dollar sign are
sign are standard
are standard ANSI
standard ANSI strings
If you need
you need Wide
need Wide or
Wide or Unicode
or Unicode strings
Unicode strings, you
have to proceed
to proceed the
proceed the name
name with two
with two dollar
two dollar signs
ANSI string equates
string equates, each
each are limited
are limited to
limited to a
to a maximum
a maximum of
maximum of 255
of 255 characters
Wide equates are
equates are limited
limited to 127
to 127 characters
String equates are
equates are global
are global through
global through your
through your entire
entire application and
application and can
can be referenced
be referenced anywhere
string equates must
equates must be
must be created
be created outside
created outside of
outside of subroutines
of subroutines, functions
methods or properties
Ideally at the
top of your
your code for
code for readability
application now, you
see the word
followed by 'space'
by 'space' followed
'space' followed by
by the record
record number appears
number appears on
appears on our
have successfully replaced
successfully replaced a
replaced a hard-coded
a hard-coded string
hard-coded string with
string with a
which I have
I have appropriately
have appropriately named
appropriately named, are
are a powerful
a powerful method
powerful method for
method for actually
for actually handling
actually handling large
handling large amounts
large amounts of
amounts of code
have a value
a value that
value that appears
that appears many
appears many times
many times throughout
times throughout your
throughout your application
your application and
application and is
and is not
to be changing
be changing during
changing during the
the application, a
constant is ideal
is ideal for
ideal for this
at creating an
creating an image
an image generating
image generating countdown
generating countdown application
be doing some
doing some more
some more work
more work with
work with graphics
with graphics controls
graphics controls and
controls and images
The dialogue you
dialogue you see
you see on
on screen here
screen here at
here at the
moment is to
user to be
able to select
to select a
select a background
a background image
Having selected this
selected this background
this background image
background image, it
graphics control on
control on the
user can then
can then select
then select a
select a date
a date from
date from the
from the Date
the Date control
be the target
the target date
target date to
date to which
going to count
to count down
count down to
Next the user
user can select
can select a
select a text
a text colour
be the colour
the colour the
colour the text
the text appears
text appears on
appears on the
then finally we're
finally we're giving
we're giving the
giving the user
the user an
user an Apply
an Apply to
Apply to Image
to Image button
This will apply
will apply the
apply the text
text on top
on top of
user is happy
is happy with
happy with what
with what they've
what they've selected
they've selected, they
they can then
can then click
then click the
click the Save
the Save Image
Save Image button
Image button at
This will extract
will extract the
extract the image
the image from
image from the
from the graphics
control and save
and save it
save it as
as a JPEG
So I've used
I've used AI
used AI to
AI to generate
to generate four
generate four images
four images which
images which we're
be using as
using as our
as our backgrounds
order to allow
to allow flexibility
allow flexibility, the
application will scan
will scan the
scan the folder
the folder and
folder and check
and check to
how many JPEGs
many JPEGs it
JPEGs it can
it can find
can find in
find in the
display the names
the names of
names of these
of these JPEGs
these JPEGs in
JPEGs in the
you wish, more
more images on
images on the
on the drop-down
drop-down list, you
you may only
may only have
to add more
add more images
more images to
images to the
Each image is
image is 1024
is 1024 by
1024 by 1024
by 1024 pixels
populate the drop-down
drop-down list for
list for the
the background images
into the callback
callback function of
function of our
of our dialogue
in the initialize
the initialize dialogue
initialize dialogue section
section of our
of our callback
our callback function
event handler, we're
One that will
that will load
will load our
load our image
our image list
We're passing this
passing this new
function to parameters
to parameters, the
dialogue and the
of the combo
the combo box
combo box that
box that we
wish to populate
new function, loadImageList
first task will
task will be
be to reset
reset the combo
Resetting the combo
combo box is
box is always
is always a
good idea when
idea when you're
when you're creating
you're creating a
allows the function
function to be
the code, ensuring
ensuring that none
that none of
none of the
of the previous
the previous data
previous data will
data will be
will be still
be still sitting
still sitting in
in the combo
using the dir$
the dir$ command
dir$ command to
command to sweep
to sweep through
sweep through our
through our current
current folder and
folder and look
and look for
look for files
for files with
files with the
with the extension
the extension jpeg
populate the str
the str file
str file variable
file variable by
by using dir$
It takes a
be the name
of the folder
the folder we
folder we are
are currently in
currently in and
in and the
and the extension
the extension we're
extension we're looking
this case jpeg
While the value
value returned by
returned by this
by this is
this is not
is not blank
not blank, we
will then add
then add the
add the value
to the combo
combo box and
box and then
and then cycle
then cycle on
cycle on to
the next file
next file to
file to be
to be looked
be looked for
Once we've added
we've added our
added our files
our files to
files to find
to find, our
our combo box
combo box will
box will be
should have four
have four entries
four entries on
entries on the
on the combo
And we do
of the files
the files is
files is now
is now appearing
now appearing with
appearing with its
with its file
its file name
file name on
name on our
on our combo
to select one
select one of
of these entries
these entries on
box and we
will then load
then load up
load up that
up that file
that file and
file and display
it on our
to the callback
callback function that
function that handles
handles the events
the events on
events on our
combo box, which
background image list
this is clicked
is clicked, the
thing we want
get the text
that is currently
is currently selected
As this combo
this combo box
box is single
is single select
single select only
select only, you
you can only
can only select
only select one
select one item
one item on
item on the
use a control
a control get
control get text
get text quite
text quite easily
using the handle
and the current
the current control
current control, which
is the CBO
the CBO background
CBO background image
And we're sending
we're sending that
sending that to
variable called strImage
This identifies the
identifies the name
functions in a
a library we've
library we've previously
we've previously created
function called loadImageFile
this takes four
takes four parameters
we specify the
specify the image
image we wish
it will return
return the width
height of that
And finally, it
return a handle
a handle to
handle to the
the bitmap, which
which it's loaded
it's loaded the
the image into
as we've used
used a few
few new variables
new variables here
variables here, we'll
to create these
create these at
we've created these
created these new
new variables, let's
our code where
code where we're
where we're calling
we're calling our
calling our include
our include files
to be pulling
be pulling in
pulling in three
in three libraries
three libraries here
of all, a
a GDI plus
GDI plus startup
plus startup library
This contains routines
contains routines for
routines for opening
for opening up
opening up GDI
up GDI plus
GDI plus and
plus and closing
and closing it
closing it down
it down once
down once we've
once we've finished
Our second library
second library is
library is dedicated
is dedicated to
dedicated to loading
to loading a
loading a JPEG
a JPEG in
JPEG in as
in as a
as a bitmap
our final library
final library is
library is to
is to do
do the reverse
the reverse to
reverse to take
a JPEG from
JPEG from a
a graphics control
save it to
it to disk
So I'll go
I'll go back
go back into
into our callback
So on the
on the assumption
the assumption that
assumption that the
that the load
the load image
load image file
image file routine
file routine will
routine will actually
will actually find
actually find our
find our image
image and convert
and convert it
a bitmap, it
command to specify
specify the graphics
control on which
on which all
which all the
all the subsequent
the subsequent operations
subsequent operations are
operations are going
We've set this
set this to
this to use
redraw option, as
as this will
to update things
update things much
things much quicker
And then at
then at the
the end, we'll
do a graphics
a graphics redraw
graphics redraw to
redraw to allow
to see the
see the completed
the completed image
the graphics copy
graphics copy to
copy to copy
to copy our
copy our bitmap
our bitmap onto
bitmap onto our
we can tell
can tell Powerbasic
Powerbasic that we've
we've finished handling
finished handling that
handling that bitmap
that bitmap to
bitmap to allow
it to free
to free up
free up the
up the resources
And finally, we
we will redraw
will redraw the
graphics control to
go to our
to our dropdown
our dropdown and
dropdown and select
and select one
have our graphics
graphics control populated
control populated with
populated with the
with the image
image on our
control is only
is only part
only part of
of the full
the full image
is because the
because the image
the image is
image is larger
is larger than
larger than the
than the graphics
graphics control in
control in pixels
way of reducing
of reducing the
reducing the size
the image so
image so that
that the whole
the whole entirety
whole entirety of
entirety of it
of it appears
it appears on
need to use
to use another
use another graphics
another graphics command
And this graphics
this graphics command
graphics command is
the graphics stretch
graphics stretch page
stretch page command
us to resize
to resize the
resize the bitmap
bitmap to fit
to fit the
fit the graphics
need to give
to give it
it a handle
it the handle
graphics control itself
control itself and
itself and two
The mix copy
mix copy source
copy source and
source and halftone
The halftone will
halftone will allow
will allow Powerbasic
allow Powerbasic to
Powerbasic to actually
to actually reduce
actually reduce the
reduce the size
size of it
of it without
it without losing
without losing much
losing much in
much in the
in the way
the way of
way of detail
again now to
see if that's
if that's made
that's made a
made a difference
And we select
we select the
select the same
the same entry
same entry from
entry from the
the dropdown and
dropdown and we
now see we're
see we're seeing
we're seeing the
seeing the entire
the entire image
we select one
the other ones
other ones And
ones And it's
And it's appearing
it's appearing quite
appearing quite happily
we've successfully taken
successfully taken a
taken a jpeg
jpeg file from
file from the
from the folder
folder and displayed
and displayed it
displayed it in
it in our
in our graphics
graphics control, adjusting
adjusting the size
So that's stage
that's stage one
next thing we
out our dates
date control will
control will allow
you to select
to select dates
select dates quite
dates quite happily
but the next
is to capture
capture the dates
the dates from
dates from the
So it's back
it's back to
callback function we're
three new variables
one we're declaring
we're declaring is
declaring is static
be the end
the end date
end date that
date that the
The next two
next two are
two are pointers
are pointers to
pointers to user-defined
to user-defined types
These are used
are used so
used so that
when the notification
the notification comes
notification comes in
comes in that
in that the
user has changed
has changed something
changed something on
something on a
on a date
a date control
date control, we
determine what they've
what they've actually
they've actually done
at the notify
the notify event
notify event in
event in our
in our callback
And here we're
here we're going
to populate, first
of all, one
of the pointers
do a test
a test to
to see what's
see what's been
what's been clicked
been clicked upon
you to put
to put multiple
put multiple date
multiple date controls
date controls on
controls on the
screen and be
and be able
able to determine
determine which one
which one the
one the user
we've determined which
determined which date
which date control
date control the
control the user
has selected, we
have to determine
And we're interested
in a date
a date time
date time change
And next we
can populate our
populate our end
our end date
end date by
date by picking
by picking up
up the information
from our pointer
our pointer for
the day, the
the month and
month and the
and the year
using the UK
the UK format
UK format of
format of dates
of dates throughout
dates throughout this
throughout this application
you use the
use the American
the American format
American format, feel
free to actually
to actually move
actually move these
move these around
allow the code
code to pick
pick up when
changed the date
the application loads
application loads initially
loads initially, we
set the date
the date as
date as being
being the current
So we'll pop
we'll pop back
pop back to
to our initialization
our initialization dialog
put two lines
first one is
one is to
populate the str_end_date
the str_end_date variable
There's a function
a function at
function at the
the application which
application which returns
which returns the
returns the UK
the UK date
UK date in
date in day
in day, month
If you're using
you're using the
using the American
free to change
to change and
change and replace
and replace this
replace this function
The second function
second function is
the date in
date in a
Strictly speaking, we
need this one
one in here
in here because
here because when
because when the
application runs, the
control will have
have the current
current date in
date in it
in it anyway
it's a useful
a useful function
useful function to
function to have
to have as
have as it
as it allows
it allows you
date control at
control at any
any point during
point during the
during the application
we've got that
got that far
that far with
far with the
the code, our
populate the text
the text colour
text colour drop-down
to select the
select the colour
colour that they
that they want
they want the
want the text
text to impose
to impose on
impose on top
in our initialization
initialization dialog section
dialog section, we
want to add
add some text
some text colour
text colour options
There's two pieces
of information needed
information needed here
The text name
text name for
name for the
the user, for
example red, white
blue and green
and green, and
Combo boxes allow
boxes allow you
you to store
text which appears
which appears to
appears to the
also a value
value which can
be a long
a long variable
long variable stored
variable stored in
in the background
user selects the
selects the first
the first setting
first setting on
setting on the
the list, it
it gets the
gets the first
the first long
first long value
up two arrays
two arrays to
arrays to dimension
to dimension between
dimension between one
one and four
and four elements
text colour string
colour string and
string and one
text colour number
to populate these
populate these arrays
As they're quite
they're quite small
quite small arrays
small arrays, it's
easy to use
assign command, giving
giving the four
the four values
four values that
values that we
that we want
we want placed
want placed in
placed in those
in those arrays
up some more
more variables at
want to keep
of the items
the items selected
items selected from
selected from the
from the combo
combo box, we
of the selected
the selected text
selected text colour
text colour, and
the two arrays
two arrays for
arrays for the
text colour and
set these arrays
these arrays up
arrays up, we
have to populate
populate the combo
combo box, and
will be using
text that the
the user gets
user gets to
gets to see
to see by
see by using
using a combo
a combo add
combo add command
takes the parameters
parameters of the
of the handle
combo box, the
the string value
string value you
value you wish
and which item
which item on
the list this
list this is
when you're adding
you're adding the
adding the first
first one, it
it would return
would return number
return number one
If the combo
box is set
is set to
set to be
to be sorted
be sorted alphabetically
sorted alphabetically, then
then when you
when you add
you add the
add the very
very first value
first value, it
will return number
number one as
one as its
as its item
add the second
second value, it
may well appear
well appear also
appear also as
also as the
the first item
first item on
the list, as
as item one
item one will
one will be
will be moved
be moved down
moved down to
down to item
to item two
item two because
two because it's
because it's now
it's now sorted
trapping the item
the item that
item that it
that it gets
it gets added
gets added as
added as, because
we'll need that
need that for
that for the
the next command
is the combo
combo box set
box set user
set user command
us to save
save the value
combo box of
box of our
our colour, red
application now, our
combo box for
box for the
for the colours
the colours should
colours should be
should be populated
be populated, which
So the next
is to apply
to apply text
apply text to
put the code
the code underneath
code underneath that
underneath that button
user may have
may have several
have several goes
several goes in
goes in actually
in actually setting
actually setting this
setting this up
this up by
up by picking
by picking dates
picking dates, our
be to re-add
to re-add the
re-add the countdown
the countdown image
countdown image to
So we'll do
we'll do as
do as we
did before, we'll
we'll capture from
capture from the
combo box the
box the name
name that the
has selected, and
populate the graphics
graphics control with
control with the
if you're doing
you're doing this
doing this a
this a lot
a lot, it
would be handy
be handy to
handy to put
put this into
into a common
have that completed
that completed, we
have to get
to get what
get what the
what the user
the user selected
user selected for
use the combo
combo box get
box get select
get select command
return the item
If the item
item number is
number is zero
is zero, it
it means the
means the user
user has yet
has yet to
yet to select
So in that
in that case
that case, we'll
we'll default it
default it to
it to item
to item number
item number one
need to pull
box the user
the user value
user value that
value that was
that was previously
was previously stored
previously stored for
stored for the
for the colour
the colour by
colour by using
using the combo
box get user
get user command
using the item
item number that
number that we've
And we're saving
we're saving that
saving that value
that value to
to the long
the long text
long text colour
text colour variable
want to apply
to apply a
apply a piece
of text to
text to our
perform that function
that function apply
function apply countdown
apply countdown text
countdown text, taking
taking the parameters
dialog handle, the
graphics control handle
control handle, the
end date the
date the user
the long value
long value of
our new apply
new apply countdown
countdown text column
of days between
days between the
between the current
date and the
the date the
has selected on
selected on the
on the date
It will then
will then take
then take that
take that information
that information, form
form up a
up a piece
of text and
text and put
put it onto
it onto the
the power time
power time class
to declare some
declare some local
track of two
of two power
two power time
power time variables
time variables, one
for the current
date and one
for the forward
the forward date
forward date that
have a variable
variable to store
store the text
work out where
out where on
graphics control we're
control we're actually
we're actually going
actually going to
to be positioning
be positioning this
positioning this piece
will take the
take the end
has selected and
selected and we
we will split
will split that
split that up
that up into
up into year
into year, month
month and day
UK format here
format here as
here as that
as that will
be the format
the format that's
format that's been
that's been passed
passed in to
in to this
populate the current
the date that
This is using
using the today
the today and
today and the
and the new
the new date
new date methods
date methods in
methods in our
in our class
So today picks
today picks up
New date picks
date picks up
up the date
user has passed
has passed in
passed in as
in as in
as in year
in year, month
use the time
the time diff
time diff method
diff method for
method for working
for working out
working out the
days between these
these two dates
a very powerful
very powerful class
powerful class which
class which gives
which gives you
gives you great
you great flexibility
great flexibility in
flexibility in working
in working out
working out dates
add this text
text onto our
control and we'll
and we'll do
that by first
by first using
first using a
ensure that all
that all subsequent
all subsequent graphics
subsequent graphics operations
graphics operations will
operations will be
will be directed
be directed towards
directed towards that
towards that control
We also want
the text fairly
text fairly large
fairly large so
large so it
so it can
can be seen
be seen by
seen by using
a graphics set
graphics set font
set a font
a font up
do that at
that at the
using the font
I've specified courier
specified courier new
new as our
as our font
The next value
next value 3
value 3 is
3 is a
is a composite
a composite of
composite of bold
of bold and
bold and italic
Value 1 would
1 would be
would be bold
be bold, value
value 2 would
2 would be
would be italic
be italic and
italic and value
and value 3
3 is both
is both bold
both bold and
Once the dialogue
the dialogue is
dialogue is closed
is closed down
closed down we
down we can
can then do
then do a
do a font
a font end
font end command
end command which
command which will
which will free
will free up
up the space
the space used
space used by
used by the
by the font
So we're also
we're also using
also using the
the graphics color
graphics color command
Using the passed
the passed in
passed in value
in value for
for the color
color for the
foreground and we're
we're using at
using at the
the moment -1
moment -1 for
-1 for the
Which means leave
means leave the
leave the background
the background as
background as it
as it was
So next we're
going to form
to form up
that says X
says X days
X days left
X being the
being the number
of days calculated
days calculated in
calculated in our
our power time
As the number
of days can
days can either
can either be
either be 1
be 1, 2
2 or possibly
or possibly even
possibly even 3
even 3 characters
3 characters length
characters length, the
the length of
length of our
text is going
to vary depending
vary depending on
the date selected
date selected by
selected by the
out just how
just how wide
how wide this
wide this piece
text is in
is in order
order to centre
to centre it
centre it in
in the middle
the middle of
be done quite
by using one
the graphics commands
the graphics command
graphics command with
command with text
with text size
text size X
size X and
and the string
the string containing
string containing the
to put on
put on the
graphics control will
control will return
will return either
return either the
either the number
number of pixels
of pixels or
pixels or the
or the page
the page dialogue
page dialogue units
control itself by
itself by using
And after that
after that it's
that it's straightforward
it's straightforward arithmetic
we've now populated
now populated a
populated a variable
variable called X
called X POS
X POS will
POS will tell
tell us exactly
us exactly where
exactly where we
to start printing
can then set
then set that
set that value
that value using
value using the
graphics set POS
set POS command
POS command and
command and then
and then print
then print our
control and then
and then redraw
then redraw this
redraw this to
see what displays
can set our
set our background
our background image
background image, we
can pick a
pick a date
a date, we
set our text
our text colour
colour and we
hit the apply
the apply to
And this displays
this displays on
displays on the
it doesn't look
doesn't look particularly
look particularly good
Better in red
We need some
need some way
some way of
way of actually
of actually removing
actually removing the
removing the plain
the plain solid
plain solid fill
solid fill background
fill background from
background from the
easily by changing
by changing one
changing one line
In the graphics
graphics colour command
colour command we're
command we're using
we're using minus
using minus one
to a minus
a minus two
minus two and
two and run
and run our
once more, select
select our image
our image, pick
pick our date
our date, select
select the text
colour and apply
and apply to
apply to the
Now the background
text is completely
is completely transparent
completely transparent, making
making it much
it much easier
easier to see
we've achieved so
achieved so far
so far is
far is we've
is we've allowed
we've allowed the
allowed the user
to pick a
a date, calculate
calculate the number
date and that
and that date
that date, display
display that information
that information on
The final task
final task is
allow the save
image button to
button to save
save the updated
the updated graphics
updated graphics control
graphics control back
control back to
to disk as
disk as a
our code I've
code I've set
I've set up
a constant to
constant to name
to name our
name our output
We could of
could of course
of course put
course put something
put something on
something on screen
on screen to
to select where
select where they
where they wanted
they wanted a
wanted a file
a file saved
file saved to
saved to and
to and what
what they wanted
they wanted to
wanted to call
we'll just call
just call it
call it test.jpg
we are back
are back in
back in the
callback function, our
our event handler
at the event
the event that
event that is
that is triggered
is triggered when
triggered when the
on the create
the create image
create image button
clicks on our
on our create
our create image
image button we
button we want
want to save
save the graphics
control to disk
So we've got
we've got a
got a new
new function that
function that will
that will perform
will perform that
perform that in
that in one
in one of
of our libraries
function is called
is called save
called save graphics
save graphics control
pick our background
pick our text
our text color
And we apply
we apply that
apply that to
on the save
image button let's
button let's have
a look inside
look inside our
inside our folder
our folder and
folder and see
if this test.jpg
this test.jpg has
test.jpg has appeared
is our test.jpg
our test.jpg file
does indeed have
indeed have our
have our text
our text on
text on it
graphics control, populated
populated it with
it with a
with a jpg
a jpg image
jpg image, updated
updated that jpg
that jpg image
jpg image by
image by writing
by writing text
writing text to
text to it
to it, and
and then saving
then saving that
saving that updated
that updated graphics
as a jpg
you a fair
flexibility in saving
in saving the
saving the images
the images that
images that you've
that you've created
you've created on
created on screen
Be they charts
they charts, images
images like this
like this or
this or any
or any other
any other content
other content within
content within a
the data commands
data commands in
commands in Power
Basic and Basic
and Basic in
Basic in general
in general date
general date back
date back a
back a long
As the name
the name suggests
name suggests the
suggests the data
the data command
data command is
command is used
is used for
used for storing
for storing data
storing data within
data is compiled
is compiled into
compiled into the
can be either
be either an
either an advantage
an advantage or
advantage or a
or a disadvantage
a disadvantage, depending
depending how you
how you look
you look at
look at it
the data is
data is embedded
is embedded within
embedded within the
the application should
application should that
should that data
that data require
data require to
require to be
to be changed
be changed then
changed then you
then you will
you will need
to amend your
amend your application
application and recompile
This isn't necessarily
isn't necessarily a
necessarily a problem
a problem if
problem if you
you are using
using the data
data commands to
commands to store
to store data
store data that
data that is
that is changed
is changed very
changed very infrequently
Most modern applications
modern applications store
applications store the
store the data
data in databases
in databases outside
databases outside your
outside your binary
your binary executable
But today we
we are going
command to store
store information within
So within our
local variable and
and then call
then call a
function to populate
populate that variable
name of that
that function is
to be build
be build data
The data statement
data statement is
statement is used
used for keeping
for keeping track
keeping track of
track of string
of string variables
you put any
put any numbers
any numbers into
numbers into your
into your data
your data statements
data statements they
statements they will
be stored internally
stored internally as
internally as strings
However you can
you can convert
can convert them
convert them when
them when you
when you pull
you pull the
created a data
a data statement
data statement with
statement with a
with a list
list of strings
of strings in
strings in this
this case eye
case eye colours
amber and grey
So these six
these six pieces
six pieces of
pieces of data
data are stored
are stored within
within the data
can we access
we access them?
access them? Well
them? Well first
Well first of
we will count
will count the
count the number
of entries in
entries in our
our data statement
the data count
data count command
This inbuilt function
inbuilt function will
number of discrete
of discrete pieces
discrete pieces of
data within your
within your data
now we are
going to cycle
to cycle through
cycle through each
through each one
each one of
of these pieces
these pieces of
of data to
data to pull
be doing that
doing that by
We have picked
have picked up
number of data
of data items
data items using
items using the
we will go
through a for
loop for lngR
within this for
loop we are
to read from
read from our
from our data
data statement and
statement and add
and add the
add the information
to the str
str data variable
do this using
this using the
using the read
the read dollar
read dollar command
function will read
will read a
read a particular
a particular data
particular data item
data item from
item from our
our data string
is the element
the element that
element that you
wish to read
we are reading
are reading each
reading each of
of the entries
the entries from
entries from 1
from 1 up
1 up until
until the total
of entries which
entries which is
which is 6
we are adding
are adding on
these strings a
strings a comma
As there will
be a trailing
a trailing comma
trailing comma in
comma in the
the string we
string we are
we are returning
are returning I
returning I am
I am using
am using the
using the rtrim
the rtrim command
rtrim command to
to trim the
trim the rightmost
the rightmost comma
rightmost comma from
comma from the
from the string
can return that
return that data
that data to
to our calling
our calling function
So having returned
having returned the
returned the data
calling function we
now put this
put this out
this out to
the log to
it has returned
it will push
will push out
push out to
the log the
log the string
the string of
string of data
of data from
the data statements
You'll notice that
notice that the
that the quotes
the quotes we
quotes we had
we had in
had in the
data statement have
statement have been
have been removed
We are purely
are purely getting
purely getting the
getting the string
string data as
data as in
in the name
of the eye
the eye color
eye color and
color and each
of the names
the names is
names is separated
is separated by
separated by a
by a comma
we do if
do if we
if we need
add more data
to the build
the build data
build data function
data function we
can add another
add another data
another data line
This time I'm
time I'm putting
I'm putting numbers
putting numbers into
numbers into the
see the 1234
the 1234 have
1234 have been
of our string
dollar command will
command will read
will read all
read all the
data statements within
statements within the
or function that
function that it
it currently exists
currently exists in
will not read
not read any
read any data
any data statements
data statements from
statements from any
from any other
any other function
other function or
However there is
is a limit
a limit of
limit of 64
of 64 kilobytes
64 kilobytes and
kilobytes and 16383
and 16383 separate
16383 separate data
separate data items
data items allowed
items allowed per
allowed per sub
per sub or
sub or function
are some limitations
some limitations to
limitations to the
data statement which
statement which you'll
which you'll have
you'll have to
have to watch
to watch out
watch out for
In other parts
other parts of
code you have
you have seen
have seen me
seen me use
me use the
prefix command places
command places the
places the text
the text immediately
text immediately following
immediately following it
following it at
it at the
of each subsequent
each subsequent line
subsequent line until
line until you
until you get
you get to
the end prefix
end prefix command
This in many
in many cases
many cases can
cases can save
can save you
save you a
However the data
data command does
command does not
does not support
not support prefix
support prefix if
prefix if we
if we tried
we tried to
tried to compile
It would generate
would generate an
generate an error
Saying data may
data may not
not be used
with the prefix
Also if you
if you attempt
you attempt to
attempt to use
use the underline
the underline character
underline character to
character to fold
to fold down
fold down the
down the data
to the following
following line this
line this will
this will also
will also not
also not be
not be accepted
wish to add
more data merely
data merely add
merely add more
more data statements
And you'll see
you'll see for
see for this
of data we've
data we've put
we've put in
put in here
here the words
the words more
words more test
more test and
test and the
the word data
word data in
data in double
in double quotes
application now you
will see you
see you are
you are actually
are actually getting
actually getting the
the data with
with the double
double quotes in
quotes in it
in it is
it is treating
is treating this
treating this whole
this whole string
whole string as
string as one
as one element
one element of
use the data
data statements to
statements to hold
to hold specific
hold specific information
specific information in
in a subroutine
a subroutine or
subroutine or a
or a function
can be called
called from anywhere
from anywhere in
anywhere in your
your application pulling
application pulling back
pulling back the
back the data
the data as
data as a
as a return
a return from
return from a
from a function
However as I
as I have
I have said
have said if
said if you
wish to change
to change any
change any of
data in these
in these data
these data statements
data statements you
statements you will
you will have
will have to
have to edit
to edit your
edit your source
your source code
source code recompile
code recompile the
recompile the application
application and release
and release it
However one other
one other option
other option if
option if several
if several applications
several applications are
applications are using
are using this
using this key
this key data
key data is
data is to
the data into
into a dynamic
dynamic link library
That way should
way should the
should the data
the data require
be changed you
changed you may
have to recompile
to recompile the
recompile the DLL
This DLL can
DLL can be
can be dynamically
be dynamically loaded
dynamically loaded by
loaded by multiple
by multiple applications
multiple applications making
you have within
have within it
if we load
we load up
up the Power
Windows compiler and
compiler and compile
and compile a
compile a DLL
a DLL just
DLL just to
just to perform
perform this purpose
we go up
up to the
the create new
create new file
new file and
file and we'll
create a DLL
a DLL framework
DLL framework using
framework using a
using a lib
a lib main
We'll save this
this into the
into the same
folder as of
as of application
of application and
call the file
the file libdata.bas
function which will
will return some
return some data
some data in
data in data
in data statements
this function fun
function fun return
fun return data
We'll give an
give an alias
an alias of
alias of the
same name and
name and we'll
and we'll mark
we'll mark this
mark this to
this to be
to be exported
be exported as
exported as string
will allow this
allow this function
this function to
called from outside
from outside the
outside the DLL
to put much
put much the
much the same
the same code
same code in
in here as
here as we
a data line
data line with
line with the
with the six
the six eye
six eye colours
I've additionally put
additionally put an
put an extra
an extra piece
of text at
the beginning saying
beginning saying DLL
saying DLL just
just to indicate
indicate that the
data is coming
is coming from
coming from a
from a DLL
This is purely
is purely so
purely so we
see the difference
the difference on
difference on screen
the read command
read command to
the data line
data line and
line and we're
we're using data
using data count
data count to
count to work
how many entries
many entries we
entries we have
have in data
in data within
if we compile
we compile that
compile that, that
that will give
give us our
us our DLL
we compile on
compile on the
on the DLL
the DLL, it
will compile cleanly
can see inside
see inside our
our folder we
folder we now
have a libdata.dll
a libdata.dll file
libdata.dll file sitting
file sitting in
sitting in there
compiler and we'll
and we'll attempt
we'll attempt to
attempt to call
call this DLL
this DLL function
order to call
call the DLL
the DLL we'll
DLL we'll need
to declare it
declare it at
using the declare
the declare function
declare function statement
name we wish
wish to refer
to refer to
refer to the
the function within
function within our
our application, the
the library name
library name in
this case libdata.dll
case libdata.dll and
libdata.dll and the
and the alias
the alias the
alias the name
the name it
name it is
it is within
For clarity I've
clarity I've kept
I've kept the
kept the name
the function the
function the same
same in this
this application as
it is in
in the DLL
Although that doesn't
that doesn't necessarily
doesn't necessarily always
necessarily always have
always have to
to be so
we're declaring it
declaring it to
it to say
say it's returning
it's returning a
returning a string
we now make
now make a
to this fun
this fun build
fun build data
data function from
from within our
will run, it
return the original
the original data
original data which
data which is
is the i-colors
the i-colors followed
i-colors followed by
followed by some
by some numbers
the data coming
data coming from
from the DLL
the DLL, as
can tell because
tell because we
because we have
have the string
the string DLL
string DLL at
DLL at the
the beginning, is
is returning also
returning also the
also the same
the same eye
same eye colors
is we've embedded
we've embedded some
embedded some data
some data within
data within some
within some data
some data statements
statements within a
within the main
the main application
We then used
then used the
used the read
dollar command to
command to read
to read that
read that data
data out and
out and return
and return to
calling function so
function so we
can display it
We've also taken
also taken the
taken the same
the same data
same data statements
data statements and
statements and created
a function in
in a DLL
to keep the
keep the DLL
the DLL and
DLL and its
and its data
its data quite
data quite separate
quite separate from
separate from the
from the main
We've then declared
then declared that
declared that DLL
that DLL function
DLL function and
function and called
and called it
called it from
it from our
from our main
our main application
main application to
Data statements can
statements can be
be a useful
a useful way
way of embedding
of embedding data
embedding data within
data within applications
But as with
as with all
with all approaches
all approaches to
approaches to data
to data processing
data processing, you
need to look
to look to
see how often
how often this
often this data
data is going
to be updated
If it's going
be a regular
a regular update
regular update, then
then possibly a
possibly a data
a data command
command is not
is not the
not the place
the place to
place to store
you have some
have some constants
some constants that
constants that you
wish to store
to store within
store within your
your application or
application or DLLs
or DLLs, the
data statement will
statement will work
work quite nicely
look at graphics
be looking again
looking again at
at the graphics
we want this
want this application
able to be
to be run
be run either
run either in
the console or
console or the
or the windows
windows compiler, we're
bit of code
in here to
here to turn
to turn off
turn off the
off the console
the console if
console if we're
if we're running
we're running under
running under the
under the console
with this piece
code in place
we are running
are running under
console compiler the
compiler the console
console will not
will not appear
function we want
create and display
and display a
display a graphics
All graphics windows
windows require a
require a handle
a handle by
handle by which
you can control
can control them
control them, so
so we'll declare
we'll declare a
variable for that
for that handle
graphics window command
to reuse a
reuse a piece
of code we
code we used
we used in
used in a
a previous program
previous program to
program to set
set the windows
the windows position
windows position to
to be topmost
is using a
using a Windows
a Windows API
This will ensure
will ensure our
ensure our graphics
window is visible
user and it
it will appear
will appear on
appear on top
top of all
of all other
all other windows
As we've now
we've now displayed
now displayed the
displayed the graphics
the graphics attach
This instructs the
instructs the application
application to direct
to direct all
direct all graphics
all graphics commands
graphics commands to
commands to this
to this specific
this specific window
using the redraw
option to buffer
to buffer any
buffer any commands
any commands going
commands going to
graphics window not
window not to
not to be
be displayed to
the user until
user until we
until we use
this would display
would display a
graphics window on
window on our
on our monitor
So having displayed
having displayed this
displayed this graphics
the user we'll
user we'll want
display some text
some text upon
text upon it
to see we're
see we're going
the text a
little bigger by
bigger by setting
as the handle
for our font
to specify that
specify that the
that the font
the font we
font we want
to use is
use is Courier
is Courier new
Courier new 18
new 18 point
We're next going
next going to
going to clear
graphics window, set
to be light
be light grey
light grey, then
colour command to
to say any
say any text
any text going
text going to
going to that
window to be
be a foreground
a foreground colour
foreground colour of
colour of black
of black and
black and a
and a background
a background colour
colour of light
light grey to
grey to match
to match the
match the background
use two graphics
two graphics print
graphics print commands
print commands to
commands to put
lines of text
However if we
if we ran
we ran the
ran the application
it stands it
stands it would
it would end
would end almost
end almost immediately
Because once the
once the graphics
graphics window had
window had been
had been displayed
been displayed there
displayed there were
there were no
were no further
no further commands
further commands in
commands in the
in the pb_main
function to execute
to execute so
execute so the
application would end
put a loop
a loop in
loop in at
end to wait
to wait for
wait for the
to be closed
be closed by
by using another
using another Windows
Windows API function
API function called
function called isWindow
This takes as
takes as a
single parameter the
parameter the Windows
the Windows handle
Windows handle we
handle we had
had created when
created when we
So we're running
we're running round
running round this
this loop every
loop every second,testing
every second,testing to
second,testing to see
the window has
window has indeed
indeed been closed
see a graphics
graphics window successfully
window successfully appears
successfully appears on
It has displayed
has displayed the
displayed the two
it's now waiting
now waiting for
waiting for the
to click X
click X on
X on the
the top right
top right hand
window to close
to close the
close the window
in the taskbar
the taskbar there
taskbar there is
an icon showing
icon showing for
showing for our
for our graphics
If we close
we close the
graphics window it
window it will
will disappear from
disappear from the
from the taskbar
the taskbar so
taskbar so the
application has now
has now terminated
However as you
will have seen
have seen the
seen the icon
the icon used
icon used for
used for the
application and on
and on the
window itself is
itself is a
is a default
a default graphic
want to replace
to replace that
replace that with
that with a
with a graphic
a graphic of
graphic of our
of our own
our own choice?
own choice? Well
choice? Well in
Well in the
the folder I've
folder I've created
created an icon
an icon called
icon called grid
called grid icon
use this icon
this icon both
icon both for
both for the
application and for
display the graphics
user we're going
to this extract
this extract icon
extract icon API
The extract icon
icon API call
API call takes
call takes three
takes three parameters
parameter is for
for the module
the module handle
If we use
we use get
use get module
get module handle
module handle and
handle and as
and as its
as its parameter
its parameter an
parameter an empty
length string it
string it will
it will get
get the module
module handle of
application we're currently
we're currently running
Next we give
of the icon
the icon we
icon we wish
Finally we give
it the parameters
the parameters zero
will return an
return an icon
an icon handle
icon handle and
handle and we
the same message
same message command
message command to
set that icon
that icon as
icon as small
as small on
small on the
be using another
using another handle
another handle only
handle only to
only to declare
to declare this
declare this one
this one up
one up at
see our graphics
graphics window now
window now has
now has an
has an icon
an icon on
icon on the
and the application
the application on
application on the
on the taskbar
the taskbar also
taskbar also has
also has the
has the same
the same icon
successfully created a
graphics window for
window for our
for our application
But what if
create a second
graphics window? How
window? How do
do we go
ahead and do
and do that?
do that? As
that? As we've
done before we
before we use
up a new
a new graphics
new graphics window
window with the
with the text
the text second
text second graphics
window and we're
we're passing it
passing it to
to another handle
another handle in
handle in this
this case window
case window two
will declare window
declare window two
window two at
two at the
have two handles
two handles for
handles for our
our graphics windows
done before we're
before we're using
using the set
the set windows
set windows position
windows position API
position API call
call to make
make the window
the window topmost
And as we've
before we need
to instruct the
instruct the application
this new window
new window using
window using the
using the win
the win to
win to handle
setting the font
the same font
same font as
We're clearing the
clearing the graphics
the graphics background
graphics background and
background and we're
printing the words
words more data
more data to
to our second
our second graphics
command to draw
draw the graphics
the graphics to
graphics to our
our second window
second window if
window if we
now see there
see there are
there are now
are now two
now two graphics
two graphics windows
graphics windows on
With the second
graphics window having
window having the
having the text
the text more
text more data
can then move
then move the
move the graphics
the graphics windows
graphics windows around
windows around the
the screen quite
screen quite happily
Should the user
the user close
user close the
close the second
graphics window the
window the application
the application continues
application continues to
continues to run
to run because
run because our
because our code
code is specifically
is specifically looking
specifically looking for
for the closure
the closure of
closure of the
having displayed two
displayed two graphics
graphics windows what
windows what if
to put more
put more text
more text onto
onto the first
We can reattach
can reattach the
reattach the first
first window by
window by simply
by simply using
simply using the
attach command again
command again and
again and the
then print some
print some more
some more text
more text to
text to that
to that first
that first window
And to ensure
ensure the user
to see this
see this we
this we can
command to display
to display that
display that on
that on screen
run that now
see our both
our both graphics
both graphics windows
graphics windows have
windows have appeared
have appeared and
appeared and the
first window has
indeed got yet
got yet more
yet more data
more data on
data on it
Since we're looking
graphics window any
window any attempt
any attempt to
attempt to close
close the first
graphics window will
window will of
of course will
course will close
close the other
the other graphics
other graphics window
window and terminate
and terminate the
we do with
do with graphics
with graphics windows?
graphics windows? Well
windows? Well to
Well to do
do this next
this next part
next part I'm
part I'm going
add another library
add the graphics
progress library which
which we covered
we covered in
covered in a
one is designed
designed to display
display a progress
a progress bar
progress bar on
bar on the
the screen for
screen for the
user using a
So as this
be a third
a third graphics
third graphics window
window we will
will need yet
need yet another
yet another handle
created a local
variable for this
for this third
this third graphics
within the new
the new library
new library we've
library we've just
we've just added
This will open
will open up
open up a
up a graphics
window with some
with some text
some text on
on it and
it and a
and a progress
This will position
will position the
position the graphics
graphics window at
window at the
at the coordinates
the coordinates relative
coordinates relative to
relative to the
with all the
the other windows
other windows we
windows we can
use the set
call to ensure
it is displayed
user and top
and top of
be a progress
progress bar we
bar we want
want to call
call a little
display some progress
some progress on
progress on the
function called report
called report progress
report progress and
progress and this
this function takes
function takes no
no parameters as
parameters as it
will be writing
writing to the
We're basically displaying
basically displaying a
displaying a progress
progress bar moving
bar moving up
moving up step
we're also displaying
also displaying a
displaying a message
a message on
message on the
the screen saying
screen saying still
saying still processing
still processing and
processing and when
and when it
when it gets
it gets to
gets to 100
to 100 percent
100 percent it
percent it will
it will say
will say completed
say completed processing
Between each step
each step we're
step we're doing
doing a delay
a delay of
delay of simulate
of simulate some
simulate some processing
some processing going
processing going on
going on in
we're calling another
calling another function
within our new
our new library
new library to
library to update
update the graphics
the graphics progress
graphics progress on
progress on screen
very end we're
end we're sleeping
we're sleeping for
sleeping for another
for another half
another half second
half second and
second and then
then we're closing
we're closing down
closing down the
down the graphics
get a progress
progress bar appearing
bar appearing on
screen and after
and after it
after it gets
we've now successfully
successfully displayed three
displayed three graphics
windows on a
on a user's
a user's screen
we do even
do even more
even more on
more on graphics
on graphics windows?
graphics windows? Let's
windows? Let's assume
Let's assume we
assume we want
want to load
to load an
load an image
an image onto
the graphics render
graphics render command
render command to
command to actually
to actually render
actually render a
render a bitmap
a bitmap to
bitmap to the
However we have
have here in
here in our
our folder a
folder a gpeg
image we want
to load onto
load onto our
onto our screen
our screen but
screen but you
but you can't
you can't load
can't load a
a jpeg directly
jpeg directly onto
directly onto a
onto a graphics
This library is
library is called
is called pbload_jpg
called pbload_jpg as
pbload_jpg as bitmap
as bitmap and
bitmap and contains
and contains all
all the functionality
the functionality to
functionality to take
a jpeg and
jpeg and hand
and hand you
hand you back
you back a
back a handle
a handle for
handle for a
for a bitmap
once we have
have that handle
that handle we
handle we can
quite happily load
happily load the
load the memory
the memory bitmap
memory bitmap onto
bitmap onto the
to need some
need some variables
some variables for
variables for this
for this one
width and a
and a height
a height variable
height variable for
for the size
the bitmap we've
bitmap we've actually
we've actually returned
actually returned and
returned and also
also the handle
the handle itself
called loadImageFile which
loadImageFile which is
which is in
This takes one
takes one input
one input parameter
input parameter and
parameter and has
and has three
has three output
three output parameters
the path in
this case map_jpg
three parameters will
parameters will return
bitmap and the
the final parameter
final parameter is
the handle to
the bitmap itself
So should this
should this function
this function return
function return true
return true, in
case it has
it has successfully
has successfully loaded
successfully loaded the
loaded the jpeg
the jpeg and
jpeg and turned
and turned it
turned it into
into a bitmap
a bitmap we
bitmap we want
again to ensure
ensure we're attaching
we're attaching and
attaching and writing
and writing to
to the correct
graphics copy command
will copy our
copy command has
command has several
has several options
case all we're
we're doing is
doing is taking
is taking the
taking the bitmap
bitmap we've loaded
we've loaded and
loaded and positioning
and positioning it
positioning it at
it at coordinates
at coordinates 100
coordinates 100 by
by 100 inside
100 inside the
will display our
display our graphic
our graphic to
Having completed the
completed the copy
the copy we
copy we can
the graphic bitmap
graphic bitmap end
bitmap end command
end command to
command to free
up the memory
the memory used
memory used by
used by working
by working on
working on the
on the bitmap
Then we could
could use the
redraw command again
display the bitmap
see our progress
progress bar appears
bar appears as
appears as before
before and once
once it has
it has completed
has completed we
completed we will
So our jpeg
our jpeg has
jpeg has now
now been rendered
been rendered as
rendered as a
a bitmap on
bitmap on the
we have used
have used graphics
used graphics commands
commands to create
create three separate
three separate graphics
separate graphics windows
on the user's
the user's monitor
Two of them
of them have
them have text
The third is
third is set
set as a
as a progress
progress bar and
bar and we
we have additionally
have additionally positioned
additionally positioned the
positioned the jpeg
the jpeg as
jpeg as a
So using these
using these commands
these commands you
can create quite
create quite a
quite a sophisticated
a sophisticated graphics
sophisticated graphics set
graphics set of
set of windows
you'll find its
find its code
its code useful
look at methods
at methods of
methods of searching
of searching large
searching large arrays
There will come
will come a
a time in
time in your
in your development
your development of
development of applications
of applications when
applications when you
when you need
need to deal
to deal with
deal with a
with a great
of the challenges
the challenges of
challenges of developing
developing applications that
applications that are
that are required
are required to
required to deal
deal with volume
with volume data
volume data is
data is where
is where do
where do you
do you get
get the volume
the volume data
volume data when
data when you're
when you're going
to be developing
be developing and
developing and testing?
and testing? Where
testing? Where this
Where this data
this data may
data may well
well be considered
be considered to
considered to be
to be personal
be personal information
personal information, there
may be restrictions
be restrictions on
restrictions on getting
on getting access
getting access to
access to live
to live production
live production data
So there may
be a need
a need to
need to generate
to generate anonymized
generate anonymized data
On the folder
the folder you
folder you can
can see before
see before you
before you, we
have our application
our application which
application which we
we have yet
have yet to
yet to develop
to develop, and
have a folder
a folder called
folder called 'Generate
called 'Generate Data'
is using code
using code we've
code we've developed
we've developed in
developed in previous
in previous applications
Within this folder
this folder we
folder we have
these files stores
files stores raw
stores raw data
For example, 'Cities'
The cities has
cities has a
has a selection
a selection of
selection of fictional
of fictional cities
is the seed
the seed data
seed data we're
data we're going
to use to
use to generate
to generate our
generate our random
our random information
It also has
also has first
has first names
first names, surnames
job titles and
titles and so
use this approach
this approach to
approach to generate
to generate raw
generate raw anonymized
raw anonymized data
anonymized data in
data in any
in any quantity
the code briefly
code briefly, that
that generates this
generates this information
application we're setting
setting a constant
constant to the
value of 50,000
is a number
of records of
records of data
of data that
data that this
that this application
this application is
going to generate
It's pulling in
pulling in a
a library which
which we developed
we developed previously
developed previously called
previously called 'Random
called 'Random Routines'
And the output
from this application
file called 'myLargeFile.Text'
Everything is done
is done within
done within the
within the 'Generate
the 'Generate File'
'Generate File' function
And within this
number of arrays
of arrays to
arrays to store
held within those
within those files
those files we
files we just
we just looked
just looked at
We'll go to
go to 'Generate
to 'Generate a
'Generate a File'
a File' which
File' which has
with the email
the email, through
through the first
and surname and
surname and finishing
and finishing up
finishing up with
up with 'Blood
with 'Blood group'
from the format
the format of
format of the
the header, this
be a tab
a tab delimited
tab delimited file
Should you require
you require a
require a comma
comma delimited file
delimited file, just
just substitute a
substitute a comma
a comma string
comma string for
string for the
for the tab
the tab constant
next part in
part in the
is to load
to load each
load each of
of these static
these static files
static files, these
these seed files
seed files, into
its own array
then once we
we have populated
have populated those
populated those arrays
those arrays, we're
loop for one
for one to
to the maximum
Generating the information
the information and
information and pushing
and pushing it
pushing it out
If we delete
we delete the
delete the 'myLargeFile.Text'
the 'myLargeFile.Text' that
'myLargeFile.Text' that currently
that currently sits
currently sits in
sits in the
folder and we
and we double-click
on the executable
the executable, it
it will launch
will launch and
launch and display
display a little
a little pop-up
little pop-up box
pop-up box telling
box telling you
telling you how
you how far
how far it's
far it's got
can see, it's
it's generating 50,000
generating 50,000 records
50,000 records very
records very quickly
very quickly indeed
It took a
took a mere
a mere nine
mere nine seconds
nine seconds to
seconds to generate
to generate that
generate that information
So should you
you need more
need more than
more than 50,000
than 50,000, you
have to adjust
adjust the constant
the value you
we can copy
can copy this
copy this 'myLargeFile'
this 'myLargeFile' into
'myLargeFile' into our
into our folder
we've actually got
actually got a
got a text
text file in
file in here
in here, let's
can see, it
it contains all
that we asked
we asked it
asked it to
it to generate
So this 50,000
this 50,000 record
50,000 record file
record file we're
going to load
load into one
into one large
one large array
large array inside
array inside our
inside our Power
our Power Basic
Power Basic application
to try three
try three different
three different methods
different methods of
methods of actually
of actually searching
actually searching out
searching out data
going to consider
to consider the
consider the unique
the unique reference
unique reference to
to our record
our record to
record to be
be the email
the email address
email address, which
first column in
column in our
let's now have
create a constant
a constant for
to load in
we will dimension
will dimension an
an array into
into which we're
load that data
functions in one
our libraries, the
Routines Library, to
load this file
this file into
file into our
into our selected
our selected array
The 'read the
'read the file
into an array'
an array' function
array' function, which
which takes two
being the path
path and name
and name of
the file, and
the second, the
load the data
the array sort
array sort command
sort command to
command to sort
to sort the
sort the data
into our array
our array in
array in ascending
ascending order, starting
starting from row
from row number
row number one
Row number zero
number zero are
zero are the
So we'll leave
we'll leave them
leave them at
having got the
got the data
data into the
the array, we're
to try and
try and search
and search some
search some data
some data out
I will create
will create another
another constant at
our application called
application called 'search
called 'search string'
is the email
be looking for
looking for within
for within our
within our file
As the array
the array has
array has been
has been sorted
been sorted alphabetically
sorted alphabetically in
alphabetically in an
in an ascending
an ascending order
ascending order, the
user we're looking
this case Shannon
case Shannon, should
should be fairly
be fairly far
fairly far down
far down the
us a good
a good test
function to search
to search using
search using a
that function 'search'
function 'search' or
'search' or 'next'
or 'next', taking
taking two parameters
being the array
array we want
want to search
to search, and
being the constant
the constant we're
constant we're passing
we're passing into
passing into that
into that function
that function for
function for what
for what we're
what we're looking
case the email
email address of
address of the
Because we want
want to know
to know how
know how long
how long it
long it takes
it takes to
takes to actually
to actually search
actually search this
search this, we
to have some
have some kind
kind of metric
of metric in
metric in here
order to get
a good metric
good metric, I'm
is a command
a command that
command that measures
that measures the
measures the clock
the clock cycles
clock cycles of
cycles of our
of our CPU
easily by defining
by defining a
defining a variable
a variable as
as a quad
can start our
start our count
our count by
count by using
tix command, followed
the variable into
variable into which
into which we
then once our
once our function
our function has
function has completed
has completed, we'll
use the tixn
the tixn command
tixn command to
command to finish
within the qCount
the qCount variable
qCount variable will
CPU cycles which
cycles which we
we can push
can push out
a log to
see how long
how long that
long that took
So now let's
now let's create
create the for
next loop function
our function taking
taking its two
A by-reference array
by-reference array as
array as a
a string, and
and our search
our search string
search string, the
email address we're
address we're looking
be a simple
for next command
command to go
go from 1
bounding of our
of our array
know how big
actually is, the
u-bound command is
command is very
return the upper
the array, the
of records within
records within it
have to compare
to compare the
compare the information
array with our
with our search
The long r
long r element
r element of
array will give
us the data
is the full
the full data
full data for
for that record
that record, including
including the email
email address, the
name and so
We're only interested
only interested in
in the left-hand
the left-hand part
left-hand part of
part of it
of it which
it which is
which is just
is just for
for the length
length of the
of the email
email address, so
using the len
the len command
len command to
out how long
how long the
long the search
the search string
search string is
So if our
if our email
our email address
email address is
address is 25
is 25 characters
25 characters, then
then it's taking
taking the left
the left 25
left 25 characters
25 characters and
characters and comparing
and comparing it
comparing it against
it against the
against the search
Remembering when you're
when you're doing
doing this kind
this kind of
kind of comparison
of comparison, it's
this case, we
we know what
know what we're
looking for, so
so the case
the case should
case should match
should match nicely
If in doubt
in doubt, you
can always use
always use an
use an L
an L case
L case or
case or a
or a U
a U case
U case to
case to force
to force it
force it to
it to upper
to upper or
upper or lower
or lower case
lower case for
case for comparison
for comparison purposes
If this returns
this returns true
returns true, then
we know our
know our entry
our entry has
entry has been
been found, and
can display some
some information on
what we found
we found and
found and what
and what row
what row number
And at that
that point, we
exit the for
So we're pushing
we're pushing out
pushing out the
out the first
the first 50
first 50 characters
50 characters to
characters to let
to let us
let us see
us see what
we found, and
we're reporting on
reporting on the
row number using
number using the
turn the numeric
the numeric variable
numeric variable into
variable into a
a string we
string we can
can display in
display in the
in the log
what we find
have indeed found
indeed found the
found the record
the record we're
record we're looking
looking for on
for on row
on row 45,625
row 45,625, and
and we took
we took just
took just over
just over 18
over 18 million
18 million CPU
million CPU cycles
cycles to find
to find that
find that entry
our baseline for
baseline for using
for using a
loop to search
to search data
search data out
data out from
from the large
the large array
at a second
a second way
second way for
way for searching
for searching our
searching our data
our data from
data from an
from an array
perform this, and
and we'll be
TIX command again
again to count
to count our
count our clock
our clock cycles
function called search
called search array
search array scan
array scan, again
passing just the
just the two
the array, and
and the search
search string we're
string we're actually
we're actually looking
actually looking for
And after that's
after that's run
that's run, we
we will report
will report on
report on a
new function, passing
passing the two
parameters and reporting
and reporting in
reporting in the
see we're searching
we're searching array
searching array scan
the array scan
array scan command
scan command, which
which is inbuilt
inbuilt to PowerBasic
to tell array
tell array scan
array scan is
scan is the
wish to scan
to scan, in
this case, strData
don't know all
know all the
in the record
the record, we
we only want
only want to
want to look
to look, in
this case, at
first column, from
the first character
first character on
character on that
on that record
that record for
record for the
scan command does
command does have
does have an
have an option
an option for
option for scanning
for scanning particular
scanning particular character
particular character positions
character positions, and
That's the from
the from command
can go from
to the length
of our search
As our search
string is an
is an email
an email address
email address, it
it will vary
will vary in
vary in length
I'm folding the
folding the code
the code line
code line down
line down to
following line so
line so you
see it all
it all on
all on one
we're doing an
doing an array
an array scan
array scan on
scan on the
on the strData
the strData array
strData array from
array from character
from character positions
character positions 1
positions 1 to
of our email
looking for it
for it to
it to be
to the parameter
the parameter that's
parameter that's been
for our function
our function, the
search string variable
And should we
should we find
find a value
a value, we're
we're passing that
passing that to
to the longR
the longR variable?
longR variable? If
variable? If a
If a scan
a scan did
scan did not
did not find
not find anything
find anything, it
it would pass
would pass the
pass the value
value 0 back
0 back for
back for that
for that variable
As it's counting
it's counting the
counting the first
the first entry
first entry in
array as entry
as entry number
entry number 1
order to report
to report this
report this correctly
this correctly, we
need to report
to report on
report on longR
on longR minus
longR minus 1
see what these
what these two
these two scans
two scans will
scans will actually
will actually give
actually give us
our first scan
first scan is
scan is giving
is giving us
value of And
of And the
us a slightly
a slightly shorter
slightly shorter 15.6
shorter 15.6 million
15.6 million cycles
So at first
at first glance
first glance, it
it would appear
would appear that
appear that the
that the array
scan is taking
is taking slightly
taking slightly less
slightly less time
less time to
time to scan
to scan for
scan for our
for our data
So next, we're
be doing an
doing an index
an index search
is our third
our third and
third and final
and final method
final method of
method of scanning
of scanning this
scanning this array
With an index
index search, the
thing we'll need
is to index
to index the
index the array
a slight bit
slight bit of
bit of overhead
of overhead on
overhead on the
on the system
So we'll count
we'll count this
count this separately
this separately to
separately to see
takes to do
do an index
an index on
index on our
on our 50,000
our 50,000 records
TIX command to
how many clock
many clock cycles
clock cycles we're
cycles we're going
to be taking
I'll set up
up a local
variable called 'unique
called 'unique field'
'unique field' to
field' to specify
specify the field
the field number
field number we're
number we're interested
it's the first
the first field
first field in
field in the
setting the delimiter
the delimiter as
delimiter as being
being a tab
to use delimiters
use delimiters other
delimiters other than
other than tabs
to create an
create an index
an index array
idea behind an
behind an index
index array is
array is that
is that we
records within this
They're currently sorted
currently sorted alphabetically
sorted alphabetically, so
all the email
the email addresses
email addresses starting
addresses starting with
with A will
A will appear
will appear at
appear at the
So for any
for any email
any email address
email address starting
address starting with
starting with letter
with letter A
letter A, its
its start index
start index will
index will be
will be row
row number 1
Its end index
end index will
be the last
the last record
last record which
record which begins
which begins with
begins with A
with A in
A in the
in the email
The next letter
next letter would
letter would be
would be B
be B and
B and it
it will start
will start from
start from one
from one more
one more than
more than that
than that and
that and go
and go up
the last one
last one of
one of B
we'll have a
have a start
a start and
start and an
an end index
end index for
index for each
for each letter
each letter A
letter A to
A to Z
you require to
require to have
to have indexes
have indexes on
indexes on numbers
on numbers, you
use this slightly
this slightly different
slightly different method
But the idea
the idea being
idea being is
being is if
is if all
email addresses are
addresses are equally
are equally distributed
equally distributed between
distributed between letters
between letters, then
able to search
to search only
search only 1
only 1 address
1 address you're
address you're looking
you're looking for
So in theory
in theory, it
should be faster
be faster once
faster once the
once the index
the index has
index has been
is an index
an index, a
a setup as
setup as 30
as 30 rows
30 rows and
rows and 2
and 2 columns
new function, index
index array, which
which is taking
is taking a
taking a number
the array which
array which we
want to index
to index, the
being the index
the index itself
index itself, and
next two parameters
two parameters are
parameters are the
are the unique
the unique field
unique field number
field number and
and the delimiter
the delimiter in
delimiter in our
in our records
after that, we
we will end
will end our
end our clock
our clock counting
clock counting and
counting and display
and display the
display the number
CPU cycles it's
cycles it's taken
it's taken to
taken to generate
to generate this
generate this index
now create the
create the index
the index array
index array function
function with its
with its parameters
This function assumes
function assumes that
assumes that the
array has already
already been sorted
It will need
be sorted prior
sorted prior to
prior to our
to our indexing
our indexing operation
An index variable
index variable, a
a current variable
current variable, a
a slot number
slot number, which
will be between
be between 1
1 and 26
and 26, as
is the character
the character that
character that starts
that starts each
starts each email
each email address
email address being
address being A
being A to
And finally, a
a unique ID
unique ID variable
The unique ID
unique ID is
ID is pulling
is pulling out
pulling out the
first column, based
on the delimiter
In this scenario
this scenario, this
email address, but
but it could
it could quite
could quite easily
quite easily be
easily be the
be the first
first name of
user or the
or the surname
the surname of
surname of the
we're extracting from
extracting from that
from that unique
that unique ID
unique ID the
ID the very
very first character
Should that value
that value be
value be blank
be blank, then
then we're skipping
we're skipping on
skipping on to
we determine which
determine which slot
which slot in
slot in our
our index array
index array this
array this is
is actually going
using the ASCII
the ASCII command
ASCII command to
to turn that
turn that first
that first character
first character into
character into an
into an ASCII
an ASCII value
ASCII value, and
and then subtracting
then subtracting 96
subtracting 96 from
96 from it
for the letter
letter A, this
you the value
the value 1
the first slot
first slot in
whether the value
of the index
index has actually
actually changed from
changed from the
we can save
can save the
save the details
details to our
to our indexed
our indexed array
using two constants
two constants here
constants here for
here for the
the start and
start and end
and end, just
just for documentation
for documentation purposes
And by the
by the time
the time we
time we get
to the very
the very last
very last value
last value in
in our array
our array, we
pick up that
up that and
that and mark
and mark its
mark its index
its index end
index end as
end as being
being the upper
the array itself
will create these
these two constants
two constants at
Index start and
start and indexed
and indexed end
see the value
first two scans
CPU cycles for
cycles for our
for our indexing
indexing operation are
operation are almost
are almost 62
almost 62 million
is quite an
quite an overhead
an overhead, and
and larger than
larger than both
than both of
the original searches
original searches combined
have to index
to index this
index this array
this array once
and make use
of this index
create another new
function called search_indexed
to take three
The two we've
two we've had
we've had for
had for the
for the previous
the previous functions
previous functions, and
and the additional
the additional parameter
additional parameter is
parameter is our
is our index
our index, the
the one we
have just generated
once that function
function is complete
is complete, we
will then throw
then throw out
throw out the
cycles to our
create this final
this final function
function taking in
taking in these
in these three
these three parameters
The data array
data array, the
search string and
string and our
and our indexed
So as with
the previous fornix
previous fornix loop
fornix loop, we're
create a fornix
a fornix loop
fornix loop in
we did when
did when we
when we indexed
we indexed the
indexed the array
up the first
first character of
character of our
be a letter
a letter between
letter between A
between A and
A and Z
going to calculate
to calculate which
calculate which slot
which slot this
slot this is
going to come
to come into
And having determined
determined that slot
that slot number
slot number, we
can pull out
pull out from
from the indexed
the indexed array
indexed array the
array the start
and end row
end row numbers
row numbers, which
need to scan
it's a straightforward
a straightforward matter
straightforward matter of
matter of using
But rather than
rather than scanning
than scanning the
scanning the whole
the whole array
whole array, we're
we're only scanning
only scanning for
scanning for the
and end rows
end rows that
rows that we
that we know
know that this
this particular email
particular email address
email address should
address should be
should be sitting
be sitting in
once we find
we find an
find an entry
an entry, we
can then throw
then throw a
throw a message
a message out
message out to
see which row
which row number
row number we
number we found
we found it
found it on
have our scans
our scans in
scans in place
loop is taking
is taking almost
taking almost 17
almost 17 million
17 million CPU
scan is now
is now down
down to 5
to 5 million
5 million cycles
indexed array scan
scan is less
less than 1
than 1 million
1 million CPU
it did have
did have an
have an overhead
an overhead of
overhead of 66
of 66 million
66 million CPU
cycles to generate
to generate the
generate the index
So to answer
to answer the
answer the question
the question which
question which of
of the three
the three methods
three methods is
methods is the
is the most
the most efficient
most efficient way
efficient way of
way of scanning
of scanning large
scanning large data
large data, it
it depends on
depends on what
on what your
what your application
be doing and
doing and how
and how often
how often it's
often it's going
be doing it
If you're looking
looking for only
for only one
only one record
one record in
record in a
in a large
a large array
large array, then
then either the
either the for
next loop or
loop or the
or the array
is the way
the way to
way to go
If you'll be
you'll be scanning
be scanning this
scanning this large
this large array
large array many
array many times
many times, then
then doing an
index on the
on the array
array is the
is the easiest
the easiest and
easiest and fastest
and fastest way
fastest way of
of actually getting
actually getting it
getting it to
it to run
to run quickly
easily see that
see that by
that by putting
by putting in
putting in a
in a scan
a scan for
scan for two
for two email
two email addresses
email addresses rather
addresses rather than
rather than one
a second search
second search string
search string at
string at the
we're now looking
now looking for
looking for two
So we paste
we paste in
paste in a
in a second
a second call
second call to
to the search
the search for
search for next
for next and
next and the
we'll add a
add a second
second call into
call into our
our index scan
So all three
all three of
three of these
of these methods
these methods of
of searching our
searching our email
our email addresses
addresses are going
be called twice
the first scan
first scan for
email addresses, it
it was 34
was 34 million
array scan, it
it was 10
was 10 million
for the index
index array, it
it was a
was a mere
a mere 3.4
mere 3.4 million
So the more
the more times
more times we
times we scan
we scan this
scan this large
large array, the
the more efficient
more efficient the
efficient the index
the index search
index search appears
search appears to
Hopefully this will
give you food
you food for
food for thought
for thought in
thought in developing
in developing your
developing your applications
your applications where
applications where large
where large data
large data is
data is involved
at how to
how to use
to use Link
use Link List
Link List Collections
List Collections within
Collections within your
to look again
again at collections
at collections under
collections under PowerBasic
under PowerBasic supported
PowerBasic supported, both
compiler and Windows
and Windows compiler
prepare a list
a list collection
can start this
start this by
this by declaring
by declaring a
variable called list
called list collect
to be declared
be declared as
declared as an
as an I-Link-List-Collection
an I-Link-List-Collection and
I-Link-List-Collection and we
set the class
the class to
class to be
to be Link-List-Collection
we've done with
done with previous
with previous videos
previous videos on
videos on collections
on collections we're
collections we're going
be using variants
using variants today
variants today to
today to put
to put data
put data into
data into and
into and take
and take data
take data out
out of this
of this collection
as a variant
a variant to
variant to contain
to contain our
contain our data
And our data
our data is
data is simply
is simply going
simply going to
a text string
text string called
string called test
number of methods
and properties with
properties with this
with this particular
this particular class
But first of
of all we'll
all we'll use
use the clear
the clear method
clear method to
method to clear
to clear anything
clear anything out
anything out of
Now since we've
since we've just
we've just created
just created the
created the collection
the collection the
collection the collection
the collection will
collection will be
will be empty
be empty but
empty but it
but it demonstrates
it demonstrates the
demonstrates the use
of the clear
clear method so
method so that
so that at
that at any
any point you
point you can
you can clean
can clean out
clean out a
out a collection
a collection very
collection very easily
very easily with
easily with a
Simple by using
using the name
the collection, in
this case list
case list connect
list connect dot
connect dot clear
We followed that
followed that with
with a message
log to return
return the count
the count of
number of items
of items in
items in our
Since our collection
our collection is
collection is entirely
is entirely empty
entirely empty this
empty this should
this should return
should return zero
does indeed return
indeed return the
the value zero
value zero for
zero for the
of items within
items within our
within our collection
to put our
put our test
our test string
test string into
string into the
the collection we
collection we can
So that's list
that's list connect
connect dot add
dot add followed
add followed in
in brackets by
brackets by the
of the variant
the variant which
variant which contains
contains our data
to write our
write our log
our log again
log again to
how many items
many items are
items are in
the collection which
collection which should
should now return
now return the
the value one
So our data
our data has
data has now
now been added
let's add another
add another piece
another piece of
of data and
data and we
will then attempt
then attempt to
attempt to pull
to pull information
pull information out
we're adding a
adding a new
a new string
new string to
string to our
collection and we're
loop to pull
a variant called
variant called item
called item output
item output and
output and we're
using the for
the for each
for each construct
each construct to
construct to pull
of our collection
for each item
each item output
item output in
output in the
the list collect
list collect and
collect and we
can push that
push that out
the log by
log by using
turn the variant
the variant back
variant back into
see we're putting
we're putting out
putting out to
log the two
the two items
two items we
items we have
have in our
The string test
string test and
string test to
test to data
So from this
from this construct
this construct you
construct you can
can see it's
see it's very
it's very easy
very easy to
easy to pull
to pull all
pull all the
the collection using
collection using a
using a simple
since we now
have two items
two items in
items in the
the collection how
collection how do
go about inserting
about inserting a
inserting a new
a new item
new item between
item between items
between items one
items one and
use the insert
the insert method
insert method with
method with an
an index number
variable called index
set the value
of that to
that to two
to two and
two and we'll
and we'll use
insert method to
method to insert
to insert our
insert our new
new data at
at the second
the second item
second item position
will take what
take what is
what is currently
is currently in
currently in item
in item two
item two and
two and move
move it down
to item three
So our collection
our collection will
collection will now
will now have
now have three
have three items
three items in
items in it
in it and
it and the
the new data
new data will
will be item
be item number
item number two
be pulling data
pulling data out
the collection on
collection on a
on a regular
a regular basis
regular basis within
basis within this
within this video
this video I'm
video I'm going
a small macro
small macro that
macro that duplicates
that duplicates this
duplicates this piece
call this macro
this macro display
macro display list
have used macros
used macros in
macros in some
in some of
the previous videos
previous videos to
videos to make
readable and a
and a little
a little less
little less verbose
What this macro
this macro will
macro will do
will do at
do at compile
compile time is
time is it
is it will
will take all
take all the
code within the
within the macro
the macro and
macro and put
into the main
the main body
main body of
application and then
then the compilation
the compilation will
compilation will continue
So from a
from a programmer's
a programmer's perspective
programmer's perspective we
perspective we merely
put a single
in to get
to get this
get this information
this information pulled
information pulled out
collection and sent
and sent to
sent to our
However I'll spend
I'll spend a
spend a moment
a moment looking
moment looking at
looking at what
at what we're
we're doing inside
doing inside this
inside this macro
this macro we're
macro we're passing
passing the name
our collection on
collection on the
using the macro
the macro temp
macro temp construct
It's followed by
by a declaration
a declaration of
declaration of that
that variable as
will be calling
calling this macro
this macro multiple
macro multiple times
multiple times within
times within our
within our function
our function without
function without using
without using macro
using macro temp
macro temp it
temp it would
it would fail
would fail at
fail at compile
compile time as
time as you're
attempting to declare
to declare the
declare the item
the item output
item output variable
output variable multiple
variable multiple times
What macro temp
macro temp does
temp does is
does is each
is each time
each time it
time it is
it is called
is called it
called it appends
it appends to
appends to the
the name a
name a four
a four digit
four digit number
digit number starting
number starting at
starting at one
at one and
one and incrementing
and incrementing each
incrementing each time
saves you as
you as a
as a programmer
a programmer having
programmer having to
having to worry
to worry about
worry about this
about this issue
So following that
following that we
have a for
a for each
for each next
each next loop
This is pulling
is pulling information
pulling information out
our list collect
list collect collection
collect collection putting
collection putting it
into the item
output variable which
which we're then
we're then sending
then sending out
sending out to
we will simply
will simply take
simply take this
take this single
of code paste
code paste it
paste it in
it in after
in after our
after our last
our last commands
last commands and
commands and this
and this should
this should send
should send the
send the information
information that's now
that's now in
now in a
in a collection
a collection out
collection out to
that now and
see if new
if new data
new data slots
data slots in
slots in to
the second index
second index position
there is new
is new data
new data in
data in as
as the second
Test2 data has
has been moved
been moved down
to the third
the third item
third item and
item and our
and our macro
our macro is
macro is working
quite nicely to
nicely to display
to display what's
display what's in
what's in the
So having built
having built up
built up a
up a collection
collection of three
of three items
three items can
items can we
can we now
we now delete
now delete an
delete an item
an item by
item by index
by index position
can perform a
perform a deletion
a deletion by
deletion by specifying
specifying the index
the index we
index we wish
this case we
case we want
to remove the
remove the first
first item in
item in our
We're then calling
calling the remove
remove method and
method and we're
we're giving a
giving a parameter
a parameter which
parameter which contains
contains our index
our index number
index number in
number in this
this case index
case index number
index number one
This will remove
will remove the
first item from
item from a
from a collection
a collection and
collection and item
and item two
item two will
two will become
will become item
become item one
then re-display our
re-display our list
So we'll see
first item which
item which was
was the test
the test string
test string has
string has now
has now disappeared
now disappeared from
disappeared from our
from our collection
collection and we
now have only
have only two
only two items
two items left
items left in
left in the
So it's very
easy to remove
to remove an
remove an item
item by its
by its index
its index number
So having deleted
having deleted an
deleted an item
an item can
item can we
can we replace
we replace an
replace an item
an item that
item that already
that already exists
We can indeed
can indeed by
indeed by using
using the replace
the replace method
Again we set
set the index
the index number
use the replace
the replace and
replace and we
and we specify
specify the index
the index and
index and the
data that we
want to slot
to slot in
slot in to
in to that
that particular index
particular index place
first item no
item no longer
no longer is
longer is called
is called new
called new data
It's now called
now called newer
called newer data
successfully replaced the
replaced the first
item in the
the collection with
collection with some
with some different
some different data
When building up
building up a
a collection there
collection there is
an index maintained
index maintained for
maintained for the
the next position
next position so
position so that
you add an
add an item
an item to
item to the
the collection it
collection it knows
it knows where
knows where to
where to put
the current index
current index by
index by using
using the index
the index property
our index variable
index variable to
the output form
output form listconnect.index
form listconnect.index with
listconnect.index with a
with a zero
a zero in
zero in the
us the current
current index and
index and we
pull out the
items in a
a collection by
collection by using
by using count
see the current
current index is
index is showing
showing as 3
The reason it
reason it is
it is showing
showing as number
as number 3
number 3 is
3 is number
is number 3
3 is the
is the next
next available position
available position for
position for new
for new data
new data to
data to be
to be inserted
be inserted into
the collection is
collection is 2
is 2 so
2 so the
the next free
next free slot
free slot would
slot would be
would be slot
be slot number
slot number 3
let's add some
some more data
data to collection
to collection to
collection to make
make it bigger
created a for
populate our variant
our variant with
variant with the
with the string
the string item
string item plus
item plus the
plus the item
give us items
us items 1
items 1 to
to 5 and
5 and we're
calling the add
add method to
method to add
add these to
these to our
now we should
should have five
have five additional
five additional pieces
of information added
information added to
we are with
are with seven
with seven items
seven items on
items on the
on the collection
the collection now
So now we're
now we're going
the last position
last position in
position in our
So it should
be sitting at
sitting at item
at item number
item number 5
perform this quite
by using listcollect.last
the last item
last item on
very last item
last item which
item which is
free slot we
slot we can
can use previous
use previous to
previous to move
to move back
move back through
back through the
through the collection
So the very
last item is
item is going
to come out
come out and
out and then
to call previous
call previous again
previous again to
again to get
the next last
see it's displaying
it's displaying the
displaying the last
last item as
item as item
as item number
number 5 and
5 and the
next last is
last is item
is item number
item number the
number the collection
the collection either
collection either from
either from the
from the beginning
the beginning using
beginning using next
using next or
next or from
or from the
from the last
the last entry
last entry using
entry using last
using last and
last and previous
So let's start
let's start from
start from the
from the other
the other end
other end of
collection and set
and set it
very first item
Easily done by
done by using
by using listcollect.first
can then pull
then pull out
the first by
first by using
using the next
next command and
next one on
one on the
the list coming
list coming out
coming out using
out using next
using next once
next once more
see the first
first item comes
item comes out
comes out as
out as newer
as newer data
newer data and
data and the
the next as
next as test2data
So it has
has successfully moved
successfully moved the
moved the index
the index back
index back to
However what if
if we wanted
wanted to pull
pull the entry
the entry out
entry out of
the collection by
collection by the
by the index
index itself rather
itself rather than
rather than having
than having stepping
having stepping through
stepping through from
through from the
the beginning or
beginning or the
or the end
perform this by
by using listcollect.item
using listcollect.item followed
listcollect.item followed in
want the fourth
the fourth item
fourth item on
is our fourth
our fourth item
fourth item which
which is item
item number 2
The fourth one
fourth one in
So far we've
far we've been
we've been populating
been populating our
populating our collection
our collection using
collection using variants
using variants which
variants which are
which are containing
are containing dynamic
containing dynamic strings
However you're not
you're not limited
not limited to
limited to just
to just dynamic
just dynamic strings
can also put
also put arrays
put arrays into
arrays into our
into our collection
our collection as
collection as we've
we'll now prepare
now prepare an
prepare an array
an array and
array and add
and add this
add this to
this to our
we are dimensioning
are dimensioning an
array with three
with three elements
three elements going
elements going from
0 to 2
to 2 as
2 as a
as a dynamic
a dynamic string
dynamic string array
then assign values
assign values to
values to those
to those three
those three elements
three elements using
we're assigning a1
assigning a1 b1
a1 b1 and
b1 and c1
and c1 to
c1 to those
three elements within
elements within that
within that array
then populating our
populating our variant
our variant by
variant by let
by let item
let item input
item input equals
input equals and
equals and the
did before we're
add method and
method and that
and that variant
that variant to
variant to our
our collection just
collection just as
with the dynamic
the dynamic strings
However to output
to output this
output this to
our console or
console or to
or to get
information out we
out we need
that the variant
the variant coming
variant coming back
coming back out
back out of
collection is an
array as opposed
to a dynamic
going to clone
to clone this
clone this macro
this macro and
macro and we'll
this new macro
new macro display
display list underline
list underline EX
I've left the
left the original
the original macro
original macro in
macro in place
in place so
place so you
see how the
how the code
the code worked
code worked previously
order to support
support this we're
more variables to
contain the data
the data which
which is held
to be coming
be coming out
from the variant
add to our
to our macro
our macro temp
macro temp list
temp list two
list two additional
two additional values
the array we're
be using and
using and one
one for a
for a for
next loop count
will dimension those
dimension those underneath
It's important that
important that we
that we dimension
we dimension the
as a zero
zero element array
as before we're
before we're still
still using for
for each to
each to go
go through each
element within our
use the variant
the variant vt
variant vt command
vt command to
command to test
test the type
variant which is
same construct we've
construct we've used
we've used in
used in previous
previous videos for
videos for collections
using a select
statement to test
test the variant
the variant type
If the variant
variant type is
type is both
is both dynamic
both dynamic string
dynamic string and
string and array
and array we
array we know
string of a
of a coming
a coming out
If it's just
it's just a
just a dynamic
dynamic string then
string then we
handle that as
that as we've
done before by
before by sending
by sending the
sending the message
the message out
log using variant
using variant dollar
variant dollar to
dollar to convert
to convert the
convert the variant
for the string
the string array
string array we're
array we're using
using the let
the let command
let command to
with the variant
the variant data
then use a
next loop going
loop going from
going from the
from the lower
lower bounding of
array we've just
we've just received
just received to
received to the
This allows it
allows it to
it to work
just how big
And for each
each item in
array we're pushing
we're pushing the
pushing the information
we've created this
created this macro
this macro we
macro we can
can now call
now call this
call this after
this after our
after our collection
our collection has
collection has been
we're on the
on the code
see we're printing
printing out to
the log all
log all the
all the items
the items in
the collection plus
collection plus the
plus the three
the three items
three items that
items that are
that are in
have successfully added
successfully added both
added both dynamic
both dynamic strings
dynamic strings and
strings and an
is we've created
created a linked
a linked list
linked list collection
We've shown we
shown we can
we can count
can count how
the collection, we
can add new
add new items
new items, we
can insert items
insert items into
items into the
into the existing
the existing collection
existing collection using
collection using an
using an index
an index, we
the index on
collection to the
can use either
use either the
either the previous
the previous or
previous or the
or the next
the next commands
next commands to
commands to step
step through the
the collection one
collection one item
one item at
item at a
quite easily step
easily step through
through the entire
the entire collection
entire collection by
next loop and
loop and we've
and we've demonstrated
we've demonstrated the
demonstrated the use
use of macros
of macros to
macros to save
you time and
time and tidy
and tidy up
tidy up your
look at running
at running your
running your applications
your applications on
applications on Linux
on Linux Mint
see we're doing
doing something a
something a little
a little different
little different today
currently running Linux
running Linux Mint
would be Linux
be Linux Mint
Linux Mint version
Mint version This
version This is
is to answer
to answer a
answer a question
a question from
question from one
from one of
of our subscribers
Can PowerBasic applications
PowerBasic applications run
applications run under
run under Linux?
under Linux? So
Linux? So we'll
start to answer
to answer that
answer that question
that question today
All I have
have added to
to this version
this version of
version of Linux
of Linux Mint
Linux Mint is
Mint is Wine
Wine is an
is an application
to allow you
you to run
to run Windows
run Windows programs
Windows programs on
programs on Linux
is an acronym
an acronym that
acronym that stands
that stands for
stands for Wine
for Wine is
Wine is not
not an emulator
Wine works by
works by redirecting
by redirecting calls
redirecting calls to
to the kernel32.dll
These root calls
root calls are
calls are redirected
are redirected to
redirected to parts
to parts of
of the Linux
the Linux system
Linux system to
system to perform
to perform the
perform the actions
the actions you
you wish in
wish in the
we have plugged
have plugged in
plugged in a
in a USB
a USB drive
USB drive which
drive which has
has a couple
couple of PowerBasic
of PowerBasic applications
PowerBasic applications on
applications on them
These applications have
applications have not
have not been
not been recompiled
been recompiled under
recompiled under Linux
They are as
are as they
they were compiled
were compiled under
compiled under PowerBasic
under PowerBasic Windows
PowerBasic Windows and
Console Compilers on
Compilers on a
on a Windows
a Windows 10
Windows 10 computer
we've now opened
now opened up
opened up a
a folder on
folder on our
on our USB
our USB drive
is the AutoForm
the AutoForm project
AutoForm project we've
project we've run
we've run in
run in a
This application has
application has two
has two executables
two executables, a
a FormRunner application
FormRunner application which
application which gives
the forms you
forms you can
you can pick
the FormRunner, it
will run and
run and display
and display our
display our dialog
This dialog is
dialog is showing
is showing the
showing the two
the two configuration
two configuration files
we pick the
pick the first
the first configuration
first configuration file
configuration file and
file and click
and click the
click the Run
Run Form, this
this will run
will run a
run a separate
a separate executable
This executable will
executable will display
screen a dialog
a dialog of
dialog of which
of which all
all the configuration
the configuration is
configuration is stored
stored in an
see the dialog
the dialog has
dialog has successfully
has successfully appeared
successfully appeared on
appeared on the
Each object on
object on the
dialog is configured
configured in a
in a config
a config file
use the navigation
the navigation bars
navigation bars, which
which are showing
are showing the
showing the tooltips
the tooltips, to
the forms stored
forms stored in
the data file
have an icon
icon on which
on which we
can click to
click to give
us a list
all the forms
the forms currently
forms currently keyed
from this, this
this PowerBasic Windows
PowerBasic Windows application
Windows application appears
application appears to
be working fine
Let's just go
just go to
the last form
last form, which
which is currently
is currently unpopulated
currently unpopulated, and
we'll put some
put some data
data in here
And finally we'll
finally we'll change
we'll change the
change the date
when we hit
hit the OK
the OK button
OK button, this
should save it
save it back
to our file
And it should
now be displayed
displayed in our
There we go
Linus user, So
So the running
the running of
running of our
of our PowerBasic
our PowerBasic Windows
to be successful
So let's come
let's come out
this application and
application and let's
and let's try
try running a
running a console
into the associated
the associated arrays
associated arrays, we
we try to
try to run
run the executable
this is successfully
is successfully bringing
successfully bringing up
bringing up on
screen a console
a console window
And displaying all
displaying all the
that we got
we got when
got when we
when we ran
we ran it
ran it on
it on a
a Windows machine
So this application
application has successfully
has successfully used
successfully used the
used the Power
the Power Collections
Power Collections class
Collections class within
class within PowerBasic
within PowerBasic itself
can see, so
so far it
far it seems
it seems very
seems very straightforward
very straightforward to
straightforward to run
run Windows applications
Windows applications on
applications on a
on a Linux
a Linux machine
Linux machine, specifically
specifically on Linux
I would stress
would stress that
stress that these
that these applications
these applications were
applications were not
were not compiled
not compiled on
compiled on PowerBasic
on PowerBasic running
PowerBasic running under
running under Linux
applications were compiled
were compiled on
compiled on Windows
on Windows 10
Windows 10, running
running the PowerBasic
we'll try in
try in part
in part two
part two to
two to actually
to actually compile
actually compile applications
compile applications on
on Linux itself
of macros in
macros in your
So what kind
kind of macros
of macros are
macros are there?
are there? We
there? We have
We have single
have single line
single line where
line where your
where your code
code is all
is all in
all in a
in a line
a line, Multiline
Multiline where the
where the macro
the macro contains
macro contains several
contains several lines
several lines of
of code, Macro
Macro Functions where
Functions where the
the macro returns
macro returns a
to cover both
both the single
the single line
single line and
line and multiline
and multiline macros
multiline macros, and
and save the
save the macro
the macro function
macro function till
function till the
till the next
some of our
of our recent
our recent videos
recent videos we
videos we have
used macros, but
but this will
the first video
first video in
video in which
in which we
which we go
go into macros
into macros in
macros in detail
in detail and
detail and explain
and explain what
explain what exactly
what exactly they
exactly they are
and what you
do with them
Inside PowerBasic a
PowerBasic a macro
a macro is
macro is a
is a powerful
a powerful text
powerful text substitution
text substitution construct
substitution construct that
construct that, as
have said, can
used in three
in three ways
have a single
single line macro
line macro, a
a multiline macro
multiline macro, or
or a macro
a macro function
This video is
video is going
cover the single
line and the
and the multiline
the multiline macros
A macro generates
macro generates no
generates no executable
no executable code
executable code unless
code unless it
unless it is
it is actually
is actually referenced
Therefore you can
you can set
can set your
set your macros
your macros up
macros up in
up in an
include file quite
file quite safely
let's create some
create some macros
some macros and
macros and show
and show how
show how they
how they are
they are used
If we demonstrate
we demonstrate first
demonstrate first of
all the single
line macro, what
we've done here
here is we've
created a macro
a macro called
macro called mPI
As my own
my own personal
own personal naming
personal naming convention
naming convention I
convention I tend
tend to precede
to precede the
precede the name
of the macro
with the letter
the letter M
to indicate later
indicate later on
later on in
the code, and
and especially where
especially where someone
where someone else
someone else is
else is looking
is looking at
looking at my
at my code
my code, that
indeed a macro
a macro keyword
macro keyword followed
keyword followed by
of our macro
our macro, mPI
value of pi
of pi to
pi to quite
to quite a
quite a number
number of decimal
of decimal places
here is setting
setting up our
up our pi
our pi as
pi as a
will see here
see here, the
the pi value
pi value has
value has at
has at the
of the numbers
the numbers two
numbers two hash
two hash signs
This is indicating
is indicating to
indicating to Power
the number we
number we are
we are providing
are providing is
providing is to
used as an
as an extended
an extended format
will allow 18
allow 18 significant
18 significant digits
significant digits, which
which should be
should be more
be more than
more than enough
than enough for
enough for use
for use of
use of pi
that we've defined
we've defined our
defined our single
our single line
line macro, giving
giving a value
to the mPI
the mPI, how
we use this
use this in
the code? What
code? What we
on screen now
screen now is
now is a
message to send
to send the
send the value
pi to our
So you'll see
you'll see in
we have referenced
have referenced mPI
When you go
you go to
go to compile
to compile your
compile your application
your application, the
the text mPI
text mPI is
mPI is replaced
is replaced with
with the actual
For example, this
This keeps your
keeps your code
your code quite
code quite clean
quite clean and
clean and succinct
using the str$
the str$ command
str$ command to
to turn this
turn this numerical
this numerical value
numerical value into
have used the
used the optional
optional parameter, comma
comma 18, to
say we want
want this to
this to 18
to 18 significant
see it prints
it prints out
prints out 18
out 18 significant
significant digits with
digits with a
with a value
a macro in
macro in this
this way allows
way allows you
you to effectively
be easily demonstrated
easily demonstrated by
demonstrated by another
by another use
another use of
of a single
What we've put
we've put on
put on screen
on screen is
screen is macro
is macro, n
n release package
release package equals
package equals macro
It may take
may take you
take you a
you a moment
moment to get
to get your
get your head
your head around
head around just
around just what
just what exactly
what exactly we've
exactly we've done
When you attempt
compile your code
your code, any
any evidence of
evidence of the
of the mReleasePackage
the mReleasePackage will
mReleasePackage will be
will be replaced
be replaced by
replaced by the
actually use this?
use this? Say
this? Say for
to store two
store two pieces
information on this
this particular piece
particular piece of
store the build
the build version
build version and
version and the
and the version
the version number
using the mReleasePackage
the mReleasePackage followed
mReleasePackage followed by
the word 'build
word 'build version'
'build version' equals
version' equals 'alpha
equals 'alpha build'
Now as you'll
you'll note, we
we haven't done
haven't done any
done any declaration
any declaration of
declaration of 'build
of 'build version'
'build version' or
version' or for
or for that
that matter 'ver
matter 'ver number'
But when the
the application compiles
application compiles, the
be replaced as
replaced as a
as a piece
text with the
this is effectively
is effectively extending
effectively extending your
extending your language
your language to
language to have
to have anything
have anything you
anything you wish
put into a
into a macro
would we reference
we reference that
reference that in
the code? If
wanted to send
to send this
send this to
our log, we
can put a
of text out
text out saying
out saying 'release
saying 'release build
'release build version
build version equals'
version equals' and
equals' and then
and then just
then just use
just use the
use the word
to be already
be already set
set up with
up with the
the value alpha
value alpha build
And the ver
the ver number
ver number is
number is going
come out with
out with our
with our version
our version number
we'll see those
see those details
those details appearing
details appearing on
appearing on our
So it doesn't
it doesn't take
doesn't take long
take long to
long to realise
to realise you
realise you can
use this construct
this construct to
construct to extend
to extend the
the language type
language type you
type you can
can use within
use within PowerBasic
So having looked
having looked at
at the single
do with multi-line
with multi-line macros?
multi-line macros? Say
macros? Say for
for example in
example in our
our code we
code we wanted
wanted to set
local variable, in
case a string
variable called 'strData'
set a default
a default value
default value to
value to that
to that string
be a comma
list of five
of five numbers
This could well
well be something
be something you'll
something you'll do
you'll do in
do in your
And you may
you may prepare
may prepare several
prepare several variables
several variables with
variables with the
with the same
the same default
same default values
values to be
be changed later
changed later on
So is there
is there an
there an easier
an easier way
easier way of
way of using
macro to set
set these default
these default values
default values up
values up for
up for you?
for you? We'll
you? We'll now
We'll now use
now use a
use a macro
a macro, which
is a multi-line
a multi-line macro
multi-line macro, to
set up this
up this construct
this construct for
construct for you
is the construct
the construct we're
construct we're going
to call our
call our macro
our macro 'mPrepFormat'
the code here
code here, it
be taking a
taking a parameter
a parameter, 'strVariable'
But unlike functions
unlike functions and
and subroutines, you'll
you'll see the
see the type
of this is
is not declared
It's not showing
not showing 'Is
showing 'Is strVariable
'Is strVariable as
strVariable as string?'
as string?' The
string?' The reason
this is this
is a straight
a straight substitution
Whatever we pass
we pass in
pass in as
as a parameter
a parameter is
parameter is going
be used inside
used inside the
inside the macro
So the two
we have within
have within this
within this macro
this macro are
macro are first
are first of
all to declare
to declare 'strVariable
declare 'strVariable as
'strVariable as a
as a string'
case the variable
is not actually
not actually called
actually called 'strVariable'
called 'strVariable', this
is a substitution
pass in on
on the parameter
parameter list is
list is going
to be substituted
be substituted for
substituted for the
for the declaration
the declaration of
declaration of the
to make whatever
make whatever that
whatever that variable
that variable is
variable is equal
is equal to
equal to our
to our comma
our comma delimited
of five values
let's try that
try that out
that out in
will first comment
first comment out
comment out where
out where we
where we put
put the lines
the lines in
lines in normally
will now put
now put in
put in our
in our single
single line 'macro
line 'macro mPrepFormat'
Containing the name
variable we wish
wish to first
to first of
of all declare
all declare and
declare and secondly
and secondly populate
we will send
will send the
that variable out
variable out to
we get 'strData'
get 'strData' equals
'strData' equals and
and the five
the five comma
five comma delimited
comma delimited numbers
delimited numbers appearing
numbers appearing on
So what this
what this single
of code has
code has done
has done is
done is it
it has declared
has declared the
declared the variable
the variable you
variable you have
you have specified
have specified and
specified and it
it has populated
has populated it
with a default
All done in
code in your
This becomes particularly
becomes particularly useful
particularly useful if
useful if you're
you're doing a
of different variables
different variables, all
all to be
to be prepared
be prepared in
prepared in the
to prepare three
prepare three additional
additional variables, data2
data3 and data4
to set data4
set data4 with
data4 with a
a different format
different format, so
so we'll set
we'll set up
up a different
a different macro
different macro to
macro to perform
perform that one
For this new
new macro we're
two parameters rather
parameters rather than
do something with
the data we're
to be putting
be putting into
putting into that
into that variable
the code, we're
we're using local
using local and
local and whatever
whatever the variable
variable is to
is to declare
then populating that
populating that variable
data that's come
that's come in
in on our
on our parameters
we add these
add these additional
these additional variables
additional variables to
variables to our
to our output
our output log
output log and
log and then
and then run
then run the
the application, we'll
we'll see the
the values come
values come out
come out quite
out quite happily
of variables to
variables to declare
to declare and
declare and populate
and populate with
populate with a
default value, this
you a very
a very easy
very easy and
easy and fast
and fast way
fast way of
way of doing
doing it in
it in your
PowerBasic compiles, it
it will expand
will expand the
expand the macros
the macros out
macros out into
out into the
do something more
something more complex
with a user
So let's declare
defined type at
type at the
have a simple
a simple udt
simple udt called
udt called storage
to contain three
contain three elements
A date string
date string, a
a value string
value string and
string and another
and another value
another value string
Ideally before you
before you reference
you reference data
reference data within
defined type in
type in your
your code, you
want to prepare
to prepare it
prepare it with
For example, empty
empty length strings
length strings or
strings or in
or in this
case a date
a date in
date in the
in the date
the date field
a new macro
new macro and
this one prep
one prep udt
will give it
give it two
type we wish
wish to actually
to actually declare
actually declare and
second variable is
variable is the
data we want
put into one
into one of
the string fields
will then print
print out both
out both the
both the date
the date and
the value from
value from that
our macro with
with the two
being a user
second being a
being a string
As before these
before these are
these are straight
are straight substitutions
Whatever comes in
comes in on
the parameters is
parameters is going
substituted for what
what we're about
will declare our
declare our user
type as a
as a uStorage
we can begin
can begin to
begin to populate
values within that
within that type
current date from
date from Date$
from Date$ into
Date$ into the
into the strDate
the strDate element
putting the input
the input value
input value passed
value passed on
parameters list into
list into the
into the value
the value field
setting the other
the other value
other value field
value field to
field to be
be an empty
some limitations with
limitations with macros
with macros which
macros which is
which is worth
is worth mentioning
worth mentioning here
When you're preparing
you're preparing one
preparing one of
of these user
these user defined
defined types I
types I quite
I quite often
quite often use
often use the
command to save
save a wee
a wee bit
wee bit of
However you can't
can't use the
prefix command within
command within a
within a macro
a macro because
macro because you're
because you're effectively
you're effectively doing
effectively doing something
doing something that's
something that's not
that's not on
not on a
It will generate
will generate an
If you also
you also use
also use the
the underline as
underline as a
as a line
a line folding
line folding command
folding command this
command this will
will also generate
also generate an
However these are
these are fairly
are fairly small
fairly small limitations
small limitations to
limitations to what
to what you
do with macros
we've actually prepared
actually prepared our
prepared our macro
our macro let's
macro let's try
The two elements
two elements are
elements are coming
are coming out
coming out to
our log quite
log quite happily
being the Date$
the Date$ value
Date$ value and
being the value
value we passed
we passed on
if you're preparing
you're preparing a
preparing a number
number of user
based on this
on this premise
this premise you
premise you can
use this command
this command again
command again on
again on a
on a differently
a differently named
differently named type
We're now creating
now creating one
creating one called
one called YouTomorrow
called YouTomorrow and
YouTomorrow and we're
we're putting new
putting new data
new data and
the date into
date into this
code now we'll
we'll see this
see this runs
this runs quite
we have touched
have touched on
touched on the
on the use
of macros within
macros within your
We started with
started with a
line macro to
macro to store
to store constants
can also use
also use a
macro to create
our own custom
own custom command
custom command words
command words to
words to store
to store constant
store constant values
constant values within
code or build
or build versions
also use our
use our macros
our macros to
macros to prepare
to prepare variables
prepare variables both
variables both declaring
both declaring and
declaring and populating
and populating them
And finally we
finally we touched
we touched on
on the ability
the ability of
ability of creating
of creating user
creating user defined
defined types and
types and prepping
and prepping them
prepping them within
them within our
within our macro
In our next
our next video
next video we'll
video we'll cover
cover the macro
the macro functions
macro functions and
functions and also
also the use
use of temp
of temp variables
temp variables within
variables within macros
However that's it
we will again
will again look
again look at
your applications, this
this time tackling
time tackling macro
tackling macro functions
video on macros
on macros we
macros we covered
we covered single
covered single line
single line macros
line macros and
macros and multi-line
and multi-line macros
looking at macro
at macro functions
But for those
you who haven't
who haven't watched
haven't watched the
watched the previous
previous video, I'll
I'll do a
do a quick
a quick recap
Mecros are basically
are basically text
basically text substitutions
text substitutions performed
substitutions performed before
performed before your
before your application
They are effectively
are effectively pre-processed
For example, on
on screen we
screen we have
have here a
here a macro
macro called m-release
called m-release package
What this will
this will do
will do when
do when your
application compiles is
compiles is that
replace the word
the word m-release
word m-release package
m-release package with
package with the
the word macro
us to create
to create things
create things on
things on the
on the fly
the fly before
fly before the
before the application
application is processed
can set a
set a macro
macro called build
called build version
version and make
make it equal
to the string
the string release
string release build
when your program
your program actually
program actually compiles
actually compiles, the
text in your
your code called
code called build
build version will
version will be
replaced by whatever
by whatever the
whatever the text
text you set
you set up
set up here
Mecros can be
a useful tool
useful tool to
tool to make
to make your
make your coding
your coding less
coding less tedious
less tedious, much
way as we
we use libraries
use libraries of
libraries of functions
get the best
the best out
best out of
of our macros
our macros we're
macros we're going
create a library
library to hold
to hold them
created a library
library file called
file called macro
called macro library
macro library as
library as an
as an encode
an encode file
encode file and
file and all
all the macros
the macros we
macros we created
last video are
video are included
are included in
included in this
in this file
going to reference
reference this encode
this encode file
encode file at
file at the
our code and
code and we
we will move
will move this
move this single
line macro into
macro into our
into our library
have referenced this
referenced this library
this library in
library in our
code we can
can now go
now go ahead
ahead and compile
and compile and
And our application
our application runs
application runs quite
quite happily, displaying
displaying the release
the release build
release build version
advantage of macros
of macros is
macros is if
is if they
not referenced in
in the main
the main bulk
main bulk of
bulk of your
your code then
code then they
then they add
they add nothing
add nothing to
nothing to the
to the size
your executable, as
these are text
are text substitutions
performed before the
before the actual
the actual compilation
So what we're
at now are
now are macro
are macro functions
macro functions themselves
So first we
first we need
we need a
need a problem
a problem which
problem which our
which our macro
macro is going
be the solution
let's say for
example we have
have two strings
two strings of
strings of data
want to fold
to fold both
fold both of
these strings in
strings in together
in together so
together so that
the characters within
characters within these
within these two
these two strings
two strings are
strings are interleaved
have created some
created some local
A data1 string
data1 string and
string and a
and a data2
a data2 string
data1 string contains
string contains four
contains four letters
four letters A
letters A, B
C and D
The data2 string
data2 string contains
contains four numbers
four numbers, 1
3 and 4
create a macro
macro function whose
is to take
take the first
first character from
character from the
the first variable
first variable and
variable and add
and add on
second variable and
and then work
then work through
work through each
through each character
each character interleaving
character interleaving as
interleaving as it
as it goes
from this macro
this macro should
macro should be
be the entire
the entire new
entire new interleaved
new interleaved string
macro we will
will store in
in our output1
our output1 variable
output1 variable which
is a string
So our macro
be called fold
called fold string
fold string and
string and will
and will take
will take two
take two parameters
two parameters, data1
data1 and data2
macro will populate
populate our output1
let's go into
our library and
library and we
new macro function
previous video we're
to be passing
be passing the
two parameters inside
parameters inside the
inside the brackets
But as this
is a macro
a macro we
macro we don't
don't need to
declare the type
this is merely
is merely a
merely a text
a text substitution
text substitution process
we were to
were to perform
perform this task
this task without
task without a
without a macro
macro we could
could probably use
probably use a
be using inside
using inside our
inside our new
our new macro
of the characters
the characters in
in the data1
the data1 variable
data1 variable, one
use the mid
the mid dollar
mid dollar command
to pull out
pull out one
out one character
one character from
variable and one
and one character
And we're building
up our output
our output variable
we'll declare these
declare these variables
these variables in
variables in our
in our function
However with macros
with macros there
macros there is
one additional command
additional command we
command we will
put in place
As this macro
this macro could
macro could be
be used several
used several times
several times within
times within the
the same function
same function or
subroutine in your
want to have
have a collision
a collision with
collision with the
with the declaration
of the local
use the macro
macro temp command
temp command to
to get around
get around that
around that problem
The micro tem
micro tem command
tem command makes
command makes sure
makes sure that
sure that the
that the declaration
declaration of longr
of longr and
longr and str
and str output
str output is
output is unique
It does this
does this by
this by adding
by adding a
adding a four
a four character
four character number
character number on
number on to
So when this
when this code
code is replaced
is replaced within
replaced within the
within the body
body of your
your code it
code it will
replaced as longr0001
as longr0001 for
longr0001 for the
the first time
first time it
it is used
this macro later
macro later on
same function it
function it will
will appear as
appear as longr
as longr 0002
And everything else
everything else within
else within this
this macro function
macro function will
function will have
will have that
have that defined
So any time
any time we
time we refer
we refer to
refer to longr
to longr it
longr it will
be replaced with
with the longr
the longr and
longr and the
version number of
the first iteration
first iteration it
iteration it will
will be 1
be 1, for
the second 2
second 2 and
2 and so
So regardless of
of how many
how many times
many times you
times you call
you call this
this macro within
macro within a
a function there
function there will
be no collision
no collision with
collision with local
with local variable
local variable declarations
variable declarations and
declarations and no
and no problems
no problems with
problems with compilation
the code the
code the output
output variable is
is the return
the return of
return of our
our macro function
macro function which
which is then
is then returned
then returned to
returned to the
will now output
now output that
output that value
log and attempt
and attempt to
attempt to run
to run our
our application has
has now run
now run and
run and the
output variable contains
variable contains A1
contains A1, B2
have successfully taken
successfully taken two
taken two variables
two variables and
variables and interleaved
and interleaved the
interleaved the string
the string constants
string constants into
constants into a
a new output
new output variable
And we've outputted
we've outputted that
outputted that to
our log so
macro function is
function is a
very straightforward and
straightforward and simple
and simple function
But it does
it does illustrate
does illustrate what
illustrate what we
do with a
with a macro
So to illustrate
to illustrate that
illustrate that calling
that calling this
macro function would
function would have
would have no
problems with the
declaration of variables
of variables let's
variables let's call
let's call it
call it once
it once more
once more within
more within the
time we're going
going to reverse
to reverse the
reverse the parameters
declared a second
a second output
second output variable
output variable, output2
populating that by
that by calling
by calling our
calling our fold
our fold string
fold string macro
string macro with
the parameters reversed
With data2 as
data2 as the
first parameter and
parameter and data1
and data1 as
data1 as the
quite cleanly and
cleanly and will
and will give
us the output
the output reversed
now have 1A
have 1A, 2B
3C and So
and So we
macro function to
a value, in
of course return
course return numerical
return numerical values
numerical values as
values as well
well as string
as string values
what other kinds
other kinds of
kinds of macros
of macros could
macros could we
could we actually
we actually create?
actually create? One
create? One of
things you may
to use within
use within your
application is the
of the randomise
randomise command is
used to seed
This seed value
seed value can
value can be
used to give
to give you
you a predictable
a predictable list
predictable list of
list of pseudo
of pseudo random
pseudo random numbers
If you want
you want your
want your randomise
your randomise routines
randomise routines to
routines to return
to return values
return values as
values as random
as random as
random as possible
as possible you
possible you want
want to seed
to seed it
seed it with
value that changes
that changes every
changes every time
The timer command
timer command can
command can be
used to do
But what we're
now is we're
small macro as
macro as a
as a function
return a randomised
a randomised seed
this macro random
macro random seed
library and we'll
we'll create this
So this macro
this macro is
return a D
a D word
D word, a
a numerical value
numerical value which
value which we
use to seed
to seed our
seed our random
our random number
to contain a
contain a piece
code which was
which was originally
was originally created
originally created by
created by Steve
by Steve Hutchesson
of the titans
the titans of
titans of the
Power Basic forum
Basic forum who
forum who is
who is sadly
is sadly no
sadly no longer
no longer with
longer with us
before we're going
to use macro
use macro temp
macro temp to
temp to ensure
to ensure there
ensure there are
there are no
are no collisions
no collisions with
collisions with the
with the variables
the variables we're
So our var
our var variable
var variable is
be a D
is what our
what our macro
using a bit
bit of inline
of inline assembly
inline assembly here
assembly here to
here to return
the value, efficiently
efficiently and very
and very quickly
Our first command
first command is
command is rdtsc
This reads the
reads the current
current value of
of the processor's
the processor's timestamp
processor's timestamp counter
timestamp counter into
counter into one
of the registers
the registers of
registers of the
of the processor
case we're particularly
we're particularly interested
particularly interested in
in the EAX
the EAX register
Our second command
second command is
command is a
is a swap
a swap command
This reverses the
reverses the by
the by order
by order within
order within the
within the EAX
And our third
and final command
final command is
command is to
is to copy
to copy the
copy the data
data within that
within that register
that register to
register to the
to the variable
have already declared
already declared, our
our D word
D word var
word var variable
This move command
move command quite
command quite efficiently
quite efficiently moves
efficiently moves the
moves the value
value within that
that register into
register into the
into the declared
the declared variable
This is one
of the strengths
the strengths of
strengths of inline
inline assembly within
assembly within Power
can pass information
pass information from
information from registers
from registers straight
registers straight into
straight into your
into your variable
And this var
this var variable
variable is what
what we're returning
we're returning to
returning to the
when we compile
we compile any
compile any reference
to the mrandom
the mrandom seed
mrandom seed will
seed will be
replaced by these
by these lines
should get back
get back a
back a nice
a nice large
nice large D
large D word
D word value
is our value
our value on
value on screen
while we're sending
we're sending this
sending this value
the screen we
screen we would
we would normally
would normally use
normally use it
it as the
as the parameter
the parameter of
parameter of the
of the randomize
randomize command as
command as you
Calling randomize and
randomize and forward
and forward by
forward by our
by our macro
We can attempt
can attempt to
to compile that
compile that and
that and it
us a random
if we declare
we declare a
called value we
value we set
that variable using
the random command
random command to
command to give
value between 1
1 and 20
can then push
then push that
push that value
that value out
value we get
we get is
get is 16
Since the random
number generator has
generator has already
already been seeded
been seeded we
seeded we can
can make a
to the random
random command once
once more and
more and get
and get a
So first time
first time we're
time we're getting
we're getting So
getting So this
So this gives
very easy way
easy way of
way of getting
of getting a
getting a pseudo
a pseudo random
pseudo random number
created a couple
couple of macro
of macro functions
These macro functions
macro functions are
functions are set
are set up
set up in
an include library
include library with
library with the
the previous macro
previous macro functions
macro functions we
functions we did
file can be
called from any
from any of
any of your
applications and will
and will only
will only add
only add to
add to the
the code of
the executable should
executable should the
should the macros
the macros be
macros be referenced
be referenced within
referenced within the
Macros are a
are a very
useful way to
way to save
to save tedious
save tedious coding
along the lines
lines of using
of using functions
using functions and
and subroutines in
subroutines in include
in include files
software add-ons or
add-ons or utilities
or utilities for
utilities for both
again at Splinterware's
at Splinterware's System
Splinterware's System Scheduler
System Scheduler, specifically
specifically for its
for its ability
its ability to
ability to monitor
to monitor services
Splinterware System Scheduler
System Scheduler comes
Scheduler comes in
comes in two
in two different
two different versions
It comes in
comes in a
in a free
a free version
free version, which
which is limited
is limited functionality
limited functionality but
functionality but is
but is still
is still very
still very useful
very useful, and
and a professional
a professional version
professional version which
version which currently
which currently costs
currently costs $30
costs $30 per
$30 per license
This license cost
license cost is
cost is a
is a one-off
a one-off perpetual
one-off perpetual license
It is not
not an annual
an annual subscription
is the professional
the professional version
professional version to
version to look
look at its
at its additional
its additional capabilities
additional capabilities, specifically
specifically the ability
monitor a service
before we get
we get into
get into that
into that we'll
that we'll have
create a service
a service to
service to monitor
want to be
able to create
a service, start
start and stop
and stop a
stop a service
a service at
service at will
So I don't
I don't want
to take down
take down any
down any of
of the normal
the normal Windows
normal Windows services
Windows services, so
to use an
use an application
an application we
application we wrote
we wrote some
wrote some time
time ago which
ago which will
which will create
create a PowerBasic
a PowerBasic Windows
PowerBasic Windows service
our application here
code of course
course will be
will be available
be available to
available to download
to download from
download from the
from the GSF
the GSF website
GSF website and
website and also
and also GitHub
What this application
do is it's
is it's going
a service called
service called 'AAAmonitor
called 'AAAmonitor folder
'AAAmonitor folder service'
It will allow
us to install
to install this
install this service
this service and
service and then
can go into
into the Task
the Task Manager
Task Manager and
Manager and start
and start the
start the service
the service from
service from the
from the Services
the Services tab
a folder that
folder that contains
that contains our
contains our compiled
our compiled CC
compiled CC service
CC service folder
service folder monitor
folder monitor EXE
monitor EXE, which
in fact the
fact the binary
the binary for
binary for our
for our service
can be installed
be installed one
installed one of
one of two
of two ways
You can install
can install it
install it using
a Windows command
Windows command prompt
command prompt or
prompt or you
or you can
install it from
it from inside
from inside PowerShell
today is use
is use PowerShell
order to install
this service we'll
service we'll need
to run PowerShell
run PowerShell as
PowerShell as administrator
of all open
all open up
open up the
up the folder
the folder which
contains the binary
the binary which
binary which is
is our service
Then we'll click
we'll click in
click in the
in the blank
the blank area
blank area underneath
area underneath and
underneath and then
and then hold
then hold down
hold down the
down the alternate
the alternate and
alternate and press
press the F
the F key
brings up the
up the little
the little window
little window which
window which allows
us to open
to open PowerShell
open PowerShell either
PowerShell either as
either as a
as a administrator
a administrator or
administrator or as
or as our
as our current
our current user
So we'll open
we'll open it
open it as
it as administrator
install this PowerBasic
Windows service we'll
to run this
run this CC
this CC service
folder monitor executable
So in PowerShell
in PowerShell all
PowerShell all we
do is press
is press the
press the period
the period key
period key, a
a slash key
slash key and
key and then
of our executable
This executable takes
executable takes a
takes a parameter
It will either
will either be
either be install
be install or
install or uninstall
Since we're attempting
attempting to install
service we'll use
use the install
the install parameter
install parameter and
parameter and then
and then press
then press the
the enter key
our service installed
service installed, a
a monitor folder
monitor folder service
can now view
now view this
view this service
this service in
service in Task
in Task Manager
Task Manager by
Manager by going
by going down
going down to
to the taskbar
the taskbar, right
right clicking and
clicking and selecting
and selecting Task
selecting Task Manager
see on the
list of services
of services the
services the AAA
the AAA monitor
AAA monitor folder
folder service is
service is currently
is currently installed
currently installed but
installed but stopped
If we right
we right click
right click we
can quite simply
quite simply start
simply start the
So our service
our service is
service is now
is now running
that far we
want to go
the system scheduler
system scheduler and
scheduler and set
and set up
up a monitoring
a monitoring process
System scheduler can
scheduler can be
can be found
be found down
found down in
down in the
the system tray
of different event
different event types
event types we
types we can
can actually set
actually set up
We're interested here
interested here in
here in setting
in setting up
up a service
a service watcher
We can give
can give it
it a title
can put in
put in the
in the service
the service name
service name to
name to watch
We can browse
can browse for
browse for the
for the service
the service names
service names and
names and just
and just pick
just pick it
pick it from
from the list
The next choice
next choice you
choice you have
have is your
is your criteria
We're specifically wanting
specifically wanting to
wanting to know
to know when
know when the
when the service
the service is
service is not
is not running
As in this
want the service
the service running
service running all
running all the
all the time
do is what
is what we
way of an
of an action
Do we want
the service, stop
stop the service
the service or
service or run
or run some
run some other
some other event
In Windows services
Windows services you
services you can
can set them
them up if
up if they
if they fail
they fail to
fail to restart
we want an
want an external
an external monitoring
external monitoring facility
monitoring facility to
facility to monitor
monitor a particular
a particular service
particular service to
service to see
to see when
see when it
when it stops
going to select
to select run
select run other
run other event
Now we haven't
haven't created another
created another event
another event to
event to run
to run so
run so we'll
so we'll save
save this as
this as it
it stands and
stands and we'll
to this in
will just disable
just disable the
disable the event
the event so
event so that
that it doesn't
it doesn't run
go into Power
into Power Basic
Basic and create
and create an
create an event
an event which
event which is
going to notify
to notify us
notify us that
us that something
that something has
something has indeed
has indeed occurred
created a very
a very small
very small program
small program called
program called test
called test event
This console application
console application will
application will open
will open a
open a console
will then send
then send this
send this piece
text out to
to a file
a file on
file on the
on the root
the root of
root of our
of our path
our path called
path called status.txt
It will append
will append to
append to that
to that file
that file each
file each time
it is triggered
will then wait
then wait for
wait for two
for two seconds
two seconds and
seconds and then
then the application
application will terminate
compile that, and
and that's the
that's the event
the event we
event we want
up in System
in System Scheduler
if we pop
we pop back
pop back in
in there, right
right click, pick
pick edit, and
now go in
go in and
in and set
up our new
our new event
be an application
So we click
we click new
click new event
new event and
event and we
can now enter
now enter the
enter the details
of this event
can browse to
browse to the
There's our test
our test event
test event EXE
put the working
the working directory
working directory in
particular application needs
application needs no
needs no parameters
is a box
a box to
to put parameters
put parameters in
parameters in, should
should they be
they be acquired
can also set
also set the
set the state
the state to
state to be
to be normal
be normal, minimized
maximized or hidden
We'll just leave
just leave it
leave it as
it as normal
as normal for
normal for the
the moment as
moment as we
to see it
see it coming
it coming up
need to schedule
to schedule this
schedule this particular
this particular event
particular event because
event because the
because the event
the event is
event is going
to be triggered
be triggered by
triggered by the
by the service
the service watcher
The advanced tab
advanced tab will
tab will come
will come back
So let's save
let's save this
this and go
to our service
our service watcher
We can edit
can edit that
edit that and
that and we
can now pick
now pick the
pick the event
the event from
event from the
Log the failure
the failure of
failure of the
of the service
we've set that
set that, we
set the schedule
How often do
often do we
want this monitoring
this monitoring process
monitoring process to
process to run?
to run? Normally
run? Normally, if
if you're monitoring
you're monitoring a
monitoring a system
a system, you
you won't want
won't want to
to check it
check it too
it too often
of this demonstration
this demonstration, we're
to run it
run it every
it every minute
So default to
default to running
to running every
running every one
every one minute
You can increase
can increase this
increase this value
this value, say
for example, to
to every 10
every 10 minutes
And it gives
gives you other
you other options
can set it
it to start
to start at
start at some
the future, at
at a particular
a particular time
particular time and
time and a
and a particular
we'll leave this
leave this at
this at one
at one minute
one minute intervals
minute intervals for
intervals for the
that now, and
if we enable
we enable the
enable the event
the event, we
we can look
can look at
at the log
the log of
log of the
of the event
the event when
event when something
when something actually
something actually triggers
As we saw
we saw earlier
saw earlier, our
is currently running
our monitoring service
monitoring service should
service should not
should not trigger
not trigger, because
because we're specifically
we're specifically looking
for the criteria
the criteria of
criteria of the
see our monitoring
our monitoring system
monitoring system has
system has kicked
has kicked in
kicked in at
in at last
at last run
last run at
run at 14.15
We can right
can right click
right click and
click and view
and view the
view the event
the event log
event log file
that the event
the event has
event has started
has started, but
but the service
service is already
is no action
no action required
So our monitor
our monitor appears
monitor appears to
to be running
be running quite
So let's test
let's test it
back to task
to task manager
manager and stop
and stop the
That's our service
our service stopped
have to wait
wait for 60
for 60 seconds
60 seconds for
seconds for the
the next run
next run of
run of our
of our monitor
What should happen
should happen is
happen is our
is our monitor
our monitor should
monitor should trigger
should trigger, check
check the service
the service, realize
realize it's not
it's not running
not running and
running and should
and should run
should run our
run our event
has indeed done
So our console
console window has
window has appeared
has appeared on
appeared on screen
So the monitor
the monitor should
monitor should now
now have checked
have checked the
checked the service
on the event
log file, we
see it's telling
it's telling us
telling us the
us the service
not running, and
now running the
running the appropriate
the appropriate action
the folder, we
can see there
now a status.txt
a status.txt, and
this is telling
is telling us
telling us that
that the service
the service has
service has indeed
has indeed stopped
indeed stopped and
stopped and the
the time it
time it stopped
it stopped at
successfully used Splinterware
used Splinterware system
system scheduler to
scheduler to monitor
a service of
service of our
This monitor can
monitor can be
be set to
set to run
to run at
run at predetermined
at predetermined intervals
predetermined intervals and
intervals and check
whether the service
service is or
is or is
or is not
And depending on
on the criteria
the criteria, which
which you have
you have selected
have selected, you
you can either
can either report
either report that
report that service
that service has
service has started
has started or
started or a
or a service
a service has
service has stopped
let's delve a
delve a little
a little deeper
little deeper into
deeper into the
into the other
the other options
other options for
options for this
for this process
We haven't yet
haven't yet looked
yet looked at
at the advanced
advanced tab has
tab has a
number of tabs
the run as
run as tab
This sets the
sets the user
used to actually
to actually run
actually run the
run the monitor
can change this
this to always
to always use
always use the
use the service
service or local
or local system
local system account
This is non
is non interactive
use this when
this when you
when you want
you want no
want no feedback
no feedback to
feedback to the
You want this
this to run
to run quite
run quite silently
save that, if
the log file
log file, we'll
we'll see at
the moment the
moment the service
service is running
is running as
running as a
as a specific
a specific user
that we've changed
we've changed the
changed the service
the service to
service to run
to run as
run as the
as the system
the system account
system account, we
we get system
get system SVC
system SVC in
SVC in brackets
tells us it's
us it's a
it's a non
a non interactive
non interactive local
interactive local system
system account that's
account that's actually
that's actually being
actually being used
you will notice
will notice that
notice that when
that when this
when this triggered
this triggered there
triggered there, it
it did not
did not display
not display your
display your console
your console on
console on the
Because it's running
it's running in
in a non
non interactive mode
interactive mode, it
not display any
display any console
any console or
console or other
or other windows
other windows to
windows to the
it can run
can run quite
quite silently and
silently and not
and not interrupt
not interrupt somebody's
interrupt somebody's work
somebody's work on
work on the
on the computer
else can system
can system schedule
system schedule do
schedule do in
do in this
in this advanced
this advanced tab?
advanced tab? We
tab? We have
have a notifications
a notifications tab
up to send
to send an
send an email
an email notification
For which you
define an SMTP
an SMTP server
defined that, you
put in an
in an email
you can trigger
can trigger emails
trigger emails when
emails when the
when the event
the event starts
event starts to
starts to run
to run, when
the event criteria
event criteria is
criteria is matched
is matched, when
criteria is not
is not matched
not matched or
matched or when
or when the
the event error
event error or
error or failure
or failure is
failure is detected
You can even
can even include
even include the
include the last
the last few
last few lines
few lines of
lines of the
log file in
file in the
go further and
further and set
and set date
set date time
date time restrictions
time restrictions on
restrictions on when
on when the
when the running
running of application
of application events
application events is
events is going
going to happen
can set holidays
set holidays, non
non working days
working days and
days and to
and to run
to run within
run within date
within date and
and time ranges
For the event
the event processing
event processing, if
if an event
an event is
event is missed
is missed, for
for example when
example when the
when the computer
the computer or
or server is
server is powered
is powered off
powered off, we
can decide to
decide to do
to do nothing
do nothing, to
run it on
it on startup
on startup or
startup or after
or after a
after a prompt
a prompt on
prompt on the
on the login
if the events
the events are
events are scheduled
are scheduled to
scheduled to run
to run once
run once only
once only, we
we can delete
can delete the
delete the completed
the completed event
completed event if
event if it's
it's not scheduled
not scheduled to
to run again
So we've monitored
we've monitored the
monitored the service
the service when
service when the
service is operational
is operational and
operational and running
service is stopped
if we de-install
we de-install the
de-install the service?
the service? Let's
service? Let's go
to our PowerShell
our PowerShell and
PowerShell and de-install
and de-install the
de-install the service
the service completely
is our monitoring
our monitoring folder
monitoring folder service
folder service now
service now uninstalled
now uninstalled from
uninstalled from the
from the computer
So what will
what will happen
will happen when
happen when the
when the monitor
the monitor is
monitor is next
is next run?
next run? And
run? And there
monitoring service actually
service actually triggered
see there's an
there's an exclamation
an exclamation mark
exclamation mark beside
mark beside the
beside the event
the event type
we look down
look down in
in the bottom
the bottom window
bottom window, it
us that this
that this service
this service does
service does no
no longer exist
click and look
and look at
scroll down to
the bottom, we'll
we'll see it's
see it's reporting
it's reporting that
reporting that the
the service does
service does not
not exist anymore
is we've installed
we've installed a
installed a Power
Basic Windows service
Windows service using
service using PowerShell
using PowerShell on
PowerShell on our
on our local
our local computer
We've started this
started this service
service and in
and in System
System Scheduler Professional
Scheduler Professional, we've
created a service
service watcher to
watcher to monitor
to monitor our
monitor our service
And should that
should that service
that service stop
service stop running
stop running, it
it will trigger
will trigger an
trigger an additional
an additional process
additional process of
process of our
It will also
will also maintain
also maintain its
maintain its own
its own log
own log file
log file for
file for when
for when the
the service was
service was running
was running, or
service was not
was not running
not running, or
the service no
service no longer
no longer existed
longer existed on
existed on the
While you can
can create some
create some of
some of this
of this functionality
this functionality within
functionality within your
your own Power
own Power Basic
Power Basic applications
Basic applications, using
using an external
an external process
external process like
process like this
like this is
is very quick
very quick and
you'll find all
find all this
in your day
your day to
day to day
to day applications
day applications, but
of pointers with
pointers with user-defined
with user-defined types
I have been
have been asked
been asked if
asked if I
if I can
I can provide
can provide a
provide a video
video on pointers
on pointers, giving
giving a simple
a simple explanation
simple explanation of
explanation of what
and how they
how they can
This will lead
will lead on
lead on nicely
on nicely from
nicely from our
from our previous
previous video on
video on user-defined
on user-defined types
types and unions
today is take
is take the
take the application
application we created
last video and
video and we're
put some pointers
some pointers at
pointers at the
For detailed coverage
detailed coverage of
coverage of the
of the creation
creation of these
of these user-defined
these user-defined types
user-defined types, if
want to watch
to watch the
watch the previous
I'll put the
put the links
the links in
But what we
have in this
application is we
we have set
have set up
up a user-defined
type called udt_account
of elements, a
a balance, a
a transaction count
transaction count, user
user information and
information and account
and account information
user and account
and account elements
account elements are
elements are both
are both, in
in themselves, user-defined
Further down in
have dimensioned an
dimensioned an array
array of 10
of 10 elements
10 elements between
elements between element
between element 1
element 1 and
1 and element
and element And
element And we've
populated the first
the array, element
element number 1
number 1, with
with the balance
the balance and
balance and the
and the transaction
the transaction count
This is fairly
is fairly standard
fairly standard operation
standard operation for
operation for a
for a user-defined
user-defined type held
type held within
held within an
within an array
of the user-defined
user-defined type is
type is to
allow you, the
to design your
design your own
your own variable
own variable type
And having defined
defined that variable
that variable type
variable type, you
can then dimension
then dimension an
array to contain
to contain elements
contain elements of
elements of that
of that type
we have actually
have actually printed
actually printed the
printed the details
the details from
details from inside
from inside the
inside the array
the array out
array out to
our log, using
array and the
and the property
the property you're
property you're actually
you're actually looking
case the balance
down the code
again we're populating
populating the user
the user information
user information, which
which is stored
is stored within
within the user
the user element
user element of
user-defined type, allowing
save the first
the last name
last name of
further down still
down still we're
still we're storing
storing the account
So we're building
building up in
up in our
our array a
array a set
set of data
of data for
data for a
for a particular
a particular user
array is 10
is 10 elements
10 elements in
elements in size
in size, we
we could store
could store 10
store 10 users'
10 users' data
And slightly further
slightly further down
the code we're
code we're showing
we're showing a
showing a shortened
a shortened version
shortened version of
version of this
We're defining a
defining a user-defined
user-defined type as
type as the
user-defined type defined
type defined at
defined at the
of the program
then we're populating
populating that user-defined
the element and
and the account
account number details
us to extract
to extract the
extract the information
from that specific
that specific element
specific element of
using a shortened
a shortened form
we're using this
using this shortened
this shortened version
shortened version to
version to print
out the full
the full account
full account information
account information or
information or the
or the department
the department information
department information using
information using our
using our user-defined
this far and
far and stored
and stored the
the information within
our array of
user-defined types, we
use a pointer
a pointer on
pointer on the
on the specific
the specific element
array we specified
we specified above
declare a pointer
So here we're
here we're declaring
declaring a variable
variable called P1
we're declaring this
declaring this as
is the udt
the udt account
udt account number
the final part
final part of
part of this
of this piece
code is ptr
is ptr, which
which is pointer
So P1 is
P1 is a
is a pointer
A pointer is
pointer is a
is a variable
a variable that
variable that holds
that holds a
holds a located
a located elsewhere
located elsewhere in
elsewhere in memory
So basically it's
basically it's a
it's a number
And this number
this number points
number points to
points to the
to the location
the location in
location in memory
in memory which
memory which this
which this information
is stored at
So having declared
having declared this
declared this variable
this variable, we
to populate it
populating the P1
the P1 variable
P1 variable using
using the var
the var pointer
var pointer command
This command takes
variable we want
want to point
to point at
declared the user
the user account
user account further
account further up
further up in
our code, here
here on this
on this line
So we're pointing
we're pointing at
pointing at where
at where that
where that information
that information is
information is actually
is actually stored
having defined where
defined where that
actually stored, we
can actually reference
actually reference it
reference it using
it using the
the pointer itself
can print out
account number, by
using the at
the at sign
at sign, the
of our pointer
pointer variable, P1
and the construct
the construct within
construct within that
within that user-defined
user-defined type that
type that we
wish to access
full account number
see what this
what this generates
is the account
account number, appearing
the 10123456, and
the pointer, we
we can obtain
can obtain exactly
obtain exactly the
the same information
So our P1
our P1 variable
P1 variable is
variable is pointing
is pointing at
user-defined type we
type we specified
we specified earlier
specified earlier in
earlier in the
code is pointing
is pointing only
pointing only at
only at the
very first element
would we handle
we handle it
handle it if
it if we
wanted to point
to point to
point to the
to the array
the array itself?
array itself? Let's
itself? Let's declare
Let's declare another
declare another pointer
call this pointer
this pointer P2
And we're pointing
we're pointing again
pointing again at
again at a
at a user-defined
user-defined type, in
this case, udtAccount
is a user-defined
type we used
we used when
used when we
when we were
we were dimensioning
were dimensioning the
the array in
array in the
the first place
is the line
the line of
we used to
used to dimension
to dimension the
The arrays between
arrays between elements
between elements So
elements So to
So to populate
populate this P2
this P2 pointer
P2 pointer, we're
use the var
pointer command again
since we're pointing
pointing at an
at an array
an array, we
have to reference
reference the very
array is between
is between elements
between elements 1
elements 1 and
1 and So
first element in
element in that
that our pointer
our pointer 2
pointer 2 is
2 is pointing
at the array
actually reference every
reference every element
every element within
something to watch
Your syntax in
syntax in actually
in actually accessing
actually accessing it
accessing it again
it again is
again is using
the at command
of the pointer
pointer variable and
variable and in
and in square
in square brackets
square brackets is
the array that
array that you
wish to get
get data from
For pointers, these
these elements always
elements always start
always start at
start at 0
of how you've
how you've dimensioned
you've dimensioned your
dimensioned your array
your array, either
either starting at
starting at 0
at 0 or
or 1 or
1 or some
or some number
some number larger
number larger than
larger than 1
than 1, the
first element, as
far as the
as the pointer
the pointer is
pointer is concerned
is concerned, is
is always going
always going to
Following that, we
in the structure
the structure that
structure that you
wish to pull
this case, strUser
strUser and strFirstName
will see we'll
see we'll get
we'll get the
our user coming
user coming out
coming out, which
same as it
it was earlier
out the other
the other parts
parts of our
defined type within
type within the
use the name
name of those
of those constructs
at P2 with
P2 with the
with the 0
the 0 element
0 element and
element and then
then the strUser
the strUser and
strUser and then
then the strLastName
And to complete
to complete the
complete the code
out the account
account number and
number and also
also the department
So this demonstrates
this demonstrates how
demonstrates how to
pointer to pull
out of an
of an existing
an existing populated
existing populated array
up this pointer
this pointer, we
also use it
use it to
it to populate
If we wished
we wished to
wished to populate
populate the very
the very next
very next element
next element of
not yet populated
yet populated, we
this using our
using our pointer
Simply by using
by using at
using at P2
at P2 and
P2 and in
square brackets the
the element we
element we wish
to populate, and
then the parts
the parts of
defined type that
And of course
of course, we
can also print
also print this
print this back
this back out
getting the name
the name returned
name returned on
returned on our
Of course, since
since we're hard
we're hard coding
hard coding this
coding this value
value in here
in here, this
this could indeed
could indeed be
indeed be a
be a variable
If we populate
populate the variable
the variable longElement
variable longElement to
longElement to be
to be 1
be 1, we
we can slot
can slot that
slot that in
that in quite
in quite happily
quite happily to
happily to our
it will still
have taken an
taken an existing
an existing array
existing array which
which is all
all user defined
have populated that
populated that array
that array with
array with data
with data, and
pointer to both
to both extract
both extract data
extract data from
from the array
array and to
and to insert
to insert data
insert data into
Hopefully this has
been an easy
an easy introduction
easy introduction to
introduction to the
to the use
how to do
to do queue
do queue handling
queue handling within
handling within your
your applications using
applications using a
using a queue
a queue collection
You will, at
some point, be
be creating applications
creating applications which
applications which need
which need to
to do things
do things in
things in a
in a certain
a certain order
certain order, depending
depending on information
on information coming
information coming into
coming into your
This is basic
is basic queue
basic queue handling
queue handling, as
in a first
a first in
first in, first
can control this
control this type
type of task
of task using
task using an
within PowerBasic there
PowerBasic there is
an inbuilt queue
inbuilt queue collection
queue collection construct
collection construct which
construct which we're
create a queue
queue collection object
Like the other
the other collection
other collection objects
collection objects within
objects within PowerBasic
within PowerBasic, this
can be created
be created quite
created quite easily
declare our variable
our variable as
variable as an
as an iQueueCollection
an iQueueCollection, and
let command, do
do the let
the let collection
let collection equals
collection equals class
equals class QueueCollection
Once created, this
this collection is
collection is currently
is currently empty
can show that
show that this
that this collection
currently empty by
empty by using
of the properties
the properties of
properties of the
the collection –
collection – the
– the Count
the Count property
store the number
that variable by
using the collection.count
have determined how
determined how many
the collection, we'll
we'll push that
can get a
get a report
a report of
report of it
As this returns
this returns a
a number, we're
the format dollar
format dollar command
turn the number
the number back
number back into
we can send
can send it
send it out
application now, so
see that it's
that it's currently
it's currently reporting
currently reporting that
reporting that there
there are zero
are zero items
zero items in
in the queue
the queue, which
is quite expected
quite expected because
expected because we
because we haven't
we haven't added
haven't added anything
added anything to
anything to the
to the queue
the queue just
queue just yet
have created our
created our collection
our collection, how
we add something
add something to
to the queue?
the queue? Well
queue? Well, you
can add something
add something quite
something quite easily
easily to the
the queue by
queue by using
using the enqueue()
the enqueue() method
the moment I've
moment I've put
I've put the
put the parameter
the parameter in
parameter in just
in just as
just as a
as a basic
a basic string
say that, we're
add the text
the text first
text first item
first item to
item to our
to our queue
to give this
give this a
this a little
little bit more
more flexibility, this
this particular method
particular method takes
method takes a
takes a variant
a variant as
variant as its
use a variant
variant to illustrate
to illustrate what
illustrate what more
what more this
more this can
declare a variant
a variant for
variant for our
for our input
variable called item
called item input
item input as
input as a
a variant variable
variant variable type
string we wish
into the queue
enqueue() method with
method with that
with that variable
variable as its
So having added
having added this
added this item
this item to
the queue, the
the queue count
queue count should
count should now
now return 1
be making many
making many calls
many calls to
calls to test
to test what's
test what's in
the queue and
queue and printing
and printing it
printing it to
the log, we're
the other features
other features of
features of Power
Basic and that
that is macros
This will save
will save a
save a bit
Macros have a
have a very
very powerful addition
powerful addition to
addition to Power
What we've created
we've created here
created here is
macro called count
called count items
count items, which
which takes in
takes in one
one parameter called
parameter called long
called long count
long count items
It then has
then has two
has two lines
One to obtain
obtain the collection
the collection count
collection count and
count and a
a second line
second line to
line to print
log the number
purpose of a
of a macro
macro is that
is that at
that at compile
compile time any
time any reference
reference to this
to this macro
macro will be
be replaced in
replaced in the
source code by
code by the
by the lines
of code within
we place a
place a call
our macro count
macro count items
count items in
code here at
here at compilation
compilation time, the
Power Basic compiler
Basic compiler will
compiler will replace
will replace this
replace this single
of code with
code with the
of code contained
code contained within
But it keeps
it keeps our
keeps our code
our code nice
code nice and
will see initially
see initially there
initially there were
there were zero
were zero items
queue and it's
it's now reporting
now reporting that
is now one
now one item
one item in
successfully added our
added our first
our first item
the queue collection
So of course
of course we
course we can
do a simple
loop to add
to add multiple
add multiple items
multiple items to
items to our
our new collection
loop for long
for long r
long r equals
r equals 1
be adding five
adding five new
five new items
new items to
loop we have
have a call
call to Enqueue
to Enqueue, to
add the word
the word test
word test followed
test followed by
case between 1
1 and 5
do a call
to our count
our count items
count items immediately
items immediately after
immediately after the
after the for
are now six
now six items
six items in
does indeed tell
indeed tell us
we've seen so
seen so far
far is we
is we can
can add items
add items to
items to the
queue and we
items are actually
are actually within
actually within the
within the queue
the queue itself
So having put
having put information
put information into
information into a
into a queue
a queue, there
information back out
back out again
know how many
are actually in
actually in the
the queue, we
do a straightforward
a straightforward for
straightforward for next
So we're declaring
we're declaring two
declaring two variables
two variables here
The item variable
item variable as
to contain what
contain what we're
what we're pulling
we're pulling out
pulling out of
of the queue
The long item
long item is
be our counter
our counter for
counter for the
of items we're
items we're actually
actually pulling out
So as it's
as it's a
it's a first
first in first
in first out
first out, we're
going to pull
out the oldest
the oldest item
oldest item from
item from the
from the queue
the queue first
queue first of
that is using
using the Dequeue
the Dequeue method
This will pull
will pull the
pull the first
first item out
item out of
queue and put
it into our
into our item
our item variant
item variant variable
As we know
we know exactly
know exactly how
exactly how many
the queue, there
there should be
should be no
be no problem
no problem pulling
problem pulling the
pulling the information
But it never
harm to actually
to actually check
actually check that
check that what
that what you've
what you've got
you've got out
got out has
out has actually
actually been populated
can test what's
what's in our
in our item
variant variable by
value of vt
of vt empty
vt empty, then
then there's nothing
there's nothing in
nothing in this
in this variable
It's completely empty
And if this
if this variant
this variant type
variant type returns
type returns something
returns something other
something other than
other than empty
than empty, then
then it contains
it contains information
a log the
string that's contained
that's contained within
within the variant
We can turn
can turn this
turn this back
a string using
string using the
now getting the
getting the six
the six items
six items coming
items coming out
The first test
first test and
and the test
the test one
test one, two
four and five
A total of
total of six
of six items
can also test
also test to
see what's left
what's left in
count should return
should return a
value of zero
we have pulled
have pulled everything
pulled everything out
everything out of
use our macro
our macro once
macro once more
more to count
to count the
count the items
have our now
our now zero
now zero items
in this demonstration
this demonstration today
demonstration today, we've
we've been merely
been merely putting
merely putting strings
putting strings into
strings into our
into our queue
our queue collection
since the information
the queue is
queue is all
is all variants
all variants, it
Variants can hold
can hold a
hold a wide
a wide range
wide range of
range of information
Variant variables can
variables can be
can be considered
be a type
a type of
type of container
of container, which
which can hold
can hold variables
hold variables of
variables of most
of most of
the data types
data types supported
types supported within
supported within Power
can store numbers
store numbers within
numbers within this
within this variant
For example, long
long integers, singles
can store dates
store dates, dynamic
strings and many
and many other
many other types
other one of
one of interest
of interest is
interest is we
can actually store
actually store entire
store entire arrays
entire arrays within
arrays within a
within a single
a single variant
So your queue
your queue collection
queue collection could
collection could contain
could contain a
contain a long
a long list
long list of
list of arrays
of arrays queued
arrays queued up
queued up waiting
up waiting for
waiting for processing
with the simple
the simple commands
simple commands of
commands of count
of count that
count that determine
that determine how
determine how many
many items there
items there are
there are in
the queue, Enqueue
Enqueue to add
to add something
queue and Dequeue
and Dequeue to
Dequeue to remove
to remove something
remove something from
flexibility for very
for very little
very little code
little code within
code within your
find these queue
these queue collections
queue collections useful
collections useful in
again at queue
at queue handling
your applications, by
queue collection to
collection to store
to store arrays
This was the
was the code
used in our
video on queue
on queue collections
had created a
created a queue
queue collection and
collection and had
and had put
had put a
put a number
number of strings
of strings into
strings into the
We had then
had then gone
then gone ahead
gone ahead and
ahead and extracted
and extracted each
extracted each of
these strings from
strings from the
the queue in
queue in the
order they were
they were placed
were placed in
placed in the
since the data
data we're putting
we're putting into
putting into these
into these queues
these queues are
queues are all
are all variant
all variant variables
variant variables, we
we did allude
did allude to
allude to the
to the fact
fact that you
you could store
could store other
store other types
information within your
within your queue
your queue, for
for example arrays
So let's clear
let's clear down
clear down this
code to the
to the basics
the basics and
basics and start
and start to
put some new
new code in
code we are
we are still
are still declaring
still declaring a
variable called collection
called collection as
collection as an
to make that
make that collection
that collection equal
collection equal to
the class queueCollection
is our variable
our variable all
variable all set
to handle our
handle our queue
queue collection now
And we're creating
new variable to
variable to count
in our queue
make use to
use to the
to the macro
the macro at
macro at the
our code called
code called countItems
called countItems, to
our queue and
queue and to
and to display
display this on
this on our
see it is
it is quite
is quite correctly
quite correctly showing
correctly showing that
showing that there
zero items currently
items currently sitting
currently sitting in
add some data
data into this
into this queue
this queue, we'll
create a variant
variant variable to
to hold our
hold our information
call that item
that item input
item input declared
input declared as
Now we want
array to add
add to this
to this queue
So we've declared
local array, which
is a single
a single dimension
single dimension array
dimension array from
zero to four
other words, it's
to hold five
hold five pieces
five pieces of
We are then
are then assigning
then assigning one
assigning one letter
one letter to
letter to each
to each element
our array, the
the letters A
D and E
then populate this
populate this variant
this variant variable
variant variable with
variable with our
with our array
Quite simply by
simply by the
the variant variable
variant variable equals
variable equals the
equals the name
array and two
and two brackets
populated this variant
this variant, we
can now place
now place it
place it within
it within our
within our queue
Exactly as we
previous video by
video by using
using the collection
the collection dot
collection dot enqueue
having put one
put one array
one array into
array into the
the queue, can
we now put
put a second
a second but
second but different
but different array
different array into
the same queue?
same queue? So
queue? So we've
we've now dimensioned
now dimensioned a
dimensioned a second
a second array
second array called
array called data
called data next
array from zero
from zero to
zero to two
it will hold
will hold three
hold three elements
are then populating
populating the three
the three elements
three elements with
elements with A1
with A1, B1
we're populating our
array and adding
and adding it
adding it to
the queue using
queue using the
using the enqueue
the enqueue method
can now count
now count how
many items we've
items we've got
we've got in
got in the
which should return
should return the
value of two
So let us
let us now
us now see
now see if
we can extract
can extract the
extract the data
order to extract
the queue, we're
we're creating an
creating an item
an item variant
data coming back
new output array
output array to
array to put
to put that
put that data
that data into
into and a
and a counter
a counter for
counter for each
important when you
you dimension that
dimension that array
that array to
array to mark
to mark it
the array, open
open bracket, zero
allows the array
array to be
to be overwritten
be overwritten by
overwritten by what's
by what's coming
what's coming back
want to step
through each item
collection and pull
and pull the
out and populate
and populate our
populate our output
a local item
local item variable
for the item
the item count
We're going from
going from that
from that equals
that equals one
we determined follow
determined follow up
follow up in
up in the
the code using
code using the
populating the VItem
the VItem variable
VItem variable using
the collection dequeue
collection dequeue method
variant variable that's
variable that's been
that's been pulled
been pulled back
pulled back to
back to make
make sure it's
sure it's not
it's not empty
not empty using
empty using the
the inbuilt variant
inbuilt variant VT
is we're not
we're not going
going to assume
to assume that
assume that all
that all the
the collection queue
collection queue is
queue is actually
is actually all
actually all arrays
The may well
may well come
well come at
come at time
at time within
time within your
your application when
application when you
store a variety
a variety of
variety of information
Some may be
may be dynamic
be dynamic strings
dynamic strings, some
may be numbers
be numbers and
numbers and some
and some may
may be arrays
out what kind
kind of information
of information is
stored within this
we can act
can act accordingly
use the select
the select command
select command to
of information we're
information we're looking
As the variant
the variant VTE
variant VTE command
VTE command returns
command returns a
a number, I'm
I'm first going
going to push
to push this
push this number
this number out
number out to
log to report
report on what
on what kind
kind of variant
of variant type
variant type it
type it is
that code as
code as it
it stands at
stands at the
the moment, we'll
two items that
items that we
the queue are
queue are both
are both of
both of variant
variant type 8200
a look in
Power Basic help
Basic help, you'll
you'll see a
list of equates
of equates that
equates that tells
that tells you
tells you what
you what kind
come back in
back in one
of these variants
And you'll also
you'll also see
the value 8200
value 8200 is
8200 is not
is not on
not on the
is because for
because for a
for a string
string array, it's
be a combination
combination of two
of two of
two of these
up an accord
an accord quite
accord quite neatly
in a case
a case statement
the string and
So we're pulling
we're pulling back
pulling back something
back something that
that is both
is both an
both an array
array and also
and also an
also an array
array of strings
our next line
next line of
code is captured
is captured in
captured in a
in a try-catch
a try-catch block
using the elect
the elect command
elect command to
our output array
output array with
data that exists
that exists in
in the variant
variant which we've
which we've pulled
we've pulled back
pulled back from
back from our
That quite simply
quite simply dimensions
simply dimensions and
dimensions and populates
and populates our
populates our array
our array automatically
And then like
then like any
any other array
other array, we
can then step
then step through
through the array
array from the
lower bounding to
bounding to the
array and push
and push that
push that information
that information out
have our two
our two arrays
The first array
first array with
five elements between
elements between the
between the letters
letters A and
A and E
and E and
E and the
the second array
second array with
the values A1
values A1, B1
and C1 in
C1 in a
in a single-dimensional
a single-dimensional array
single-dimensional array of
array of three
of three elements
have successfully populated
successfully populated a
populated a collection
a collection queue
collection queue with
queue with two
with two separate
two separate arrays
We have then
have then pulled
then pulled that
pulled that information
the queue into
queue into another
into another array
another array and
array and displayed
displayed it on
So that's very
that's very useful
very useful, but
but how can
can we prove
we prove that
prove that the
that the variants
the variants aren't
variants aren't just
aren't just pointing
just pointing to
the original arrays
original arrays which
arrays which are
which are set
within our code?
we look back
look back to
array we set
set up called
up called data_next
called data_next, which
which has three
has three elements
three elements in
elements in it
We then put
then put that
put that into
that into the
if we reuse
we reuse that
reuse that array
that array for
array for some
for some other
some other purpose
other purpose and
purpose and put
and put different
put different data
different data into
data into it?
into it? So
it? So we've
we've now assigned
now assigned different
assigned different sets
different sets of
sets of data
the same named
same named array
the same area
same area of
area of memory
of memory to
memory to store
to store that
store that and
that and should
and should have
should have overwritten
have overwritten the
overwritten the data
data that was
that was originally
was originally in
originally in that
So having repopulated
having repopulated this
repopulated this existing
this existing array
existing array with
array with different
with different information
different information, let's
now add it
And having added
having added it
added it to
the queue, let's
application again and
see what information
what information we
information we get
we get coming
get coming back
have an information
an information coming
information coming back
first array is
array is coming
coming out correctly
out correctly, as
as is the
And the third
the third array
third array, which
which was using
was using the
the same array
same array name
array name, is
is coming back
coming back with
back with the
with the information
information we put
we put into
put into that
So it's not
it's not using
not using the
using the original
the original array
original array at
array at all
The information going
information going into
going into the
queue is handled
is handled quite
handled quite separately
quite separately, even
even if we
we are continually
are continually reusing
continually reusing the
reusing the same
using this approach
this approach it's
approach it's quite
quite possible to
possible to put
to put different
put different types
We have so
have so far
so far put
far put three
put three sets
three sets of
sets of arrays
of arrays into
What happens now
happens now if
add a dynamic
dynamic string item
string item to
the queue? As
queue? As we
did in our
variant with a
with a dynamic
dynamic string, in
case the words
the words 'Apple
words 'Apple Pie'
use our enqueue
our enqueue method
enqueue method to
to add that
add that to
now have four
have four items
four items in
the queue, three
three arrays and
arrays and a
and a dynamic
we go down
go down to
down to our
code where our
where our case
our case statement
case statement is
statement is testing
testing the type
type of variant
of variant we've
variant we've got
we've got back
got back from
can add two
case statements, one
one to test
test for dynamic
for dynamic strings
it will use
use the variant$
the variant$ command
variant$ command to
to turn what's
turn what's in
in our variant
display it to
it to our
user in the
And if there's
if there's any
there's any other
any other type
other type coming
type coming back
can display a
display a simple
a simple message
we're getting our
getting our three
our three arrays
three arrays as
arrays as we
as we were
we were before
were before coming
before coming back
the collection, plus
plus we have
have our variant
our variant type
variant type 8
type 8, which
is our string
our string data
string data, and
and it's displayed
it's displayed on
the screen simply
screen simply as
simply as data
as data equals
data equals Apple
equals Apple Pie
in summary, we
can see using
see using this
this method that
method that you
you can put
can put different
of information as
information as variants
as variants into
variants into our
our collection queue
then pull the
information back one
back one item
time and display
display it or
it or use
or use it
allows the collection
collection queue to
queue to be
be very flexible
very flexible indeed
can use such
use such queues
such queues to
queues to keep
track of information
your application, for
on a list
list of computers
of computers to
computers to actually
to actually poll
actually poll for
poll for information
Once you have
you have contacted
have contacted the
contacted the computer
the computer, you
can put them
put them back
them back at
back at the
There are, however
limitations to putting
to putting arrays
putting arrays into
arrays into collection
into collection queues
The help file
help file that
ships with Power
with Power Basic
Basic does say
does say there's
say there's a
there's a limit
a limit to
limit to the
number of dimensions
of dimensions such
dimensions such a
such a queue
a queue can
queue can actually
can actually handle
In my time
my time in
time in programming
in programming, I've
I've used a
used a great
great many single-dimension
many single-dimension arrays
I've used many
used many more
many more two-dimensional
more two-dimensional arrays
two-dimensional arrays, a
a small number
small number of
number of three-dimensional
of three-dimensional arrays
three-dimensional arrays, and
and once I've
once I've used
used a four-dimensional
a four-dimensional array
of dimensions a
dimensions a collection
collection queue can
queue can handle
can handle is
handle is eight
is eight dimensions
I can't honestly
can't honestly conceive
honestly conceive a
conceive a need
a need for
need for an
an array that
array that has
that has eight
has eight dimensions
eight dimensions, but
but that's the
that's the limit
the limit that
limit that the
that the queue
queue collection can
collection can actually
So as a
as a limit
a limit, I
I think it's
think it's high
it's high enough
high enough up
enough up the
up the scale
the scale that
scale that you
that you may
you may never
may never encounter
never encounter it
you'll find queue
find queue collections



































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































