Welcome! In this
In this series
this series of
series of short
of short videos
short videos we
videos we will
we will look
will look at
look at topics
at topics for
topics for the
for the Power
the Power Basic
Power Basic Windows
Basic Windows Compiler
Today we will
look at the
at the creation
the creation of
creation of game
of game utilities
In looking at
looking at game
at game utilities
game utilities we're
utilities we're going
we're going to
going to start
to start by
start by looking
by looking at
at game maps
I considered making
considered making this
making this video
this video into
video into a
into a project
a project, however
however as we're
as we're not
we're not going
not going to
going to create
to create a
create a fully
a fully operational
fully operational game
operational game we'll
game we'll keep
we'll keep this
keep this as
this as a
as a snippet
a snippet video
It will however
will however give
however give the
give the advantage
the advantage in
advantage in showing
in showing how
showing how we
how we can
we can layout
can layout and
layout and design
and design a
design a new
a new application
What we have
we have on
have on screen
on screen here
screen here is
here is a
is a prototype
a prototype for
prototype for demonstration
for demonstration to
demonstration to a
to a user
This screen has
screen has all
has all the
all the controls
the controls on
controls on it
on it the
it the eventual
the eventual application
eventual application is
application is going
is going to
going to have
We have a
have a list
a list of
list of three
of three buttons
three buttons, two
two of which
of which are
which are initially
are initially deactivated
We have two
have two graphics
two graphics controls
graphics controls both
controls both labelled
both labelled 'World
labelled 'World Map'
'World Map', a
a smaller world
smaller world map
world map and
map and a
and a larger
a larger world
larger world map
And as you
as you will
you will see
will see from
see from the
from the two
the two labels
two labels on
labels on screen
on screen we're
screen we're keeping
we're keeping track
keeping track of
track of current
of current turns
current turns and
turns and current
and current rulers
So this is
this is going
going to be
to be a
be a turn
a turn based
turn based game
In designing an
designing an application
an application it's
application it's sometimes
it's sometimes very
sometimes very useful
very useful to
useful to prototype
to prototype what
prototype what the
what the application
the application is
going to look
to look like
So you can
you can discuss
can discuss it
discuss it with
it with the
with the user
the user to
user to make
to make sure
make sure you
sure you fully
you fully understood
fully understood their
understood their requirements
So what this
what this application
this application is
to be doing
be doing is
doing is we're
is we're going
going to allow
to allow a
allow a user
a user to
user to click
to click on
click on the
on the smaller
the smaller world
world map graphics
map graphics control
This will allow
will allow them
allow them to
them to select
to select a
select a world
a world map
world map from
map from disk
It will be
will be loaded
be loaded into
loaded into the
into the graphics
the graphics control
graphics control and
control and displayed
and displayed to
displayed to the
to the user
After that point
that point it
point it will
it will then
will then be
then be interrogated
be interrogated by
interrogated by the
by the application
The map will
map will contain
will contain both
contain both sea
both sea and
sea and land
and land areas
And this will
this will be
will be displayed
be displayed in
displayed in a
in a larger
a larger format
larger format in
format in the
in the large
the large graphics
large graphics control
graphics control labelled
control labelled 'World
So let's do
let's do the
do the first
the first task
first task to
task to allow
to allow the
allow the user
user to select
to select the
select the initial
the initial world
initial world map
will see I
see I have
I have designed
have designed two
designed two very
two very simplistic
very simplistic world
simplistic world maps
These are set
are set up
set up as
up as being
as being 100
being 100 by
100 by 50
by 50 pixels
If we zoom
we zoom in
zoom in we
in we get
we get a
get a rough
a rough idea
rough idea of
idea of what
of what this
what this world
this world map
world map looks
map looks like
It's basically a
basically a large
a large island
With one large
one large body
large body of
body of water
of water within
water within the
within the area
the area of
area of the
of the island
Each pixel on
pixel on this
on this screen
this screen is
screen is going
going to become
to become territory
become territory in
territory in the
in the program
the program itself
So let's have
let's have a
have a look
a look at
at the code
Our first task
first task is
task is to
is to allow
world map screen
map screen and
screen and allow
and allow them
to select either
select either of
either of these
of these two
these two world
two world bitmaps
So we will
we will have
will have a
at the callback
the callback function
callback function, the
the event handler
event handler for
handler for the
for the main
the main screen
And this is
this is the
is the game
the game builder
game builder screen
If we have
a look in
look in here
in here we'll
here we'll see
we'll see we've
see we've created
we've created already
created already a
already a number
a number of
number of variables
of variables to
variables to allow
to allow us
allow us to
us to control
to control what
control what the
what the user
the user is
user is doing
In the initialization
the initialization section
initialization section we're
section we're setting
we're setting up
setting up the
up the build
the build version
build version number
version number and
number and the
and the version
the version number
version number from
number from constants
from constants held
constants held at
held at the
at the beginning
the beginning of
beginning of the
of the program
These macros we
macros we covered
we covered in
covered in a
in a previous
a previous video
We're also setting
also setting the
setting the total
the total number
total number of
number of users
of users from
users from a
from a constant
In this case
this case it's
case it's a
it's a value
a value of
value of 50
And there is
there is the
is the code
the code where
code where we
where we disable
we disable two
disable two of
two of the
of the buttons
The process turns
process turns button
turns button and
button and the
and the process
the process bulk
process bulk turns
bulk turns button
So let's look
let's look at
look at clicking
at clicking on
clicking on the
on the graphics
Here we have
we have the
have the name
the name of
name of the
of the small
the small graphics
small graphics map
And we're already
we're already set
already set up
set up to
up to detect
to detect button
detect button clicks
button clicks on
clicks on that
on that control
When designing the
designing the form
the form we
form we set
we set this
set this graphics
this graphics control
graphics control up
control up with
up with the
with the notify
the notify option
This allows any
allows any event
any event happening
event happening on
happening on the
graphics control to
control to be
to be notified
be notified to
notified to this
to this callback
this callback function
So in order
in order to
order to allow
user to actually
to actually select
actually select a
select a file
a file we're
file we're going
going to use
to use the
use the display
the display open
display open file
open file command
This prompts the
prompts the user
the user with
user with a
with a standard
a standard dialog
standard dialog to
dialog to select
a file, which
which we put
we put a
put a title
a title on
title on it
on it saying
it saying select
saying select map
select map file
And we are
we are specifically
are specifically looking
specifically looking for
looking for files
for files with
files with the
with the extension
the extension BMP
extension BMP, bitmap
have the option
the option of
option of setting
of setting a
setting a flag
I'm going to
going to set
to set this
set this flag
this flag to
flag to ensure
to ensure that
ensure that the
that the file
the file must
file must exist
So the user
the user can't
user can't key
can't key in
key in the
in the name
name of a
of a file
a file by
file by hand
The return from
return from this
from this function
this function of
function of display
of display open
open file is
file is the
is the name
the name and
name and path
and path to
path to the
to the file
the file the
file the user
the user has
user has selected
If the user
the user does
user does not
does not select
not select a
a file and
file and clicks
and clicks on
clicks on the
on the cancel
the cancel then
cancel then the
then the map
the map file
map file variable
file variable will
variable will be
will be empty
So we test
we test that
test that to
that to ensure
that the user
user has indeed
has indeed selected
indeed selected a
selected a file
Next we use
we use the
use the graphics
the graphics attach
graphics attach command
attach command to
command to instruct
to instruct the
instruct the application
the application that
application that all
that all graphics
all graphics commands
graphics commands are
commands are to
are to be
to be directed
be directed towards
directed towards this
towards this specific
this specific graphics
specific graphics control
This is especially
is especially important
especially important as
important as we
as we have
graphics controls on
controls on the
on the dialog
So we're using
we're using graphics
using graphics attach
graphics attach followed
attach followed by
followed by three
by three parameters
The first being
first being the
being the handle
the handle of
handle of the
of the dialog
the dialog, the
the second being
second being the
of the graphics
control and the
and the final
the final command
final command is
command is the
is the redraw
the redraw command
This means we
means we want
we want any
want any instruction
any instruction going
instruction going to
going to the
to the graphics
graphics control not
control not to
not to be
to be made
be made visible
made visible to
visible to the
the user until
user until we
until we use
use the redraw
This radically speeds
radically speeds up
speeds up the
up the speed
the speed at
speed at which
at which graphics
which graphics can
graphics can be
can be generated
Next we want
we want to
want to take
to take the
take the bitmap
the bitmap file
bitmap file and
file and render
and render it
render it to
it to the
to the graphic
We do this
do this by
this by using
by using the
using the graphics
the graphics render
graphics render bitmap
render bitmap command
bitmap command and
command and it
and it takes
it takes two
takes two parameters
being the path
the path and
path and name
and name to
name to the
the file in
file in this
this case map
case map file
map file and
file and the
and the second
being the size
the size of
size of the
of the file
file in coordinates
Our dialog has
dialog has been
has been generated
been generated using
generated using the
using the pixels
the pixels option
It's much better
much better to
better to use
use the pixels
pixels option when
option when you're
when you're doing
you're doing specific
doing specific graphics
specific graphics operations
graphics operations on
operations on the
on the screen
So we can
we can then
can then use
then use the
the graphics copy
graphics copy command
copy command to
command to copy
to copy our
copy our bitmap
And then having
then having done
having done that
done that we
that we can
we can close
can close off
close off the
off the area
area of memory
of memory which
memory which has
which has been
has been used
been used to
used to generate
to generate the
generate the bitmap
the bitmap by
bitmap by using
the graphics bitmap
graphics bitmap end
bitmap end command
And then finally
then finally the
finally the graphic
the graphic redraw
graphic redraw command
redraw command to
command to redraw
to redraw the
redraw the graphic
the graphic onto
graphic onto the
onto the screen
And allow the
user to see
to see what's
see what's been
what's been done
So let's try
let's try running
try running that
running that code
that code now
If we click
we click on
on the world
the world map
world map we
map we will
we will get
will get the
get the select
the select map
map file on
file on screen
And if we
if we select
we select one
select one of
one of the
of the bitmaps
the bitmaps and
bitmaps and hit
and hit the
hit the open
the open button
open button the
button the graphic
the graphic has
graphic has now
has now been
now been populated
So our first
our first achievement
first achievement is
achievement is to
is to get
to get that
get that on
that on the
the screen to
screen to allow
to see it
They can then
can then at
then at any
at any point
any point later
point later pick
later pick a
pick a different
a different graphic
different graphic and
graphic and allow
and allow it
allow it to
it to be
to be loaded
So the next
the next task
next task is
is to rebuild
to rebuild the
rebuild the larger
the larger graphics
larger graphics control
So back to
back to the
to the code
So we're going
going to call
to call a
call a new
a new function
new function here
function here whose
here whose task
whose task it
task it is
it is to
rebuild the big
the big map
We're passing it
passing it naturally
it naturally in
naturally in a
in a number
number of parameters
being the dialog
the dialog handle
dialog handle and
handle and the
and the next
the next two
next two parameters
two parameters are
parameters are the
are the graphics
graphics control handles
graphics control of
control of the
of the smaller
the smaller graphic
smaller graphic and
graphic and the
and the one
the one of
of the larger
the larger graphic
larger graphic which
graphic which we
which we wish
we wish to
wish to populate
If this returns
this returns true
returns true then
true then our
then our rebuilding
our rebuilding of
rebuilding of the
the larger map
larger map has
map has been
has been successful
And we can
can then display
then display this
display this to
this to the
the user by
user by using
using the graphic
And then we're
then we're going
to set a
set a message
a message on
message on the
on the status
the status bar
status bar at
bar at the
at the bottom
the bottom of
bottom of the
of the screen
the screen just
screen just to
just to let
to let the
let the user
the user know
user know that
know that the
that the map
the map has
has been loaded
We will go
will go into
go into the
into the rebuild
the rebuild map
rebuild map routine
map routine in
routine in a
in a moment
a moment and
moment and create
and create it
But as there
as there are
there are a
are a couple
a couple of
couple of other
of other things
other things we
things we want
want to actually
to actually set
actually set up
up as the
as the user
user has just
has just loaded
just loaded a
loaded a map
want to set
to set the
set the turn
the turn number
turn number to
number to be
to be zero
is the very
the very first
very first turn
set a global
a global variable
global variable called
variable called turn
called turn number
turn number and
number and we'll
and we'll set
we'll set that
set that to
that to zero
And we want
want to update
to update the
update the screen
screen to update
update the current
the current turn
current turn field
we will create
will create another
create another function
another function called
function called set
called set turn
set turn number
turn number whose
number whose task
task it will
will be to
be to update
to update that
update that label
that label control
As we will
we will be
will be calling
be calling this
calling this function
this function at
function at several
at several points
several points during
points during the
during the run
the run of
run of the
of the application
So we now
we now have
now have two
have two new
two new functions
new functions to
functions to create
rebuild map and
map and the
and the set
the set turn
do the set
turn number first
This function takes
function takes a
takes a single
a single parameter
single parameter being
parameter being the
being the turn
the turn we
turn we want
to actually update
be a very
a very short
very short function
short function with
function with only
with only three
only three commands
The first is
first is a
is a control
a control set
control set text
This is to
is to set
to set text
set text on
text on the
on the particular
the particular text
particular text box
text box to
box to the
to the value
the value we
value we have
we have been
have been passed
been passed in
passed in on
in on the
on the parameters
the parameters list
Next we're going
to use a
use a control
a control redraw
control redraw command
command to force
to force windows
force windows to
windows to redraw
redraw the value
the value within
value within that
within that control
that control immediately
set the global
the global turn
global turn number
to be the
be the value
the value passed
value passed in
The reason we're
reason we're using
we're using a
using a control
control redraw rather
redraw rather than
rather than waiting
than waiting for
waiting for windows
for windows to
redraw the control
the control itself
control itself is
itself is that
is that part
that part of
part of this
of this application
this application will
application will be
will be running
be running in
running in a
in a loop
Running through a
through a large
a large number
large number of
number of turns
of turns one
turns one after
one after another
after another and
another and we
we want the
want the turn
number to keep
to keep track
keep track as
track as the
as the application
the application runs
So having populated
having populated that
populated that function
that function let's
function let's now
let's now go
now go and
go and create
and create the
create the rebuild
rebuild map function
is the function
the function that's
function that's going
that's going to
going to load
to load the
load the graphics
graphics control from
control from the
from the smaller
the smaller graphics
smaller graphics control
As you can
you can see
can see it
see it is
it is taking
is taking in
taking in the
in the three
the three parameters
three parameters, the
the dialogue handle
dialogue handle and
and the handles
the handles of
handles of both
of both of
both of the
the graphics controls
So there are
there are going
are going to
to be three
be three new
three new functions
new functions called
functions called within
called within this
within this function
first is to
is to load
to load an
load an array
an array of
array of data
of data from
data from the
from the first
the first graphics
first graphics control
control and we'll
and we'll call
we'll call that
call that function
that function load
function load map
load map array
So the first
the first thing
first thing the
thing the rebuild
map function is
function is going
going to do
to do is
do is to
to load data
load data into
data into an
into an array
will be the
be the map
the map array
So before we
before we go
we go any
go any further
any further let's
further let's go
let's go and
and create this
create this new
this new function
And there are
there are three
are three parameters
three parameters the
parameters the dialogue
dialogue handle, the
the reference to
reference to the
to the map
map array and
array and the
and the handle
small graphics control
going to step
to step through
step through each
through each of
each of the
of the pixels
the pixels within
pixels within our
within our graphics
our graphics control
graphics control get
control get the
get the value
the value of
value of that
of that pixel
that pixel and
pixel and determine
and determine whether
determine whether this
whether this is
to be sea
be sea or
sea or is
or is it
is it going
it going to
to be land
I've already worked
already worked out
worked out what
out what the
what the value
value of the
of the blue
the blue and
blue and green
and green pixels
green pixels are
pixels are going
So this way
this way we
way we know
we know which
know which are
which are sea
are sea and
sea and which
and which are
which are land
And I've set
I've set those
set those into
those into two
into two constants
two constants one
constants one code
one code to
code to Terrain
to Terrain sea
Terrain sea and
sea and one
and one code
to Terrain land
graphics controls we're
controls we're going
use a graphics
a graphics attach
that all operations
all operations are
operations are going
to be on
be on this
on this specific
graphics control, the
the smaller map
to do a
do a nested
a nested for
nested for next
for next loop
The structure of
structure of our
of our map
our map array
map array is
array is going
be a one
a one dimensional
one dimensional array
It's going to
to have 50
have 50 rows
This is equivalent
is equivalent to
equivalent to the
to the rows
the rows in
rows in the
in the graphics
And each row
each row is
row is going
to have 100
have 100 characters
100 characters, spaces
spaces which are
which are either
are either going
either going to
be a zero
a zero for
zero for sea
for sea or
sea or a
or a one
a one for
one for terrain
So this will
will be a
be a nested
Each time we
time we go
we go to
go to a
to a new
a new row
new row we
row we will
we will repopulate
will repopulate the
repopulate the data
the data variable
data variable putting
variable putting into
putting into it
into it 100
it 100 spaces
The space dollar
space dollar command
dollar command is
command is very
is very useful
very useful when
useful when you
when you want
you want to
want to put
to put a
put a fixed
a fixed number
fixed number of
number of spaces
of spaces into
spaces into a
into a variable
a variable to
variable to initialize
to initialize it
the graphics get
graphics get pixel
get pixel command
pixel command to
command to pull
to pull off
pull off the
off the pixel
the pixel at
pixel at our
at our coordinate
our coordinate position
This populates the
populates the pixel
the pixel variable
pixel variable and
variable and we
can then test
then test the
test the value
value of it
And having tested
having tested the
tested the value
value we can
can then determine
then determine whether
determine whether we
whether we want
put a zero
a zero or
zero or a
a one into
one into our
into our row
We're using the
using the mid
the mid dollar
mid dollar command
dollar command which
command which is
which is a
is a powerful
a powerful way
powerful way of
way of actually
of actually updating
actually updating just
updating just a
just a single
a single character
single character within
character within that
within that 100
that 100 character
100 character string
And then once
then once we
once we get
we get to
get to the
to the end
the end of
end of the
of the row
the row we
row we can
can then populate
then populate the
populate the array
the array by
array by putting
by putting the
putting the entire
the entire data
entire data string
data string into
string into that
into that value
And just to
just to allow
us to see
see what's gone
what's gone into
gone into the
into the array
the array we
array we can
we can dump
can dump the
dump the whole
the whole array
whole array out
array out to
out to a
to a text
a text file
text file using
file using one
using one of
of the functions
the functions in
functions in our
in our libraries
The array dump
array dump command
And we will
we will return
will return true
return true to
true to see
to see that
see that this
that this function
this function has
function has been
Before we run
we run our
run our application
our application we'll
application we'll need
we'll need to
need to ensure
ensure that our
that our map
map array has
array has been
has been properly
been properly dimensioned
properly dimensioned at
dimensioned at the
of the code
In the beginning
beginning of our
of our pb_main
our pb_main function
pb_main function we're
function we're using
using the randomize
the randomize timer
randomize timer command
This allows us
allows us to
us to use
use a pseudo
a pseudo random
pseudo random number
random number generator
number generator which
generator which we'll
which we'll need
we'll need later
need later on
later on in
on in the
So let's go
go and prepare
and prepare our
prepare our array
using the redim
the redim command
redim command to
command to dimension
to dimension our
dimension our map
be a value
the map height
map height constant
Allowing us 50
us 50 rows
50 rows in
rows in each
in each map
try running our
running our application
our application now
we can select
can select our
select our world
our world map
And let's look
let's look to
look to see
to see if
see if the
if the array
the array file
array file has
file has been
has been created
And there we
there we have
we have array.txt
If we open
we open that
open that up
that up we
up we will
we will see
will see it
it is all
is all ones
all ones and
ones and zeros
is the equivalent
the equivalent to
equivalent to what
to what we
have on our
on our map
So we have
we have successfully
have successfully selected
successfully selected a
selected a map
a map and
map and loaded
and loaded data
loaded data into
data into it
So now that
now that our
that our data
our data is
data is actually
is actually inside
actually inside the
inside the application
the application within
application within an
within an array
an array we
array we now
we now want
now want to
want to start
to start drawing
start drawing information
drawing information to
information to the
to the big
So we'll need
need to use
to use another
use another graphics
another graphics attach
that all new
all new graphics
new graphics commands
commands are going
are going towards
going towards the
towards the large
Now we need
we need to
need to draw
to draw the
draw the information
the information onto
information onto this
onto this terrain
this terrain map
So we'll do
we'll do that
do that in
that in a
in a new
call that drawTerrainMap
And we're passing
we're passing three
passing three variables
three variables to
variables to this
to this new
handle of our
of our large
our large graphics
and the data
the data held
data held within
held within the
within the map
let's go to
go to that
to that function
that function and
function and populate
and populate it
to be using
be using another
using another nested
another nested for
next loop here
And we'll be
we'll be looking
be looking at
looking at each
at each value
each value held
value held within
held within that
within that array
that array, the
we'll be populating
be populating coloured
populating coloured squares
coloured squares on
squares on the
screen to represent
to represent either
represent either sea
either sea or
sea or terrain
going to need
to need a
need a number
number of local
of local variables
local variables to
us to keep
keep track of
track of all
of all of
all of this
order to make
make sure how
sure how big
how big the
big the large
large graphics map
graphics map is
map is we're
use a graphic
a graphic get
graphic get size
get size command
size command to
to pull back
pull back the
back the size
the size and
size and pixels
and pixels both
pixels both width
both width and
width and height
and height of
height of our
of our graphics
Having determined that
determined that we
that we now
now have to
have to work
to work out
work out how
out how big
how big our
big our boxes
our boxes are
boxes are going
to be, what
what our X
our X and
X and our
and our Y
our Y sizes
Y sizes are
we can do
can do this
this by dividing
by dividing both
dividing both the
both the width
the width and
width and the
and the height
the height by
height by the
by the map
the map width
map width and
and the map
Our map width
map width is
width is 100
is 100 characters
100 characters and
characters and our
and our map
our map height
map height is
height is 50
is 50 characters
will see the
see the division
the division we're
division we're doing
we're doing is
doing is an
is an integer
an integer division
This means we're
means we're taking
we're taking a
taking a whole
a whole number
whole number division
So there'll be
there'll be no
be no decimal
no decimal places
So having worked
having worked out
worked out how
out how large
how large the
large the boxes
the boxes are
to be we
be we now
have to go
to go through
go through our
through our for
our for next
With for next
for next loops
next loops I
loops I tend
I tend to
tend to always
to always put
always put the
put the variable
the variable after
variable after the
after the next
the next command
next command although
command although this
although this is
this is not
is not actually
not actually necessary
While it's quite
it's quite easy
quite easy at
easy at the
at the moment
the moment to
moment to see
to see what
see what variable
what variable the
variable the next
next command is
command is actually
is actually operating
actually operating on
operating on either
on either long
either long R
long R or
R or long
or long C
Where the application
the application has
application has a
has a large
a large amount
large amount of
amount of code
of code between
code between the
between the for
the for and
for and the
the next commands
It's not always
not always obvious
always obvious which
obvious which is
which is which
So for documentation
for documentation purposes
documentation purposes I
purposes I always
I always put
next command to
command to make
to make it
make it obvious
it obvious which
obvious which variable
which variable is
variable is about
is about to
about to be
to be incremented
Next we need
need to work
work out the
out the coordinates
the coordinates on
coordinates on screen
on screen that
screen that we
that we want
to start at
Coordinates in graphics
in graphics controls
graphics controls are
controls are always
are always counted
always counted from
counted from the
from the top
the top left
top left hand
left hand corner
hand corner of
corner of the
graphics control which
control which is
which is always
is always 0
always 0 0
to need two
need two X
two X coordinates
X coordinates and
coordinates and two
and two Y
two Y coordinates
This will determine
will determine the
determine the top
small graphics box
graphics box we're
box we're going
going to draw
to draw and
draw and the
and the bottom
the bottom right
bottom right hand
right hand corner
will allow us
the graphics box
graphics box command
using a method
a method by
method by which
by which we're
which we're taking
we're taking long
taking long R
long R which
R which is
which is our
is our height
our height minus
height minus one
minus one multiplied
one multiplied by
multiplied by the
by the size
the size plus
size plus one
So for the
for the very
very first iteration
first iteration this
iteration this will
this will have
have a value
value of one
Both for the
for the X
the X and
X and the
and the Y
the Y coordinate
And then the
then the X2
the X2 and
X2 and the
and the Y2
the Y2 the
Y2 the bottom
of the box
the box are
box are going
of one plus
one plus the
plus the size
So this should
this should allow
should allow us
us to actually
to actually place
actually place all
place all the
all the boxes
the boxes on
boxes on the
on the big
the big graphics
big graphics control
graphics control quite
control quite efficiently
need to determine
to determine what
determine what color
what color the
color the box
the box is
box is going
going to refer
to refer to
refer to the
to the array
the array using
array using the
dollar command to
back the coordinates
the coordinates and
coordinates and give
and give us
give us one
us one character
This will either
will either be
either be 0
be 0 or
0 or 1
or 1 and
1 and we
we can set
can set the
set the full
the full color
full color either
color either to
either to light
to light blue
light blue for
blue for sea
sea or green
or green for
green for land
And all we
all we need
need to do
to do now
do now is
now is to
is to generate
generate the graphics
box command using
command using these
using these populated
these populated variables
And finish off
finish off by
off by marking
by marking the
marking the function
the function as
function as true
So a graphics
a graphics box
box command specifies
command specifies the
specifies the top
hand corner and
corner and the
And we're designated
we're designated the
designated the fill
the fill color
fill color for
color for both
for both the
both the outline
the outline of
outline of the
the box and
box and the
and the color
the color of
color of the
There are two
are two extra
two extra variables
extra variables which
variables which we've
which we've currently
we've currently populated
currently populated as
populated as zero
The one I
one I have
I have highlighted
have highlighted at
highlighted at the
the moment is
moment is the
is the one
the one that
one that designates
that designates what
designates what the
what the corners
the corners are
corners are like
are like on
like on the
on the box
If you mark
you mark it
mark it as
it as zero
as zero it's
zero it's got
it's got square
got square corners
This is basically
is basically a
basically a rounding
If the value
the value is
value is 100
is 100 it
100 it means
it means you're
means you're not
you're not drawing
not drawing a
drawing a graphics
graphics box you're
box you're drawing
you're drawing a
drawing a circle
a circle or
circle or more
or more correctly
more correctly an
correctly an ellipse
the final value
final value is
value is the
is the fill
the fill style
The default is
default is zero
is zero which
zero which is
is a solid
a solid fill
You can of
can of course
of course do
course do horizontal
do horizontal lines
horizontal lines, vertical
vertical lines or
lines or diagonal
or diagonal lines
But for the
for the purposes
the purposes of
purposes of what
of what we're
what we're doing
we're doing a
doing a solid
solid fill is
fill is ideal
now that we've
that we've created
we've created the
created the fun
the fun redraw
fun redraw terrain
redraw terrain map
terrain map let's
map let's return
let's return true
true to the
to the calling
the calling function
calling function and
function and run
and run the
run the application
the application once
application once more
map and we
we will find
will find that
find that our
that our large
map is now
is now populated
We have all
have all the
all the sea
the sea and
sea and all
and all the
all the terrain
the terrain marked
terrain marked on
marked on the
have successfully taken
successfully taken a
taken a world
map and pulled
and pulled it
pulled it in
it in and
in and displayed
However it's all
it's all one
all one large
one large graphics
You cannot see
cannot see the
see the individual
the individual territories
So what we're
what we're going
is to impose
to impose a
impose a grid
a grid on
grid on top
on top of
top of this
of this control
So after the
after the draw
the draw terrain
draw terrain map
terrain map we're
map we're going
new function called
function called drawGrid
And it's going
going to take
to take two
take two parameters
of the large
and create our
create our drawGrid
our drawGrid function
you can probably
can probably guess
probably guess there's
guess there's going
there's going to
to be more
be more for
more for next
next loops here
So we'll create
we'll create a
create a number
us to step
step through this
And as we
as we did
we did before
did before we're
before we're going
going to work
out the size
size of our
graphics control using
control using the
the graphic gate
graphic gate size
gate size command
are two sets
two sets of
sets of lines
of lines we
lines we need
to draw here
The vertical and
vertical and the
and the horizontal
to do two
do two separate
two separate for
separate for next
first is going
to be between
be between 1
between 1 and
1 and 101
Now this is
to be one
be one more
one more than
more than the
than the map
So I will
I will replace
will replace those
replace those hard
those hard codings
hard codings with
codings with our
with our constants
us to change
to change the
change the size
our graphics map
graphics map quite
map quite easily
quite easily at
easily at any
any point in
point in the
in the future
So this works
this works out
works out the
out the X
the Y coordinates
And we're using
the graphics line
graphics line command
line command to
command to draw
to draw a
draw a straight
a straight line
straight line from
line from the
the top of
top of the
screen to the
to the bottom
In a colour
a colour which
colour which we're
which we're designating
we're designating as
designating as black
If we try
we try running
that code as
code as it
as it stands
it stands we
stands we can
we can load
can load our
load our map
And it will
it will display
will display on
display on screen
on screen and
screen and we'll
and we'll have
we'll have the
have the vertical
the vertical lines
So all we
is to do
to do the
do the for
the for next
next loop for
loop for the
for the horizontal
the horizontal lines
Which is taking
is taking exactly
taking exactly the
exactly the same
the same approach
There are of
are of course
of course a
course a number
number of different
of different ways
different ways of
ways of generating
of generating grids
generating grids on
grids on graphics
on graphics controls
But if we
try running this
running this now
this now to
now to see
see if it
if it meets
it meets our
meets our needs
we have our
have our graphics
graphics control with
control with each
with each territory
each territory clearly
territory clearly shown
So in summary
in summary what
summary what we've
what we've done
we've done today
done today is
today is we've
is we've taken
we've taken a
taken a two
a two colour
two colour bitmap
We've allowed the
allowed the user
user to load
to load this
load this into
this into the
into the application
the application which
application which has
which has populated
has populated a
populated a string
a string array
This string array
string array has
array has then
has then been
then been used
to generate a
generate a larger
a larger and
larger and more
and more visible
more visible graphics
visible graphics control
Where the user
the user can
user can see
can see all
see all of
all of the
of the terrain
the terrain quite
terrain quite clearly
What we will
we will do
will do in
do in the
in the next
the next video
next video is
video is to
is to take
to take this
take this one
this one stage
one stage further
stage further and
further and generate
and generate computer
generate computer controlled
computer controlled rulers
Whose task is
is to run
to run round
run round the
round the map
the map and
map and try
and try and
try and occupy
and occupy territory
However we'll leave
we'll leave that
leave that for
that for the
for the next
That's it for
it for today
Thank you for
you for watching.
short videos, we
will look again
look again at
again at the
game utilities with
utilities with our
with our game
our game map
In our last
our last video
last video, we
we had created
had created an
created an application
an application which
application which allows
which allows us
us to load
to load a
load a world
This is done
is done by
done by the
by the user
the user clicking
user clicking on
clicking on a
on a graphics
a graphics control
control and then
and then selecting
then selecting the
selecting the map
the map of
map of choice
This then displays
then displays in
displays in a
a larger graphics
graphics control the
control the area
of the map
the map, which
which is Sea
is Sea, and
and the area
the area which
area which is
which is Land
there is a
is a grid
a grid superimposed
grid superimposed upon
superimposed upon that
upon that map
that map to
map to show
to show the
show the area
area of each
of each of
of the territories
to do in
do in today's
in today's video
today's video is
video is we're
to create 50
create 50 rulers
50 rulers which
rulers which are
which are going
to be positioned
be positioned on
positioned on the
on the Land
the Land portions
Land portions of
portions of this
of this map
They are then
are then going
then going to
to be animated
be animated as
animated as they
as they move
they move around
move around the
around the map
map and attempt
and attempt to
attempt to gain
to gain territory
Since we are
we are going
to the bother
the bother of
bother of creating
of creating this
creating this map
this map with
map with its
with its grid
its grid onto
grid onto which
onto which all
which all this
all this action
this action is
action is going
be animated, we
we don't want
don't want to
want to regenerate
to regenerate the
regenerate the map
the map for
map for every
for every single
every single frame
single frame of
frame of the
of the animation
going to store
to store the
store the map
the map as
map as it
as it currently
it currently stands
currently stands inside
stands inside a
inside a string
a string variable
do this in
this in Power
in Power Basic
Power Basic with
Basic with a
with a single
a single graphics
single graphics command
We're now looking
now looking at
looking at the
at the rebuild
the function which
function which takes
which takes our
takes our map
array and creates
and creates the
creates the terrain
the terrain map
terrain map and
map and draws
and draws the
draws the grid
the grid upon
grid upon it
Once that grid
that grid has
grid has been
has been drawn
been drawn, we
want to store
store the whole
the whole graphics
whole graphics map
graphics map into
map into a
into a single
a single variable
can do that
do that with
that with a
a single command
single command, 'graphics_get_bits'
This takes the
takes the graphic
the graphic control
graphic control which
which is currently
is currently the
currently the attached
the attached one
attached one, and
and takes all
takes all the
all the information
the information on
information on the
control and saves
and saves it
saves it to
it to this
to this string
this string variable
We've designated this
designated this as
as a global
a global string
global string to
string to allow
to allow it
to be accessed
be accessed from
accessed from anywhere
from anywhere within
anywhere within the
within the application
There is also
is also a
also a corresponding
a corresponding 'graphics_setbits'
corresponding 'graphics_setbits' command
'graphics_setbits' command to
command to put
to put that
put that string
that string back
string back into
back into the
into the control
do that at
that at the
at the start
the start of
start of each
of each turn
So if we
if we go
we go back
go back into
into the callback
callback function where
function where this
where this rebuild
this rebuild map
map function was
function was called
was called from
called from, we
we can see
can see this
see this is
this is where
is where the
where the turn
turn number is
number is actually
is actually set
is the initial
the initial setup
initial setup of
setup of the
What we want
want the user
user to do
is to click
on the 'Process
the 'Process Turns'
'Process Turns' button
Turns' button to
button to enable
to enable the
enable the first
the first turn
first turn to
turn to be
to be executed
And in that
in that first
that first turn
first turn, we
will create and
create and position
and position all
position all the
all the rulers
So at the
the moment, the
Turns' button is
button is currently
is currently deactivated
going to enable
to enable that
enable that here
do that using
that using the
using the 'Control
the 'Control Enable'
'Control Enable' command
Enable' command, which
which takes two
two parameters, the
the first parameter
first parameter being
the dialog, and
the second handle
second handle is
handle is the
is the handle
of the button
the button we
button we wish
wish to enable
Following that, we're
going to display
to display the
display the number
the number of
number of rulers
of rulers on
rulers on the
the screen by
screen by using
using the global
the global variable
global variable, which
which is the
is the long
the long current
long current rulers
if we run
application now, we
will see we
see we can
we can click
can click on
world map, we
we can pick
can pick our
pick our map
our map, and
and once the
once the map
the map is
map is displayed
is displayed, the
the 'Process Turn'
'Process Turn' button
Turn' button is
button is now
is now functional
our next task
is to put
to put some
put some code
some code in
code in the
in the event
event handler behind
handler behind the
behind the click
the click event
click event of
event of this
of this button
let's go into
So here we
here we are
we are inside
are inside the
inside the callback
callback function, our
our event handler
event handler, for
for the 'Process
When the button
the button is
button is clicked
is clicked, we
want to process
to process a
process a turn
to have to
have to create
create a new
new function whose
function whose purpose
whose purpose is
purpose is to
is to process
process a single
a single turn
to take three
take three parameters
dialog handle, and
the second is
second is the
The final parameter
final parameter we're
parameter we're giving
we're giving is
giving is the
is the turn
We're storing this
storing this in
this in a
in a global
And once this
once this very
this very first
first turn has
turn has been
has been processed
been processed, we
we can test
can test to
test to see
if the turn
the turn is
turn is now
is now turn
now turn number
turn number one
And at that
at that point
that point, we're
to be enabling
be enabling the
enabling the 'Bulk
the 'Bulk Turn'
'Bulk Turn' button
So once the
once the first
been processed, the
the user will
user will then
then be able
be able to
able to click
on the bulk
the bulk turns
we have that
have that set
that set up
up to process
to process But
process But we
But we first
we first have
first have to
to create the
create the 'Process
'Process Turn' function
Turn' function, so
let's do that
do that one
that one first
Our very first
very first command
first command in
command in here
in here should
here should be
should be to
be to attach
to attach to
attach to the
graphics control we're
control we're going
So our three
our three parameters
the one we're
one we're interested
we're interested in
interested in, is
is the big
big map variable
This is a
is a handle
a handle of
using a graphics
to instruct PowerBasic
instruct PowerBasic that
PowerBasic that all
that all subsequent
all subsequent commands
subsequent commands that
commands that are
that are graphics
are graphics related
graphics related will
related will be
will be directed
directed towards that
towards that control
turn number which
number which has
has been passed
parameters list is
list is a
is a value
value of 0
This indicates that
indicates that we
that we have
we have yet
have yet to
yet to process
to process the
process the first
As part of
of this first
this first turn
first turn processing
turn processing, we
want to position
to position and
position and update
and update the
update the rulers
the rulers on
on the map
is the first
So we're testing
we're testing the
testing the value
of the turn
turn number variable
number variable which
variable which has
which has come
has come in
come in on
in on our
on our parameters
As this is
this is 0
is 0, we
want to first
to first of
first of all
of all call
all call a
new function to
function to position
to position the
position the rulers
the second to
second to update
will create the
create the position
the position rulers
position rulers first
rulers first of
of all so
all so we
can test that
test that out
So this function
function takes no
takes no parameters
So we are
to be creating
be creating some
creating some local
some local variables
local variables, however
is to step
through each ruler
each ruler using
ruler using the
using the long
the long R
long R variable
R variable and
variable and to
and to determine
to determine the
determine the coordinates
the coordinates that
coordinates that the
that the ruler
the ruler will
ruler will appear
will appear on
appear on the
the map going
map going into
going into the
into the X
X and Y
and Y variables
As I only
I only want
only want the
want the rulers
the rulers to
rulers to appear
to appear on
on the landmass
the landmass and
landmass and not
and not in
not in the
in the sea
the sea, we're
use another variable
another variable, valid
to see whether
see whether the
whether the position
the position that
position that has
that has been
has been selected
been selected is
selected is valid
is valid or
valid or not
use a for
a for next
This will step
will step through
each of our
of our rulers
our rulers, initially
initially working out
working out that
out that the
that the position
the position its
position its in
its in is
in is false
And while that
while that is
that is false
is false, we
want to determine
to determine our
determine our X
and Y coordinates
where the randomise
the randomise command
randomise command we
command we set
we set up
set up the
up the beginning
the code is
code is going
to be used
We can use
can use the
use the RND
the RND command
RND command to
command to generate
generate a value
a value between
value between 1
1 and the
width and 1
and 1 and
is 100 and
100 and the
this will give
will give us
give us an
us an X
an X and
and Y coordinate
Y coordinate into
coordinate into which
into which we
which we can
see whether that
whether that coordinate
that coordinate is
coordinate is sea
is sea or
sea or land
This information is
information is stored
is stored in
stored in the
in the map
use the MID$
the MID$ command
MID$ command to
command to pick
to pick out
pick out the
out the value
the value in
value in that
in that string
that string of
string of that
of that array
value is 1
is 1, then
then we have
we have selected
have selected a
selected a land
a land area
As I don't
I don't want
don't want two
want two rulers
two rulers to
rulers to occupy
to occupy the
occupy the same
the same territory
same territory in
in the first
first turn, we're
to the Owner
the Owner Map
Owner Map array
This is an
is an array
an array which
array which has
which has one
has one element
one element for
element for each
for each territory
each territory on
territory on the
the map, and
this will tell
will tell us
tell us if
us if the
if the territory
the territory currently
territory currently has
currently has an
has an owner
an owner or
owner or not
So if the
value is 0
is 0, then
then it's not
it's not currently
not currently owned
currently owned, and
and our first
first task will
task will be
be to set
set the owner
the owner to
owner to be
be the ruler
the ruler we're
ruler we're processing
We're now going
now going to
to be looking
at the Rulers
the Rulers array
Rulers array, which
which is an
array of user-defined
of user-defined types
Just for clarity
for clarity, I'm
I'm displaying here
displaying here the
here the user-defined
the user-defined type
user-defined type, which
which we're going
to be referring
be referring to
documentation purposes, this
this is quite
is quite useful
want to populate
to populate that
populate that Rulers
that Rulers array
Y coordinates are
coordinates are the
are the position
position that the
the ruler is
ruler is on
is on the
The power element
power element is
element is 1
is the number
number of territories
of territories accumulated
territories accumulated by
accumulated by the
is the user
the user just
user just being
just being positioned
being positioned on
the map, they
they only have
only have one
have one territory
And each ruler
each ruler which
ruler which is
which is active
is active has
active has a
has a 1
a 1 in
1 in the
in the active
the active element
So our 50
our 50 rulers
50 rulers will
rulers will all
will all be
all be positioned
the map, be
be given the
given the value
value of 1
of 1 for
1 for power
for power, and
and they'll all
they'll all be
all be active
We can now
can now mark
now mark this
mark this one
this one as
one as being
as being valid
being valid, as
we have positioned
have positioned this
positioned this ruler
this ruler on
ruler on a
on a landmass
So the purpose
the purpose of
purpose of this
of this function
this function is
function is to
is to position
to position all
the rulers in
rulers in the
in the arrays
done that, we
have to position
to position them
position them on
them on the
the map based
map based on
based on this
on this data
the next function
next function we
function we have
we have to
to create is
create is the
is the Update
the Update Rulers
Update Rulers on
Rulers on map
This will actually
will actually place
actually place each
place each ruler
each ruler on
ruler on the
the map, so
so we'll want
we'll want a
want a small
a small marker
small marker to
marker to show
to show their
show their position
their position so
position so we
can see where
see where all
where all the
the rulers are
I've decided to
decided to make
to make this
make this marker
this marker red
marker red in
red in colour
So again, we're
to be needing
be needing some
needing some local
probably guess, we're
be doing yet
doing yet another
yet another For
another For Next
order to give
to give us
give us some
us some flexibility
some flexibility, just
just in case
in case you
case you wish
you wish to
wish to change
size of these
of these maps
these maps, I'm
going to determine
determine the size
graphics control based
control based on
based on what's
on what's on
what's on screen
on screen at
screen at this
at this point
this point in
point in time
in time, by
the graphic size
graphic size command
This will populate
will populate two
populate two variables
two variables, width
And then we
then we will
we will determine
the terrain boxes
terrain boxes by
boxes by dividing
by dividing the
dividing the width
the width by
width by the
So this tells
this tells us
tells us the
us the size
size of each
of each individual
each individual territory
individual territory on
And now we
now we have
So this goes
this goes from
goes from 1
from 1 to
1 to the
to the constant
the constant we
constant we populated
we populated for
populated for the
for the total
of rulers, which
is currently 50
We will at
will at some
at some point
some point later
point later want
later want to
put a ruling
a ruling to
ruling to remove
to remove rulers
remove rulers which
rulers which have
which have only
have only a
only a single
a single territory
is a ruler
a ruler whose
ruler whose empire
whose empire is
empire is declining
But we'll leave
leave that bit
that bit for
bit for now
Our first test
first test will
test will be
be to test
to test to
whether the ruler
ruler is currently
is currently active
currently active or
active or not
Once a ruler
a ruler has
ruler has been
has been killed
been killed off
killed off, they
they will no
will no longer
no longer be
longer be active
testing the active
active element of
element of our
of our ruler's
our ruler's array
If that equals
that equals 1
equals 1, the
ruler is active
is active and
active and we
can pick up
pick up their
up their X
their X and
is the terrain
the terrain on
terrain on the
the map they're
map they're actually
they're actually currently
actually currently in
work out where
out where the
where the coordinates
the coordinates are
coordinates are on
are on the
So we've got
we've got a
got a bit
a bit of
bit of a
of a arithmetic
a arithmetic to
arithmetic to do
to do here
I want to
want to display
display the rulers
the rulers as
rulers as basically
as basically circles
Small circles in
circles in red
in red on
red on the
order to do
to do that
do that, we're
be using the
For which we
which we need
need to specify
to specify the
specify the top
top left and
left and the
bottom right coordinates
And we're going
box command with
command with our
with our calculated
our calculated coordinates
value of 80
of 80 to
80 to make
to make the
make the box
the box almost
box almost circular
almost circular and
circular and specifying
and specifying two
specifying two colors
this case, red
both the color
of the circle
the circle and
circle and the
and the surround
the surround border
surround border of
border of that
of that circle
our application, we'll
need to test
test to make
make sure we've
sure we've actually
we've actually set
set up these
up these new
these new arrays
new arrays which
arrays which we're
which we're now
we're now accessing
at the pb_main
the pb_main function
We have already
have already dimensioned
already dimensioned the
dimensioned the map
two new arrays
new arrays, the
the ruler's array
ruler's array and
and the owner's
the owner's map
owner's map array
need to set
to set those
set those up
So the ruler's
ruler's array is
array is an
array of a
of a user
a user defined
user defined type
array is a
is a two-dimensional
a two-dimensional array
two-dimensional array of
array of 100
of 100 by
now that those
that those arrays
those arrays are
arrays are set
set up, let's
let's go back
go back to
to the function
function which processes
which processes turns
As we specified
we specified up
specified up here
up here to
here to use
attach command with
command with the
with the redraw
the redraw option
redraw option, in
order to get
to get the
get the data
the data appearing
data appearing on
appearing on screen
on screen to
the user, we'll
a graphics redraw
graphics redraw command
So we'll put
we'll put that
put that in
that in at
in at the
at the end
of the function
Without this graphics
this graphics redraw
redraw command, the
the user would
user would not
would not see
not see anything
see anything we
anything we have
we have updated
have updated on
updated on the
try running the
running the application
the application now
application now and
now and loading
and loading our
loading our map
And once we
once we click
on the process
the process turn
process turn button
turn button, our
our rulers should
rulers should be
should be displayed
we have 50
have 50 rulers
50 rulers displayed
rulers displayed on
displayed on the
the landmass of
landmass of the
the graphics map
So that is
that is our
is our very
very first initial
first initial turn
initial turn with
turn with all
with all the
rulers in place
next task for
task for turns
for turns beyond
turns beyond the
beyond the very
first turn is
turn is to
is to work
out the movement
the movement for
movement for the
for the rulers
now that we
the map, should
should the user
the user click
user click on
turn button once
button once more
once more, we'll
we'll want to
want to move
to move the
move the rulers
function whose task
be to move
to move our
move our rulers
our rulers around
rulers around the
end of this
this function we'll
function we'll want
want to increment
to increment the
increment the turn
move the turn
turn number on
number on by
on by one
by one value
one value, each
each time this
time this function
function is called
do that quite
that quite easily
quite easily by
easily by using
using the increment
the increment command
increment command, which
which adds one
adds one to
one to the
to the variable
the variable that
variable that follows
that follows it
So our turn
our turn number
number is initially
is initially zero
initially zero and
zero and is
and is then
is then incremented
then incremented by
incremented by one
by one to
one to have
to have a
can then set
then set the
number on screen
on screen by
screen by calling
by calling the
calling the setTurnNumber
the setTurnNumber function
setTurnNumber function, which
which as we
we did in
did in the
in the last
the last video
last video will
video will update
will update the
update the text
the text control
text control on
control on screen
So let's now
let's now look
now look at
look at this
at this new
new function, the
one that will
that will move
will move our
So this one
this one is
one is going
be a little
a little more
little more complex
more complex as
complex as we're
as we're building
we're building in
building in some
in some rules
some rules and
rules and functions
and functions for
functions for the
First we'll have
we'll have some
have some local
local variables as
variables as before
And again, we'll
we'll have a
have a for
in the previous
the previous function
previous function, we're
of our array
our array for
array for rulers
for rulers to
rulers to ensure
ruler is indeed
is indeed active
Once our ruler
our ruler becomes
ruler becomes inactive
becomes inactive, we
we will no
no longer move
longer move them
move them or
them or show
or show them
show them on
We will initially
will initially set
initially set the
set the terrain
the terrain to
terrain to be
be Sea, which
is an area
an area into
area into which
which we don't
don't want the
want the ruler
the ruler going
And we'll create
we'll create another
create another loop
another loop, a
a while loop
while loop, to
whether the terrain
the terrain is
terrain is Sea
Sea or not
to have 10
have 10 attempts
10 attempts at
attempts at moving
at moving a
moving a ruler
of all, we
where the ruler
the ruler actually
ruler actually is
actually is on
we can get
can get that
get that information
that information by
information by using
using the X
Y coordinates in
coordinates in the
in the rulers
Next we have
have to determine
determine the direction
the direction in
direction in which
in which the
which the ruler
ruler is going
going to move
going to pass
to pass back
pass back to
back to us
to us two
us two parameters
two parameters, a
a delta X
delta X and
X and a
and a delta
a delta Y
As the ruler
to move one
move one terrain
one terrain space
terrain space in
space in any
in any direction
any direction, this
this value could
value could be
could be either
be either 0
either 0, 1
1 or -1
or -1 for
-1 for each
for each of
each of these
of these parameters
And to ensure
to ensure our
ensure our ruler
our ruler will
ruler will not
will not wander
not wander off
wander off the
off the edge
the edge of
edge of the
which they shouldn't
they shouldn't do
shouldn't do, we'll
we'll test the
the value we're
value we're going
going to end
to end up
end up with
up with for
with for their
for their X
We'll come back
come back in
back in a
create the Get
the Get Direction
Get Direction function
Direction function, but
but let's push
let's push on
push on from
on from here
So now we
now we know
we know the
know the X
Y coordinate the
coordinate the ruler
ruler will be
will be moving
be moving into
moving into, we
determine the terrain
the terrain type
see whether this
this is Sea
So to determine
the terrain, we're
going to dip
to dip back
dip back into
into the map
map array, pulling
pulling back the
back the terrain
If that value
that value is
then the terrain
the terrain we'll
terrain we'll be
we'll be moving
moving into is
into is Sea
is Sea, so
we can iterate
can iterate the
iterate the loop
the loop and
loop and attempt
attempt to move
to move in
move in a
in a different
a different direction
to determine whether
determine whether the
terrain is already
is already owned
already owned or
owned or not
If the terrain
terrain is not
is not owned
not owned, then
then the ruler
the ruler can
ruler can move
can move into
move into that
into that terrain
that terrain and
terrain and mark
and mark it
it as belonging
as belonging to
belonging to them
value in the
in the Owner
If it's 0
it's 0, then
it's not owned
not owned, so
can then update
then update it
update it to
value of our
of our ruler
We can increment
can increment the
increment the number
of territories the
territories the ruler
ruler actually has
actually has, and
we can also
can also populate
also populate the
populate the X
coordinates in our
in our Rulers
our Rulers array
Of course, there's
there's always the
always the possibility
the possibility that
possibility that this
that this terrain
this terrain will
terrain will be
will be owned
be owned by
owned by the
by the ruler
the ruler themselves
So if that's
if that's the
that's the case
the case, we
we just want
just want to
move the ruler
the ruler into
ruler into that
And the other
the other possibility
other possibility is
possibility is that
is that the
that the terrain
terrain is owned
is owned by
owned by someone
by someone else
the case, there's
there's likely to
likely to be
be a battle
a battle to
battle to see
to see who's
see who's going
who's going to
going to own
to own the
own the terrain
the terrain, but
but we'll cover
we'll cover that
cover that one
that one later
that we've got
we've got to
got to the
end of that
of that function
that function, in
order to test
to test this
test this out
this out we'll
out we'll need
need to create
create the other
the other function
other function we've
function we've referenced
we've referenced, which
is the Get
a very small
very small function
small function to
function to return
to return a
return a random
a random direction
This again uses
again uses the
uses the RND
RND command, giving
giving us back
us back a
back a value
value between -1
between -1 and
-1 and plus
and plus 1
the value coming
value coming back
coming back for
back for both
both the X
Y coordinates is
coordinates is 0
then that would
that would mean
would mean the
mean the ruler
ruler is not
is not moving
not moving from
moving from the
from the terrain
the terrain they're
terrain they're currently
they're currently in
So we're running
we're running this
running this well
this well up
well up to
up to ensure
user will always
will always be
always be moving
be moving from
So as we
we have now
have now worked
now worked out
worked out where
where the rulers
rulers are going
to move to
move to on
to on the
map and updated
and updated the
updated the arrays
the arrays, we
have to update
the map itself
As we've already
we've already created
already created a
created a function
a function to
function to do
do that, we
we can just
can just paste
just paste this
paste this in
this in as
in as the
as the next
the next thing
next thing to
thing to do
want to redraw
redraw the basic
the basic map
As we've stored
we've stored that
stored that in
that in the
in the Game
the Game Map
Game Map global
Map global variable
global variable, we
can now use
now use the
use the GraphicsSetBits
the GraphicsSetBits command
GraphicsSetBits command to
to put the
put the map
the map back
So what the
the application should
application should do
should do now
do now on
now on the
on the first
first turn after
turn after the
after the rulers
the rulers have
rulers have been
have been positioned
been positioned is
positioned is to
is to move
rulers to another
to another location
This updates the
updates the internal
the internal arrays
internal arrays, then
then we restore
we restore the
restore the game
game map to
map to its
to its pristine
its pristine state
pristine state of
state of just
of just the
just the bare
the bare terrain
bare terrain and
terrain and the
and the grid
the grid, and
then we update
we update the
rulers on their
on their new
their new positions
So we try
application now, select
select our map
and click the
click the ProcessTurn
the ProcessTurn function
can now see
now see that
see that the
that the rulers
been positioned on
we click ProcessTurn
click ProcessTurn once
ProcessTurn once more
once more to
more to move
move to turn
to turn number
turn number 2
number 2, we
can see that
rulers have indeed
have indeed moved
we click it
click it once
it once more
once more, they
they have moved
have moved again
So our function
our function to
function to move
to move rulers
move rulers around
the map appears
map appears to
appears to be
to be working
be working quite
working quite happily
And the turns
the turns keep
turns keep increasing
in summary, what
what we've achieved
we've achieved today
achieved today is
today is we
is we have
we have generated
have generated 50
generated 50 rulers
have positioned them
positioned them on
and we now
now have a
have a nice
a nice little
nice little animation
little animation going
animation going each
going each time
each time the
time the user
the user clicks
user clicks ProcessTurn
The rulers decide
rulers decide in
decide in which
in which direction
which direction to
direction to move
to move, and
and move in
move in that
in that direction
While the arrays
the arrays in
arrays in the
in the background
the background are
background are being
are being updated
being updated to
updated to see
to see which
see which territories
which territories the
territories the users
the users are
users are controlling
are controlling, we're
we're not displaying
not displaying anything
displaying anything on
anything on the
screen to indicate
to indicate which
indicate which territories
which territories are
territories are actually
are actually owned
actually owned by
owned by which
by which rulers
we'll cover this
cover this in
this in the
Plus the battling
the battling between
battling between rulers
between rulers to
rulers to see
going to win
game utilities, with
game map by
map by adding
by adding territorial
adding territorial boundaries
This was our
was our application
our application at
application at the
of the last
We have created
have created a
created a terrain
a terrain map
This can be
can be loaded
be loaded by
loaded by clicking
by clicking on
on the 'Graphics
the 'Graphics Control'
'Graphics Control', which
is the world
then displays the
displays the terrain
terrain map in
map in a
graphics control, and
we can progress
can progress the
progress the game
the game by
game by clicking
clicking on 'Process
on 'Process Turn'
This will position
will position all
We have at
have at the
the moment Clicking
moment Clicking 'Process
Clicking 'Process Turn'
'Process Turn' once
Turn' once more
once more will
more will move
will move the
the rulers round
rulers round the
map and let
and let them
let them attempt
them attempt to
We have another
have another button
another button on
button on the
the screen, which
is the 'Process
the 'Process Bulk
'Process Bulk Turns'
This is designed
is designed to
designed to process
to process sequentially
process sequentially a
sequentially a series
a series of
series of turns
Currently we have
we have this
have this set
this set up
to process 100
process 100 turns
the code and
code and see
and see how
see how we
Event Handler, which
which is triggered
is triggered when
triggered when the
when the user
user clicks on
on the 'Bulk
the 'Bulk Turns'
'Bulk Turns' button
And here is
here is the
is the section
the section of
section of that
of that callback
that callback function
first task within
task within this
within this section
this section of
section of the
code is to
is to disable
to disable the
disable the 'Process
'Process Turns' and
Turns' and 'Bulk
and 'Bulk Turns'
'Bulk Turns' buttons
Turns' buttons, as
as the computer
the computer will
computer will be
will be busy
be busy processing
busy processing the
processing the request
the request, and
and you don't
you don't want
on the button
the button a
button a second
a second time
second time before
time before the
before the first
the first set
first set of
set of processing
of processing has
processing has completed
the 'Control Disable'
'Control Disable' command
Disable' command, specifying
specifying each of
the buttons we
buttons we wish
wish to 'Grey
to 'Grey Out'
Now all we
do is a
is a 'For
a 'For Next'
'For Next' loop
There is already
is already a
already a routine
a routine called
routine called 'Process
called 'Process Turn'
'Process Turn', and
and all we're
all we're going
to do within
do within this
within this 'For
this 'For Next'
Next' loop is
loop is to
is to call
to call that
call that routine
that routine once
routine once for
once for each
for each iteration
each iteration of
iteration of the
of the loop
'Bulk Turns' constant
Turns' constant is
constant is currently
is currently set
currently set to
set to the
value of 100
of 100, and
and we call
we call 'Process
call 'Process Turn'
'Process Turn' by
Turn' by passing
by passing its
passing its three
its three parameters
The 'Dialogue Handle'
'Dialogue Handle', the
the 'Handle of
'Handle of the
Large Graphics Control'
Graphics Control', and
and the 'Current
the 'Current Turn
'Current Turn Number'
And we're giving
we're giving it
giving it a
it a slight
a slight delay
slight delay of
delay of next
of next iteration
next iteration of
Once that loop
that loop has
loop has completed
has completed, we
can then re-enable
then re-enable the
re-enable the 'Process
Turns' and the
and the 'Bulk
So with this
with this small
this small amount
small amount of
of code, we've
we've now enabled
now enabled the
enabled the 'Bulk
Let's run the
the application and
application and see
see how it
how it performs
We click 'Process
click 'Process Turn'
'Process Turn' for
Turn' for the
for the initial
the initial turn
initial turn, then
then after that
after that we
Bulk Turns' to
Turns' to let
to let it
let it step
it step through
step through 100
through 100 turns
as we can
can see, it's
it's moving all
moving all the
the rulers around
rulers around quite
around quite happily
although the rulers
rulers are moving
are moving around
moving around, we're
we're not actually
not actually seeing
actually seeing which
seeing which territories
which territories they
territories they actually
they actually control
There's nothing on
nothing on the
the map to
map to indicate
to indicate where
indicate where one
where one territory
one territory is
territory is aligned
is aligned to
aligned to another
to another territory
another territory and
territory and owned
and owned by
owned by this
by this same
this same ruler
That's what we
what we need
to do next
do next, so
so let's get
let's get back
get back to
If we now
at the 'Process
Turn' function, the
Turn' function performs
function performs all
performs all the
all the calculations
the calculations and
calculations and the
and the moving
the moving of
moving of our
the moment, we're
we're doing this
doing this 'Update
this 'Update Rulers
'Update Rulers on
Rulers on Map'
There are additional
are additional functions
additional functions we'll
functions we'll need
need to slot
to slot in
slot in here
The next one
next one is
be the 'Update
the 'Update Territories'
new function is
going to redraw
redraw the territorial
the territorial borders
territorial borders and
borders and needs
and needs no
needs no parameters
So as you
the territories on
territories on the
have a nested
And we'll need
we'll need again
need again some
again some local
did in previous
in previous functions
previous functions, we're
graphics control by
control by using
using the 'graphic
the 'graphic get
'graphic get size'
get size' command
we will use
will use the
use the output
the output from
output from this
from this command
this command, the
the height, to
of each territory
territory on screen
And now we'll
now we'll do
we'll do our
do our nested
our nested For
Within this loop
this loop, we
work out what
out what kind
what kind of
kind of terrain
of terrain we're
terrain we're talking
we're talking about
going to delve
to delve in
delve in again
in again as
again as we
did before to
before to pick
out the terrain
terrain type from
type from the
from the map
as we are
we are only
are only interested
only interested in
interested in landmasses
in landmasses, if
if it's a
it's a zero
a zero, that
that means the
means the terrain
we can ignore
can ignore that
want to get
get the ruler
the ruler who
ruler who is
who is the
is the owner
the owner of
owner of that
of that territory
If the ruler
ruler is zero
is zero, then
then the territory
the territory is
territory is not
not owned by
owned by anyone
And if that's
need to go
to go no
go no further
no further in
further in this
in this particular
this particular loop
particular loop because
loop because the
because the territory
the territory not
territory not being
not being owned
being owned will
owned will keep
will keep its
keep its existing
its existing borders
have to check
to check if
check if the
ruler is now
is now inactive
In other words
other words, has
has this ruler
this ruler been
ruler been killed
been killed off?
killed off? And
off? And if
And if they
if they have
they have, then
then the ruler's
the ruler's claim
ruler's claim to
claim to the
to the territory
territory is null
is null and
null and void
can test the
test the ruler's
ruler's array to
array to see
whether the active
the active flag
active flag is
flag is zero
is zero or
zero or one
If it's zero
it's zero, then
then we can
we can clear
can clear the
clear the territorial
the territorial ownership
territorial ownership of
ownership of that
of that on
on the owner
And move on
move on to
on to the
to the next
the next territory
If we've got
we've got this
got this far
this far, then
the territory must
territory must be
must be owned
we now need
now need to
out the borders
the borders on
borders on all
on all four
all four sides
four sides of
sides of this
of this particular
this particular territory
store the top
the top left-hand
top left-hand coordinates
left-hand coordinates of
coordinates of the
of the territory
the territory we're
territory we're currently
we're currently looking
currently looking at
is a straightforward
a straightforward piece
straightforward piece of
piece of arithmetic
of arithmetic, taking
taking the X
Y coordinates, subtracting
subtracting one from
one from each
from each of
each of them
of them, and
and then multiplying
then multiplying by
multiplying by the
of our territory
This gives us
gives us the
us the pixel
the pixel coordinates
pixel coordinates on
on screen, within
within the graphics
to check each
check each of
of the terrains
the terrains, to
to the left
the left, to
to the right
the right, above
above and below
of all, we'll
we'll do the
do the one
the one to
the left of
left of the
we're currently in
We can work
can work this
work this out
this out quite
out quite easily
easily by subtracting
by subtracting one
one from the
from the X
the X coordinate
function called 'checkTerrain'
called 'checkTerrain' for
'checkTerrain' for ownership
for ownership, passing
passing it the
it the owner
owner of the
currently in, the
the coordinate we
coordinate we want
to actually check
actually check, the
the Y, and
and then, if
if that returns
that returns true
returns true, then
we can redraw
can redraw our
redraw our border
returns true, it
it means the
means the territory
the territory to
territory to the
of the one
one we're in
we're in is
in is owned
by the same
the same person
same person that
person that owns
that owns this
owns this current
this current territory
the graphic line
graphic line in
line in a
in a green
a green colour
green colour, effectively
effectively wiping it
wiping it out
So let's create
let's create this
this new 'checkTerrain'
new 'checkTerrain' for
for ownership function
And here we
have the skeleton
the skeleton of
skeleton of our
of our new
our new function
within this new
is to determine
to determine if
determine if the
if the X
Y coordinates we're
coordinates we're looking
we're looking at
looking at are
at are outside
are outside the
outside the boundaries
the boundaries of
boundaries of the
Are they zero
they zero or
zero or greater
or greater than
greater than the
map width or
width or map
or map height?
map height? If
height? If that
If that is
that is the
is the case
the case, then
territory we're trying
we're trying to
trying to look
to look at
look at is
at is off
is off the
off the map
we can return
can return false
have to test
whether the 'map'
the 'map' array
'map' array has
array has this
has this particular
this particular terrain
particular terrain as
terrain as zero
as zero or
it's zero, we're
we're not interested
not interested as
interested as it's
as it's a
it's a 'Sea
a 'Sea Terrain'
if it's 'land'
it's 'land', we
can then check
then check to
check to see
whether the owner
owner of this
of this terrain
this terrain is
terrain is equal
is equal to
equal to the
the terrain we're
terrain we're coming
we're coming from
that value matches
value matches, then
then we'll be
we'll be turning
be turning the
turning the value
the value true
value true for
true for the
for the function
If not, we'll
we'll return false
And that completes
that completes the
completes the logic
the logic in
logic in this
in this function
this function, so
we can go
can go back
back to our
to our calling
our calling routine
that we've checked
we've checked the
checked the terrain
terrain to the
the left, we
have to do
to do exactly
do exactly the
the same calculation
same calculation for
calculation for the
for the terrain
the right, the
the terrain above
terrain above and
above and the
and the terrain
the terrain below
we will paste
will paste in
paste in the
in the code
the code to
code to do
to do these
So the entire
the entire logic
entire logic of
logic of this
of this routine
this routine is
routine is to
is to check
to check the
check the ownership
the ownership of
ownership of the
the terrains surrounding
terrains surrounding the
surrounding the terrain
terrain we're currently
If they all
they all have
all have the
have the same
the same owner
same owner, then
we can effectively
can effectively wipe
effectively wipe out
wipe out the
So if we're
if we're on
we're on the
on the application
application now to
now to try
to try our
try our changes
our changes, we
load our world
map and click
and click on
click on 'Process
we click the
click the 'Process
Turns' to give
give us a
us a hundred
a hundred iterations
hundred iterations of
iterations of the
the turn processing
moving around the
And as they
they are attempting
are attempting to
attempting to gain
to gain new
gain new territory
can see now
see now that
now that it's
that it's completed
it's completed a
completed a hundred
a hundred turns
hundred turns, we
can see the
see the borders
the borders have
borders have been
have been wiped
been wiped out
wiped out and
out and we
see the extent
the extent of
extent of each
of each little
each little empire
rulers are only
are only occupying
only occupying and
occupying and owning
and owning territories
owning territories where
territories where the
where the terrain
the terrain currently
terrain currently has
currently has no
has no owner
can now move
now move on
the next stage
next stage, which
which involves battle
involves battle simulation
to do this
do this, we
need to look
to look again
at the 'Move
the 'Move Rulers'
'Move Rulers' function
function is designed
designed to move
is a section
a section which
section which determines
which determines if
determines if the
then the user
user just moves
just moves into
moves into it
into it, and
and becomes the
becomes the new
the new owner
have to populate
to populate the
populate the case
the case where
case where it
where it is
it is owned
So first of
need to pick
to pick up
pick up who
up who the
who the previous
the previous owner
previous owner actually
owner actually is
actually is, looking
at the owner
we will populate
will populate a
populate a variable
variable to contain
to contain the
contain the number
number of the
of the previous
a new routine
new routine called
routine called 'Battle
called 'Battle Won'
This routine will
routine will return
return true if
true if the
the ruler, who
who has attempted
has attempted to
attempted to move
to move into
move into this
into this territory
this territory, has
has actually won
actually won the
won the territory
the territory in
territory in battle
we'll create that
create that routine
that routine in
a moment, but
but first we'll
first we'll push
we'll push on
push on with
on with the
with the code
the code within
code within here
within here, on
on the assumption
the assumption that
assumption that the
the ruler has
ruler has actually
won the battle
we can update
can update the
update the ruler's
the ruler's location
ruler's location to
location to the
to the location
the location of
location of the
terrain we're moving
we're moving into
can also mark
also mark it
it as owned
as owned and
owned and increment
and increment the
increment the ruler's
the ruler's power
ruler's power –
power – the
– the number
of territories they
territories they currently
they currently own
And if the
if the battle
the battle has
battle has not
has not been
not been won
been won, we
we won't move
won't move the
ruler into it
We'll leave the
leave the ruler
the ruler where
ruler where they
where they currently
they currently are
now we can
we can look
can look at
look at creating
at creating and
creating and populating
and populating our
populating our 'Battle
our 'Battle Won'
'Battle Won' function
order to determine
to determine who
determine who wins
who wins the
wins the battle
the battle, there
there has to
has to be
to be some
be some logic
some logic in
logic in here
in here working
here working out
working out which
out which of
which of the
of the two
the two rulers
two rulers is
rulers is the
is the more
the more powerful
create a couple
couple of variables
variables to work
out how many
how many points
many points the
points the defender
the defender and
defender and how
and how many
points the attackers
the attackers actually
attackers actually have
And is the
is the defender
the defender themselves
defender themselves actually
themselves actually present
actually present in
present in the
in the terrain
the terrain that's
terrain that's being
that's being invaded?
being invaded? And
invaded? And in
And in addition
in addition to
addition to these
to these, we'll
need to make
to make some
make some kind
some kind of
kind of adjustment
of adjustment for
adjustment for the
for the number
number of victories
of victories or
victories or defeats
or defeats each
defeats each of
of the rulers
the rulers actually
rulers actually has
actually has in
has in the
in the past
will populate our
populate our defender
our defender powerpoints
defender powerpoints and
powerpoints and our
and our attacker
our attacker powerpoints
attacker powerpoints based
powerpoints based on
based on the
on the number
of territories that
territories that each
that each of
rulers actually currently
actually currently has
I will determine
will determine whether
whether the defender
the defender is
defender is actually
is actually within
actually within the
within the territory
the territory or
territory or not
If the defender
defender is in
is in the
in the territory
the territory, then
then this should
this should increase
should increase the
increase the chances
the chances of
chances of success
ruler's array for
array for the
Y coordinates of
coordinates of our
of our defenders
is actually in
actually in the
the territory, we're
going to increase
to increase their
increase their powerpoints
their powerpoints by
powerpoints by 10%
we will make
will make some
make some adjustments
some adjustments for
adjustments for previous
for previous victories
previous victories and
victories and subtract
and subtract any
subtract any defeats
any defeats, both
for the attacker
the attacker and
attacker and the
and the defender
the defender, and
and these values
these values will
values will be
will be added
be added on
added on to
to the powerpoints
the powerpoints they
powerpoints they have
they have accumulated
if the attacker's
the attacker's powerpoints
attacker's powerpoints are
powerpoints are greater
are greater than
than the defender's
the defender's powerpoints
defender's powerpoints, then
we will reduce
will reduce the
reduce the territories
the territories owned
territories owned by
by the defender
the defender by
defender by using
using the 'Decrement'
the 'Decrement' command
'Decrement' command to
command to decrement
to decrement their
decrement their power
their power value
power value in
in the ruler's
we will increment
will increment the
number of defeats
of defeats by
defeats by the
defender and increment
of victories by
victories by the
by the attacker
If at this
this point the
point the defender's
the defender's power
defender's power is
power is down
is down to
down to zero
to zero, in
other words they
words they have
they have no
have no territories
no territories left
territories left, then
then the last
the last territory
last territory has
territory has gone
has gone, so
we will mark
will mark the
mark the defender
the defender as
defender as inactive
if the attacker
the attacker has
attacker has won
has won and
won and the
the defender was
defender was present
was present in
going to mark
to mark the
defender as being
as being eliminated
being eliminated, in
other words we
words we will
will make them
make them inactive
will return 'true'
return 'true' to
'true' to the
the defender themself
defender themself has
themself has actually
actually won this
won this battle
this battle, then
attacker and increment
and return the
return the value
the value false
value false to
false to the
that we've completed
we've completed our
completed our battle
our battle routines
battle routines and
routines and updated
updated the territories
the territories, there's
there's another two
another two functions
two functions we'll
need to call
First one is
one is a
is a check
a check on
check on the
on the territories
by the rulers
the second routine
second routine to
routine to complete
to complete this
complete this section
this section will
section will be
update the ruler
the ruler count
ruler count on
count on screen
on screen, as
as some of
some of the
the rulers may
rulers may have
may have been
have been made
been made inactive
made inactive and
inactive and you
and you want
want to reduce
to reduce the
reduce the number
of rulers shown
rulers shown on
shown on the
on the front
the front screen
front screen to
at the 'Check
the 'Check ruler
'Check ruler territories'
ruler territories' first
of territories owned
owned by rulers
by rulers to
that the count
the count is
count is actually
is actually correct
you can guess
can guess, this
this is another
is another 'for
another 'for next'
So within this
this loop, we're
the active property
active property of
property of each
is currently inactive
currently inactive, then
then they should
they should have
should have no
have no territorial
no territorial power
So in each
in each case
each case, we're
we're ensuring this
ensuring this is
this is containing
is containing the
containing the value
the value 0
ruler is still
is still active
still active, then
then we want
want to recount
to recount the
recount the number
owned by them
we will drop
will drop into
drop into another
into another new
another new function
new function, whose
whose job it
job it is
is to count
to count these
count these up
these up, passing
passing a single
single parameter which
parameter which is
is the OwnerNumber
And again, this
is another nested
another nested 'for
nested 'for next'
next' loop, looking
at the OwnerMap
the OwnerMap array
Should the OwnerMap
OwnerMap array equal
array equal the
equal the owner
the owner we're
owner we're actually
we're actually looking
actually looking at
looking at, then
then we'll increment
we'll increment a
increment a count
a count variable
will return that
return that count
that count variable
count variable to
variable to the
the calling routine
And that will
that will feed
will feed into
feed into the
into the power
the power value
the final call
final call within
call within this
this section is
section is the
is the call
the call to
call to update
ruler count function
count function, which
which we have
we have previously
have previously completed
running our simulation
our simulation once
simulation once more
can select the
select the World
can click Process
click Process Turn
Process Turn to
Turn to process
first turn, and
we will click
will click Process
click Process Bulk
As the rulers
the rulers move
rulers move around
the map, you
see the current
the current number
current number of
of rulers is
rulers is being
is being reduced
Each time one
time one of
the rulers is
rulers is eliminated
is eliminated, the
the screen will
screen will be
will be updated
be updated to
updated to show
show the current
the current rulers
So we've now
we've now lost
now lost three
lost three of
three of our
If we process
we process it
process it once
once more, we
see that rulers
that rulers are
rulers are increasing
are increasing the
increasing the size
size of their
of their territories
And in the
in the process
the process of
process of doing
of doing that
doing that, some
of the other
the other rulers
other rulers are
rulers are being
are being eliminated
So what we've
we have enabled
have enabled the
enabled the Process
Turns button, to
us to execute
to execute 100
execute 100 turns
100 turns at
turns at a
at a time
In addition, the
boundaries of territory
of territory are
territory are being
being updated by
updated by redrawing
by redrawing the
redrawing the map
the map, eliminating
eliminating the boundaries
the boundaries between
boundaries between territories
This on screen
on screen gives
screen gives you
gives you a
you a nice
a nice display
nice display to
display to show
to show you
show you which
you which territories
territories are bigger
are bigger than
bigger than others
And you can
you can easily
can easily see
easily see which
which territories have
territories have not
have not been
not been owned
been owned by
we have added
have added some
added some simple
some simple battle
simple battle routines
battle routines, working
working out the
out the strength
the strength of
strength of both
of both attackers
both attackers and
attackers and defenders
These are very
are very simple
very simple routines
simple routines, but
but they do
they do give
do give you
give you a
you a good
a good simulation
Hopefully you find
you find this
find this type
this type of
type of code
of code interesting
code interesting, but
but that's it
by adding a
adding a zoom
a zoom window
The dialog we
dialog we see
we see on
see on screen
screen here allows
here allows us
us to select
Having selected a
selected a world
world map, it's
it's displayed on
on the large
can then attempt
then attempt to
attempt to process
a turn, which
which positions 50
positions 50 rulers
50 rulers on
Once we hit
we hit the
hit the 'Bulk
'Bulk Turns' it
Turns' it will
will then process
then process 100
100 turns and
turns and allow
and allow each
allow each of
rulers to move
to move around
map and start
and start to
start to gain
This gives you
gives you an
you an indication
an indication of
indication of the
of the size
of the little
the little empires
little empires that
empires that the
rulers are creating
to do today
do today is
today is zoom
is zoom in
zoom in on
on the main
the main graphics
main graphics map
If we move
we move a
move a mouse
a mouse over
mouse over one
over one of
the territories, or
or perhaps one
perhaps one of
the rulers, and
and left click
left click on
on the mouse
the mouse, we
get a pop-up
a pop-up window
This pop-up window
pop-up window shows
window shows us
shows us the
us the X
It also shows
also shows us
us the owner's
the owner's number
owner's number and
number and some
and some details
some details about
details about the
about the owner
This owner is
owner is currently
currently active and
active and they
and they have
they have control
have control of
control of 38
of 38 of
38 of the
look at now
at now is
now is how
is how we
how we achieved
we achieved the
achieved the clicking
the clicking on
and the determination
the determination of
determination of which
of which terrain
which terrain we
terrain we were
we were actually
were actually clicking
actually clicking on
event handler of
handler of the
of the main
the main dialog
In here is
the code that
code that handles
that handles each
handles each of
of the events
the events that
events that occur
that occur on
occur on the
We're specifically looking
specifically looking at
at the graph
the graph territories
graph territories graphics
territories graphics control
Here we're picking
we're picking up
picking up the
up the fact
the fact that
fact that it
that it has
it has been
has been clicked
been clicked on
determine the X
Y coordinates on
coordinates on the
graphics control itself
by using a
using a couple
a couple Windows
couple Windows API
Windows API calls
of all is
all is the
the get cursor
get cursor position
cursor position call
This takes a
parameter which we're
designating as the
as the letter
the letter P
If we look
we look at
beginning of this
this function, we
will see that
that the local
the local variable
local variable P
variable P is
P is a
is a point
a point API
point API user
API user defined
defined type which
type which we're
which we're using
we're using to
using to determine
determine the mouse
the mouse position
mouse position on
position on the
So the get
position call will
call will populate
populate our P
our P variable
use the screen
screen to client
to client call
client call passing
call passing it
passing it two
it two parameters
The CBL param
CBL param and
param and the
and the user
the user defined
defined type P
give us the
Y coordinates which
coordinates which are
which are two
are two elements
two elements of
elements of that
of that user
that user defined
then determine the
the terrain by
terrain by dividing
dividing the X
control by the
of our terrain
our terrain boxes
we're passing these
passing these two
these two values
two values, the
Y coordinates to
coordinates to our
to our dialogue
our dialogue terrain
dialogue terrain info
is a second
a second dialogue
second dialogue in
dialogue in our
in our application
see it takes
it takes the
takes the standard
the standard parent
standard parent variable
parent variable which
variable which tells
which tells it
tells it which
it which dialogue
which dialogue called
dialogue called this
called this dialogue
this dialogue and
dialogue and the
and the X
coordinates we're bringing
we're bringing in
Having got the
got the X
Y coordinates we
coordinates we can
we can determine
can determine who
determine who the
who the owner
the terrain actually
terrain actually is
actually is by
is by interrogating
by interrogating our
interrogating our owner
our owner map
got the owner
the owner number
owner number we
number we can
can then interrogate
then interrogate the
interrogate the ruler's
array to work
work out whether
out whether that
whether that ruler
that ruler is
is active or
If it's returning
it's returning a
returning a value
of 1 then
1 then the
then the owner
the owner is
If the owner
owner is 0
is 0 then
0 then this
then this terrain
this terrain currently
we can populate
can populate the
populate the text
the text box
text box on
box on screen
screen to show
to show those
show those details
Plus we're calling
we're calling the
calling the count
the count territory's
count territory's owned
territory's owned function
owned function to
function to determine
to determine how
determine how many
how many territories
many territories that
territories that ruler
that ruler actually
ruler actually controls
populate the controls
controls on screen
screen to pass
to pass this
pass this information
this information back
information back to
to our user
So while this
while this provides
this provides some
provides some interesting
some interesting information
interesting information, however
however there is
there is more
is more we
more we can
can do with
do with this
with this pop-up
to display two
display two additional
two additional graphics
additional graphics controls
One giving us
giving us a
us a display
a display of
display of the
the terrain from
terrain from the
from the main
the main map
main map and
map and one
and one giving
us a 3D
a 3D look
3D look at
at the terrain
a look back
look back at
back at the
at the dialogue
the dialogue to
dialogue to see
see what we're
going to add
of all we're
to add the
add the two
the two graphics
graphics controls to
controls to the
to the list
the list of
list of objects
of objects on
objects on this
on this second
this second dialogue
have a small
a small graphics
control and a
a larger 3D
larger 3D terrain
3D terrain one
We'll cover the
cover the code
the code for
code for the
for the small
the small map
small map first
map first of
order to copy
to copy part
copy part of
this first graphics
graphics control I
control I want
to actually pick
actually pick up
pick up the
up the location
the location, the
Y coordinates that
user has actually
has actually clicked
actually clicked on
Now we're already
we're already picking
already picking them
picking them up
them up in
up in this
in this PX
this PX and
PX and PY
So I want
want to pass
to pass them
pass them as
them as additional
as additional parameters
additional parameters to
parameters to the
to the show
the show dialogue
show dialogue terrain
terrain info call
there are our
are our additional
our additional parameters
I'm passing the
passing the handle
the handle for
handle for the
for the graphics
graphics control that
control that we
that we wish
wish to copy
to copy and
copy and the
that function we
function we want
want to add
to add those
add those parameters
those parameters onto
parameters onto the
onto the parameter
the parameter list
And there they
there they are
they are on
on the list
order to accommodate
to accommodate these
accommodate these two
these two new
two new graphics
new graphics controls
graphics controls we'll
controls we'll need
make the dialogue
the dialogue a
dialogue a little
a little bit
little bit bigger
there we are
we are taking
are taking our
taking our dialogue
our dialogue up
dialogue up to
up to 501
to 501 pixels
501 pixels wide
pixels wide and
wide and 350
and 350 pixels
350 pixels high
we will additionally
will additionally move
additionally move some
move some of
of the controls
the controls around
controls around to
around to accommodate
to accommodate our
accommodate our two
our two new
two new controls
we will add
will add the
the two new
This is for
is for our
for our graphics
our graphics 3D
graphics 3D terrain
3D terrain and
terrain and for
and for the
Additionally I want
to put something
put something on
something on the
on the text
the text to
text to indicate
to indicate to
indicate to the
the user that
user that the
the ruler for
ruler for that
for that particular
that particular territory
particular territory is
territory is actually
inside the territory
Because this is
this is used
is used for
used for calculation
for calculation when
calculation when we
when we get
get to a
to a battle
a battle routine
we will slot
will slot a
slot a little
a little if
little if condition
if condition in
condition in there
in there that
there that tests
that tests the
tests the X
of the ruler
If they're actually
they're actually matching
actually matching the
matching the X
the terrain the
terrain the user
user has clicked
has clicked on
clicked on then
on then we
that the owner
owner is in
to copy a
copy a piece
a piece of
piece of the
graphics control on
control on the
on the original
the original parent
original parent dialogue
parent dialogue we
dialogue we need
need to actually
to actually use
actually use a
command to specify
to specify that
specify that where
that where we're
where we're wanting
we're wanting to
wanting to draw
to draw to
draw to is
to is going
be the new
the new graphics
new graphics control
on the child
the child dialogue
So the graphics
attach command specifies
specifies the small
graphics map on
map on a
on a new
a new dialogue
graphics get size
up the X
and Y sizes
Y sizes of
sizes of our
On the small
graphics control we
control we want
want to center
to center the
center the location
the location the
location the user
the user clicked
user clicked on
clicked on in
in the center
the center of
center of the
we're using an
using an offset
an offset command
offset command to
command to determine
can then pass
then pass that
pass that to
that to the
copy command takes
command takes a
takes a number
The first two
first two parameters
two parameters designate
parameters designate the
designate the handle
of the payment
the payment dialogue
payment dialogue and
the payment graphics
payment graphics control
And the values
the values in
values in brackets
in brackets after
brackets after that
after that and
that and the
and the location
the location onto
location onto which
onto which you
which you want
want to place
to place that
place that data
then we're using
using graphics redraw
graphics redraw to
redraw to redraw
to redraw it
redraw it to
to the screen
the screen so
screen so the
user can actually
can actually see
actually see that
So we've also
we've also declared
also declared some
declared some new
some new variables
new variables at
variables at the
beginning of that
and Y offsets
Y offsets and
offsets and the
world map, process
first turn and
turn and if
click on a
on a location
a location we're
location we're getting
we're getting our
getting our populated
our populated small
populated small graphics
graphics control showing
control showing the
showing the location
the location that
location that the
This is very
very useful as
useful as it
as it saves
it saves having
saves having to
having to move
move the dialogue
see what's underneath
that we've achieved
we've achieved that
achieved that, we
to display to
display to the
the user a
user a 3D
a 3D polygon
3D polygon map
This will help
will help differentiate
help differentiate between
differentiate between locations
between locations which
locations which are
are sea terrain
sea terrain and
terrain and which
are land terrain
is a piece
piece of code
of code we
code we wrote
we wrote for
wrote for a
for a previous
previous video which
video which we're
which we're just
we're just going
just going to
going to reuse
to reuse in
reuse in here
This piece of
of code is
use the larger
So as we're
as we're using
using a different
a different graphics
different graphics control
control we need
So there's our
there's our graphics
our graphics attach
graphics attach attaching
attach attaching to
attaching to the
to the larger
larger graphics map
order to improve
to improve the
improve the look
the look of
look of the
the graphics we're
graphics we're going
to display I'm
display I'm going
the graphics scale
graphics scale command
scale command allows
command allows you
allows you to
you to set
set a custom
a custom scale
custom scale for
scale for the
Y coordinate system
coordinate system within
system within your
within your graphics
your graphics control
this case we're
case we're making
we're making the
making the top
hand corner 0,0
corner 0,0, which
which is quite
is quite normal
quite normal, and
graphics control 680
control 680 by
680 by 580
function to draw
draw the polygons
the polygons on
polygons on our
on our terrain
our terrain map
terrain map, passing
it the X
order to use
to use these
use these polygons
these polygons there's
polygons there's a
there's a couple
couple of user
of user defined
user defined types
defined types we
types we need
to set up
set up at
up at the
of our code
And here they
here they are
have the first
the first user
first user defined
defined type set
type set up
up as polypoint
as polypoint, which
is taking X
taking X and
and Y elements
Y elements, both
The poly array
poly array has
array has count
has count as
count as the
as the first
the first element
first element, which
is a long
a long, and
and it has
it has one
has one called
one called X
called X and
and Y, which
this is array
is array of
array of polypoints
have a polygon
a polygon which
polygon which has
which has four
has four sides
four sides, and
and each of
of the vertices
the vertices of
vertices of this
of this four
this four sided
four sided polygon
sided polygon will
polygon will have
will have an
have an X
and a Y
a Y coordinate
And the variables
the variables underneath
variables underneath this
underneath this for
this for the
and Y are
Y are going
be the size
of our polygon
our polygon map
to have 15
have 15 terrains
15 terrains left
terrains left to
left to right
to right and
right and 15
and 15 terrains
15 terrains top
terrains top to
top to bottom
So we'll now
we'll now create
now create this
this new draw
new draw polygons
draw polygons terrain
polygons terrain function
There's a fair
a fair bit
fair bit of
bit of code
of code in
code in this
this function, which
which I will
I will go
will go through
go through line
through line by
line by line
by line so
line so we
we can understand
can understand what
understand what it's
what it's attempting
it's attempting to
attempting to do
of all, we're
we're passing the
passing the two
the two parameters
Y coordinates, which
which are the
are the coordinates
the coordinates of
And we obviously
we obviously have
obviously have a
have a number
Variables of note
of note, first
of all, is
is the UDT
the UDT polygon
This is set
is set up
up as a
as a poly
a poly array
poly array, which
which is one
is one of
of the types
the types we
types we created
we created a
created a moment
a moment ago
We're specifying the
specifying the starting
the starting coordinates
starting coordinates of
coordinates of this
this map to
map to be
to be 250
be 250 by
250 by 50
And the size
the size is
size is the
is the size
of the polygons
using a graphic
a graphic scale
graphic scale here
scale here, so
so it will
will be scaled
be scaled automatically
scaled automatically for
automatically for us
for us by
us by the
by the graphics
whether the graphic
the graphic we're
graphic we're going
to be displaying
be displaying is
displaying is zero
is zero in
zero in height
in height, i.e
sea level, or
or it's going
to be terrain
The corners of
corners of each
the vertices are
vertices are going
be one terrain
us to show
to show where
show where the
where the land
the land is
land is moving
is moving up
moving up from
up from sea
from sea level
sea level or
level or down
or down to
down to sea
to sea level
And our polygon
our polygon count
polygon count is
count is going
to be four
be four, as
as each of
the polygons we're
polygons we're going
to draw will
draw will have
will have four
have four corners
And then most
then most of
most of the
of the rest
the rest of
rest of this
of this is
this is pure
is pure arithmetic
pure arithmetic, working
Y coordinates where
coordinates where each
where each of
the polygons is
polygons is going
to start, and
the other three
other three polygon
three polygon corners
And finally, we're
we're setting the
setting the color
color of our
our polygon by
polygon by designating
by designating either
designating either deep
either deep sky
deep sky blue
sky blue for
sea or lime
or lime green
lime green for
Using this method
this method, we
have two heights
two heights of
heights of each
vertices of the
of the polygon
It's either going
to be considered
be considered to
considered to be
be zero in
in height, or
be one in
one in height
is where our
where our vertical
our vertical offset
vertical offset comes
offset comes in
It will allow
allow us, in
in future code
future code, to
to actually have
actually have mountains
have mountains, valleys
valleys and flat
and flat land
So naturally, this
is going through
going through a
through a forenix
a forenix loop
forenix loop, looking
at the height
let's try learning
try learning the
learning the application
now and see
and see what
see what we
what we get
and we'll click
we'll click on
Bulk Turns' button
button to move
move the game
the game on
game on by
on by 100
by 100 turns
will allow our
allow our rulers
our rulers to
rulers to actually
to actually attain
actually attain some
attain some territory
some territory, and
can then click
then click to
click to see
see what's happening
So there we
have a ruler
a ruler beside
ruler beside what
beside what looks
what looks like
looks like an
like an inland
an inland sea
click on that
on that now
that now, we
can see we
see we have
have the small
graphics map populated
map populated, and
and we have
have a 3D
a 3D terrain
3D terrain map
terrain map showing
map showing on
showing on the
on the right-hand
the right-hand side
you a very
a very clear
very clear indication
clear indication of
indication of what
of what the
what the terrain
the terrain looks
terrain looks like
the moment, we
we only have
only have either
have either sea
either sea level
level or land
There are no
are no mountains
no mountains in
mountains in this
click on another
on another area
another area, we
can see quite
see quite easily
quite easily a
easily a much
a much better
much better graphical
better graphical representation
graphical representation from
representation from a
from a 3D
a 3D perspective
3D perspective of
perspective of the
of the land
video is we
is we will
will add further
add further terrain
further terrain with
terrain with mountains
with mountains, mountain
mountain ranges to
ranges to our
to our terrain
by adding hills
adding hills and
hills and mountains
and mountains to
mountains to the
to the 3D
the 3D view
created a load
a load map
load map, which
has been displayed
been displayed on
user can then
then click the
click the Process
Turn button to
button to position
to position rulers
position rulers on
Currently the system
the system supports
system supports 50
supports 50 rulers
On processing the
processing the bulk
bulk turns, or
or a single
single turn, the
the rulers will
rulers will start
will start to
start to move
map to acquire
to acquire territory
When we click
click on one
on one of
the map, we
graphics controls displayed
controls displayed to
the user in
user in a
a new dialog
is a small
a small reduction
small reduction of
reduction of the
the main global
main global map
second is a
is a 3D
a 3D rendering
3D rendering of
rendering of a
of a perspective
a perspective view
perspective view of
view of the
The terrain in
terrain in the
game map at
map at the
the moment has
moment has only
has only two
only two possible
two possible statuses
It is either
is either sea
level or it
or it is
it is land
We are storing
are storing this
in a one-dimensional
a one-dimensional array
one-dimensional array, storing
storing either the
either the value
value 0 or
0 or the
or the value
the value 1
value 1 to
1 to indicate
to indicate sea
indicate sea or
today is to
is to introduce
to introduce hills
introduce hills and
This should give
should give our
give our 3D
our 3D map
3D map a
map a little
little more realism
also a small
a small bug
small bug needing
bug needing to
needing to be
to be fixed
be fixed in
fixed in the
in the 3D
the 3D map
3D map, whereas
whereas the right
the right hand
right hand and
hand and bottom
and bottom edges
bottom edges of
edges of the
of the So
the So let's
code to see
to see how
can do all
do all of
Since we're going
going to introduce
to introduce mountains
introduce mountains, the
the question is
question is just
is just how
just how many
how many mountains
many mountains are
mountains are we
are we going
we going to
to add to
add to the
to the system?
the system? To
system? To allow
To allow this
allow this to
this to be
to be reasonably
be reasonably flexible
reasonably flexible, I'm
create a constant
a constant at
constant at the
code to specify
specify the number
number of mountains
As we may
we may want
may want to
want to change
change the height
the height of
height of mountains
of mountains and
mountains and other
and other landmass
other landmass, we
set this as
as a constant
a constant as
constant as well
two new constants
new constants, max
max mountains, which
which we're currently
we're currently setting
currently setting to
setting to 50
to 50 for
50 for the
of mountains we
mountains we wish
wish to inject
to inject into
inject into the
into the terrain
the terrain, and
and 10 for
10 for the
for the vertical
the vertical offset
Setting the vertical
vertical offset as
offset as a
a constant will
constant will allow
to change it
change it to
it to improve
of the 3D
the 3D graphics
3D graphics map
graphics map, should
should we think
we think it
think it needs
it needs more
needs more vertical
more vertical height
if we locate
we locate where
locate where the
where the vertical
vertical offset is
offset is actually
is actually used
actually used, we
we can substitute
can substitute the
substitute the hard-coded
the hard-coded 10
hard-coded 10 for
10 for that
for that value
offset is currently
is currently held
currently held within
within the 'DetermineTerrain'
the 'DetermineTerrain' function
'DetermineTerrain' function, and
and the moment
the moment it's
moment it's hard-coded
it's hard-coded for
hard-coded for the
for the value
value of 10
we will replace
will replace that
replace that with
that with our
with our constant
our constant to
constant to allow
change it easily
it easily at
easily at the
before we make
we make radical
make radical changes
radical changes to
changes to the
to the fix
the fix, and
and that is
is the edges
the edges of
of the right
right hand side
hand side and
side and the
terrain map, which
which are currently
are currently showing
currently showing as
showing as 0
as 0 in
0 in height
in height, each
time the grid
the grid is
grid is displayed
Currently the 3D
3D map is
map is generated
is generated inside
generated inside the
inside the function
the function that
function that shows
that shows the
shows the 'TerrainInfo'
the 'TerrainInfo' dialog
'TerrainInfo' dialog, by
calling the 'DrawPolygonsTerrain'
the 'DrawPolygonsTerrain' function
While this works
this works well
works well, it
it does mean
does mean that
mean that the
that the graphics
map is entirely
is entirely generated
entirely generated before
generated before the
before the form
the form is
form is shown
is shown to
shown to the
For debug purposes
debug purposes, it
it would be
would be ideal
be ideal if
ideal if we
if we could
we could slow
could slow down
slow down the
down the drawing
the drawing of
drawing of the
graphics map, so
so we could
we could see
could see each
see each polygon
each polygon as
polygon as they're
as they're drawn
have to use
use a timer
a timer on
timer on this
on this form
this form, to
to delay the
delay the creation
creation of the
of the population
the population of
population of this
of this graphics
if we come
we come in
come in at
in at this
at this code
this code, it
it currently displays
currently displays the
displays the polygons
go to the
to the callback
handler for this
for this dialog
at this section
the code, and
if we place
we place it
place it within
it within the
within the callback
the dialog, there
are two pieces
two pieces of
pieces of information
of information we're
information we're going
have to store
to store, the
which the user
clicked on and
on and which
and which were
which were passed
were passed into
passed into this
into this function
this function as
function as parameters
We can save
can save these
save these two
two values quite
values quite easily
using the 'dialogSetUser'
the 'dialogSetUser' command
Each dialog has
dialog has 8
has 8 user
8 user values
user values you
values you can
you can actually
can actually store
actually store within
store within the
within the dialog
the dialog itself
So we pass
we pass a
pass a number
of parameters during
parameters during this
during this one
first is the
is the dialog
dialog handle, the
the next is
next is the
is the slot
the slot into
slot into which
wish to push
to push the
push the value
the value, and
final parameter is
parameter is the
is the value
value we want
Having stored these
stored these in
these in the
in the dialog
the dialog, we
can now go
now go to
within this callback
callback function, we're
going to declare
to declare two
declare two local
two local variables
local variables, x
These will be
will be populated
be populated with
populated with the
with the values
the values we
values we saved
we saved in
saved in the
create a timer
a timer, which
which will trigger
will trigger inside
trigger inside the
inside the 'Initialize'
the 'Initialize' dialog
'Initialize' dialog event
We'll create this
create this timer
this timer one
timer one constant
one constant at
our code in
code in a
but the purpose
of this timer
this timer is
timer is to
is to trigger
to trigger 200
trigger 200 milliseconds
200 milliseconds after
milliseconds after the
after the dialog
the dialog is
dialog is displayed
is displayed to
set up an
up an event
an event to
event to handle
to handle the
handle the triggering
the triggering of
triggering of that
of that timer
once the timer
the timer has
timer has been
has been triggered
been triggered, we
want to kill
to kill off
kill off and
off and stop
and stop the
stop the timer
the timer, as
as we don't
don't want it
want it triggering
it triggering every
triggering every 200
every 200 milliseconds
we can pull
can pull back
back the values
the values from
values from our
from our dialog
our dialog to
dialog to populate
to populate those
populate those x
those x and
y coordinates, by
using the 'dialogGetUser'
the 'dialogGetUser' command
'dialogGetUser' command to
pull back slots
back slots 1
slots 1 and
1 and 2
and 2 to
2 to the
to the x
we can add
can add back
add back in
back in the
the code we
code we commented
we commented out
commented out in
out in the
attach to a
to a 3D
a 3D graphics
3D graphics control
graphics control, set
set the scale
the scale, draw
the polygons and
polygons and do
and do the
do the graphics
the graphics redraw
Before we try
set up this
up this timer
this timer constant
timer constant at
of our application
there is our
is our timer
...it should run
should run exactly
run exactly as
exactly as it
as it did
it did before
So next we're
going to put
put a delay
a delay into
delay into the
into the code
the code which
code which draws
which draws these
draws these polygons
order to see
to see these
see these polygons
these polygons getting
polygons getting drawn
getting drawn as
drawn as they
as they are
they are created
are created, I'm
going to comment
to comment out
comment out the
out the redraw
redraw option on
option on the
if we nip
we nip into
nip into the
into the draw
the draw polygons
...and we'll want
to set in
set in a
in a couple
couple of sweep
of sweep commands
sweep commands to
commands to slow
to slow the
slow the system
the system down
system down enough
down enough so
enough so that
so that we
we can actually
actually see it
see it doing
it doing something
If we put
put a 100ms
a 100ms sleep
100ms sleep in
sleep in, this
this should do
should do the
do the job
the job nicely
...click on 'Roadmap'
...and click on
click on an
on an area
And we should
we should now
should now see
now see the
see the polygons
the polygons getting
getting drawn one
drawn one at
one at a
So for debug
debug purposes, this
this is ideal
is ideal when
ideal when you've
when you've got
you've got a
got a bug
a bug in
bug in the
can actually step
actually step through
step through to
through to see
to see where
see where the
where the bug
the bug occurs
So it's drawing
it's drawing the
drawing the polygons
the polygons quite
polygons quite happily
quite happily, but
but it does
it does seem
does seem to
seem to have
have a problem
a problem with
problem with the
with the periphery
the periphery of
periphery of the
Now there's something
there's something we
something we want
The dimensions of
dimensions of our
our array are
array are both
are both using
both using maxX
That needs to
needs to be
to be maxY
we look in
look in the
in the load
the load map
map array, we've
we've got some
got some hard-coded
some hard-coded values
hard-coded values in
values in here
in here we
here we want
want to replace
to replace with
replace with constants
Replacing these with
these with constants
with constants will
constants will allow
the map later
map later on
later on, should
should we need
to do so
Plus there are
a couple other
couple other changes
other changes we'll
changes we'll need
to make to
make to the
Currently the map
the map handles
map handles either
handles either a
either a 0
a 0 or
0 or a
or a 1
have to put
to put in
put in values
in values which
values which are
which are greater
greater than 1
Therefore any testing
any testing we
testing we do
we do of
do of the
map to see
see whether it's
whether it's sea
it's sea or
or land, we'll
need to check
to check to
see if it's
if it's not
it's not 0
have a test
a test for
test for the
for the map
the map checking
map checking to
checking to see
whether it's We
it's We can
We can quite
can quite easily
quite easily change
easily change that
change that to
that to make
make it not
it not equal
not equal to
equal to 0
to 0, to
determine whether it's
whether it's land
it's land or
land or not
I'll also change
also change the
change the logic
logic in determineTerrain
in determineTerrain, not
not to use
use these constants
these constants, but
but to use
use the size
of the array
Rather than that
than that function
that function where
function where we
where we determine
we determine whether
or not and
not and we
and we set
we set the
set the height
the height, I'm
going to make
make the height
the height equal
height equal to
to the offset
the offset multiplied
offset multiplied by
by the terrain
So where the
land is 1
then the offset
the offset will
offset will be
will be 10
Where the height
the height is
height is going
to be 2
be 2 for
2 for hills
for hills, it
will be double
be double and
double and triple
and triple for
triple for mountains
and see if
see if that's
if that's improved
that's improved anything
terrain map is
is now correctly
now correctly showing
correctly showing at
showing at the
at the edge
3D map, and
and that we're
that we're still
we're still in
still in land
in land, it's
it's not going
not going down
going down to
down to the
to the sea
the sea level
So it would
it would appear
would appear we've
appear we've cured
we've cured that
cured that little
that little bug
little bug in
the 3D terrain
So we'll return
we'll return the
return the code
the code so
code so that
so that it
that it draws
it draws this
draws this map
this map all
map all at
all at one
at one time
will do that
do that by
that by putting
by putting back
putting back in
in the redraw
that we've cured
we've cured the
cured the bugs
the bugs and
bugs and set
and set up
up the system
the system slightly
system slightly more
slightly more flexibly
more flexibly, we
can now look
look at injecting
at injecting some
injecting some mountains
some mountains into
mountains into the
into the system
So once we've
once we've loaded
we've loaded a
loaded a MapArray
a MapArray, we
want to build
to build some
build some mountains
at the loadMapArray
the loadMapArray function
before we dump
we dump the
dump the array.txt
the array.txt file
array.txt file, we'll
need to inject
to inject in
inject in a
in a call
a call to
call to a
function called buildMountains
function to build
to build the
build the mountains
the mountains is
mountains is not
is not going
be a complicated
a complicated one
have a constant
a constant setup
constant setup for
setup for the
for the maximum
the maximum number
maximum number of
do a while
while loop to
loop to step
step through that
through that until
that until all
until all the
all the mountains
the mountains have
mountains have actually
have actually been
actually been positioned
using the randomNumber
the randomNumber function
randomNumber function to
function to give
us a number
a number between
number between 1
That will determine
coordinates on which
on which we
wish to put
put the mountain
So we need
make sure that
sure that the
that the territory
the territory we
territory we have
we have picked
have picked is
picked is not
is not a
not a sea
a sea location
other words, it
it is not
is not zero
If it's land
it's land, then
going to slot
slot in a
in a mountain
We will update
update the terrain
terrain to mark
to mark it
it as level
as level 3
level 3, and
we will advance
will advance the
advance the counter
the counter for
counter for the
mountains we have
we have located
want to create
to create some
create some hills
some hills around
hills around this
around this mountain
probably guess in
guess in this
in this code
this code, we're
we're not testing
not testing to
testing to see
see whether we've
whether we've randomly
we've randomly picked
randomly picked a
picked a location
a location which
location which already
which already has
already has a
has a mountain
code we can
we can always
can always add
always add later
create the createHills
the createHills function
to do something
do something very
something very similar
We're passing in
passing in the
in the row
the row and
row and column
and column coordinates
column coordinates of
at the 9
the 9 territories
9 territories surrounding
territories surrounding the
surrounding the selected
the selected territory
territory is the
one we're actually
we're actually in
actually in, we're
going to iterate
to iterate to
iterate to the
the next loop
We'll double check
double check to
check to make
make sure we're
sure we're within
we're within the
we will check
will check to
make sure it
sure it is
is not sea
And I've added
I've added another
added another random
another random number
random number calculation
number calculation to
calculation to give
us a 75%
a 75% chance
75% chance of
chance of putting
of putting a
putting a hill
a hill beside
hill beside the
beside the mountain
That way, all
all the mountain
the mountain ranges
mountain ranges won't
ranges won't look
won't look the
look the same
And if that
if that passes
that passes, then
then we're putting
we're putting the
putting the value
the value 2
value 2 into
2 into the
application now, pick
our map, open
open it up
it up, and
and what it
what it should
it should have
should have done
have done, it
should have created
have created the
created the array.txt
at the array.txt
array.txt file, we
can see there
see there are
there are 0
are 0 for
0 for sea
for sea, 1
1 for land
for land, and
there are some
are some 2s
some 2s and
2s and So
and So we
have successfully populated
successfully populated the
populated the array
the array with
array with values
with values 1
values 1, 2
2 and 3
is to display
to display these
display these on
these on our
need to pop
to pop into
pop into the
into the 'dva-polygon's-terrain'
the 'dva-polygon's-terrain' function
to create another
create another local
another local variable
local variable called
variable called 'mountain'
called 'mountain', used
used to determine
to determine hills
determine hills and
And within our
within our loop
our loop, we
we will default
will default that
default that to
the value 'false'
Further down the
down the code
the code, you'll
you'll see this
see this line
This line looks
line looks to
looks to see
if the offset
the offset is
offset is greater
is greater than
greater than 0
than 0, then
then the value
of the sea
the sea variable
sea variable is
variable is false
to be amending
be amending this
amending this to
this to check
see if this
if this is
this is indeed
is indeed a
indeed a mountain
a mountain or
mountain or not
do this for
this for each
vertices of our
So we check
we check to
than 0, in
in which case
which case it's
case it's not
it's not a
a sea, and
then we need
is a mountain
create another new
function called 'determine-mountain'
called 'determine-mountain', taking
taking two parameters
One for the
of the offset
the offset, and
and one for
for the flag
the flag is
flag is it
is it a
it a mountain
This is because
is because if
because if any
if any one
any one of
of the four
the four vertices
four vertices of
the polygon is
polygon is greater
than the value
value 1, then
going to consider
to consider this
consider this to
be a hill
a hill or
hill or a
or a mountain
The reason for
reason for doing
for doing this
doing this is
this is I
is I want
I want these
want these polygons
these polygons coloured
polygons coloured differently
coloured differently to
differently to the
to the landmass
going to duplicate
to duplicate this
duplicate this code
this code through
code through the
through the rest
rest of the
of the checks
the checks for
checks for each
for each vertice
As the same
the same check
same check, we'll
we'll be required
be required for
required for each
And at the
bottom of this
this function, where
we determine the
determine the colour
the colour of
colour of the
the polygon, we're
to put an
put an extra
an extra condition
extra condition in
condition in here
This will test
will test our
test our new
our new variable
new variable 'all-mountain'
If that turns
that turns true
turns true, then
use a different
a different colour
different colour for
colour for the
for the polygon
we can take
can take our
take our two
our two sleep
two sleep commands
sleep commands out
commands out, as
want to slow
slow the code
the code down
code down any
down any more
create the 'determine-mountain'
the 'determine-mountain' function
here is our
is our new
our new 'determine-mountain'
new 'determine-mountain' function
'determine-mountain' function, with
with its two
its two parameters
two parameters –
parameters – the
– the 'vertical
the 'vertical offset'
'vertical offset' and
offset' and the
and the 'mountain'
the 'mountain' variable
If the mountain
the mountain variable
mountain variable is
variable is true
is true, then
then it's already
it's already a
already a mountain
mountain or hill
it's not yet
not yet a
yet a mountain
a mountain, we're
we're taking the
taking the height
height of the
of the vertical
vertical offset divided
offset divided by
divided by the
by the 'vertical
'vertical offset' value
This quite easily
quite easily gives
easily gives us
us the value
value 1, 2
2 or 3
or 3, and
and tells us
us the terrain
us to display
display the polygon
the polygon correctly
see how our
how our polygons
our polygons are
polygons are looking…
are looking… So
looking… So we
So we select
we select the
the world map…
world map… …and
map… …and we'll
…and we'll process
we'll process the
is our 3D
3D map now
map now showing
now showing hills
The hills are
hills are showing
are showing in
showing in a
in a light
a light brown
light brown colour
brown colour, the
the standard landmass
standard landmass, which
which is flat
is flat, is
is showing in
showing in green
in green, and
and the sea
the sea areas
sea areas are
areas are showing
showing in blue
if we pick
we pick another
pick another area
can see we're
see we're quite
we're quite happily
quite happily getting
happily getting mountains
getting mountains and
mountains and hills
So our 3D
our 3D terrain
3D terrain is
terrain is now
is now showing
now showing correctly
showing correctly, and
and much more
much more realistically
is we've added
we've added hills
added hills and
mountains to our
to our game
We've amended the
amended the 3D
the 3D routines
3D routines to
routines to display
to display hills
display hills in
hills in a
different colour, so
so that they
that they stand
they stand out
stand out visually
out visually for
visually for the
for the user
In our next
our next video
next video, we're
going to change
change the battle
the battle routines
battle routines to
routines to allow
allow the position
the position of
position of a
of a higher
a higher ground
higher ground territory
ground territory to
territory to be
be more advantageous
more advantageous to
advantageous to the
to the defender
And we're also
we're also going
also going to
put some navigation
some navigation controls
navigation controls on
controls on this
on this dialogue
this dialogue, to
us to move
around the graphics
graphics map without
map without having
without having to
having to leave
to leave the
leave the dialogue
by adding navigation
adding navigation to
navigation to the
We have displayed
have displayed a
displayed a 3D
a 3D map
and this 3D
this 3D map
3D map can
map can be
can be displayed
be displayed for
displayed for any
for any part
any part of
part of the
currently there is
there is no
is no ability
no ability to
ability to move
move around this
around this map
You have to
to go back
to the original
the original large
original large map
large map and
to add today
add today is
today is a
is a navigation
a navigation facility
navigation facility at
facility at the
the bottom right-hand
bottom right-hand corner
right-hand corner of
corner of this
of this dialog
let's go in
go in and
in and have
and have a
order to achieve
to achieve this
achieve this, we're
to be adding
be adding another
adding another library
we've now added
now added the
added the Button
the Button Plus
Button Plus library
Plus library, which
which will allow
us to put
to put icons
put icons on
icons on buttons
Next I'm going
going to amend
to amend the
amend the vertical
vertical offset by
offset by increasing
by increasing it
increasing it from
it from 10
from 10 to
10 to 15
We've also made
also made a
made a minor
a minor modification
minor modification to
modification to the
to the library
the library load_jpeg
library load_jpeg as
load_jpeg as bitmap
as bitmap, to
comment out these
out these first
these first two
first two sections
two sections here
sections here of
here of the
the types and
types and the
and the declaration
the declaration of
declaration of one
of one function
one function and
function and one
and one subroutine
is because the
because the new
the new library
new library, the
Plus library we've
library we've added
we've added, already
already has these
has these declares
So I'm going
going to try
to try running
try running an
running an application
an application now
Load up our
up our load
our load map
load map and
an area of
that the vertical
vertical offset for
offset for the
for the mountains
the mountains shows
mountains shows them
shows them as
them as higher
as higher on
higher on the
This makes mountains
makes mountains more
mountains more distinct
more distinct from
distinct from the
from the lower
the lower land
now go back
code and put
and put the
put the changes
the changes in
changes in we'll
in we'll need
make to allow
to allow navigation
allow navigation of
navigation of this
of this 3D
So to support
to support these
support these changes
these changes we're
changes we're going
put in some
in some more
some more graphics
to have icons
have icons for
icons for East
for East, West
North and South
and South and
South and also
and also a
also a terrain
a terrain compass
terrain compass and
compass and a
and a terrain
a terrain icon
support these new
these new graphics
new graphics we're
create some new
some new constants
be the constants
the constants that
constants that define
that define each
define each of
of the new
the new objects
new objects on
objects on our
on our dialog
Plus we've added
we've added another
added another 5
another 5 resource
5 resource icons
resource icons to
icons to the
the next part
next part of
part of our
have the graphics
the graphics out
graphics out of
out of the
of the way
the way let's
way let's look
at the rest
In the main
main dialog we
dialog we have
we have not
have not yet
not yet assigned
yet assigned an
assigned an icon
an icon to
icon to the
to the dialog
be the dialog
the dialog that
dialog that shows
that shows for
shows for our
for our application
So just before
just before we
before we show
we show the
show the dialog
dialog we will
we will set
will set its
set its icon
And we're setting
we're setting this
setting this to
the value 2001
value 2001 which
2001 which is
is our terrain
our terrain icon
With icons the
icons the very
very first icon
first icon defined
icon defined in
defined in your
in your resource
your resource list
resource list will
list will be
be the icon
the icon that
icon that is
that is automatically
is automatically assigned
automatically assigned by
assigned by Windows
by Windows to
Windows to the
to the application
the application itself
Next we will
the terrain info
terrain info dialog
Now we're going
make this dialog
this dialog slightly
dialog slightly larger
slightly larger to
larger to accommodate
to accommodate the
accommodate the new
new objects we
objects we want
to place on
place on it
So we're increasing
we're increasing it
increasing it to
it to 609
to 609 by
609 by 418
And having done
add the new
new objects to
objects to the
be adding most
adding most of
most of these
of these as
these as image
as image buttons
add the compass
the compass in
compass in the
center of these
of these buttons
these buttons as
buttons as our
as our graphics
are our new
our new image
new image buttons
One for north
for north, one
one for south
for south, one
one for west
for west and
west and one
one for east
Having defined each
defined each of
of these objects
these objects we
objects we now
populate those objects
those objects with
objects with our
with our controls
use the button
plus library to
library to set
set up each
up each of
see how these
how these new
new graphics look
there we can
see the new
new graphics at
graphics at the
I'll come back
come back to
to the terrain
But we can
now see we
we have buttons
have buttons for
buttons for north
for north, south
west and east
And we also
we also have
also have a
have a step
a step field
using the step
the step field
step field to
field to see
see how many
how many terrains
many terrains we
terrains we will
we will actually
will actually step
actually step north
step north, south
east or west
or west at
west at one
will allow you
allow you fine
you fine control
fine control of
control of down
of down to
down to one
to one terrain
one terrain or
terrain or up
or up to
up to perhaps
to perhaps 10
perhaps 10 terrains
As we're going
user to dynamically
to dynamically move
dynamically move the
move the viewpoint
the viewpoint of
viewpoint of our
of our 3D
3D map, we'll
need to change
change the way
the way the
way the 3D
map is actually
is actually called
When the showDialogueTerrainInfo
the showDialogueTerrainInfo function
showDialogueTerrainInfo function is
is called, which
which displays this
displays this dialog
this dialog to
dialog to the
the user, we're
passing in an
in an x
is to indicate
indicate which terrain
which terrain the
user is actually
is actually centering
actually centering the
centering the map
the map upon
So as the
user is going
to be moving
be moving this
moving this point
this point of
point of origin
of origin, we'll
need to store
to store these
store these x
these x and
and y values
use the dialog
the dialog SetUser
dialog SetUser command
SetUser command to
command to store
to store them
store them in
them in the
So here is
is our dialog
our dialog SetUser
dialog SetUser commands
SetUser commands, storing
storing the x
coordinates in slots
in slots 1
user to move
the map, there
a small snippet
small snippet of
snippet of the
main graphics control
This also will
also will have
will have to
have to move
to move at
move at the
at the same
the same time
same time we're
time we're moving
we're moving the
moving the 3D
going to grab
to grab part
grab part of
map and display
and display it
display it as
it as a
as a small
a small map
small map on
map on this
on this dialog
going to perform
to perform that
perform that by
that by using
using a smallMap
a smallMap function
of parameters, the
the dialog we're
dialog we're currently
we're currently on
currently on, the
small map, the
the parent dialog
parent dialog from
dialog from where
from where the
where the information
the information has
information has been
has been taken
been taken, the
large graphics territories
graphics territories map
territories map and
let's create that
create that new
that new function
is a very
a very straightforward
very straightforward function
straightforward function and
function and will
and will be
will be similar
be similar to
similar to some
to some of
of the routines
the routines we've
routines we've used
we've used in
used in the
the previous videos
specify the graphic
graphic control we
control we wish
We're then using
then using the
the graphics Clear
graphics Clear command
Clear command to
sure that graphic
that graphic is
graphic is completely
is completely clear
completely clear before
clear before we
before we start
we start drawing
start drawing on
drawing on it
can then get
then get the
get the size
the size, determine
determine the offsets
the offsets and
offsets and use
and use the
use the graphic
the graphic Copy
graphic Copy command
to copy from
copy from the
the main territorial
main territorial map
territorial map on
map on the
the first dialog
first dialog to
dialog to this
this new graphics
new graphics map
graphics map and
map and then
and then redraw
then redraw it
redraw it on
it on the
In addition, we
have to make
to make a
make a small
a small change
small change to
change to the
to the DrawPolygonsTerrain
the DrawPolygonsTerrain function
the previous video
previous video, this
this function drew
function drew the
drew the 3D
terrain map on
this dialog only
dialog only once
around this 3D
3D map, there
is a possibility
a possibility that
possibility that some
that some mountains
some mountains might
mountains might still
might still show
still show as
show as polygons
as polygons on
polygons on the
on the background
want to use
command to ensure
graphics control is
control is completely
is completely blank
completely blank before
blank before we
So the simple
the simple addition
simple addition of
addition of a
of a graphics
a graphics Clear
Clear command before
command before we
start drawing to
drawing to the
graphics control will
control will solve
will solve this
solve this problem
have all that
all that in
that in place
in place, our
some code behind
code behind each
behind each of
the buttons that
buttons that allow
that allow the
user to navigate
Clicking on these
on these buttons
these buttons will
buttons will trigger
will trigger an
trigger an event
an event in
event in the
in the callback
go into that
into that callback
callback function and
function and put
and put some
So in the
handler of this
this dialog, we
have a wmCommand
a wmCommand section
This is fairly
is fairly lightly
fairly lightly coded
lightly coded at
coded at the
the moment and
moment and this
where our code
our code is
going to go
But before we
before we do
we do that
make a slight
a slight change
slight change to
to the variables
the variables at
y variables within
variables within this
this function are
function are declared
are declared as
declared as locals
This was fine
was fine in
fine in the
previous video because
video because this
because this function
this function would
function would only
would only be
only be called
be called once
called once when
once when the
when the dialog
the dialog was
dialog was displayed
store the x
y coordinates as
coordinates as static
as static variables
static variables so
variables so that
that they are
they are remembered
are remembered between
remembered between each
between each call
up the step
number of terrains
of terrains we're
terrains we're going
to move up
move up, down
left or right
are our redefined
our redefined static
redefined static variables
let's now put
now put the
put the event
event handler in
is the event
event handler to
handler to pick
pick up changes
up changes to
to the step
A simple control
simple control get
control get text
get text will
text will get
the value and
value and store
and store it
store it in
it in our
in our step
our step variable
is a static
a static variable
we'll have to
put an event
event in each
in each of
of the navigation
the navigation buttons
navigation buttons for
east and west
So each of
of these is
these is going
to be remarkably
be remarkably similar
at the one
the one for
for the north
the north button
Once the button
is clicked, we're
testing the y
Subtracting from it
from it, the
the step variable
if the step
step variable is
variable is 1
is 1, we're
we're testing to
testing to make
that the y
y coordinate is
coordinate is greater
This will ensure
will ensure we're
ensure we're not
we're not moving
not moving off
moving off the
If it passes
it passes that
passes that test
that test, we're
we're then subtracting
then subtracting the
subtracting the step
step variable from
variable from the
from the y
y coordinate to
coordinate to give
us a new
a new y
new y coordinate
can then attach
then attach to
wish to draw
draw and call
and call draw
call draw polygons
draw polygons and
polygons and then
then redraw the
redraw the image
the image to
image to the
We're then calling
then calling our
calling our new
small map, to
redraw the small
And of course
of course, we're
we're doing exactly
doing exactly the
the same thing
same thing for
thing for each
the other buttons
For moving south
moving south, we're
we're adding to
adding to the
to the y
For moving west
moving west, we're
x coordinate and
coordinate and taking
and taking the
taking the step
the step from
step from it
And moving east
moving east, we're
we're adding the
adding the step
the step to
step to the
our application, there
there is one
is one final
one final change
final change we
change we need
variable is a
to set it
set it to
value 1 in
1 in our
in our initialization
our initialization section
initialization section of
we select our
our map and
map and pick
and pick a
pick a location
a location, we
see the 3D
3D map and
and the small
the small section
small section of
main map displayed
we click north
click north, the
terrain map for
map for the
for the 3D
the 3D moves
3D moves north
moves north as
north as also
as also does
also does the
does the small
the small terrain
small terrain map
we try moving
try moving to
moving to the
to the east
the east, it
it will move
will move quite
move quite happily
quite happily to
happily to the
the east, one
one terrain at
terrain at a
The same for
same for the
for the south
the south and
south and the
and the same
for the west
If we increase
we increase the
increase the step
the step size
step size, for
for example to
example to the
the value 5
value 5, it
will move 5
move 5 terrains
5 terrains at
terrains at a
a time, allowing
allowing the user
to navigate quite
navigate quite happily
quite happily and
happily and quickly
and quickly around
quickly around the
we've taken our
taken our original
our original code
original code of
code of displaying
of displaying a
displaying a small
a small section
and a 3D
a 3D version
3D version of
version of the
map and we've
and we've given
we've given the
given the user
the user navigation
user navigation controls
navigation controls to
controls to move
to move north
move north, south
and west by
west by either
by either a
either a single
a single terrain
single terrain at
a time or
time or up
up to a
to a value
value of perhaps
of perhaps 10
This allows the
allows the user
user to quite
to quite easily
quite easily move
easily move around
Hopefully you'll find
you'll find this
find this approach
this approach useful
approach useful in
useful in your
in your applications
your applications, but
map by fixing
by fixing some
fixing some bugs
some bugs and
bugs and adding
and adding a
adding a few
a few enhancements
Regardless of how
of how long
how long you've
long you've been
you've been coding
been coding in
coding in any
in any particular
any particular programming
particular programming language
programming language, there
there comes a
comes a time
a time when
time when you
when you have
have to fix
to fix bugs
of course, are
are unwanted functionality
Either the application
application is doing
is doing something
doing something incorrectly
something incorrectly, or
or is doing
doing something unexpected
And then to
then to correct
to correct the
correct the problem
the problem, you
to do some
do some investigation
Once you complete
you complete your
complete your investigation
your investigation, you
you should have
should have a
have a good
a good idea
good idea of
idea of what's
of what's causing
what's causing the
causing the problem
This will, of
of course, require
require changing either
changing either data
either data or
data or code
or code or
code or both
first thing we're
thing we're going
going to investigate
to investigate is
investigate is a
is a problem
problem with moving
with moving players
moving players around
players around the
If we load
we load up
up our application
our application, load
load up the
up the old
the old map
old map, process
see all the
all the players
the players on
players on the
the map, marked
marked as red
bulk turns, we'll
we'll see that
that the players
the players move
players move around
they're supposed to
supposed to do
in a random
a random fashion
But there is
there is something
is something not
something not quite
not quite right
quite right with
right with the
with the direction
the direction that
direction that the
the players are
players are actually
are actually moving
They're in fact
in fact all
fact all moving
all moving in
moving in the
in the same
the same direction
same direction, more
more or less
or less at
less at the
So there's something
there's something wrong
something wrong with
wrong with the
with the process
the process by
process by which
by which we
which we get
we get the
get the direction
in which players
which players are
players are supposed
are supposed to
supposed to move
order to fix
to fix this
fix this bug
this bug or
bug or feature
or feature, let's
have the mainMoveRulers
the mainMoveRulers function
This function runs
function runs in
runs in a
in a for
loop for each
for each ruler
each ruler, each
each character within
character within the
the application, to
determine what they're
what they're going
they're going to
in the way
the way of
way of movement
Within this for
this for next
next loop, there
is a single
a single function
single function called
function called getDirection
determine the deltaX
the deltaX and
deltaX and deltaY
and deltaY, which
which direction the
direction the player
the player is
player is actually
is actually going
actually going to
at the getDirection
the getDirection function
getDirection function, we
that the deltaX
and deltaY are
deltaY are determined
are determined using
determined using the
using the RND
RND command, the
the random command
Pulling back a
-1 and plus1
It's embedded in
embedded in a
in a while
loop to ensure
that the X
and Y deltas
Y deltas are
deltas are not
are not going
to be both
be both zero
both zero, and
it will run
will run on
run on a
on a loop
a loop until
loop until the
until the player's
the player's character
player's character is
character is moving
is moving in
moving in one
in one direction
one direction or
direction or another
or another, but
but not staying
not staying in
staying in the
the same terrain
there's a flaw
a flaw in
flaw in this
in this logic
There's nothing necessarily
nothing necessarily wrong
necessarily wrong with
wrong with this
with this particular
this particular function
the values we're
values we're passing
passing in should
in should initially
should initially be
initially be zero
look at moveRulers
at moveRulers once
moveRulers once more
see that within
that within this
next loop, these
two values are
values are not
are not reinitialised
not reinitialised, and
this is our
is our problem
Once these values
these values have
values have been
have been populated
been populated, the
the function we're
function we're calling
calling the getDirection
the getDirection will
getDirection will only
will only trigger
only trigger if
trigger if both
if both values
both values are
values are zero
are zero, so
so what we
is to initialise
to initialise these
initialise these to
these to zero
to zero before
zero before we
before we call
we call getDirection
This way, the
the function should
function should behave
should behave normally
how it looks
We will load
will load our
We will process
will process the
turn to place
to place the
place the rulers
will do a
do a process
a process bulk
bulk turns, which
which is going
going to run
to run for
run for 50
for 50 iterations
that the characters
the characters are
characters are moving
are moving in
moving in a
in a fairly
a fairly random
fairly random direction
random direction each
direction each time
each time they
time they are
they are run
They're not all
not all going
all going in
going in the
So that's our
that's our first
our first bug
first bug actually
bug actually fixed
next thing we're
at is how
is how the
how the characters
the characters move
characters move around
map and how
and how they
how they build
they build their
build their empires
can see from
see from this
from this corner
this corner of
the map, the
the player has
player has a
has a number
It now has
now has 11
has 11 terrains
11 terrains set
terrains set up
We've also got
also got the
got the terrain
the terrain navigation
terrain navigation buttons
navigation buttons at
buttons at the
the bottom here
will see, we're
currently on 35
on 35, 6
6 as coordinates
as coordinates with
coordinates with owner
with owner number
owner number 9
we move 1
move 1 to
the right, these
these numbers are
numbers are not
are not being
not being updated
being updated, nor
nor are the
are the owner
the owner details
owner details, despite
despite the fact
fact that we're
that we're now
we're now moving
now moving away
moving away from
away from the
from the original
the original location
need to update
to update both
update both the
the owner and
owner and the
and the owner
the terrain we
terrain we are
we are centred
are centred on
centred on is
on is not
is not indicated
not indicated on
indicated on this
on this mini
this mini map
mini map, which
which would be
be ideal to
ideal to give
to give a
give a bit
a bit more
bit more clarity
code and correct
and correct these
correct these problems
terrain info function
info function, this
is a function
a function that
function that displays
that displays this
displays this map
this map on
Once the dialogue
the dialogue has
dialogue has been
been created, there
is a series
series of lines
of lines of
lines of code
of code following
code following that
following that to
that to pick
up the owner
the owner, to
out whether the
owner is active
is active, and
and to display
to display this
the user on
user on screen
this is how
is how this
how this information
this information gets
information gets initially
gets initially populated
But the problem
the problem is
problem is, when
when you move
you move around
the map using
map using the
using the navigation
navigation buttons, these
these details are
details are not
are not updated
need to duplicate
duplicate this functionality
this functionality elsewhere
functionality elsewhere in
elsewhere in the
in the application
the application on
application on the
the button click
button click events
So the easiest
the easiest way
easiest way to
way to do
do this is
take the code
code we see
screen here and
here and turn
and turn it
turn it into
it into a
into a function
that function from
function from several
from several places
several places within
places within the
for the moment
comment out all
out all this
all this code
this code in
code in here
in here, and
to put it
put it into
it into its
into its own
its own function
to call this
call this new
new function updateTerrainDetails
to pass three
pass three parameters
three parameters to
parameters to this
user is currently
is currently at
is the skeleton
function updateTerrainDetails taking
updateTerrainDetails taking in
taking in its
in its three
us to perform
to perform this
perform this task
got a variable
a variable called
variable called Owner
called Owner which
Owner which is
to be our
be our owner's
our owner's number
going to hold
to hold that
hold that as
that as a
as a string
we have owner
have owner details
owner details to
details to contain
contain the information
the information we
information we display
we display at
display at the
of the dialogue
we're also using
also using a
using a template
a template string
template string variable
is to pick
of the comment
the comment terrain
comment terrain, based
on the x
owner is a
of 0 or
0 or not
the owner value
owner value is
then there is
is no comment
no comment owner
comment owner of
up the owner's
number and putting
and putting it
putting it into
it into our
into our string
our string variable
to start populating
start populating the
populating the str
the str value
str value variable
value variable to
variable to see
or not, and
and whether the
the terrain has
terrain has an
now use our
use our rulers
rulers array to
array to determine
owner is actually
we will start
will start populating
populating the ownerDetails
the ownerDetails variable
This is what's
is what's going
what's going to
going to appear
to appear in
appear in the
in the text
text box at
box at the
And now that
that we've amassed
we've amassed all
amassed all this
all this information
this information, we're
going to continue
to continue to
continue to update
update the owner
owner details with
details with the
with the number
territories the owner
the owner actually
owner actually possesses
this function will
function will be
will be called
be called when
called when the
when the dialogue
the dialogue is
dialogue is initially
is initially displayed
initially displayed to
addition to that
to that, we
to actually go
actually go into
into the event
event handler, the
callback function for
function for this
for this dialogue
on the north
the north, south
or west buttons
west buttons can
buttons can be
can be trapped
be trapped, and
call this function
this function inside
function inside those
inside those events
look at that
at that callback
is our callback
our callback function
we move further
move further down
the code, we
can see here
see here are
here are the
are the buttons
the buttons for
buttons for image
for image north
image north, south
south and so
and so on
So after we've
after we've copied
we've copied the
copied the small
small map from
map from the
from the big
the big dialogue
big dialogue to
dialogue to the
to the small
the small one
small one, we're
is our call
our call to
call to the
to the update
the update terrain
update terrain function
terrain function, passing
passing it these
it these three
these three parameters
the dialogue we
dialogue we are
we are currently
are currently on
duplicate this for
these buttons, the
there are the
are the entries
the entries to
entries to call
once more, loading
loading up our
up our map
our map, processing
processing our first
our first turn
turn and doing
and doing some
doing some bulk
some bulk turns
So now that's
now that's completed
that's completed, let's
at the smaller
the smaller dialogue
see we're on
we're on x
on x equals
x equals 31
equals 31 and
31 and y
and y equals
y equals 5
we move one
one terrain to
the right, to
it now moves
now moves to
moves to 32
And the detail
the detail at
detail at the
the screen has
screen has also
has also been
also been updated
been updated, which
which is ideal
the one thing
one thing we're
thing we're still
we're still missing
still missing is
missing is knowing
is knowing exactly
knowing exactly which
exactly which terrain
which terrain this
terrain this map
this map refers
map refers to
that's our next
This is additional
is additional functionality
additional functionality we
functionality we wish
wish to add
Perhaps with a
with a small
a small circle
small circle around
circle around the
around the terrain
I think it's
think it's probably
it's probably that
probably that one
can actually do
actually do that
So where in
where in the
the code do
code do we
do we actually
we actually need
actually need to
make this change?
this change? There
change? There is
a section of
code which copies
which copies the
copies the small
from the large
the large dialogue
large dialogue to
to the smaller
the smaller one
this is in
is in a
in a function
a function called
function called 'copy
called 'copy small
'copy small map'
And in here
in here, this
where the graphics
copy command is
command is used
is used to
used to copy
copy a section
large graphics terrain
graphics terrain map
terrain map to
map to the
control on our
on our new
our new dialogue
So following the
following the display
the display of
display of this
of this small
this small graphics
graphics map, we
want to draw
draw a circle
a circle around
around the center
the center terrain
work out exactly
out exactly which
which terrain that
terrain that actually
that actually is
to create two
create two local
local variables, an
an x terrain
x terrain and
terrain and a
a y terrain
And these, when
when populated, will
will be used
be used to
used to mark
to mark which
mark which terrain
which terrain we're
terrain we're actually
we're actually going
to draw our
draw our circle
our circle around
So we work
we work on
work on the
terrain is likely
is likely to
to be near
be near the
near the very
the very center
very center of
center of our
So we'll take
we'll take the
take the size
graphics map, which
which was determined
was determined up
determined up here
up here using
here using the
the graphics set
graphics set size
set size command
size command, and
and we'll divide
we'll divide it
divide it by
it by 2
by 2 as
2 as an
as an integer
us a whole
we will subtract
will subtract from
subtract from that
from that the
that the size
is a box
a box which
box which determines
which determines how
determines how big
how big each
big each of
the terrains actually
terrains actually is
is on screen
that we've determined
we've determined roughly
determined roughly where
roughly where the
where the center
center terrain actually
actually is, we're
the graphics ellipse
graphics ellipse command
ellipse command to
to draw on
draw on screen
on screen a
screen a circle
use the existing
the existing graphics
existing graphics redraw
command to display
this is determined
is determined by
determined by the
by the top
left hand and
and bottom right
right hand boundings
hand boundings of
boundings of our
of our circle
our circle as
circle as a
as a square
we're using x
using x and
and y terrain
y terrain, and
and we're adding
we're adding onto
adding onto that
onto that the
that the box
the box size
making the circumference
the circumference of
circumference of our
our circle in
circle in yellow
We're using -2
using -2 to
-2 to ensure
ensure that what's
that what's underneath
what's underneath the
underneath the circle
the circle shows
circle shows through
setting the fill
the fill to
fill to be
to be 0
let's try with
try with one
with one of
of the players
the players near
players near the
near the edge
Now we're very
we're very close
very close to
close to having
to having this
having this correct
have our circle
our circle on
circle on screen
on screen, but
but it's not
it's not quite
not quite centered
quite centered over
centered over the
over the terrain
terrain we want
want to have
So possibly one
possibly one or
one or two
or two pixels
two pixels out
we will come
will come out
come out and
out and we'll
and we'll make
we'll make a
a small adjustment
small adjustment to
adjustment to these
to these x
running that now
that now to
if that's giving
that's giving us
us a better
a better location
And we'll again
we'll again go
again go for
go for one
for one on
one on the
on the terrain
the terrain near
terrain near the
near the sea
have our yellow
our yellow circle
yellow circle circling
circle circling very
circling very close
close to the
to the center
center of what
of what we've
what we've clicked
we've clicked on
not quite in
quite in the
the map, but
but it is
it is circling
is circling the
circling the terrain
terrain we have
we have actually
have actually clicked
we move to
move to the
the right, it
it is of
is of course
of course now
course now obvious
now obvious which
obvious which terrain
we go into
go into this
into this one
this one here
one here, it's
it's now picking
now picking up
we go here
go here, it's
it's picking up
up the other
the other owner
So this circle
this circle on
circle on the
map is very
next thing we
thing we want
want to look
the characters in
characters in this
in this simulation
this simulation actually
simulation actually build
actually build their
One thing I've
thing I've noticed
I've noticed is
noticed is that
is that depending
that depending on
depending on how
on how they
how they move
they move, they
they can wander
can wander into
wander into other
into other territories
other territories, and
one of these
of these, we
that this particular
this particular ruler
particular ruler has
ruler has eight
has eight territories
Now it's not
it's not particularly
not particularly obvious
particularly obvious which
obvious which eight
which eight territories
eight territories these
territories these actually
these actually are
actually are, and
and I suspect
I suspect in
suspect in some
in some cases
some cases there
cases there are
there are rulers
are rulers who
rulers who have
who have larger
have larger territories
larger territories, but
but these territories
these territories are
territories are not
are not joined
not joined together
need to find
to find a
find a way
a way of
way of allowing
of allowing the
allowing the users
the users to
users to more
to more intelligently
more intelligently expand
intelligently expand their
expand their empires
Now you could
you could do
could do this
this by some
by some really
some really fancy
really fancy AI
fancy AI routines
AI routines, or
or we could
we could just
could just be
just be more
be more careful
more careful about
careful about how
about how the
how the rulers
rulers actually move
actually move around
So on the
assumption that we
want to make
make the change
the change to
the code as
code as simple
as simple from
simple from a
from a maintenance
a maintenance point
maintenance point of
point of view
of view as
view as possible
as possible, let's
look at just
at just changing
just changing how
changing how they
So again we're
again we're going
at the moveRuler's
the moveRuler's function
So in here
have the section
code which determines
which determines where
determines where the
the ruler moves
ruler moves, and
and below this
below this is
the section which
section which works
which works out
works out is
out is the
the terrain already
terrain already owned
already owned, and
and works out
works out whether
out whether it
whether it needs
it needs to
a battle or
battle or not
is where I
where I want
put the new
the new piece
new piece of
of code, and
going to box
to box this
box this in
this in in
in in a
new function, and
new function terrain_adjacent
This will work
will work out
work out is
is the terrain_adjacent
the terrain_adjacent to
terrain_adjacent to an
to an existing
an existing owned
existing owned territory
pass three variables
coordinates we're planning
we're planning to
planning to move
move to, and
and the longR
the longR, which
which in this
this case is
case is the
is the ruler
the ruler number
So here's the
here's the skeleton
new function taking
function taking the
taking the three
y variables are
variables are where
are where they
where they are
they are going
be moving to
moving to, and
and longR is
longR is the
is the plan
the plan number
So we're creating
we're creating some
us to work
out what we're
of all we
all we will
we will pick
will pick up
up the common
the common location
common location of
of the player
the player, the
can pull this
pull this out
out quite happily
quite happily from
happily from the
from the ruler's
ruler's array, where
where the locations
the locations of
locations of all
of all the
are actually stored
So first we
first we will
we will test
will test the
test the x
user is moving
is moving to
moving to against
to against where
against where they
If all the
all the values
the values are
values are the
are the same
the same then
same then the
then the player
player is not
not moving, so
we'll return a
return a function
a function equals
function equals true
So if this
is not true
not true then
true then the
player is definitely
is definitely moving
So next we
is moving into
into is actually
is actually adjacent
actually adjacent to
adjacent to one
to one which
one which they
which they already
they already own
to use an
use an if
an if command
if command here
command here with
here with a
with a number
number of else
of else if
else if conditions
use the owner
owner map to
map to determine
whether this terrain
the user or
user or not
all we're working
we're working at
working at the
at the y
y coordinate minus
coordinate minus one
If that matches
that matches then
matches then our
then our return
our return from
function is true
do the same
same for each
of the conditions
the conditions we're
conditions we're looking
we're looking for
So we're specifically
looking for where
for where the
where the y
coordinate is plus
is plus or
plus or minus
or minus one
minus one and
one and the
x coordinate is
Everything else will
else will return
will return the
have that in
in place let's
place let's try
our application once
our map up
map up, we
turn and we
will process some
process some bulk
give us 50
us 50 iterations
50 iterations of
of the empire
the empire building
see the rulers
rulers are not
are not wandering
not wandering off
wandering off diagonally
off diagonally and
diagonally and they're
and they're only
they're only expanding
only expanding their
expanding their empire
their empire based
empire based on
based on terrain
on terrain which
terrain which is
which is adjacent
is adjacent to
adjacent to existing
this should actually
should actually save
actually save our
save our rulers
our rulers wandering
rulers wandering into
wandering into other
other territories and
territories and then
and then disconnecting
then disconnecting from
disconnecting from their
from their existing
their existing empires
can see if
see if we
click on any
on any of
any of these
of these this
these this particular
ruler has 24
has 24 territories
we try for
try for one
for one of
the larger ones
larger ones this
ones this has
this has 35
has 35 territories
As we move
move further into
further into the
into the simulation
the simulation, processing
processing additional bulk
additional bulk turns
bulk turns, we
can see whether
whether the rulers
the rulers start
rulers start to
start to steal
to steal territory
steal territory from
territory from each
from each other
For example down
example down here
So now the
now the building
the building of
building of rulers
of rulers territories
rulers territories now
territories now seems
now seems to
seems to be
be more logical
They might be
might be more
be more needed
more needed within
needed within the
within the code
code to make
make the users
the users more
users more realistically
more realistically in
realistically in building
in building empires
However this is
is a major
a major step
major step forward
step forward on
forward on what
on what we've
what we've had
we've had before
is we've fixed
we've fixed a
fixed a bug
a bug with
bug with movement
with movement of
movement of rulers
We've also enhanced
also enhanced it
enhanced it slightly
it slightly to
slightly to allow
allow the terrain
terrain map when
map when clicked
when clicked upon
clicked upon to
upon to give
to give you
you a little
a little yellow
little yellow circle
circle circling the
circling the area
the area we're
area we're now
the detail within
detail within this
within this terrain
this terrain information
terrain information dialog
information dialog is
dialog is now
is now being
now being updated
being updated when
updated when you
Hopefully you'll have
you'll have found
have found this
found this video
this video interesting
video interesting, but
for the PowerBasic
the PowerBasic Windows
PowerBasic Windows Compiler
at the use
the use of
use of checkboxes
of checkboxes on
checkboxes on Windows
on Windows Forms
order to demonstrate
to demonstrate the
demonstrate the use
of checkboxes, we
are currently in
currently in the
in the PowerBasic
the PowerBasic Forms
PowerBasic Forms Designer
us to create
to create dialogs
create dialogs and
dialogs and to
and to place
to place controls
place controls upon
controls upon those
upon those dialog
those dialog If
dialog If we
look at our
at our Toolkit
our Toolkit here
Toolkit here, there
are two controls
two controls here
controls here we're
here we're going
be working with
of all, the
the Checkbox Control
Checkbox Control and
and the Check
the Check 3
Check 3 State
3 State Box
State Box Control
If we double-click
we double-click on
double-click on the
on the checkbox
the checkbox, we'll
we'll get a
get a checkbox
a checkbox on
checkbox on the
can then position
So there is
is our first
our first checkbox
If we save
we save this
save this and
this and go
and go back
to our source
our source code
source code, it
it will reload
will reload and
reload and we
that the checkbox
the checkbox has
checkbox has now
now been added
been added to
added to the
function which controls
which controls all
controls all the
all the objects
the objects for
objects for that
for that dialog
will see our
see our checkbox
our checkbox appears
checkbox appears on
appears on the
the screen and
screen and allows
and allows us
us to either
to either tick
either tick or
tick or untick
or untick the
untick the checkbox
make this a
this a little
little more readable
more readable, we're
to add a
add a new
a new font
So we've added
we've added two
added two lines
two lines of
of code for
for the font
the font, one
one to add
to add it
add it as
as a new
new font before
font before we
and one to
one to end
to end the
end the font
the font after
font after the
the dialog completes
be adding several
adding several checkboxes
several checkboxes to
checkboxes to this
to this form
this form, I'm
use the prefix
the prefix command
prefix command to
make it nice
it nice and
nice and easy
and easy and
easy and tidy
and tidy to
tidy to add
to add more
add more controls
more controls to
to the Control
the Control Set
Control Set Font
Set Font command
This will set
will set the
set the font
the font for
font for our
for our first
first checkbox to
checkbox to the
to the font
the font we've
font we've just
we've just specified
we run the
the application, we'll
need to declare
to declare the
declare the hFont
the hFont variable
hFont variable as
variable as a
as a D-word
application now, we'll
see that our
that our checkbox
our checkbox does
checkbox does appear
does appear in
appear in a
in a much
a much larger
much larger font
larger font and
font and is
and is therefore
is therefore easier
therefore easier to
easier to see
So what other
what other options
other options do
options do we
do we have
we have in
have in the
in the forms
the forms designer
forms designer for
designer for the
for the checkbox?
the checkbox? If
checkbox? If we
the checkbox and
checkbox and have
at the styles
the styles, there
are a few
a few options
few options in
options in here
in here worth
here worth looking
worth looking at
set the position
position of the
of the text
text to be
to be either
be either at
either at the
at the top
the top, as
as you'll see
you'll see it's
see it's now
it's now moved
now moved up
moved up, you
you can set
can set it
set it at
it at the
at the center
the center, which
is the default
the default, or
or you can
We'll leave this
leave this one
this one at
one at the
you can shift
can shift it
shift it left
it left, right
right and centered
So your text
your text is
text is now
is now centered
now centered in
centered in the
in the width
the width of
width of the
of the control
So you have
you have some
have some flexibility
some flexibility in
flexibility in how
in how the
how the text
the text is
text is actually
is actually displayed
So we'll move
we'll move it
move it back
it back to
to the left-hand
the left-hand side
left-hand side for
side for the
you don't have
don't have in
have in here
in here the
here the option
of setting the
setting the foreground
the foreground color
You can't change
can't change the
change the color
the text from
text from inside
from inside this
inside this box
But we'll come
to the color
the text later
text later on
in the video
So what I
what I want
want to do
up the value
value of this
of this checkbox
Is it ticked
it ticked or
ticked or is
is it not
it not ticked?
not ticked? So
ticked? So let's
add a text
a text box
text box in
box in here
in here into
here into which
can actually put
actually put text
put text to
text to explain
to explain what's
explain what's actually
what's actually happened
actually happened on
happened on the
So we'll declare
we'll declare the
declare the constant
the constant for
constant for this
for this text
this text box
So we're now
event handler, who
who has the
has the task
the task of
task of picking
of picking up
picking up events
up events where
events where the
where the object
the object has
object has been
been clicked upon
to declare a
declare a local
a local variable
variable called result
called result, which
going to pick
of our checkbox
And further down
the code in
in the command
the command section
command section, there
already a key
a key statement
key statement for
statement for checkbox
for checkbox 1
Checkboxes in Windows
in Windows are
Windows are a
are a special
a special kind
special kind of
kind of button
use the same
the same kind
same kind of
kind of logic
of logic as
logic as we
as we would
we would when
would when someone
when someone clicks
someone clicks on
clicks on a
on a button
This picks up
picks up the
up the button
button click, and
here we can
can actually interrogate
actually interrogate the
interrogate the checkbox
the checkbox to
checkbox to see
see what its
what its current
its current state
current state is
use the control
the control get
control get check
get check command
check command, giving
giving it the
it the parameters
the parameters of
parameters of the
of the handle
the dialog and
dialog and the
we're passing this
passing this to
this to our
to our result
our result variable
We're using this
using this construct
this construct here
construct here, cb.ctl
the control that
control that actually
that actually has
actually has been
We could have
could have put
have put in
put in checkbox
in checkbox 1
checkbox 1, but
but as we're
several checkboxes, I
want to reuse
to reuse the
reuse the code
can now put
now put in
put in a
in a select
a select case
select case statement
case statement to
statement to determine
determine the value
of the checkbox
Ordinary checkboxes only
checkboxes only have
only have two
have two states
They are either
are either unchecked
either unchecked or
unchecked or they
or they are
they are checked
the value returned
value returned from
returned from this
from this control
this control get
get check statement
check statement returns
statement returns 0
returns 0, then
then it is
it is unchecked
If it returns
it returns the
returns the value
then it's checked
set the value
value in our
in our text
our text output
text output to
output to say
to say either
say either unchecked
unchecked or checked
I've left our
left our third
our third state
third state in
state in here
in here, which
which we will
we will tackle
will tackle later
tackle later on
is for the
for the three
the three state
three state checkboxes
running our code
our code now
So the checkbox
the checkbox is
checkbox is now
is now appearing
now appearing on
If we tick
we tick the
tick the checkbox
the checkbox, then
then the word
the word checked
word checked appears
checked appears in
appears in our
in our textbox
our textbox, and
if we untick
we untick it
untick it, the
the word unchecked
we are correctly
are correctly determining
correctly determining the
determining the current
the current state
current state of
state of our
to have several
have several checkboxes
several checkboxes on
checkboxes on the
the screen, I
make this code
this code quite
code quite generic
new function, which
to do what
do what this
what this piece
code is currently
is currently doing
currently doing, allowing
allowing us to
us to reuse
to reuse it
reuse it for
it for the
for the other
the other checkboxes
other checkboxes we're
checkboxes we're going
be creating a
creating a new
function called displayCheckState
This will take
will take three
the control, and
the handle to
handle to the
to the textbox
the textbox we
textbox we wish
put the text
the text into
us to get
to get rid
get rid of
rid of all
of all this
this code, making
making our code
our code much
code much tidier
let's create the
create the new
the new function
new function with
function with the
with the three
three parameters we
parameters we mentioned
first thing to
do in here
here is to
is to declare
to declare our
declare our local
our local variable
local variable, and
and to use
use the control.getCheck
the control.getCheck command
control.getCheck command to
command to get
in the checkbox
So I'm now
I'm now adding
now adding two
adding two additional
two additional checkboxes
additional checkboxes to
checkboxes to our
to our dialog
I'm adding the
adding the normal
the normal checkbox
normal checkbox, and
and I'm adding
I'm adding a
adding a check3
a check3 statebox
If we update
update the constants
the constants at
constants at the
we now go
back into our
into our forms
our forms designer
forms designer, and
have the three
the three checkboxes
three checkboxes on
Checkbox 1, checkbox
checkbox 2, and
and a third
a third checkbox
third checkbox, which
is a three
a three state
three state checkbox
see the three
three checkboxes, checkbox
checkbox font, checkbox
and checkbox 3
So let's make
let's make all
make all checkboxes
all checkboxes use
checkboxes use the
the same font
have our prefix
our prefix control
prefix control set
font command in
We'll just add
just add two
add two new
two new checkboxes
new checkboxes to
checkboxes to that
to that list
As we've added
we've added new
added new checkboxes
new checkboxes, we'll
to go to
go to our
to our event
event handler, our
callback function, and
put some additional
some additional code
additional code in
have the event
the event in
event in for
in for checkbox
Now as the
as the code
here is completely
is completely generic
completely generic, we
can just copy
just copy that
copy that and
that and paste
and paste it
paste it into
it into both
into both checkbox
both checkbox 2
checkbox 2 and
2 and the
and the three
code now, it
it should correctly
should correctly pick
correctly pick up
pick up checkbox
up checkbox 1
checkbox 1, also
also checkbox 2
we pick the
pick the third
the third checkbox
third checkbox, it
it is checked
The second state
second state is
state is indeterminate
is indeterminate, and
and it puts
it puts a
puts a square
a square into
square into the
into the middle
the middle of
middle of the
the checkbox, and
the final state
final state is
state is unchecked
it will cycle
will cycle within
cycle within these
within these three
these three states
three states each
states each time
each time you
time you click
So the other
the other thing
other thing I
thing I mentioned
I mentioned earlier
mentioned earlier in
earlier in the
the video was
video was we
was we didn't
we didn't have
didn't have the
have the ability
the ability to
ability to change
change the text
the text colour
text colour for
colour for each
of these checkboxes
We'll now see
now see how
can actually achieve
actually achieve this
you'll see that
see that using
using the forms
forms designer puts
designer puts this
puts this line
this line of
line of code
of code into
code into your
into your includes
The checkboxes.PBR is
checkboxes.PBR is a
is a compiled
a compiled resource
see the PBR
the PBR file
PBR file in
file in here
Now if we
if we copy
we copy the
copy the RC
the RC file
RC file into
file into our
into our Power
our Power Basic
Power Basic window
Basic window, and
a look to
see what goes
what goes into
goes into this
And all it's
all it's actually
it's actually doing
actually doing is
doing is adding
is adding this
adding this line
of code, the
a moment we're
moment we're going
to start adding
start adding extra
adding extra resources
extra resources to
resources to our
to our application
our application, but
but I don't
want to mix
to mix the
mix the use
use of the
of the PBR
PBR file and
file and resources
and resources command
resources command within
command within the
within the Power
Power Basic application
So what I'm
what I'm going
is to comment
comment out this
out this line
And I'm going
going to replace
to replace this
replace this line
of code with
code with this
with this single
this single resource
single resource command
resource command to
specify the resource
the resource manifest
And the application
the application will
application will still
will still run
still run quite
run quite happily
And do all
do all you
all you would
you would expect
would expect it
expect it to
it to do
can determine what
determine what the
what the XPtheme
the XPtheme XML
XPtheme XML file
XML file the
file the manifest
the manifest is
manifest is actually
is actually doing
It's putting a
putting a theme
a theme on
theme on your
on your application
If we comment
we comment this
comment this out
this out and
out and run
the application again
application again, the
still run fine
But you'll notice
you'll notice that
notice that the
that the objects
the objects on
objects on screen
on screen look
screen look slightly
look slightly different
The tickbox, when
when it is
it is indeterminate
is indeterminate, is
is effectively grayed
effectively grayed out
So the addition
the addition of
addition of the
of the manifest
is actually changing
actually changing the
changing the theme
the theme of
theme of your
of your application
that we've commented
we've commented out
commented out the
out the theme
the theme, it
it gives us
gives us more
us more control
more control over
control over checkboxes
the function where
function where our
where our dialog
our dialog is
dialog is set
set up, I'm
use the Ctrl-Set
the Ctrl-Set Color
Ctrl-Set Color command
Color command to
command to attempt
to attempt to
attempt to change
the text for
text for each
of the checkboxes
the checkboxes, to
make the foreground
foreground color blue
color blue and
blue and the
and the background
the background color
background color left
color left as
left as is
see that we
now have control
have control over
control over the
over the color
go back and
back and put
put the manifest
the manifest back
manifest back in
back in again
in again, and
application again, we
that the color
the color has
color has gone
So the XML
the XML theme
XML theme is
theme is actually
is actually turning
actually turning off
turning off our
off our ability
our ability to
ability to control
to control the
control the color
color of checkboxes
the moment, I'm
out the manifest
the manifest line
other thing that's
thing that's worth
that's worth noting
worth noting, if
at the standard
the standard checkbox
standard checkbox in
checkbox in the
Forms Designer, if
the styles, you'll
see that in
that in this
in this section
this section here
section here, it
it defaults to
defaults to the
to the BS
the BS Text
BS Text option
But there are
are two other
two other options
other options for
options for icon
for icon and
icon and bitmap
So can we
can we set
we set an
set an icon
an icon rather
icon rather than
rather than text
than text against
text against one
against one of
of the checkboxes?
the checkboxes? As
checkboxes? As I
As I said
I said, the
checkbox is in
is in fact
in fact a
fact a button
a button in
button in Windows
It's a special
of button that
button that displays
that displays the
displays the tickbox
So let's from
let's from the
from the moment
the moment comment
moment comment out
comment out Checkbox
out Checkbox Number
Checkbox Number 2
the code, we're
to add in
add in some
in some graphics
we will put
will put back
put back Checkbox
back Checkbox 2
the Control Add
Control Add button
Add button command
to be Auto
be Auto Checkbox
Auto Checkbox, which
which will make
will make it
make it a
it a checkbox
But we're going
to be defining
be defining an
defining an icon
And the icon
the icon we're
icon we're going
be adding is
adding is this
is this one
this one, Add
use a Windows
a Windows API
Windows API call
API call called
call called loadImage
to load from
load from file
from file an
file an icon
The loadImage command
loadImage command takes
command takes in
takes in a
the first of
first of which
of which is
is the null
the null value
the file we
file we wish
wish to load
to load, in
this case an
case an icon
We're defining it
defining it as
it as an
as an icon
an icon, and
using the Load
the Load from
from File option
File option, using
using the default
the default colors
And having loaded
having loaded that
loaded that value
that value into
value into our
into our handle
our handle each
handle each image
each image, we
then use a
a Control Send
Control Send command
Send command to
command to send
to send that
send that image
that image to
image to our
to our checkbox
Now we've declared
we've declared an
declared an each
an each image
each image, maybe
maybe we'll therefore
we'll therefore want
therefore want you
want you to
you to find
to find that
find that at
...we will see
that our second
our second checkbox
second checkbox now
checkbox now no
now no longer
no longer has
longer has text
has text, but
it does have
does have an
have an icon
an icon in
icon in place
The checkbox will
checkbox will still
will still operate
still operate as
operate as it
But we now
now have the
option of placing
of placing an
placing an icon
an icon against
icon against the
against the checkbox
the checkbox, which
which in some
some cases could
cases could be
could be useful
So let's add
let's add another
add another checkbox
another checkbox, but
but this time
this time with
time with a
with a different
a different image
So I've created
I've created a
created a bitmap
a bitmap image
bitmap image here
image here, which
which I'm just
I'm just going
going to paste
to paste in
And this bitmap
this bitmap image
bitmap image is
image is going
be a longer
a longer image
longer image, with
with the plus
the plus icon
plus icon at
icon at the
the beginning, and
and a piece
piece of text
of text following
text following it
So we want
want to load
to load that
load that bitmap
that bitmap up
bitmap up and
up and display
display it in
it in place
in place of
place of the
create a third
third checkbox with
checkbox with an
with an image
did before, we're
the Control and
Control and Button
and Button command
Button command, but
this time the
time the option
the option we're
option we're giving
giving it is
it is 'bs_bitmap'
use the Load
the Load Image
Load Image command
Image command again
command again, but
this time pointing
time pointing it
pointing it towards
it towards our
towards our Confirm
our Confirm bitmap
Confirm bitmap, with
with an option
an option of
option of 'bitmap'
of 'bitmap' this
'bitmap' this time
this time, as
as opposed to
opposed to the
to the icon
the icon one
icon one we
one we used
we used previously
we'll use the
the Control Send
to our control
run our code
code now, we
see we now
have a large
a large bitmap
large bitmap sitting
bitmap sitting beside
sitting beside the
beside the tickbox
Now you can
you can create
can create bitmaps
create bitmaps and
bitmaps and position
and position them
them on screen
on screen separately
screen separately from
separately from the
from the checkboxes
this approach allows
approach allows the
allows the image
image to be
to be permanently
be permanently attached
permanently attached to
attached to the
to the checkbox
the checkbox itself
checkbox itself, and
and gives quite
gives quite a
quite a visual
a visual appearance
visual appearance to
appearance to what
to what the
is doing on
doing on screen
And as before
as before, we
we will need
will need to
need to put
code in place
in place in
place in the
Handler to handle
handle the events
the events when
events when the
clicks on this
on this checkbox
we will just
will just copy
just copy this
copy this piece
we will change
will change the
change the value
the value to
value to 'Checkbox3'
And 'Checkbox3' is
'Checkbox3' is now
is now working
now working perfectly
working perfectly well
is we've looked
we've looked at
looked at the
at the checkbox
checkbox and the
and the three-state
the three-state checkbox
We have avoided
have avoided using
avoided using the
using the XP
the XP manifest
XP manifest to
manifest to allow
us to set
set the colour
the text on
text on a
on a checkbox
a checkbox control
And additionally, we
we have used
have used both
used both an
both an icon
an icon and
icon and a
and a bitmap
a bitmap, rather
than text, on
on a standard
a standard checkbox
will give you
give you, hopefully
a great deal
great deal more
deal more flexibility
more flexibility on
flexibility on how
on how you
how you can
you can use
can use checkboxes
use checkboxes within
checkboxes within your
within your applications
look at dialogues
at dialogues with
dialogues with conditional
with conditional coding
conditional coding to
coding to activate
to activate or
activate or deactivate
or deactivate dialog
deactivate dialog controls
In the applications
the applications we've
applications we've created
we've created up
created up until
up until now
until now, all
all of these
of these have
these have had
have had fairly
had fairly simple
fairly simple dialogues
there will become
will become a
become a time
time when you're
when you're designing
you're designing applications
designing applications when
applications when your
when your dialogues
your dialogues need
dialogues need to
need to be
be more interactive
more interactive with
interactive with the
of the objects
objects on your
on your dialog
your dialog may
dialog may need
may need to
need to appear
to appear and
appear and disappear
and disappear or
disappear or be
or be activated
be activated and
activated and deactivated
and deactivated depending
deactivated depending on
depending on what
on what the
user does or
does or on
or on some
on some piece
some piece of
piece of underlying
of underlying data
is a fairly
a fairly simple
fairly simple dialog
have a text
box to allow
user to enter
to enter a
enter a name
have two drop-down
two drop-down lists
drop-down lists which
lists which are
which are populated
have a tick
a tick box
tick box and
box and we
have two sets
sets of date
of date controls
date controls to
controls to allow
select a date
a date, to
to start and
start and a
and a date
a date to
date to finish
have two buttons
two buttons, one
one to submit
to submit the
submit the form
the form and
form and one
one to exit
to exit the
exit the application
what if we
if we want
want the text
text box only
box only to
only to appear
to appear when
appear when the
has selected a
selected a specific
a specific department
specific department, for
for example, facilities
And the tick
the tick box
box and its
and its label
its label are
label are not
are not to
to be selectable
be selectable or
selectable or usable
or usable when
usable when the
has selected something
selected something other
something other than
other than the
than the facilities
the facilities department
And as far
as far as
far as the
as the start
the start and
start and end
and end date
end date controls
date controls are
controls are concerned
are concerned, if
the user picks
user picks 'Yes'
picks 'Yes' for
'Yes' for permanent
for permanent staff
permanent staff, then
is no end
no end date
user picks 'No'
picks 'No' for
'No' for permanent
permanent staff, we
want the end
the end date
end date control
date control to
control to appear
So how are
how are we
going to achieve
achieve this in
this in our
in our code?
our code? Let's
code? Let's have
callback function is
function is a
is a special
kind of function
function will perform
will perform all
perform all the
all the tasks
the tasks that
tasks that you
that you need
you need to
need to happen
to happen when
happen when users
when users interact
users interact with
interact with the
with the controls
the dialog loads
dialog loads, there's
there's an event
an event which
event which triggers
which triggers called
triggers called 'initialize
called 'initialize dialog'
This happens before
happens before the
before the dialog
So this gives
you an opportunity
an opportunity to
opportunity to populate
to populate any
populate any controls
any controls on
the dialog or
dialog or set
or set anything
set anything conditional
we've done in
done in here
in here to
here to populate
populate the department
the department dropdown
department dropdown list
dropdown list is
list is to
up the name
a file containing
file containing all
containing all the
all the department
the department names
department names, which
which is in
the same folder
same folder as
folder as our
as our executable
whether that file
that file exists
file exists using
exists using the
using the 'isFile'
the 'isFile' function
'isFile' function, which
which is inbuilt
is inbuilt to
inbuilt to Power
to Power Basic
we can attempt
can attempt to
attempt to read
to read the
read the file
the file into
file into a
into a local
a local array
This array is
array is dimensioned
is dimensioned within
dimensioned within our
within our callback
I'm then using
then using one
functions in one
in one of
the two libraries
two libraries we
libraries we have
In this application
this application, the
two libraries we've
libraries we've added
we've added are
added are the
are the 'pbFileHandlingRoutines'
the 'pbFileHandlingRoutines' library
'pbFileHandlingRoutines' library and
library and the
and the 'pbWindowsControls'
the 'pbWindowsControls' library
These two libraries
two libraries contain
libraries contain a
contain a few
a few functions
few functions we're
functions we're going
be using within
using within this
within this application
which is 'read
is 'read the
'read the file
file into an
into an array'
takes the file
the file we've
file we've specified
we've specified and
specified and loads
and loads it
loads it into
into a specified
a specified array
specified array, allowing
to load all
load all the
all the data
the data at
data at one
at one go
The second function
second function we're
function we're going
to be calling
be calling is
calling is the
is the 'populateCombo'
the 'populateCombo' function
It takes four
takes four parameters
of the combination
the combination dropdown
combination dropdown list
dropdown list box
list box that
box that we
to populate, the
the third is
third is the
is the array
the array containing
array containing the
containing the data
the data we
data we wish
to put into
put into that
into that combo
that combo box
combo box, and
final parameter which
parameter which allows
which allows you
you to pre-select
to pre-select one
pre-select one of
of the items
the items on
items on the
on the dropdown
the dropdown list
this particular case
particular case, we
don't want anything
want anything pre-selected
anything pre-selected, so
so we'll just
we'll just set
just set the
set the selection
the selection variable
selection variable to
variable to an
to an empty
an empty length
empty length string
The second set
second set of
set of logic
of logic in
is to populate
populate the 'yes
the 'yes, no'
no' dropdown list
dropdown list for
list for permanent
For that one
that one, we're
we're simply re-dimensioning
simply re-dimensioning the
re-dimensioning the array
the array to
array to have
to have two
have two items
using the array
the array assign
array assign command
assign command to
command to set
set the two
the two items
two items up
items up as
as being 'yes'
being 'yes' and
'yes' and 'no'
There was again
was again no
again no pre-selection
no pre-selection, and
and we're calling
calling the 'populateCombo'
'populateCombo' function once
function once more
more to populate
populate that dropdown
that dropdown list
then we're setting
setting the focus
the focus to
focus to the
to the text
the text name
that's our application
our application as
application as it
as it starts
it starts now
So at this
in time when
time when the
the user actually
user actually sees
actually sees the
sees the dialog
the dialog for
dialog for the
for the first
the first time
first time, they
they have not
not yet selected
yet selected the
selected the department
want to either
to either deselect
either deselect the
deselect the tick
tick box so
box so it
so it cannot
it cannot be
cannot be selected
be selected, or
or to make
make it invisible
I find it
find it much
it much cleaner
much cleaner to
cleaner to make
make the object
the object invisible
That way the
way the user
the user doesn't
user doesn't see
doesn't see it
see it and
it and doesn't
and doesn't attempt
doesn't attempt to
attempt to click
click on it
The same with
same with the
with the permanent
the permanent staff
permanent staff, as
have not designated
not designated whether
designated whether the
whether the staff
the staff are
staff are going
to be permanent
be permanent or
permanent or temporary
Then we'll want
we'll want the
end date box
date box to
box to disappear
to our callback
put in that
in that logic
we will first
will first attempt
first attempt to
attempt to make
make the manual
the manual handling
manual handling checkbox
handling checkbox invisible
checkbox invisible to
invisible to the
want to hide
to hide that
hide that control
that control, and
we also want
also want to
to hide the
hide the label
the label above
label above it
We can perform
can perform that
perform that function
that function quite
function quite easily
the 'control hide'
'control hide' command
It gets followed
gets followed by
followed by two
by two parameters
of the object
the object which
object which you
which you wish
wish to hide
be doing this
doing this twice
this twice, and
and in some
some cases with
cases with other
with other applications
other applications you
applications you may
you may be
may be making
be making a
making a number
number of controls
of controls invisible
controls invisible, we
command to save
to save you
save you a
little bit of
bit of typing
Proceeding the 'control
hide' command with
with the word
the word prefix
word prefix allows
prefix allows you
you to group
to group all
group all the
the objects you
objects you wish
wish to make
to make invisible
make invisible at
invisible at one
at one goal
can add to
the list quite
list quite easily
quite easily the
easily the label
the label for
label for the
for the manual
What Power Basic
Power Basic will
Basic will do
will do at
do at compile
at compile time
compile time is
time is it
is it will
it will prepend
will prepend the
prepend the control
the control hide
control hide and
hide and the
to the beginning
beginning of each
of the next
the next lines
next lines until
lines until it
until it gets
it gets to
gets to the
of the prefix
This makes your
makes your code
your code look
code look tidier
look tidier and
tidier and is
and is easier
is easier to
easier to follow
So we attempt
we attempt to
attempt to run
to run our
see that when
that when the
dialog loads, the
the tickbox and
tickbox and its
and its associated
its associated label
associated label are
label are now
are now invisible
we'll now do
now do the
thing for the
for the permanent
permanent staff, where
where we want
end date and
date and the
and the control
the control for
control for the
for the dates
the dates to
dates to be
to be invisible
be invisible to
will use exactly
use exactly the
the same logic
same logic by
logic by putting
by putting in
putting in another
in another prefix
another prefix command
prefix command and
command and a
and a control
a control hide
control hide command
hide command, followed
followed by the
by the handles
handles of the
the two date
two date objects
date objects, the
the date control
date control itself
control itself and
itself and the
and the label
label above the
above the date
we run that
run that code
that the end
end date, datebox
datebox and the
the label are
now invisible to
So that handles
that handles setting
handles setting up
up the dialog
the dialog initially
Now what we
do is we
is we need
the logic so
logic so that
so that when
when the department
the department is
department is selected
is selected, for
for example facilities
example facilities, that
our checkbox and
checkbox and its
label are displayed
are displayed to
And then when
then when you
when you return
you return to
return to a
to a different
a different department
different department, then
then those two
those two objects
two objects will
objects will again
will again be
again be hidden
So it's back
it's back to
event handler, to
put the logic
logic in there
So further down
further down in
down in our
in our callback
looking for the
for the wm
the wm command
wm command section
where the process
the process control
process control notifications
control notifications for
notifications for objects
for objects on
objects on the
the screen are
screen are actually
are actually handled
And you'll see
that the forms
forms designer has
designer has already
has already put
already put in
in some case
some case statements
case statements for
statements for each
the objects that's
objects that's currently
that's currently on
currently on the
the screen that
screen that the
user can interact
can interact with
one we're looking
looking for is
for is the
is the CBO
the CBO department
CBO department object
department object, and
and that's this
that's this one
put some logic
in here that
here that handles
that handles a
handles a button
a button click
And by pasting
by pasting this
pasting this in
this in, where
where the control
the control message
control message equals
message equals bn
equals bn clicked
bn clicked or
clicked or the
or the control
message equals one
equals one, then
then we know
we know that
know that that
that that object
that object has
object has indeed
has indeed been
indeed been clicked
need to interrogate
to interrogate this
interrogate this combo
this combo box
combo box to
box to see
see what the
what the department
department is currently
currently set up
using the control
the control gate
control gate text
gate text statement
will work fine
work fine for
fine for this
for this particular
this particular combo
particular combo box
combo box as
box as this
as this combo
combo box only
box only allows
only allows a
allows a single
a single entry
single entry to
entry to be
to be selected
we pass this
pass this function
this function, the
the dialogue, the
the object and
object and a
and a variable
a variable into
variable into which
into which you
the text that
text that currently
that currently is
currently is selected
is selected on
selected on that
on that object
to declare this
declare this as
a new variable
new variable at
variable at the
of our function
And having declared
having declared that
declared that, we
can now test
now test the
the value going
value going into
going into that
into that variable
value is facilities
is facilities, we
want to show
show the two
the two objects
two objects to
prefix command here
command here to
here to save
to save a
save a little
So to show
show the object
the object to
object to the
we're using control
using control normalize
This normalizes the
normalizes the controls
on screen, in
it makes them
makes them visible
them visible to
As before, it
takes the two
the dialogue and
the object you
object you wish
wish to show
to show to
show to the
we've added to
added to this
to this list
this list the
list the checkbox
the checkbox for
checkbox for manual
for manual handling
manual handling and
handling and the
label for manual
A good naming
good naming convention
naming convention for
convention for all
for all your
all your objects
your objects makes
objects makes it
makes it very
it very easy
very easy to
easy to understand
to understand what
understand what we're
what we're actually
we're actually doing
I've prefixed the
prefixed the name
name of my
of my objects
my objects with
objects with CHK
with CHK for
CHK for checkbox
for checkbox and
checkbox and LBL
and LBL for
LBL for label
And as they're
as they're both
they're both to
both to do
to do with
do with manual
with manual handling
manual handling, I've
I've got the
got the remainder
the remainder of
remainder of the
of the name
the name as
name as manual
as manual handling
find this saves
this saves you
saves you a
you a great
great deal of
deal of time
of time debugging
time debugging your
debugging your code
your code later
code later on
later on, or
or when you
when you come
you come back
back to your
to your code
your code in
code in several
in several weeks
several weeks or
weeks or months
or months later
So that will
that will handle
will handle showing
handle showing these
showing these two
these two controls
two controls when
controls when the
when the facilities
facilities department has
department has been
we'll see initially
see initially the
initially the two
the two controls
two controls are
controls are not
are not shown
we pick facilities
pick facilities, they
they are now
are now appearing
appearing on the
screen and they
and they are
they are selectable
when we pick
we pick one
pick one of
the other departments
other departments, they
they are not
are not disappearing
logic in to
in to hide
to hide these
hide these when
these when some
when some department
some department other
department other than
other than facilities
than facilities is
facilities is selected
as we showed
we showed both
showed both of
both of these
these objects before
objects before to
before to the
the user when
user when facilities
when facilities were
facilities were selected
were selected, we
have to hide
hide the objects
the objects because
objects because facilities
because facilities is
facilities is not
is not selected
will do this
this in exactly
in exactly the
the same way
same way as
way as we
we did when
did when we
when we set
up the dialogue
the dialogue initially
hide command to
command to hide
to hide both
hide both of
application now, the
two objects are
objects are initially
are initially invisible
We select facilities
select facilities and
facilities and they
and they appear
We select some
select some other
some other department
other department and
department and they
and they disappear
they disappear again
for the start
the start date
have to when
to when the
the user selects
user selects not
selects not permanent
not permanent staff
want the extra
the extra date
extra date control
date control shown
And when the
user selects yes
selects yes for
yes for permanent
we want it
want it hidden
it hidden again
And this time
this time we're
time we're handling
we're handling the
handling the CBO
the CBO permanent
CBO permanent staff
permanent staff object
So exactly the
if the button
the button hasn't
button hasn't been
hasn't been clicked
get text command
text command to
back the selected
the selected text
selected text from
text from that
from that drop
that drop down
drop down list
And we're populating
we're populating the
populating the text
the text variable
text variable with
variable with that
with that value
And just as
just as we
did before, when
when the text
the text equals
text equals no
equals no, we're
making the end
date controls visible
Otherwise we're making
we're making them
making them hidden
them hidden again
So we run
our code again
see that since
that since permanent
since permanent staff
permanent staff has
staff has not
has not yet
yet selected, the
the end dates
end dates are
dates are invisible
are invisible to
And as invisible
as invisible, they
they cannot be
cannot be clicked
be clicked upon
user selects no
selects no, the
end date label
date label and
label and date
and date control
date control appear
control appear and
appear and allow
to select from
select from it
When we again
we again select
again select the
select the yes
the yes from
yes from the
from the drop
the drop down
down list, these
two controls will
controls will disappear
will disappear from
disappear from the
from the user's
the user's site
what we've seen
we've seen today
seen today is
very straightforward method
straightforward method in
method in your
in your callback
your callback function
callback function, your
your event handler
for controlling what
controlling what is
what is visible
is visible and
visible and not
and not visible
not visible to
allow you to
you to make
to make your
make your dialogues
your dialogues more
dialogues more interactive
Either with underlying
with underlying data
underlying data or
data or with
or with what
with what the
has selected on
selected on screen
give you the
you the maximum
the maximum amount
maximum amount of
amount of functionality
of functionality with
functionality with the
with the minimum
the minimum amount
minimum amount of
find this useful
this useful in
look at an
at an application
an application to
application to display
to display CSV
display CSV files
CSV files without
files without amending
without amending or
amending or reformatting
or reformatting the
reformatting the data
the data in
data in the
in the display
the display grid
Today we're going
be doing our
doing our video
our video slightly
video slightly differently
to start off
start off by
off by showing
by showing the
showing the finished
the finished application
finished application and
application and after
and after demonstrating
after demonstrating this
demonstrating this we'll
this we'll double
we'll double back
double back and
back and have
code that created
that created it
all this application
this application was
application was created
was created to
created to solve
to solve a
solve a specific
a specific problem
have in this
in this folder
this folder a
folder a CSV
a CSV file
of the tasks
the tasks you
tasks you may
you may have
may have to
to do on
do on a
on a daily
a daily basis
daily basis is
basis is to
is to look
look at CSV
at CSV files
that the construct
the construct of
construct of the
the file is
file is intact
is intact and
intact and there
is no dodgy
no dodgy data
dodgy data within
data within it
are a number
number of applications
of applications you
applications you can
can use to
use to view
to view a
view a CSV
Ranging from Notepad
from Notepad right
Notepad right up
right up to
up to Expensive
to Expensive Spreadsheet
Expensive Spreadsheet Systems
If we first
we first of
of all look
all look at
at the CSV
the CSV file
CSV file in
file in Notepad
see the construct
construct of this
of this file
this file does
file does look
does look like
look like a
like a standard
a standard CSV
standard CSV file
have a header
a header line
header line at
line at the
the top which
top which is
which is comma
is comma Delimited
number of data
of data records
data records underneath
records underneath this
underneath this header
this header line
of these rows
these rows of
rows of data
of data is
data is delimited
is delimited by
delimited by a
by a comma
As well as
well as the
as the text
the text contained
text contained within
contained within the
within the data
the data rows
data rows we
rows we also
we also appear
also appear to
appear to have
to have some
have some dates
some dates and
dates and some
and some numbers
The dates are
dates are in
are in year
in year month
year month day
month day format
day format and
format and the
and the numbers
the numbers are
numbers are zero
are zero filled
This particular CSV
particular CSV file
CSV file looks
file looks fine
looks fine as
fine as far
far as I
as I can
I can see
can see by
see by looking
looking at it
at it in
it in Notepad
However Notepad does
Notepad does not
does not arrange
not arrange the
arrange the text
the text very
text very well
very well to
well to make
make it easy
it easy to
easy to check
to check a
check a file
If we attempt
attempt to open
to open the
open the file
the file up
file up in
up in Excel
will see first
see first of
of all Excel
all Excel gives
Excel gives a
gives a warning
To say that
say that by
that by default
by default Excel
default Excel will
Excel will perform
will perform the
perform the following
the following dating
following dating conversions
dating conversions in
conversions in this
in this file
And first of
first of those
of those is
those is to
is to remove
to remove leading
remove leading zeros
Ideally we wish
wish to see
to see the
see the file
file in the
in the format
the format in
format in which
in which it
which it has
has been presented
We do not
do not want
not want an
want an application
an application making
application making any
making any conversions
any conversions changes
conversions changes or
changes or manipulation
or manipulation of
manipulation of the
of the data
the data that
data that come
that come in
So in this
this case we
case we will
will click don't
click don't convert
can see in
see in the
in the current
the current column
current column all
column all the
However in the
in the start
start date column
date column Excel
column Excel has
Excel has converted
has converted the
converted the dates
the dates into
dates into a
into a different
a different format
It is now
is now sitting
now sitting in
sitting in the
in the regional
the regional day
regional day month
day month year
month year format
And as this
is not the
not the format
the format that
format that the
the file was
file was presented
was presented with
can be a
be a problem
a problem if
problem if you're
if you're looking
you're looking for
looking for issues
for issues with
issues with the
with the data
Now while there
while there are
there are things
are things you
things you can
you can do
can do in
do in Excel
in Excel and
Excel and other
and other spreadsheet
other spreadsheet systems
spreadsheet systems to
systems to prevent
to prevent such
prevent such manipulation
such manipulation and
manipulation and conversion
Ideally you want
want to view
to view the
view the file
the file as
file as it
as it was
it was presented
was presented straight
presented straight away
So that was
that was my
was my task
my task in
task in creating
in creating a
creating a Power
a Power Basic
Basic application that
application that would
that would perform
would perform this
So I have
I have created
have created an
an application called
application called view
called view CSV
view CSV file
CSV file dot
file dot exe
If we double
we double click
double click on
the application it
application it presents
it presents us
presents us with
us with a
with a file
a file selection
file selection dialog
is our HR
our HR staff
HR staff list
staff list CSV
list CSV file
up we can
can see on
on screen we
screen we have
we have 33
have 33 records
33 records of
records of data
of data with
data with the
with the header
the header line
application has automatically
has automatically widened
automatically widened the
widened the columns
the columns based
columns based on
on the data
the data contained
data contained within
contained within them
It is also
is also presented
also presented the
presented the start
start date in
date in the
format that it
that it was
was presented in
presented in as
in as in
as in year
And the account
the account column
account column is
column is zero
is zero filled
zero filled as
filled as it
So there has
there has been
has been no
been no manipulation
no manipulation of
manipulation of data
of data that
data that has
that has come
on the file
the file exactly
file exactly as
as it stood
it stood but
stood but it
it is better
is better presented
better presented in
presented in rows
in rows and
rows and columns
And each alternate
each alternate row
alternate row is
row is color
is color coded
color coded to
coded to make
make it easier
it easier to
easier to actually
to actually see
actually see the
see the data
click the widget
the widget at
widget at the
the top right
top right hand
the screen we
screen we can
we can change
can change the
Up to the
to the full
the full size
full size of
the screen or
screen or down
down to a
to a minimum
a minimum size
minimum size beyond
size beyond which
beyond which it
which it will
it will not
will not progress
So if that
is our application
our application how
application how did
how did we
did we achieve
we achieve this
this in code?
in code? Let's
at the application
the application then
is a source
a source code
source code for
code for our
is set to
set to compile
to compile into
compile into the
into the name
name of ViewCSVfile.exe
If it works
it works slightly
works slightly further
slightly further down
further down we
down we can
see the include
the include files
include files that
files that have
that have been
have been used
used to compile
to compile this
compile this application
We're including my
including my little
my little grid
little grid sll
That's the static
the static link
static link library
link library or
library or the
or the my
the my little
little grid grid
grid grid control
I'll put links
put links in
links in the
in the description
the description below
description below where
below where you
where you can
can actually download
actually download this
download this free
this free add-on
We're using three
using three sets
three sets of
sets of libraries
of libraries which
libraries which are
which are of
are of our
of our own
our own construction
One to allow
to allow you
you to easily
to easily use
easily use my
use my little
little grid, one
one for file
for file handling
file handling routines
handling routines and
routines and one
one to provide
to provide some
provide some macros
some macros for
macros for you
Additionally this application
this application makes
application makes use
makes use of
of the layout32
the layout32 static
layout32 static link
is a purchased
a purchased library
purchased library which
library which I
which I have
I have found
have found incredibly
found incredibly useful
incredibly useful to
useful to allow
you to resize
to resize your
resize your dialogs
your dialogs and
dialogs and automatically
and automatically position
automatically position the
position the controls
the dialog according
dialog according to
according to the
to the size
size and position
and position of
This static link
link library will
library will not
will not be
not be included
be included with
included with the
with the source
the source code
source code when
code when I
when I upload
I upload this
So I've set
I've set it
set it up
it up so
up so that
so that if
that if you
if you comment
you comment out
out the single
the single line
single line of
of code it
code it will
will not use
not use that
use that library
that library and
library and will
and will make
will make use
make use of
use of code
of code elsewhere
code elsewhere in
elsewhere in our
While this isn't
this isn't as
isn't as good
as good as
good as the
as the layout32
the layout32 it's
layout32 it's enough
it's enough to
enough to let
to let you
let you demonstrate
you demonstrate how
demonstrate how this
how this application
this application works
But I would
I would recommend
would recommend the
recommend the use
the layout32 library
layout32 library, it's
it's a very
a very useful
very useful library
useful library and
library and saves
and saves you
of time when
time when designing
when designing Windows
designing Windows dialogs
Especially those that
those that users
that users will
users will want
will want to
want to resize
pb_main function, the
the first function
first function that
function that is
that is executed
is executed when
executed when our
when our application
our application runs
thing the pb_main
pb_main function does
function does is
does is it
is it has
it has a
has a look
look at any
at any parameters
any parameters that
parameters that have
that have come
have come in
on the command
the command line
This allows you
you to use
to use this
use this application
this application as
application as the
as the default
the default application
default application for
application for a
for a particular
a particular type
particular type of
type of extension
So all my
all my CSV
my CSV files
CSV files will
files will launch
will launch this
launch this application
this application if
application if double
if double clicked
double clicked on
If we just
we just double
just double click
on the CSV
CSV file it
file it will
it will launch
this application automatically
If something comes
something comes in
comes in on
command line and
line and the
the application cannot
application cannot find
cannot find that
find that file
that file it
it will give
you a message
a message box
message box to
box to say
to say the
say the file
the file cannot
file cannot be
cannot be accessed
If nothing comes
nothing comes in
command line you
line you will
you will then
then be presented
be presented with
presented with a
with a dialog
a dialog allowing
dialog allowing you
allowing you to
you to select
This will default
will default to
default to the
to the current
the current path
current path of
path of the
of the executable
the executable and
executable and will
and will look
will look for
look for all
for all files
all files with
files with a
with a CSV
a CSV extension
And with the
with the flags
the flags we've
flags we've set
we've set it
it to where
to where the
where the file
must exist and
exist and the
and the path
the path must
path must exist
So this prevents
this prevents the
prevents the user
the user typing
user typing in
typing in file
in file names
file names that
names that do
that do not
do not currently
not currently exist
we will display
will display our
display our dialog
dialog is fairly
is fairly straightforward
There's a toolbar
a toolbar at
toolbar at the
the dialog, there's
there's a label
a label to
label to display
to display how
display how many
how many records
many records we
records we pull
we pull back
pull back from
back from the
from the file
the file and
file and there's
and there's a
there's a button
a button to
button to exit
We're using one
of the built
the built in
built in functions
in functions in
one of our
of our libraries
our libraries to
libraries to read
to read a
read a CSV
CSV file into
into a two
a two dimensional
two dimensional array
And after that
after that is
is the initialization
initialization section for
section for my
for my little
takes the output
output from our
from our function
our function which
function which is
is the rows
the rows and
and columns within
columns within the
within the file
We have additionally
have additionally set
additionally set an
set an option
an option to
option to set
set a right
a right click
right click menu
user actually goes
actually goes into
goes into the
the application, right
right clicks, they
they have three
have three options
They can copy
can copy the
copy the data
the data within
data within a
within a specific
a specific cell
specific cell or
cell or they
or they can
they can sort
can sort the
sort the column
the column based
column based either
based either on
either on ascending
on ascending or
ascending or descending
or descending characters
pick the name
the name column
name column, right
right click and
click and sort
and sort it
sort it alphabetically
a very easy
very easy and
easy and quick
and quick way
quick way of
way of sorting
of sorting data
sorting data within
data within our
within our grid
our grid without
grid without changing
without changing the
changing the underlying
the underlying file
can return it
return it to
it to its
to its original
We'll cover more
cover more about
more about the
about the sorting
the sorting when
sorting when we
get to that
to that line
that line in
line in code
little grid has
grid has a
has a great
a great number
great number of
number of options
of options, but
but we're using
we're using most
using most of
of the basic
the basic ones
basic ones to
ones to set
set this up
And this line
of code here
code here is
is the single
of code that
code that takes
that takes all
in the array
array we have
we have loaded
have loaded from
loaded from the
from the CSV
CSV file and
file and places
and places this
places this data
this data within
data within the
within the grid
the grid itself
We are then
are then updating
then updating the
updating the label
the label on
label on screen
screen to say
to say how
say how many
many records have
records have been
have been returned
been returned by
returned by loading
by loading the
loading the file
We're then making
then making use
making use of
use of three
of three functions
three functions within
functions within our
within our My
our My Little
Little Grid library
One to widen
to widen the
widen the columns
the columns in
columns in the
in the grid
This sets the
sets the column
the column width
column width to
width to be
be the maximum
the maximum width
maximum width of
width of text
of text either
text either in
either in the
in the headers
the headers or
headers or in
or in the
in the data
second function colour
function colour banks
colour banks the
banks the grid
the grid rows
grid rows in
rows in alternate
in alternate colors
This makes it
makes it much
it much easier
much easier to
easier to read
to read when
read when you
you have a
a large spreadsheet
command is to
is to refresh
to refresh the
refresh the grid
the grid to
grid to ensure
to ensure everything
ensure everything we
everything we have
we have just
have just done
just done gets
done gets drawn
gets drawn to
drawn to the
to the grid
the grid on
grid on screen
screen that your
that your user
your user can
can then see
Further down at
down at the
particular function is
function is our
is our code
our code for
code for layout32
Layout32 gives you
you a mechanism
a mechanism by
mechanism by which
by which you
which you can
can actually apply
actually apply rules
apply rules to
rules to each
to each of
You can say
can say in
say in this
this case for
case for the
for the grid
the grid we
grid we were
we were allowing
were allowing the
allowing the grid
grid to be
to be stretched
be stretched when
stretched when the
the dialog upon
dialog upon which
upon which it
which it sits
it sits is
sits is made
is made larger
It will also
will also contract
also contract when
contract when the
dialog is made
is made smaller
And it's tied
it's tied to
tied to the
the right and
right and to
and to the
also have two
have two rules
two rules for
rules for the
for the exit
the exit button
exit button, the
the abort button
move the object
the object on
object on screen
on screen based
screen based on
on the bottom
And the rule
the rule at
rule at the
at the very
the very bottom
very bottom of
of this section
section is to
set a minimum
minimum size for
size for the
for the dialog
user can make
can make the
make the dialog
the dialog larger
dialog larger than
larger than this
than this but
this but it
but it will
will not allow
not allow it
it to make
make it smaller
So with these
with these small
these small number
small number of
number of rules
of rules you
rules you can
you can control
can control what
control what appears
what appears on
Well you can
you can code
can code this
code this yourself
this yourself in
yourself in the
application which we
will see in
see in a
If you have
number of objects
the dialog it's
dialog it's much
it's much easier
much easier using
easier using this
using this rule
this rule based
rule based approach
based approach where
approach where someone
where someone else
someone else has
else has actually
has actually written
actually written the
written the code
code for you
at the event
event handler this
handler this handles
this handles all
handles all the
If the layout
the layout 32
layout 32 code
32 code is
code is not
is not being
not being used
being used this
used this will
will actually be
actually be included
be included in
included in the
These are the
are the additional
the additional variables
additional variables we'll
variables we'll need
need to handle
to handle all
handle all the
all the resizing
the resizing code
resizing code ourselves
Initially when the
when the application
the application loads
application loads we
loads we maximise
we maximise the
maximise the dialog
the dialog on
dialog on screen
Maximising the dialog
the dialog will
dialog will kick
will kick off
kick off a
off a size
a size event
The dialog has
dialog has changed
has changed size
changed size therefore
size therefore the
therefore the code
in here will
here will be
will be executed
If the dialog
has been minimised
been minimised this
minimised this exits
this exits straight
exits straight away
straight away as
away as it's
as it's not
it's not visible
the user therefore
user therefore there's
therefore there's no
there's no code
no code needed
And this large
this large section
large section of
section of code
the code you
code you will
you will have
have to have
to have in
have in in
in in order
order to resize
to resize the
resize the objects
the dialog if
dialog if you're
if you're not
you're not using
not using layout
using layout 32
Basically it's working
it's working out
of the client
the client area
client area of
dialog and working
and working out
working out whether
whether the minimum
the minimum size
minimum size has
size has been
has been reached
been reached or
reached or not
have to get
of the exit
exit button to
button to work
work out its
out its new
its new position
new position on
position on screen
then finally we
finally we have
with the grid
the grid control
grid control itself
control itself to
itself to work
out how wide
how wide it
wide it is
it is and
is and how
and how wide
wide it needs
to be and
be and how
and how high
how high it
high it needs
to be to
be to fit
to fit on
fit on the
on the newly
the newly resized
newly resized dialog
If we're using
we're using layout
layout 32 these
32 these lines
these lines of
of code are
code are not
are not required
And our final
our final section
final section here
section here is
little grid itself
grid itself is
itself is set
up to use
to use notifications
the user performs
user performs something
performs something on
on the grid
the grid a
grid a message
a message is
message is sent
is sent to
sent to the
to the WM
the WM notify
WM notify event
notify event inside
event inside this
inside this callback
using this MLGN
This variable is
is a user
user defined my
defined my little
little grid pointer
you to work
work out that
out that it
it has indeed
indeed been your
been your grid
your grid that
grid that has
You can in
can in theory
in theory have
theory have more
have more than
more than one
than one grid
one grid on
grid on a
on a dialog
this case you
case you can
you can determine
can determine that
determine that the
that the grid
the grid being
grid being selected
being selected is
selected is the
the first grid
And this section
of code will
code will only
will only apply
only apply to
apply to the
to the first
We're then looking
then looking at
at the NM
the NM header
NM header code
us to pick
up the event
the event that
event that has
been triggered on
triggered on the
case we're looking
at the right
the right click
A user has
user has right
has right clicked
right clicked somewhere
clicked somewhere on
somewhere on the
dialog and we
and we need
pick up what
up what menu
what menu item
menu item they've
item they've actually
they've actually picked
this particular grid
particular grid there
grid there are
are three menu
three menu items
One to copy
to copy to
copy to the
to the clipboard
A second one
second one to
one to sort
to sort A
sort A to
A to Z
to Z and
Z and a
a third one
third one to
to sort Z
sort Z to
Z to A
Sorting is quite
is quite straightforward
We merely have
merely have to
have to send
to send a
send a single
a single line
of code using
code using the
using the send
the send message
send message command
message command back
command back to
One to say
to say it's
say it's sorting
A second parameter
second parameter to
parameter to say
to say we
say we want
we want an
want an ascending
an ascending sort
parameter is to
is to say
to say which
say which column
which column we
column we wish
wish to sort
to sort on
this particular application
particular application I've
application I've left
I've left all
left all the
all the columns
the columns as
columns as being
as being character
being character columns
Therefore all the
all the sorting
the sorting being
sorting being done
being done on
done on this
on this particular
particular grid will
grid will be
will be done
be done as
done as if
as if everything
if everything are
everything are straightforward
are straightforward string
straightforward string characters
You can define
can define in
define in my
in my little
little grid columns
grid columns to
columns to be
to be numbers
be numbers or
numbers or dates
And my little
my little grids
little grids sorting
grids sorting routine
sorting routine will
routine will respect
will respect these
respect these choices
In those cases
those cases numbers
cases numbers will
numbers will sort
will sort numerically
sort numerically as
numerically as will
as will dates
I usually set
usually set up
set up a
up a boolean
a boolean flag
boolean flag to
flag to say
say that something
that something is
something is sorting
You can test
can test this
test this later
this later on
code to ensure
ensure that you're
that you're not
you're not performing
not performing any
performing any other
any other changes
other changes to
the grid while
grid while it's
while it's in
it's in the
process of sorting
Sorting is very
is very quick
very quick but
quick but you
but you don't
don't want something
want something else
something else triggering
else triggering while
triggering while you're
while you're in
you're in the
in the middle
middle of a
of a sort
And with my
with my little
little grid one
grid one of
of the things
the things to
things to remember
to remember is
remember is to
is to have
have a wm_paint
a wm_paint event
When the grid
grid is being
is being repainted
being repainted you
repainted you need
do a control
control redraw on
redraw on the
This ensures that
ensures that the
grid is shown
is shown correctly
shown correctly and
correctly and doesn't
and doesn't have
doesn't have any
have any bounding
any bounding lines
bounding lines in
lines in the
of the grid
Further down our
down our code
our code we
code we have
event that handles
that handles clicking
handles clicking on
on the open
open button on
on the toolbar
This allows a
allows a user
select a new
a new CSV
new CSV file
CSV file to
file to load
This uses almost
uses almost exactly
almost exactly the
the same code
same code as
code as we
as we saw
we saw at
saw at the
It launches the
launches the display
open file dialog
select a CSV
CSV file from
file from somewhere
from somewhere on
on the machine
the machine or
machine or indeed
or indeed from
indeed from the
from the network
And again we're
again we're using
using the read
the read the
read the CSV
an array again
array again to
again to load
to load whatever's
load whatever's in
whatever's in the
in the CSV
dimensional array which
array which can
which can then
can then be
then be placed
be placed on
placed on the
little grid stores
grid stores the
stores the information
the information that
information that appears
that appears on
the grid in
grid in an
in an array
use the inbuilt
the inbuilt function
inbuilt function mlg
function mlg array_redim
mlg array_redim to
array_redim to resize
to resize that
resize that grid
And then you
then you can
use the put
the put x
put x command
x command to
command to take
to take webbers
take webbers in
webbers in your
in your array
your array and
array and plonk
and plonk it
plonk it straight
it straight into
straight into the
into the grid
can then widen
then widen the
the columns, color
color bank the
bank the rows
rows and refresh
and refresh the
from this there
this there is
there is not
not a great
deal of code
of code involved
code involved in
involved in displaying
in displaying a
displaying a CSV
file to the
the user using
user using a
using a my
a my little
little grid control
with the addition
of the Layout
Layout 32 you
32 you can
you can make
the dialog resizable
dialog resizable and
resizable and aware
and aware of
aware of larger
of larger screens
larger screens or
screens or smaller
or smaller screens
smaller screens depending
screens depending on
is actually using
put links to
links to my
to my little
little grid and
grid and to
to the Layout
Layout 32 in
32 in the
find this utility
this utility useful
utility useful in
in your day
your day to
day to day
to day work
at the display
the display dialogues
display dialogues commands
dialogues commands inbuilt
commands inbuilt to
inbuilt to PowerBasic
When you are
you are creating
are creating a
creating a PowerBasic
a PowerBasic Windows
PowerBasic Windows application
Windows application, there
there will come
will come a
come a time
you want the
user to be
to be able
able to select
select either a
either a folder
a folder to
folder to read
to read from
read from, a
folder to write
to write to
write to, or
or to open
to open or
open or to
or to save
save a file
The first part
first part of
part of these
of these activities
these activities would
activities would be
would be allowing
be allowing the
to select where
select where to
where to read
read from or
from or to
or to write
The Windows API
Windows API provides
API provides a
provides a number
number of function
of function calls
function calls that
calls that would
that would allow
would allow this
allow this functionality
PowerBasic goes even
goes even further
even further and
further and provides
and provides a
number of wrapper
of wrapper commands
wrapper commands to
commands to these
to these Windows
these Windows API
And that's what
that's what we're
looking at today
at today, the
the display dialog
display dialog commands
looking at display
at display browse
display browse, which
select a folder
a folder from
folder from your
from your disk
open file, which
a file to
file to open
And finally display
finally display save
display save file
save file, which
a file or
file or files
or files to
files to save
to save to
to make these
make these individual
these individual commands
individual commands easy
commands easy to
easy to use
to use and
use and understand
and understand, we're
to create three
create three functions
And each function
each function is
to perform one
perform one of
of these display
these display commands
So we'll start
we'll start with
start with the
with the display
the display browse
display browse command
As the purpose
a folder, we'll
create a local
local variable into
into which we're
to store this
store this folder
And this variable
this variable will
variable will hold
will hold both
hold both the
both the path
path and the
and the name
of the folder
will create a
variable called folderPicked
to store our
store our path
our path and
and name of
the folder that
folder that has
going to populate
to populate this
populate this folder
this folder by
folder by the
by the output
the output of
output of a
of a new
which we'll call
we'll call display
call display browse
We're not passing
not passing any
passing any parameters
any parameters to
to this function
this function, but
but you always
you always could
always could in
could in your
in your own
your own applications
local variables just
variables just to
just to make
easy to populate
populate the parameters
parameters of our
of our display
our display browse
And these are
are the local
the local parameters
local parameters we're
parameters we're going
is a parent
a parent variable
of the parent
This could be
could be the
be the desktop
the desktop if
desktop if there
if there is
is no parent
no parent dialog
parent dialog, or
or it could
it could be
be the handle
handle of whatever
of whatever parent
whatever parent has
parent has actually
has actually triggered
actually triggered this
triggered this function
are the x
and y position
y position coordinates
where our new
our new display
new display browse
display browse dialog
browse dialog is
dialog is to
is to appear
value of these
these two variables
two variables is
variables is based
is based on
on the top
The next parameter
next parameter is
is the title
is the string
the string of
string of text
of text you
text you want
want to appear
This is useful
is useful to
useful to indicate
the user what
user what they're
what they're attempting
they're attempting to
The next variable
next variable is
variable is the
is the starting
the starting folder
starting folder path
is the folder
folder that will
that will initially
will initially appear
initially appear to
appear to the
a long variable
This flags variable
flags variable is
variable is used
used to hold
to hold the
hold the style
the style attributes
style attributes of
attributes of the
you to change
way the dialog
dialog will behave
cover that in
The final variable
final variable is
the folder picked
is the variable
the variable into
into which the
which the output
output from the
from the display
browse command will
command will place
will place the
place the path
the folder the
folder the user
has actually selected
the cancel button
cancel button then
button then this
then this variable
will be an
be an empty
an empty lens
empty lens string
So let's set
let's set up
value of each
of these variables
all we're setting
setting the parent
the parent to
parent to be
is because when
because when this
when this function
is called there
called there are
are no dialogs
no dialogs showing
dialogs showing on
showing on screen
If you were
you were calling
were calling this
calling this from
this from another
from another dialog
another dialog then
dialog then you
you can put
can put in
put in the
in the handle
handle of that
of that dialog
that dialog as
dialog as the
as the parent
have the X
this case being
case being 50
being 50 50
Since we're giving
we're giving the
giving the parent
the parent as
parent as the
as the desktop
the desktop this
desktop this is
is the position
the position relative
position relative to
relative to the
to the top
of the desktop
These values are
values are in
are in pixels
So our new
our new dialog
new dialog for
dialog for display
for display browse
display browse will
browse will appear
will appear at
appear at the
at the coordinates
the coordinates 50
coordinates 50 by
50 by 50
by 50 at
50 at the
corner of our
of our screen
Next we're populating
populating the title
the title variable
of text we
text we want
to see to
see to give
to give them
give them an
them an indication
of what we
we want them
want them to
them to do
this case saying
case saying the
saying the words
the words please
words please select
please select a
populate the start
the start path
This tells Power
tells Power Basic
Power Basic which
Basic which drive
which drive and
drive and folder
and folder we
folder we wish
wish to start
to start the
start the dialog
the dialog at
will populate the
case we're using
we're using EXE.Path$
a special command
special command that
command that will
that will instruct
will instruct Power
instruct Power Basic
Power Basic to
Basic to return
to return the
the folder in
folder in which
in which our
which our current
our current executable
current executable resides
of course substitute
course substitute any
substitute any other
any other valid
other valid path
valid path for
path for your
for your application
set the flags
the flags variable
is a variable
a variable that
variable that holds
that holds the
holds the style
dialog we're about
we're about to
about to present
to present to
present to the
I'm using just
using just a
a single option
single option here
option here, the
the new dialog
new dialog style
dialog style which
style which is
at the Windows
the Windows Help
Windows Help we
Help we can
all the attributes
the attributes we
attributes we can
can actually set
actually set on
set on this
this particular dialog
The only attribute
only attribute I've
attribute I've picked
I've picked is
picked is the
is the new
If we left
we left the
left the flags
flags variable as
variable as unpopulated
as unpopulated we
unpopulated we would
we would inherit
would inherit this
inherit this style
If we wish
we wish the
wish the dialog
the dialog not
dialog not to
not to allow
user to create
a new folder
new folder, for
for example by
example by hiding
by hiding the
hiding the new
the new folder
new folder button
folder button, we
can add on
add on this
on this extra
this extra attribute
could be done
be done by
done by using
using the OR
the OR command
You're basically ORing
basically ORing both
ORing both of
of these attributes
these attributes together
attributes together to
together to give
give a value
a value to
value to store
to store in
store in the
in the flags
I'm using the
using the underline
the underline character
underline character at
character at the
of the line
the line to
line to fold
to fold the
fold the line
the line down
line down to
the next line
So basically this
basically this allows
us to be
be a single
that we've populated
we've populated each
populated each of
these variables we
variables we can
can now call
now call the
call the display
is our display
browse command with
command with each
with each of
each of its
of its parameters
all the handle
to the parent
the parent, the
y coordinates, the
the title of
title of the
start path, the
the flags and
flags and the
and the variable
which we're putting
putting the output
the output, the
folder that the
user has picked
this function all
function all we
is to return
return the folder
has been picked
been picked to
picked to the
calling function, like
to our code
our code at
code at the
the start, now
have created this
created this function
this function we
function we will
value and place
and place it
place it in
it in this
in this variable
order to let
to let us
let us see
us see which
see which folder
which folder has
folder has been
been selected we'll
selected we'll use
we'll use a
use a message
message box command
box command to
display this on
now and so
and so the
so the dialog
dialog will appear
appear on screen
This dialog is
dialog is resizable
is resizable and
resizable and as
and as you'll
you'll see at
see at the
the dialog it
dialog it has
it has highlighted
has highlighted the
highlighted the folder
the folder we
folder we are
the code folder
And as we've
as we've set
we've set the
set the application
the application not
application not to
not to display
display the new
folder button you'll
button you'll see
see that there
that there is
is no new
no new folder
folder button at
button at the
If we cancel
we cancel out
cancel out of
out of this
of this we'll
this we'll see
that the folder
the folder returned
folder returned is
returned is blank
to our function
our function and
function and we
and we take
we take out
take out the
out the line
the line of
code that sets
that sets the
sets the new
folder button to
button to be
be invisible and
invisible and we
and we run
once more we
more we will
have the make
the make new
make new folder
folder button appearing
button appearing on
we click new
click new folder
new folder we
folder we can
we can create
can create a
a new test
new test folder
test folder underneath
folder underneath our
underneath our code
our code folder
we can name
can name that
name that and
that and now
that it's highlighted
it's highlighted if
highlighted if we
we click OK
click OK our
OK our message
our message box
message box will
box will return
return the path
the path to
path to our
to our test
our test folder
have successfully used
successfully used a
used a function
function to allow
folder from their
from their computer
look at display
at display open
There will be
will be times
be times in
times in your
in your application
your application when
application when you
when you will
you will prompt
will prompt the
prompt the user
to open for
open for reading
You may of
may of course
of course want
course want the
user to open
to open multiple
open multiple files
So this command
this command in
command in the
open file allows
file allows for
allows for both
for both single
both single and
single and multiple
and multiple files
multiple files opening
us to do
first being a
being a variable
variable called file
called file count
This will count
will count the
count the number
number of files
of files that
have been selected
been selected by
selected by the
The second variable
second variable will
variable will contain
will contain either
contain either the
either the path
of a single
a single file
single file or
file or the
or the path
and the names
the names of
names of multiple
of multiple files
us to access
to access this
access this command
this command easily
we'll call this
this function open
function open file
open file and
file and we're
to pass to
pass to it
to it the
it the variable
the variable file
variable file count
file count and
count and the
and the output
be the files
the files variable
be the path
and create that
function with its
with its passed
its passed parameter
passed parameter the
parameter the file
the file count
count and returning
and returning in
returning in this
this case a
case a string
I've named the
named the parameter
the parameter as
parameter as o_lng_FileCount
to indicate for
indicate for my
for my documentation
my documentation purposes
documentation purposes that
purposes that this
that this variable
variable is an
is an output
an output variable
output variable from
variable from this
have a very
a very similar
very similar list
similar list of
list of variables
of variables as
variables as we
as we had
we had in
had in the
For example the
example the handle
for the parent
parent dialog, the
the title, a
variable to hold
hold the starting
the starting point
starting point, the
the folder which
folder which we
which we want
want to begin
to begin at
Plus we have
have added a
added a new
a new one
new one called
one called filter
us to filter
to filter in
filter in the
the dialog the
dialog the files
the files the
files the user
to be opening
be opening a
opening a file
a file we'll
file we'll probably
we'll probably know
probably know which
know which file
which file type
file type we're
type we're going
to be loading
it a text
a text file?
text file? Is
file? Is it
it a basic
a basic file
basic file with
file with a
with a BAS
a BAS extension
BAS extension or
extension or an
or an INC
an INC extension?
INC extension? Then
extension? Then we
we can default
can default to
default to having
to having the
having the starting
the starting file
starting file name
us to pre-select
to pre-select a
pre-select a name
a name which
name which will
which will be
be the default
the default so
default so if
user just clicks
just clicks OK
clicks OK it
OK it will
it will attempt
will attempt to
attempt to load
load that one
can also have
have a default
a default extension
is a default
default extension on
extension on the
the file name
file name for
name for example
for example txt
have the flags
the flags as
flags as we
we had before
had before which
before which are
are the style
have a files
a files variable
files variable which
variable which is
going to contain
contain the path
the path plus
path plus the
plus the name
the file or
or files that
files that the
And finally we
have a long
long variable which
of files the
So as before
as before we're
to populate each
populate each of
each of those
of those variables
The first ones
first ones are
ones are exactly
are exactly the
the same as
same as we
the last function
the title and
title and the
and the initial
the initial folder
populate the filter
the filter and
filter and it
has a particular
a particular way
particular way of
way of doing
of doing it
The filter variable
filter variable is
is a null
a null delimited
null delimited string
have a piece
of text which
text which can
which can be
can be anything
be anything you
anything you wish
case we're putting
putting the word
the word basic
Followed by a
by a chr$(0)
a chr$(0) which
chr$(0) which is
We're adding on
adding on to
on to that
to that string
that string the
string the *.bas
is the filter
the filter we
filter we wish
wish the user
actually see and
see and to
and to filter
to filter the
filter the data
data that appears
And we follow
we follow that
follow that with
with a final
a final chr$(0)
Additionally you can
you can also
can also use
also use the
use the chr$
the chr$ command
chr$ command slightly
command slightly differently
slightly differently and
differently and a
and a little
a little less
little less verbose
less verbose as
verbose as shown
as shown in
shown in the
in the two
the two commented
two commented out
commented out lines
The first one
first one duplicates
one duplicates the
duplicates the very
very first line
have the chr$
the chr$ followed
chr$ followed by
followed by basic
by basic 0
basic 0, the
the wildcard, *.bas
*.bas and then
and then a
then a 0
a 0 at
0 at the
Alternatively if you
if you wish
you wish the
user to pick
to pick from
pick from a
from a selection
a selection of
selection of different
of different types
different types of
types of files
of files, for
for example BAS
example BAS files
BAS files, INC
INC files and
files and BAK
use the final
the final option
final option which
option which will
which will display
will display to
the user all
user all three
all three extension
three extension types
set the start
start and the
and the default
the default extension
default extension variables
going to leave
to leave these
leave these as
these as empty
as empty length
empty length strings
finally we can
I'm setting the
setting the flags
the flags in
flags in this
this case to
case to say
say that the
exist and to
and to allow
user to multi-select
to multi-select files
file command to
command to prompt
to prompt the
the user for
user for the
for the files
the files to
files to open
As before this
before this command
this command takes
of parameters which
parameters which of
which of all
all the variables
the variables we
variables we have
we have populated
the title, the
the initial starting
initial starting folder
starting folder, the
wish to apply
to apply, the
the start, the
default extension, the
the flags attribute
flags attribute and
attribute and the
and the two
the two variables
two variables we're
variables we're outputting
we're outputting to
all the files
variable which will
which will contain
will contain the
names of the
of the files
the files and
files and the
second variable is
at the help
the help file
help file for
file for Power
for Power Basic
Basic Windows we
Windows we will
will see there
number of other
of other attributes
other attributes we
can actually use
Which of these
of these you
these you actually
you actually have
actually have in
have in your
your own application
own application will
application will depend
will depend what
depend what you
what you want
to see and
see and how
and how you
how you want
you want this
want this particular
this particular dialogue
particular dialogue to
dialogue to behave
As before if
before if the
selects no files
no files at
files at all
at all then
all then the
then the number
of files selected
files selected will
selected will be
will be 0
be 0 and
0 and the
and the str
the str files
str files variable
files variable will
But the final
the final task
final task within
return the number
files selected and
selected and the
and name like
name like so
have populated that
populated that we
our calling function
have populated two
populated two variables
two variables, the
files variable and
variable and the
and the file
file count variable
in time we
time we don't
we don't know
don't know how
know how many
how many files
many files the
And the way
the way Power
way Power Basic
Power Basic and
Basic and Windows
and Windows returns
Windows returns this
returns this list
this list of
list of files
of files is
files is slightly
is slightly different
slightly different for
different for a
for a single
single file as
as it is
it is for
is for multiple
for multiple files
For the single
the single file
single file it
it will return
return the actual
the actual path
actual path and
and name as
name as one
as one string
If multiple files
multiple files have
files have been
been selected the
selected the return
the return in
return in the
in the files
files variable is
variable is slightly
It returns a
returns a delimited
a delimited list
first element is
element is the
is the path
to the folder
has selected and
the next elements
next elements are
elements are going
be one for
one for each
the file names
file names selected
And all of
this is delimited
delimited by the
by the null
the null character
create a return
a return file
return file list
file list function
list function as
function as that's
as that's quite
that's quite useful
quite useful to
useful to keep
to keep our
keep our code
our code nice
code nice and
nice and tidy
a new file
new file called
file called return
called return file
Taking its two
two parameters first
parameters first of
all the file
count and secondly
and secondly the
secondly the files
new function as
function as we
will need this
need this function
this function for
function for the
for the save
the save file
save file dialog
file dialog as
dialog as well
function taking its
two parameters the
parameters the file
and the files
If the file
file count is
count is one
is one then
one then it
it is a
single file that
file that user
that user has
selected and we
can return quite
return quite simply
quite simply the
simply the files
files variable to
count variable contains
variable contains a
contains a value
a value greater
value greater than
greater than one
than one then
one then multiple
then multiple files
attempt to return
to return something
return something to
something to the
user that will
that will be
will be displayable
be displayable on
displayable on screen
know that there
that there are
number of elements
of elements in
elements in this
in this string
this string so
string so that
will be our
be our parameter
our parameter count
very first element
first element of
of our file
our file string
file string is
string is going
the folder containing
folder containing our
containing our files
And we'll want
want to return
to return to
return to the
user a file
a file list
populate the path
the path variable
using the parse
the parse command
taking its three
being the variable
the variable containing
variable containing the
containing the string
is the delimiter
the delimiter in
delimiter in this
this case chr$(0)
case chr$(0) which
is the element
So we're looking
first element in
element in the
in the string
going to build
to build up
build up our
up our file
our file list
we will initialize
will initialize our
initialize our file
file list as
list as an
as an empty
look at each
at each element
each element of
element of the
of the string
the string starting
string starting from
starting from the
from the second
the second element
will add to
the file list
file list variable
list variable for
variable for each
of the values
Taking what's in
what's in the
in the file
file list previously
Adding on the
on the path
the path which
path which we
we have stored
have stored in
stored in our
in our path
our path variable
And then using
parse command in
command in exactly
same way to
way to pull
to pull out
pull out the
out the element
the element that
element that we
that we are
we are interested
are interested in
adding on a
on a carriage
a carriage return
carriage return line
return line feed
line feed so
feed so it'll
so it'll look
it'll look quite
look quite tidy
quite tidy on
tidy on screen
screen to our
this function which
function which we
have just created
just created will
created will be
be our list
It will show
will show first
show first of
all the browsing
the browsing for
browsing for the
for the folder
will click OK
click OK on
OK on that
on that one
that one and
one and get
and get the
the value back
And we're now
we're now into
now into our
into our second
our second dialogue
Now as you
will see this
see this dialogue
this dialogue has
dialogue has the
has the folder
folder which we've
which we've specified
of files which
files which are
which are all
are all of
the basic variety
we pick both
pick both of
files and open
The return is
return is the
path to both
to both of
of these files
In a second
second one we
one we will
will pick a
pick a single
it will turn
will turn just
turn just the
just the path
name of that
of that single
that single file
we've achieved in
achieved in this
function is the
is the ability
ability to select
to select one
select one or
one or more
or more than
than one file
If we wanted
we wanted our
wanted our user
our user to
user to only
to only select
only select a
select a single
single file and
file and not
and not to
not to have
to have the
the option for
option for multiple
Then we would
we would change
would change the
change the attributes
the attributes of
attributes of our
of our command
our command when
command when we
when we call
we call the
Now we come
we come to
come to the
to the last
the last display
last display command
display command in
command in today's
Which is display
is display save
Again with the
with the open
the open file
open file with
file with the
with the save
save file you
file you will
will have in
own applications the
applications the need
the need for
need for saving
for saving to
saving to files
some cases the
cases the user
user will have
will have no
have no option
no option to
option to where
file is saved
But where you
where you wish
wish to give
to give the
give the user
the user the
user the option
the option where
option where to
where to save
This display save
save file command
file command is
very useful and
useful and time
and time saving
did before we'll
before we'll create
couple of local
being the file
the file to
file to save
I'm populating that
populating that with
that with the
with the name
the name testfile.txt
There may be
may be times
be times when
times when you
to pick the
Or other times
other times where
times where you
where you want
want to impose
to impose the
impose the file
Here today we're
today we're imposing
we're imposing the
imposing the file
file name of
name of testfile.txt
Next you want
store the returned
the returned file
returned file path
create a little
a little function
little function to
us to save
to save this
save this file
And having saved
having saved the
saved the file
file and stored
and stored the
stored the path
the path the
path the user
can then call
then call our
call our message
with the return
the return file
file list which
list which we
display the details
the details to
details to the
As with the
file command the
command the save
file command doesn't
command doesn't actually
doesn't actually save
actually save a
it does give
does give you
by which the
can actually select
actually select where
select where it's
where it's to
it's to be
to be saved
create our save
our save file
save file function
before we're passing
we're passing two
passing two parameters
passing the name
And an output
output variable which
be the file
file count returned
count returned by
returned by this
by this function
And the function
the function itself
function itself also
itself also returns
also returns a
returns a string
We've created a
created a number
local variables which
variables which will
will be starting
be starting to
starting to look
to look very
look very familiar
and y positions
y positions, the
initial folder, the
the filter for
filter for what
for what appears
what appears to
appears to the
user on the
or files selected
And finally the
finally the number
The parent is
parent is going
the desktop, the
y positions are
positions are going
to be 5050
populate the title
the title, we
set the initial
initial folder path
the filter to
filter to limit
to limit the
limit the number
see on the
set the default
default extension in
extension in this
case to be
to be txt
the user types
user types in
types in a
in a file
a file name
file name this
name this will
this will add
will add txt
add txt as
txt as the
as the extension
with the other
the other commands
other commands there
commands there are
of options for
options for our
for our flags
our flags attribute
As seen here
Although we're setting
setting the user
user to save
or files, the
user can have
can have a
have a multi-select
a multi-select option
setting the overwrite
the overwrite prompt
overwrite prompt to
prompt to allow
user in this
case to pick
to pick a
pick a file
a file that
file that may
that may already
may already exist
If you do
you do not
not want the
the user overwriting
user overwriting files
overwriting files that
files that already
that already exist
already exist, you
you merely have
have to remove
to remove this
remove this attribute
we're now calling
now calling display
calling display save
save file with
file with all
with all its
all its parameters
did before for
before for the
for the open
And this command
this command outputs
command outputs to
outputs to the
to the files
the file selected
file selected variables
did before we
before we can
can return these
return these to
these to the
So having got
having got this
got this in
this in place
in place, let's
is our browse
our browse for
browse for folder
Returning its path
have the file
the file for
file for opening
our final one
final one is
one is to
is to select
a file saving
file saving or
saving or location
or location and
location and file
we specified the
specified the default
the default name
default name it
name it is
it is already
is already pre-populated
can then change
then change the
change the folder
the folder and
folder and they
they have the
option of changing
of changing the
changing the file
if they hit
they hit save
hit save it
save it will
it will come
will come back
come back with
back with the
with the path
the path for
path for the
for the test
the test folder
test folder and
folder and the
the name that
name that they
that they have
they have selected
what we've covered
we've covered today
covered today are
today are three
are three of
three of the
of the standard
the standard display
standard display dialogues
Display browse to
browse to allow
a folder, display
save file and
file and display
and display load
display load file
Using these standard
these standard display
display dialogues gives
dialogues gives you
gives you two
you two advantages
of all it
all it presents
it presents to
presents to the
user a standard
a standard way
standard way of
way of performing
of performing these
performing these actions
Which should be
should be the
be the same
the same in
same in almost
in almost all
almost all applications
user will be
will be familiar
be familiar with
familiar with what's
with what's happening
Secondly it saves
it saves you
saves you time
you time creating
time creating the
creating the dialogues
the dialogues yourself
is always a
always a good
a good thing
are two more
two more display
more display dialogues
display dialogues but
dialogues but we'll
we'll cover those
cover those in
those in the
use of ListViews
of ListViews on
ListViews on Windows
has been some
been some time
some time since
time since we
since we did
we did any
did any videos
any videos on
videos on ListViews
on ListViews, so
so that's what
to start tackling
start tackling today
We're starting off
starting off with
off with a
with a completely
a completely pristine
completely pristine project
pristine project here
project here, and
create a dialogue
a dialogue onto
dialogue onto which
onto which we're
put a button
a button and
button and a
and a ListView
will go in
in and we
will create our
create our application
our application, and
we will save
will save that
save that to
that to disk
Having saved that
saved that to
to disk, we're
to go into
into the Forms
we will double-click
will double-click on
on the dialogue
dialogue and set
and set a
set a couple
couple of the
of the styles
We will select
will select Caption
select Caption and
Caption and SysMenu
and SysMenu and
SysMenu and the
and the Minimize
the Minimize box
Once we've okayed
we've okayed that
okayed that, you
you can always
can always test
always test your
test your dialogue
your dialogue by
dialogue by clicking
on the Test
the Test button
Test button inside
button inside the
inside the Forms
Forms Designer, so
can see what
what the dialogue
dialogue is going
has a close
a close X
close X at
X at the
the top right-hand
top right-hand corner
right-hand corner and
corner and a
and a minimize
a minimize gadget
on the Exit
the Exit Test
Exit Test Mode
Test Mode, we
to the dialogue
in the styles
the styles, we're
going to centre
to centre this
centre this dialogue
this dialogue on
dialogue on the
change the name
dialogue to ListViewDemo
So now we've
now we've got
we've got the
got the dialogue
the dialogue set
dialogue set up
set up, we're
put the button
the button on
button on it
We'll put this
put this down
this down at
corner and we
will make this
make this an
this an Exit
an Exit button
here to exit
exit the dialogue
add the ListView
the ListView control
We'll just drag
just drag this
drag this into
will see, it's
it's demonstrating a
demonstrating a ListView
a ListView with
ListView with three
with three columns
three columns and
columns and many
and many rows
have this in
in the dialogue
the dialogue, we'll
we'll click Save
click Save and
Save and we
will save to
save to the
file we created
we created earlier
Now we've finished
we've finished the
finished the designing
the designing of
designing of a
of a dialogue
a dialogue, we
we can exit
can exit the
exit the Form
the Form Designer
Form Designer and
Designer and go
to the main
the main IDE
we go down
go down to
of this, it
it will have
here the copy
the copy of
copy of the
the code before
code before we
before we import
we import it
we'll just take
just take this
take this out
this out completely
at the pbMain
the pbMain function
pbMain function, which
first function our
function our application
our application will
application will execute
will execute, it's
it's got two
got two lines
One to initialize
to initialize the
initialize the common
the common controls
common controls and
controls and one
one to show
show the dialogue
the dialogue on
dialogue on screen
at that function
that function, we
see here is
is our dialogue
PowerBasic uses dynamic
uses dynamic dialogue
dynamic dialogue tools
dialogue tools to
tools to make
it easier for
easier for you
for you to
you to create
to create Windows
create Windows and
Windows and dialogues
our dialogue new
dialogue new command
new command, which
which will create
create the dialogue
the dialogue itself
dialogue itself, and
have two further
two further commands
further commands, one
add a button
button and one
add a ListView
After that, we'll
we'll see there
see there is
there is another
is another function
function called SampleListView
we'll see the
see the dialogue
the dialogue appears
dialogue appears on
appears on screen
screen and not
and not only
not only has
only has the
has the dialogue
the dialogue appeared
dialogue appeared with
appeared with our
with our ListView
our ListView on
ListView on it
on it, it's
it's even populated
even populated some
populated some data
some data into
data into the
into the ListView
the ListView for
ListView for us
is a perfect
a perfect opportunity
perfect opportunity to
opportunity to see
see how ListViews
how ListViews are
ListViews are actually
are actually created
actually created and
created and populated
and populated, all
all without you
without you writing
you writing a
writing a single
of code so
code so far
if we close
we close this
close this down
this down, and
In here are
are the events
events that are
that are triggered
are triggered when
clicks on something
on something on
on the form
Before we look
we look further
look further at
further at the
put a little
in here, a
single line, to
us to exit
the application when
application when the
in the wmCommand
the wmCommand section
wmCommand section, you'll
that our forms
designer has put
has put the
in for us
for us, but
but all it's
all it's done
it's done is
done is to
put a message
message box in
box in to
in to be
be executed when
executed when the
We will remove
will remove that
remove that and
that and put
and put in
the dialogue end
dialogue end command
After dialogue end
dialogue end, we
we put in
the dialogue that
dialogue that we
wish to end
this case, CB.HNDL
CB.HNDL will close
will close the
close the currently
the currently displayed
currently displayed dialogue
where we set
set up our
up our dialogue
our dialogue, so
where the button
the button and
and the ListView
the ListView are
ListView are being
are being added
being added to
They have their
have their positions
their positions on
positions on screen
on screen specified
screen specified, and
name that appears
The sample ListView
sample ListView function
ListView function is
see how a
how a ListView
a ListView is
ListView is actually
is actually populated
actually populated, so
is the sample
ListView function, and
can see some
see some information
some information being
information being passed
being passed in
There appear to
appear to be
be three parameters
three parameters, one
one being a
being a dialogue
a dialogue handle
dialogue handle, one
one being the
being the control
the control handle
control handle, and
and one being
being the column
the column count
we look back
back at where
at where this
where this command
this command was
command was actually
was actually called
actually called from
called from, we'll
see there were
there were the
were the three
There's the dialogue
dialogue handle, there's
there's the handle
are two additional
two additional parameters
additional parameters, 3
3 and 30
number of columns
of columns they
columns they want
they want in
want in this
this particular control
particular control, and
and So let's
a look further
look further in
further in the
see what it's
what it's actually
The first command
first command we
command we can
can see is
see is this
is this ListView
this ListView getStyleX
If we hit
hit the F1
the F1 on
F1 on this
on this to
this to see
see what this
what this command
this command actually
command actually does
We'll see all
all the ListView
the ListView commands
ListView commands come
commands come up
come up in
up in one
in one section
at the ListView
the ListView getStyleX
ListView getStyleX, here
is our command
This statement retrieves
statement retrieves the
retrieves the current
the current setting
current setting of
setting of this
of this special
this special extended
special extended style
extended style and
style and assigns
and assigns it
assigns it to
to the long
the long integer
long integer variable
So let's move
let's move this
move this to
to the side
the side and
side and have
So we're giving
it the dialogue
we're populating this
populating this variable
this variable here
variable here with
here with the
with the current
the current style
using the ListView
the ListView setStyle
ListView setStyle command
setStyle command to
command to add
to the styles
the styles we've
styles we've already
we've already set
case it's set
it's set a
set a value
value of full
of full row
full row select
row select and
select and grid
and grid lines
once more and
more and see
see how that
how that affects
that affects the
affects the grid
can see when
see when the
user selects on
selects on the
on the ListView
the ListView the
ListView the entire
the entire row
entire row is
row is selected
we have grid
have grid lines
if we took
we took that
took that line
that line of
of code out
code out, just
just to see
see what difference
what difference it
difference it would
it would make
on a row
a row it's
row it's always
it's always selecting
always selecting the
selecting the first
the first column
The other columns
other columns and
columns and rows
and rows are
rows are not
are not doing
not doing anything
So that command
that command appears
command appears to
to be quite
be quite useful
let's move on
have a forNex
a forNex loop
forNex loop going
loop going from
going from 1
to the number
of columns that
columns that we
we have specified
have specified on
specified on the
on the incoming
the incoming parameters
incoming parameters, which
case is 3
is 3, so
so it's running
it's running for
running for a
for a forNex
forNex loop from
loop from 1
1 to 3
we're using another
using another command
another command called
command called ListViewInsertColumn
in the help
the help we
see the ListViewInsertColumn
the ListViewInsertColumn is
ListViewInsertColumn is a
is a command
a command to
command to insert
to insert a
insert a new
a new vertical
new vertical column
vertical column into
column into the
using this to
this to create
to create each
create each of
of the three
the three columns
It takes a
of parameters, obviously
obviously the dialog
control handle, the
the column that
column that we
to add, and
the string expression
This describes the
describes the text
text name that
name that you
that you wish
wish to place
place on the
on the column
the column header
we have column
have column width
column width and
width and a
and a format
column width specifies
width specifies the
specifies the width
of the column
the column in
column in other
in other dialog
other dialog units
dialog units or
units or pixels
or pixels, depending
how you created
you created the
created the dialog
value of format
of format describes
format describes the
describes the position
the position either
position either left
either left, right
right or centre
or centre justified
very first column
first column is
column is always
is always left
always left justified
see in here
in here, we're
we're placing the
placing the word
the word column
word column followed
column followed by
by the column
the column number
will see we're
see we're getting
we're getting column
getting column 1
column 1, column
column 2 and
2 and column
and column 3
after the columns
the columns are
columns are created
are created, we
we now get
now get to
to the section
code that puts
that puts sample
puts sample data
sample data into
into the columns
is a nested
are two For
two For Next
Next Loops running
Loops running here
one is handling
is handling rows
handling rows and
rows and the
the second one
second one is
is handling columns
the first row
first row, we're
using a ListViewInsertItem
a ListViewInsertItem command
The ListViewInsertItem command
ListViewInsertItem command is
is to add
new row to
row to the
to the ListView
first column in
column in a
new row, we
use this command
this command to
command to tell
to tell PowerBasic
tell PowerBasic that
PowerBasic that we're
that we're creating
we're creating a
creating a brand
a brand new
brand new row
the first item
first item on
item on that
on that row
So again, we
have the usual
the usual parameters
usual parameters, the
control handle and
and the third
the third parameter
third parameter is
is the item
the item number
is the row
the row number
You do have
do have the
option of using
of using images
using images within
images within ListView
within ListView controls
ListView controls, but
going to cover
to cover that
in a separate
a separate video
parameter is a
is a string
a string expression
is the text
text that you
into that cell
this case, we're
word column and
column and the
and the word
the word row
word row followed
row followed by
column number and
and the row
can see, we're
using the Using$
the Using$ command
Using$ command is
command is an
is an inbuilt
an inbuilt function
inbuilt function to
function to format
to format one
format one or
or more string
more string or
string or numeric
or numeric expressions
useful and quite
and quite powerful
quite powerful when
powerful when you're
when you're using
you're using ListViews
So inside this
inside this first
this first row
first row loop
row loop, we
have a column
a column loop
column loop and
loop and we're
using the ListViewSetText
the ListViewSetText command
This is operating
is operating from
operating from column
from column 1
column 1 to
1 to column
to column number
column number 3
we're using it
using it to
it to set
set the text
the text within
text within that
within that row
from the help
the help, the
that you have
you have passed
have passed in
passed in for
in for the
for the specified
the specified data
specified data item
data item is
item is replaced
is replaced by
replaced by the
by the new
the new text
new text in
text in your
in your string
your string expression
This command, when
when it's used
it's used in
in the zone
the zone, will
will not create
not create a
You must use
must use the
use the ListViewSetItem
the ListViewSetItem first
ListViewSetItem first to
first to create
create a row
So we're specifying
specifying the dialog
row and the
and the column
passing in this
The final section
final section in
section in this
in this is
is to auto-size
to auto-size the
auto-size the columns
we're going from
going from column
to the column
column number we've
number we've passed
we've passed in
passed in, which
is 3, as
we have three
have three columns
three columns in
columns in our
in our dialog
our dialog ListView
And the command
the command we're
command we're using
we're using is
using is this
is this ListViewFitHeader
this ListViewFitHeader command
are two ListViewFit
two ListViewFit commands
There's a ListViewFitContent
a ListViewFitContent and
ListViewFitContent and a
and a ListViewFitHeader
The ListViewFitContent command
ListViewFitContent command will
command will widen
will widen or
widen or narrow
or narrow a
narrow a column
a column based
column based on
within the cells
taking three parameters
column number you
number you wish
wish to adjust
This command is
command is ideal
ideal when the
when the data
in the columns
the columns is
columns is larger
is larger than
larger than the
than the column
the column headers
you have data
have data in
data in a
in a column
a column header
column header, which
which is wider
is wider than
wider than the
than the data
in the column
the column itself
column itself, you
you will lose
will lose part
lose part of
of the header
The ListViewFitHeader command
ListViewFitHeader command is
command is useful
is useful when
when you need
need to take
to take into
take into account
into account both
account both the
the text in
text in the
in the header
the header and
header and the
and the width
text in a
in a cell
So it sets
it sets the
sets the minimum
minimum size of
of the entire
the entire column
entire column based
text in both
if the text
in your header
your header is
header is wider
than the text
the data column
data column, then
then the minimum
the minimum width
minimum width of
the column will
column will be
will be set
be set to
set to accommodate
to accommodate that
has one special
one special condition
special condition where
condition where the
where the specified
the specified column
specified column is
column is the
is the last
the last column
last column, in
in our case
our case column
case column 3
column 3, then
then its width
its width is
width is set
set to fill
to fill the
fill the remaining
the remaining width
remaining width of
of the ListView
ListView control itself
will see, the
the third column
third column takes
column takes up
takes up the
up the remaining
the remaining space
remaining space in
space in the
in the control
there's nothing to
nothing to stop
to stop a
stop a user
a user moving
user moving to
top of a
of a column
a column and
column and adjusting
and adjusting it
adjusting it manually
This without you
And also the
also the scroll
the scroll bars
scroll bars work
bars work quite
work quite nicely
quite nicely to
nicely to scroll
to scroll up
scroll up and
up and down
and down, and
and right and
right and left
will see, you
you get quite
get quite a
quite a lot
a lot of
lot of functionality
of functionality very
functionality very easily
very easily from
easily from a
from a ListView
a ListView control
ListView control, as
as it does
it does allow
does allow you
you to display
to display a
display a basic
a basic grid
basic grid on
grid on the
we will enhance
will enhance this
enhance this ListView
this ListView further
ListView further, allowing
to select columns
select columns and
columns and pull
and pull information
pull information out
information out of
out of them
and also to
also to change
change the look
the ListView itself
ListView itself to
itself to make
make it more
it more user-friendly
have a single
a single dialog
single dialog which
dialog which displays
which displays a
displays a ListView
a ListView demonstration
This ListView has
ListView has three
has three columns
three columns, which
which we've used
we've used the
used the inbuilt
the inbuilt facilities
inbuilt facilities of
facilities of the
of the Forms
Forms Designer to
Designer to set
set up and
up and populate
today is we're
to add some
add some colour
some colour to
colour to this
to this grid
this grid, so
so that each
that each alternate
row is a
is a different
In addition, we're
user to sort
to sort the
sort the grid
the grid based
grid based on
based on a
on a specific
a specific column
specific column, either
either ascending or
select a cell
a cell within
cell within the
grid itself, and
display the data
the data that's
data that's held
that's held within
within that cell
that cell in
cell in the
in the status
do the colouring
the colouring of
colouring of the
of the rows
So to perform
perform this, we're
do a custom
a custom draw
custom draw inside
draw inside the
up a custom
custom draw pointer
draw pointer at
pointer at the
This is using
is using the
using the Windows
the Windows, NMLV
custom draw, user
to get this
get this to
this to work
to work, we
use a notify
a notify event
notify event, so
when the control
the control is
control is drawn
is drawn on
drawn on screen
on screen, this
this sends a
sends a notification
a notification to
notification to our
have the notify
the notify event
notify event in
event in place
in place, we
to determine which
determine which control
which control on
control on this
this dialog has
dialog has actually
actually triggered the
triggered the notification
up a select
is using one
of the properties
the properties of
properties of the
of the callback
the callback, the
the NMID, which
is a notification
a notification ID
tells us which
us which control
which control has
control has actually
using the case
the case statement
statement to say
to say we're
say we're interested
interested in the
in the ListView
that we know
know which control
triggered this notification
this notification, we
need to know
to know what
know what kind
kind of notification
of notification it
notification it is
use another select
another select case
determine which event
which event type
event type has
type has actually
has actually been
actually been triggered
using the NM
the NM custom
NM custom draw
is where we're
where we're going
to make use
of the pointer
the pointer we
pointer we defined
we defined at
defined at the
this function, by
by populating it
populating it using
it using the
using the CB.Lparam
Because there are
number of these
of these custom
these custom draw
custom draw events
draw events, we'll
of all, there's
there's the prepaint
the prepaint and
prepaint and the
and the item
the item prepaint
item prepaint events
For these, we're
going to return
return a constant
a constant called
constant called notify
called notify item
notify item draw
Other ones we're
ones we're really
we're really interested
really interested in
interested in are
in are the
are the item
item prepaint and
and the sub-item
the sub-item events
is where we
where we decide
we decide whether
decide whether the
whether the row
the row is
row is to
is to be
to be covered
be covered or
covered or not
a little common
little common function
common function called
function called colored
called colored row
colored row, which
to return true
return true or
true or false
True if we
want the row
the row colored
row colored and
colored and false
and false if
false if we
want to leave
to leave it
leave it as
it as is
will create that
create that function
that function in
function in a
So here are
here are our
are our two
our two statements
two statements, one
one for true
for true and
true and one
one for false
set the color
of the foreground
the foreground and
foreground and background
will be when
be when we
when we want
want to color
to color the
color the row
So using our
using our pointer
our pointer, we
we can specify
can specify the
specify the text
the text color
text color and
color and the
We're using two
using two inbuilt
two inbuilt values
inbuilt values, which
which are constants
are constants within
constants within Power
within Power Basic
Power Basic, one
for the color
the color black
color black and
black and one
one for pale
for pale green
pale green, which
of the RGB
the RGB colors
The parameter we're
parameter we're passing
we're passing to
passing to the
to the colored
the colored row
colored row is
row is basically
is basically the
basically the line
the line number
So if colored
if colored row
colored row returns
row returns true
returns true, we
set the background
background color to
color to pale
to pale green
pale green and
green and the
text on that
on that background
that background to
background to be
to be black
we'll keep the
keep the background
the background as
background as white
as white and
white and the
and the text
the text as
text as black
the event handling
event handling in
handling in place
create this colored
this colored row
colored row function
single parameter, which
using the modulus
the modulus function
modulus function to
function to work
whether the division
the division of
division of the
of the number
the number by
number by two
by two gives
two gives a
gives a remainder
a remainder of
remainder of zero
of zero or
zero or not
If it gives
it gives a
of zero, we're
we're then going
return true, which
which will color
will color the
we will leave
will leave the
leave the row
the row with
row with its
with its original
its original color
running this code
this code now
code now and
have our grid
our grid on
can see, alternate
alternate rows are
rows are different
are different colors
easier to identify
to identify information
identify information within
information within the
got the rows
the rows colored
rows colored, what
what can we
can we do
we do about
do about sorting
about sorting the
sorting the columns?
the columns? Let's
columns? Let's drop
Let's drop back
drop back into
to put another
put another case
another case statement
case statement in
statement in here
Where we've defined
we've defined an
defined an event
an event for
event for a
for a custom
custom draw, we're
going to define
to define an
define an event
event for clicking
for clicking on
fact that the
the user had
user had clicked
had clicked on
clicked on the
And in order
use of this
of this, we're
be a user-defined
a user-defined type
which is nmlistview
use the typeset
the typeset command
typeset command to
command to populate
populate that variable
Using another inbuilt
another inbuilt function
inbuilt function, cb
cb nh hdr
nh hdr $
hdr $, which
is the headers
And this takes
case we're returning
we're returning the
returning the size
size of LV
of LV data
to be an
be an ascending
ascending sort or
sort or a
or a descending
a descending sort
One easy way
easy way of
of doing this
this is toggling
is toggling between
toggling between ascending
between ascending and
ascending and descending
So when you
when you click
you click initially
click initially, it
it will sort
will sort one
sort one way
And when you
you click again
click again, it
will sort in
sort in the
in the opposite
the opposite direction
variable called sort_direction
use the XOR
the XOR command
XOR command, so
we will toggle
will toggle this
So each time
time the code
the code passes
code passes through
passes through here
through here, it
it will swap
will swap from
swap from true
from true to
true to false
we will declare
will declare this
declare this new
this new variable
top of our
will mark this
one as static
static variable within
variable within a
within a function
a function maintains
function maintains its
maintains its value
its value between
value between calls
between calls to
calls to the
So basically it
basically it remembers
it remembers the
remembers the value
having got that
got that in
to test the
of the sort_direction
the sort_direction variable
Is it ascending
it ascending or
ascending or is
is it descending?
it descending? The
descending? The inbuilt
The inbuilt list_view
inbuilt list_view command
list_view command has
command has a
has a sort
a sort option
sort option, and
List_view sort takes
sort takes a
the next being
next being the
control handle of
the last two
last two parameters
are the column
column number, and
and is it
to be ascending
be ascending or
ascending or descending?
or descending? We're
descending? We're using
using the LV_data
the LV_data sub-item
LV_data sub-item plus
sub-item plus 1
plus 1, as
as the LV_data
the LV_data counts
LV_data counts from
counts from 0
And List_view expects
List_view expects the
expects the first
first column to
column to be
to be column
be column number
column number 1
And for sorting
for sorting descending
sorting descending, it's
it's exactly the
same thing, only
only with a
a different parameter
different parameter on
parameter on the
on the end
So using this
using this single
this single line
of code, we
should now be
now be able
able to sort
running the code
the code now
have our data
the column heading
column heading of
heading of column
of column 3
column 3, we
see that it
that it sorts
it sorts quite
sorts quite happily
of course sorting
course sorting alphabetically
So apart from
apart from the
from the last
the last part
last part of
the string being
string being a
being a number
a number, it
it is sorting
is sorting in
sorting in alphabetic
in alphabetic order
So 1 appears
1 appears before
appears before 10
before 10 and
10 and 19
and 19 appears
19 appears before
appears before 2
click on each
on each column
each column and
column and it
it will reverse
will reverse the
reverse the sort
the sort order
sort order each
order each time
you click on
at the Power
Power Basic help
Basic help, you'll
there are other
are other options
other options other
options other than
other than just
than just ascend
just ascend or
ascend or descend
This last parameter
last parameter is
is a comma
a comma delimited
comma delimited option
delimited option list
So these can
these can be
can be cumulative
be ascending comma
ascending comma ucase
comma ucase, in
case it's alphanumeric
it's alphanumeric data
But the casing
the casing of
casing of the
of the character
the character is
character is not
is not significant
Or if one
if one of
one of your
of your columns
your columns is
columns is entirely
is entirely numeric
entirely numeric, you
can use ascend
use ascend comma
ascend comma numeric
And that way
that way it
way it will
will sort them
sort them in
them in numeric
in numeric order
final option is
option is a
is a date
a date sort
date sort format
sort format, where
be a number
types of date
of date format
gives you quite
you quite a
quite a bit
bit of flexibility
of flexibility using
flexibility using this
this single sort
single sort command
that we've done
we've done two
done two of
the tasks for
tasks for this
for this video
this video, the
final task will
be to pick
up the cell
the cell within
the grid that
grid that the
actually clicked upon
will see at
the moment in
moment in the
the grid, when
a row, the
reason for this
for this can
can be seen
be seen where
seen where we
set the list
the list view
list view up
at the function
function where the
where the list
list view is
view is defined
is defined and
defined and added
and added to
the dialogue, we
there are in
are in fact
in fact no
fact no options
no options defined
a look inside
look inside the
inside the sample
the sample list
sample list view
list view function
view function, we'll
we'll see we're
we're getting the
getting the style
the style into
style into this
into this style
this style variable
style variable, and
then we're adding
we're adding two
two additional options
additional options, a
a full row
to change these
change these options
these options slightly
options slightly to
to do clicking
do clicking on
clicking on one
on one cell
now added one
added one click
one click activate
click activate and
activate and single
and single row
the grid will
be displayed, but
but when you
when you select
you select on
select on the
first column, just
just the one
the one cell
one cell is
cell is selected
when we select
we select any
select any of
any of the
other columns, nothing
nothing is being
is being selected
So there's a
there's a little
little bit more
bit more work
more work we
work we need
hit the F2
the F2 button
F2 button, go
to our list
our list of
list of functions
of functions and
functions and go
here is we're
going to subclass
to subclass the
subclass the list
list view control
us to receive
to receive extra
receive extra events
extra events that
events that we
that we cannot
we cannot do
cannot do within
do within here
do that, I'm
declare a couple
variables to make
to make life
make life a
life a little
a little easier
little easier for
easier for us
to create one
create one variable
one variable called
variable called 'oldListViewProc'
be the address
the address of
address of the
the callback procedure
callback procedure that
procedure that the
that the list
list view has
view has been
has been set
been set up
set up with
us to toggle
to toggle between
toggle between the
between the old
the old and
old and the
and the new
the new callback
new callback procedures
I'm also going
create two globals
two globals, one
one for rows
for rows and
rows and one
one for columns
number of rows
of rows and
and columns in
grid is actually
is actually hard-coded
in here, there
are the columns
the columns and
columns and the
and the rows
rows in hard-coding
to change that
change that slightly
that slightly and
slightly and set
and set them
set them up
them up as
up as values
as values in
values in these
in these global
these global variables
to access these
access these values
these values later
values later on
callback function, in
in the initialised
the initialised dialog
initialised dialog event
dialog event, we're
up this subclassing
is using a
using a Windows
call called 'setWindowLongW'
this function we're
function we're storing
we're storing in
storing in the
in the 'longOldLVProc'
the 'longOldLVProc' variable
'longOldLVProc' variable we
variable we have
have just set
just set up
at the parameters
the parameters, it's
it's using another
using another Windows
another Windows API
API call, 'getDialogueItem'
This function turns
function turns these
turns these two
two values into
values into a
a single value
single value that
value that the
that the Windows
Windows API can
API can make
can make sense
make sense of
then using a
using a constant
a constant, 'gwlwndProc'
using a code
a code pointer
code pointer to
pointer to our
to our 'lvProc'
our 'lvProc' function
'lvProc' function, which
not yet created
be the callback
for the functionality
the functionality we
functionality we want
put into our
into our ListView
our ListView control
Since you may
you may use
may use this
use this functionality
this functionality in
functionality in your
your application, which
which could have
could have many
have many forms
many forms, it's
it's always good
always good practice
good practice to
practice to use
use a 'wmDestroy'
a 'wmDestroy' event
'wmDestroy' event to
event to restore
to restore the
restore the ListView
the ListView control's
ListView control's original
control's original callback
original callback procedure
callback procedure when
procedure when the
when the form
form is destroyed
Even if you
if you don't
you don't actually
don't actually have
actually have to
use this, as
as you have
a single dialogue
single dialogue application
dialogue application, it's
practice to have
to have it
have it in
it in your
in your code
This calls the
calls the same
the same function
same function again
function again, but
time we're passing
it the handle
of the old
the old ListView
old ListView callback
ListView callback function
So with that
with that in
the new 'lvProc'
new 'lvProc' function
This is taking
is taking the
taking the four
the four parameters
four parameters we're
parameters we're passing
we're passing from
passing from the
from the 'initializeDialogue'
the 'initializeDialogue' event
'initializeDialogue' event in
the main callback
main callback function
in here we're
up a number
track of things
of things like
things like the
like the column
the column and
column and row
and row number
row number, the
of rows per
rows per page
per page, and
and our ability
our ability for
ability for picking
for picking up
picking up mouse
up mouse clicks
mouse clicks on
And finally available
finally available to
available to hold
hold the data
the data we're
data we're going
going to pull
pull out of
of the cell
the cell that
cell that the
Much of the
the code I'm
code I'm about
I'm about to
about to put
put in here
in here has
here has been
has been borrowed
been borrowed from
borrowed from the
from the code
code within the
within the demo
the demo section
demo section of
section of PowerBasic
of PowerBasic for
PowerBasic for ListViews
So it saves
having to re-code
to re-code this
re-code this yourself
this yourself, as
it does the
does the job
the job quite
job quite nicely
up the coordinates
the coordinates, X
and Y, of
of the mouse
the mouse when
mouse when the
when the left
the left mouse
left mouse button
mouse button has
button has been
This is triggered
is triggered by
triggered by the
by the L
the L button
L button down
button down event
Y coordinates, we're
now looking to
looking to see
see if there's
if there's a
there's a ListView
a ListView item
ListView item and
item and sub-item
and sub-item at
sub-item at these
at these coordinates
these coordinates, using
using the sendMessageW
that returns something
returns something other
other than a
than a -1
a -1, then
then we are
we are indeed
are indeed clicking
indeed clicking on
on a ListView
Otherwise we can
can ignore the
ignore the mouse
the mouse click
new function we're
to make big
make big use
big use of
use of called
of called 'UpdateLVSelect'
this function multiple
function multiple times
multiple times within
times within this
within this particular
return the row
column that the
clicked upon, so
can actually pick
up the data
data within that
that cell using
cell using the
using the ListView.getText
the ListView.getText command
And this populates
populates the str
the str data
str data variable
clicked on, we're
our dialog and
dialog and we're
add a status
a status bar
status bar control
bar control to
control to the
So we'll come
back to this
this function in
but let's pop
let's pop into
pop into where
into where the
where the dialog
dialog is actually
is actually defined
actually defined and
defined and we'll
and we'll put
we'll put in
put in our
in our status
our status bar
is the status
We don't need
don't need to
to specify any
specify any coordinates
any coordinates for
coordinates for the
for the status
status bar, as
as in this
this case it
case it will
it will automatically
will automatically go
automatically go to
we've added a
a new constant
new constant, we'll
need to define
to define this
define this at
this at the
our new constant
the function we
function we were
we were building
were building up
use a Control-Set
a Control-Set Text
Control-Set Text to
Text to set
up the text
text in our
status bar to
bar to report
to report on
report on the
on the row
the data found
data found within
found within that
that we've handled
we've handled this
handled this specific
this specific message
specific message, we
can then return
then return a
return a zero
a zero and
zero and not
and not call
not call the
call the original
the original ListView
original ListView callback
This avoids events
avoids events being
events being triggered
being triggered twice
the other piece
other piece of
of code I'm
code I'm going
paste in here
here is straight
is straight from
straight from the
from the sample
the sample section
pick up where
up where the
user is using
using the keyboard
the keyboard rather
keyboard rather than
rather than the
than the mouse
the mouse to
mouse to move
using the key
the key down
key down event
looking for a
for a number
of different things
different things here
The up, down
and left buttons
left buttons on
buttons on the
on the keyboard
Each time calling
time calling this
calling this new
new function we
function we are
we are yet
are yet to
yet to create
to create, updatelvSelect
And also it
also it handles
it handles page
handles page up
page up, page
page down, home
home and end
we're passing back
passing back the
back the value
the value zero
value zero to
zero to say
say that we've
handled this message
this message and
message and we
and we do
not want to
want to call
to call the
So now with
now with all
with all that
all that code
that code in
the new updatelvSelect
new updatelvSelect function
So this particular
this particular subroutine
particular subroutine is
subroutine is taken
is taken straight
taken straight from
from the samples
the samples that
samples that ship
that ship with
ship with PowerBasic
with PowerBasic for
PowerBasic for ListView
for ListView controls
And again, what
what this is
this is actually
doing is looking
is looking to
see what row
what row number
row number the
number the user
The important parts
important parts in
parts in here
here is it's
is it's using
it's using the
the ListView unselect
ListView unselect to
unselect to ensure
ensure that anything
that anything previously
anything previously selected
previously selected is
selected is unselected
is unselected on
unselected on screen
And then it's
then it's using
the ListView select
ListView select command
select command to
command to highlight
to highlight on
highlight on screen
on screen the
screen the cell
And the very
the very last
very last piece
last piece of
of code within
code within this
within this subroutine
this subroutine is
subroutine is ListView
is ListView visible
that the cell
clicked on is
on is actually
is actually visible
actually visible on
visible on screen
particular case, this
this is probably
is probably unnecessary
probably unnecessary because
unnecessary because the
because the user
the user themselves
user themselves has
themselves has clicked
on the cell
the cell, therefore
therefore the user
user can already
can already see
already see it
the ListView visible
ListView visible command
visible command is
have a ListView
a ListView as
ListView as a
as a grid
a grid displayed
grid displayed to
on screen containing
screen containing many
containing many items
many items, if
is doing a
doing a search
a search on
search on that
on that grid
that grid to
grid to find
find a particular
a particular item
particular item, the
the item they
item they are
they are searching
are searching for
searching for may
for may not
may not be
not be visible
be visible on
visible on the
once you've located
you've located where
located where it
where it exists
it exists within
exists within the
the grid, you
use the ListView
ListView visible to
visible to automatically
to automatically scroll
automatically scroll the
scroll the data
grid to make
make the selection
the selection visible
selection visible to
So we'll leave
leave this line
we save our
save our application
now and try
and try running
try running it
running it once
can see our
see our grid
our grid is
is displayed on
displayed on screen
have our status
first column, first
first row, it
will display row
display row number
row number one
number one, column
column number one
number one, and
the data coming
data coming out
coming out of
out of that
of that is
that is column
is column one
column one, row
we try, for
for example, column
column number three
number three, it's
fact that we
we have indeed
have indeed clicked
indeed clicked on
clicked on column
on column number
number three and
three and it's
and it's pulling
it's pulling the
pulling the information
the information out
of that cell
that cell quite
cell quite happily
we pick a
pick a row
a row further
row further down
down the grid
the grid, it's
it's pulling out
pulling out row
out row ten
row ten and
ten and it's
it's going for
going for column
for column number
number three, which
which we've clicked
To prove this
prove this is
this is working
is working correctly
working correctly, we
will click on
on a column
column header so
header so that
so that the
that the row
row is now
is now sorted
that the entry
the entry down
entry down here
down here that
here that says
that says column
says column three
column three, row
row 20 is
20 is in
in fact now
fact now column
now column three
column three, but
but row 13
row 13, but
but it's still
it's still pulling
still pulling the
pulling the right
the right information
right information out
can now quite
now quite happily
quite happily select
happily select any
and columns and
and the value
the value appears
value appears down
appears down in
down in the
when we sort
we sort the
the column, we
see the value
value is obviously
is obviously still
obviously still highlighted
But if you
if you click
on another cell
another cell, the
the original cell
original cell is
cell is not
is not de-highlighted
is not unselected
the same problem
same problem would
problem would be
would be there
be there for
there for possibly
for possibly three
possibly three columns
So when we
when we resort
we resort the
resort the column
the column either
column either ascending
or descending, we
we should unselect
should unselect all
unselect all the
the values the
values the user
we will blank
will blank out
blank out the
out the entry
the entry in
entry in the
to pop back
pop back to
code and we're
little function whose
function whose job
job it will
be to perform
So in our
callback function, where
where we're doing
we're doing the
doing the sorting
the sorting, immediately
immediately the sort
the sort has
sort has completed
we will call
will call a
function called deselect
called deselect all
will take two
of the list
And finally, we
will use a
set text command
command to blank
to blank out
out the status
this function to
function to deselect
to deselect all
deselect all entries
all entries in
entries in the
in the list
the list box
list box is
to be very
be very straightforward
very straightforward and
straightforward and basically
and basically just
basically just a
just a for
next loop, whipping
whipping through each
rows and each
of the columns
the columns, using
the global we've
global we've set
we've set up
set up previously
up previously to
previously to define
to define how
define how many
how many rows
many rows and
and columns the
columns the list
list view actually
view actually has
we'll be using
using the list
list view unselect
view unselect command
unselect command to
command to unselect
to unselect any
unselect any entry
any entry that's
entry that's been
that's been selected
been selected in
selected in that
in that row
that row and
can quite happily
of the entries
the entries in
the grid and
grid and if
if we sort
we sort it
sort it, we
that the previous
the previous entry
previous entry is
entry is no
is no longer
no longer there
longer there and
there and the
status bar has
bar has been
has been blanked
been blanked out
achieved today are
are three things
of all, we've
we've added some
added some color
some color to
color to our
our list view
list view to
view to make
to make each
make each alternate
alternate row a
row a different
a different color
We've additionally allowed
additionally allowed the
sort the entire
the entire grid
entire grid based
based on one
the columns, either
And finally, we've
on a single
a single cell
single cell within
within the list
list view grid
have displayed both
displayed both the
both the row
column number that
number that the
clicked on, plus
plus the data
within that grid
next video in
video in this
this series, we'll
we'll be making
be making our
our code a
code a little
little more generic
more generic, to
to load, for
for example, a
CSV file directly
file directly into
directly into a
into a list
a list view
view control, acting
acting as a
as a simple
a simple grid
use of OpenGL
That's the Open
the Open Graphics
Open Graphics Library
Graphics Library within
Library within your
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
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
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
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
couple of small
of small additions
I'll put a
put a link
a link to
link to Gary's
to Gary's website
Gary's website in
website in the
This site contains
site contains lots
contains lots of
lots of useful
of useful examples
useful examples of
examples of PowerBasic
of PowerBasic code
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
the list, which
which we'll cover
we'll cover later
cover later in
later in the
What you can
can see at
is the use
of the points
We have six
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
have two lines
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
next is Line
is Line Strip
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
go to Triangles
to Triangles, we
we can demonstrate
can demonstrate the
use of gradient
of gradient fills
Each corner of
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
one is Triangle
is Triangle Fan
can see, this
takes the concept
the concept a
concept a little
a little further
Again with a
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
Next is Polygons
you to specify
specify the coordinates
coordinates of each
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
at the Wire
the Wire Sphere
us to specify
to specify quite
specify quite easily
quite easily on
easily on screen
screen a sphere
a sphere with
sphere with a
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
the north and
and south poles
south poles, which
which are triangle
are triangle fans
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
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
the final one
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
Power Basic code
Basic code that's
code that's been
that's been used
to generate these
generate these images
go and have
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
the zip file
zip file to
file to make
it easy for
easy for you
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
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
dialog is quite
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
doing a number
number of things
of things to
things to set
using two subroutines
two subroutines, first
of all to
all to get
get the render
the render context
render context and
context and secondly
and secondly, to
initialize the scene
We'll cover these
cover these in
these in a
setting up a
up a timer
a timer, triggering
triggering every 50
every 50 milliseconds
to change your
change your viewpoint
your viewpoint of
viewpoint of the
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
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
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
of parameters, either
either to have
to have rotation
have rotation or
rotation or no
or no rotation
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
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
both the colour
the colour bits
colour bits and
bits and for
for the depth
this command here
command here, 'control
'control handle', gets
gets the handle
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
using the get_dc
the get_dc call
get_dc call to
call to get
get the device
the device context
And another Windows
API call, setPixelFormat
to set our
set our pixel
our pixel format
pixel format up
format up and
up and ready
and ready to
ready to render
Once this is
is done, we're
we're into the
into the initialize
the initialize scene
where we start
we start using
start using some
using some of
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
the X, Y
Y and Z
and Z coordinates
And we're stepping
we're stepping through
stepping through each
of the possible
the possible selections
possible selections the
selections the user
user has made
So we're basically
we're basically checking
basically checking to
see which option
which option button
option button has
We're then clearing
then clearing the
clearing the buffers
the buffers and
buffers and we're
we're going through
through a series
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
to be routines
be routines you
routines you have
you have not
have not used
not used before
this is all
is all set
all set up
using a rotate
a rotate call
rotate call to
call to work
out the rotation
the rotation of
rotation of our
of our coordinates
our coordinates, both
Y and the
and the Z
the Z coordinates
And the main
the main work
main work begins
in the case
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
kind of object
of object we're
object we're dealing
we're dealing with
dealing with, in
this case points
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
the first corner
first corner is
corner is green
is green, the
second is red
is red and
red and the
one is blue
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
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
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
to the circle
the circle, this
one is slightly
using the triangle
triangle fan and
fan and we're
using a for
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
draw the circle
the circle on
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
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
setting the three
three parameters using
parameters using this
using this function
this function here
This single function
single function will
function will display
screen a solid
a solid sphere
solid sphere of
sphere of this
of this radius
this radius and
radius and the
and the number
number of subdivisions
of subdivisions you
subdivisions you specify
And in this
we're using 64
using 64 to
64 to give
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
function is setting
is setting up
up the lighting
the lighting and
lighting and the
and the material
the material parameters
once we pop
we pop this
pop this matrix
this matrix, at
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
With the teapot
the teapot, we're
we're using exactly
using exactly the
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
at this library
this library, you
in the function
the function list
function list there
list there are
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
see there's a
there's a large
of code to
code to define
define the coordinates
of the areas
the areas of
areas of the
of the teapot
And this saves
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
can use these
use these together
And looking at
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
this has been
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
look at going
at going beyond
going beyond the
beyond the basic
the basic list
basic list box
list box by
box by using
by using an
using an Owner
an Owner Drawn
Owner Drawn control
until now all
now all the
the work we've
work we've been
we've been doing
been doing with
doing with the
with the PowerBasic
Windows Compiler has
Compiler has been
has been using
been using the
using the Dynamic
the Dynamic Dialog
Dynamic Dialog Tools
to go a
go a little
little further and
further and to
and to stray
to stray into
stray into the
realm of Owner
of Owner Drawn
Owner Drawn controls
screen at the
moment is a
is a Results
a Results page
There may well
may well be
well be some
be some applications
some applications you
applications you create
you create for
create for your
for your users
your users which
users which are
which are used
are used to
used to perform
to perform a
perform a number
number of sequential
of sequential tasks
As these may
these may take
may take some
take some time
some time to
time to complete
to complete you
complete you may
you may want
to display for
display for the
user a Results
a Results screen
This Results screen
Results screen will
screen will give
will give a
give a list
list of all
tasks that have
have been undertaken
been undertaken and
undertaken and whether
and whether they
whether they have
they have succeeded
have succeeded or
succeeded or have
or have failed
is the application
the application we're
application we're going
to create today
on screen is
screen is a
is a list
a list box
list box which
box which is
used to list
to list the
list the result
the result of
result of each
The icon to
icon to display
to display whether
display whether the
whether the task
the task has
task has been
been successful or
successful or not
our application there
application there is
there is only
is only one
only one additional
one additional include
additional include file
That of the
of the Date
the Date functions
Date functions because
functions because we
because we want
display the date
the date in
date in our
in our list
our list box
We're including four
including four bitmaps
four bitmaps, a
a tick and
tick and a
and a cross
a cross and
cross and a
and a small
a small tick
small tick and
those in more
in more detail
more detail when
detail when we
to that point
that point in
In our PBMain
our PBMain function
PBMain function we're
function we're launching
we're launching a
launching a single
a fairly standard
fairly standard dialog
standard dialog allowing
dialog allowing the
to click a
click a button
the dialog in
dialog in the
in the frame
the frame is
frame is going
be a text
text box and
box and this
to hold a
hold a summary
a summary of
summary of the
of the outcome
the outcome of
outcome of our
of our tasks
list box itself
box itself is
itself is going
Each row detailing
row detailing the
detailing the outcome
outcome of the
of the running
the running of
running of a
of a task
In our event
event handler we're
handler we're going
We've covered these
covered these in
these in previous
in previous videos
This particular timer
particular timer is
timer is going
going to trigger
to trigger after
trigger after two
after two seconds
Initially we're going
going to hide
hide the outcome
And after the
after the timer
the timer triggers
timer triggers it
triggers it will
it will first
will first of
of all kill
all kill off
kill off the
off the timer
timer and then
and then we'll
then we'll call
we'll call a
call a function
function to display
to display our
display our results
function will update
update the list
list box details
we're setting to
setting to be
be a maximum
a maximum number
number of tasks
of tasks of
tasks of 10
to put 10
put 10 rows
10 rows into
rows into this
into this list
this list box
And once each
once each task
each task has
has been updated
been updated we're
updated we're going
going to update
update the overall
the overall outcome
overall outcome of
of our process
if we test
we test run
test run the
see it in
it in its
in its basic
its basic format
There's a dialog
a dialog appearing
dialog appearing on
screen and two
and two seconds
two seconds later
seconds later it's
later it's updated
it's updated to
updated to say
to say success
say success, all
all tasks have
tasks have been
have been completed
starting point of
point of today's
of today's video
to do first
do first is
first is we're
amend the properties
properties of our
of our list
list box to
box to make
make it owner
it owner drawn
is the control
control and list
and list box
list box command
box command highlighted
command highlighted in
highlighted in the
the dialog creation
add some properties
some properties to
properties to the
of this command
one here is
is the important
the important one
be the owner
the owner draw
owner draw setting
allow us full
us full control
full control over
control over what
over what appears
what appears within
appears within this
this particular list
particular list box
list box on
Normally when you're
you're using dynamic
using dynamic dialog
dialog tools you'll
tools you'll just
you'll just use
just use the
use the out
the out of
the box values
Allowing Windows and
Windows and Power
and Power Basic
Basic to do
do a great
deal of the
of the work
the work for
work for you
be using an
drawn control there's
control there's more
there's more we
more we have
have to consider
As we now
now have full
have full control
full control of
control of what
of what appears
what appears inside
appears inside that
inside that control
go into our
into our display
our display result
display result function
result function and
function and start
start to expand
to expand it
So having executed
having executed a
executed a list
list box reset
box reset command
reset command to
blank out any
out any data
any data in
list box we
box we now
to populate it
have a local
variable called str
called str text
We're populating that
the word task
word task and
task and the
and the task
the task number
Now we want
want to simulate
to simulate whether
simulate whether this
whether this particular
this particular task
particular task has
task has succeeded
has succeeded or
succeeded or failed
or failed or
failed or partially
or partially failed
function called result
this will return
will return a
return a number
a number either
number either a
either a zero
a zero, a
a one or
one or a
or a two
using the randomise
Returning a number
number between zero
between zero and
zero and two
Zero for failure
for failure, one
one for success
for success and
success and two
and two for
two for a
for a non-critical
a non-critical failure
value of what
of what comes
what comes back
comes back from
back from this
from this result
this result function
it returns zero
returns zero then
zero then we
then we consider
we consider that
consider that as
as a task
a task failure
set our bitmap
our bitmap ID
bitmap ID to
ID to be
be the small
the small cross
The upgrade outcome
upgrade outcome to
outcome to be
to be failure
And the individual
the individual task
individual task result
task result also
result also to
also to be
And we'll do
for the result
the result which
result which is
is a success
And also for
also for where
where the task
has been only
been only a
only a partial
a partial failure
that we've actually
actually set those
set those values
those values we
values we now
to update our
update our task
our task box
new routine to
routine to add
to add our
add our bitmap
our bitmap and
bitmap and our
and our text
our text to
text to the
We're passing a
passing a number
of parameters to
this new sub-routine
list box handle
box handle, the
the text, adding
on the task
the task result
task result and
result and our
and our bitmap
The one we've
one we've designated
we've designated up
designated up here
of our sub-routine
our sub-routine taking
sub-routine taking in
in the five
the five parameters
have two options
two options here
If we've populated
we've populated the
populated the bmp
the bmp file
bmp file variable
file variable with
variable with the
to load, we
can then load
then load the
load the image
the image from
image from that
from that file
case we're passing
we're passing that
passing that in
that in as
in as an
an empty ln
empty ln string
Therefore we're going
load the bitmap
bitmap by the
by the handle
the handle that
handle that we've
that we've passed
Rather than loading
than loading it
loading it from
it from a
from a file
from this Windows
this Windows API
API call which
call which loads
which loads the
loads the image
the image is
image is to
is to this
to this handle
this handle here
use of that
of that handle
to send this
send this string
this string using
string using string
using string pointer
string pointer to
pointer to add
to add this
add this to
use the bitmap
the bitmap handle
bitmap handle which
handle which we
have just obtained
just obtained using
obtained using load
using load image
load image to
image to send
to send also
send also to
also to this
list box and
box and to
and to set
set the item
the item data
This stores the
stores the bitmap
bitmap handle for
handle for later
for later processing
later processing in
processing in our
in our owner
our owner drawn
owner drawn event
set up, we
the event handle
event handle of
of our dialog
Since we have
we have designated
have designated the
designated the list
list box as
box as being
as being a
being a control
a control which
control which we're
we're using owner
using owner draw
owner draw on
draw on, we'll
have to specify
to specify a
specify a custom
a custom event
custom event to
handle the drawing
drawing of this
this particular item
create a wmDrawItemEvent
testing the callback
the callback functions
callback functions w
functions w param
this is equal
list box, then
we have got
have got the
got the right
the right control
you to do
to do draw
do draw item
draw item on
item on a
on a number
of controls within
controls within your
within your dialog
your dialog should
dialog should you
should you need
Now we'll need
local variables in
variables in this
in this event
this event handler
cover these as
these as we
as we come
come to them
The first variable
first variable we're
variable we're going
to populate is
populate is this
is a pointer
a pointer to
pointer to a
to a draw
a draw item
draw item structure
item structure user
structure user defined
This user defined
defined type is
type is going
hold the information
the information for
information for our
for our list
this is one
of the uses
the uses you
uses you will
you will find
will find for
find for pointers
for pointers in
pointers in order
order to structure
to structure things
structure things so
things so you
you can communicate
can communicate with
communicate with the
with the Windows
we can make
make the LP
the LP this
LP this variable
this variable equal
variable equal to
to the callbacks
the callbacks L
callbacks L parameter
test the item
the item ID
item ID property
If it has
it has this
has this value
this value here
value here, then
then the list
box is empty
is empty and
empty and we
we need do
need do nothing
Otherwise we know
we know there's
know there's at
there's at least
at least one
least one item
one item in
item in the
box which we'll
draw on the
the box itself
next variable we're
this one, the
the RC variable
up as another
as another user
another user defined
defined type, which
is the rectangle
the rectangle user
rectangle user defined
And we're making
we're making equal
making equal to
to the pointer
the pointer, which
which is this
one here and
here and the
and the RC
the RC item
RC item property
see what action
what action has
action has actually
been triggered here
using a select
case statement here
statement here on
here on the
on the item
the item action
item action property
looking for one
for one where
one where it's
where it's a
it's a draw
a draw the
draw the entire
the entire list
entire list box
list box or
box or where
or where the
list box has
box has been
if the item
the item is
item is not
not selected, we
we must be
must be drawing
be drawing the
drawing the list
now we'll start
we'll start to
start to use
use a number
number of Windows
of Windows API
API calls to
calls to actually
to actually fill
actually fill in
fill in details
in details on
details on the
on the part
the part of
first thing we
thing we will
will do is
is to clear
clear the background
the background using
background using the
using the full
the full rectangle
full rectangle API
rectangle API call
And here again
here again is
again is our
is our pointer
the handle, the
the RC user
RC user defined
API call gets
call gets sys
gets sys color
sys color brush
color brush and
brush and it
has a parameter
a parameter of
parameter of the
of the color
of the window
This way if
way if the
user has radically
has radically changed
radically changed the
changed the color
the color scheme
color scheme you
scheme you can
you can pick
pick up that
up that quite
that quite happily
quite happily using
happily using this
using this command
will use another
use another API
another API call
API call to
call to set
background color of
have a point
a point of
point of drawing
of drawing this
drawing this list
list box, let's
Well so far
so far nothing's
far nothing's appearing
nothing's appearing on
So we've obviously
we've obviously got
obviously got more
got more code
more code to
code to put
put into place
However our failure
our failure and
failure and the
and the subsequent
the subsequent underlying
subsequent underlying non-critical
underlying non-critical task
non-critical task reporting
task reporting is
reporting is working
is working quite
So let's push
with the rest
So as with
the code above
code above we're
above we're going
the same commands
same commands again
full rectangle and
rectangle and the
the set background
set background and
background and set
and set text
set text colors
also using the
using the RC
defined type to
type to define
define the left
the left and
left and right
and right margins
So how do
how do we
do we get
the data to
data to appear
appear on our
on our list
our list box?
list box? First
box? First thing
First thing we'll
thing we'll need
get the text
the text which
text which has
has been added
can use a
send command for
command for this
We're sending to
sending to the
the dialog, to
to the specific
the specific list
specific list box
box and we're
it a get
a get text
passing it again
it again by
again by this
by this pointer
this pointer, the
item ID, the
the entry on
entry on the
we're giving a
giving a var
a var pointer
var pointer for
pointer for the
for the text
text which we
which we set
is a 300
a 300 character
300 character ASCII
character ASCII Z
ASCII Z type
going to adjust
to adjust the
adjust the text
the text position
text position ever
position ever so
ever so slightly
so slightly by
slightly by incrementing
by incrementing the
incrementing the nTop
the nTop property
nTop property of
property of the
of the RC
defined type, the
setting the eLeft
the eLeft to
eLeft to be
be our text
our text margin
text margin, which
is a constant
a constant we
constant we set
use the draw
the draw text
draw text command
Yet another Windows
Windows API to
API to allow
us to draw
to draw text
draw text to
text to a
to a specific
a specific control
the handle using
handle using our
it the string
the string we
string we just
we just got
just got a
got a moment
We're telling it
telling it how
it how long
how long that
long that string
that string is
it the user
type which is
And we're specifying
we're specifying a
specifying a single
single line and
line and we're
and we're marking
we're marking it
marking it as
it as vertically
as vertically centered
now have enough
have enough code
enough code within
code within our
within our owner
our owner drawing
owner drawing section
drawing section to
section to actually
to actually draw
actually draw the
draw the text
see what it
what it looks
it looks like
is a dialogue
a dialogue and
dialogue and two
seconds later we
later we get
get the 10
the 10 tasks
10 tasks appearing
So we've done
we've done the
done the first
first part, we've
got the text
But now we
put the graphics
the graphics, the
the bitmaps themselves
use another control
another control send
and we're requesting
we're requesting the
requesting the item
item data this
data this time
Using the pointer
the pointer to
to our item
our item ID
item ID and
ID and populating
and populating this
variable here, the
the ITD variable
be our handle
And assuming it
assuming it returns
it returns something
other than zero
than zero, we
can now attempt
now attempt to
attempt to draw
draw the current
the current item's
current item's bitmap
This of course
of course uses
course uses another
uses another Windows
API call, the
the draw state
draw state call
again we're passing
we're passing yet
passing yet more
yet more parameters
more parameters to
parameters to it
Again our pointer
our pointer with
pointer with the
with the handle
to the bitmap
the bitmap which
bitmap which we
which we recovered
we recovered a
recovered a moment
And we're telling
telling it our
it our margins
our margins and
margins and we're
and we're on
screen to actually
to actually position
actually position it
And with this
with this complete
this complete we
complete we can
can now exit
now exit the
exit the function
are our bitmaps
However vertically the
vertically the lines
the lines for
lines for each
the entries appear
entries appear a
appear a little
a little compressed
little compressed, as
as it's cutting
it's cutting off
cutting off a
off a little
bit of our
of our bitmap
set the vertical
the vertical height
vertical height of
height of each
box to be
to be larger
back to where
dialog was created
was created, enter
enter our show
our show dialog
show dialog results
dialog results function
going to send
to send to
send to the
use the set
the set item
set item height
to set that
that to around
to around 22
around 22 pixels
22 pixels, which
should be big
be big enough
big enough for
enough for our
for our bitmaps
can see we've
see we've now
we've now got
now got more
got more space
more space and
space and it
and it looks
it looks more
looks more presentable
more presentable on
presentable on screen
So is there
is there anything
there anything more
anything more we
actually do to
do to this
box to enhance
to enhance its
enhance its look?
its look? If
look? If we
event handler and
handler and in
and in a
in a section
of code which
code which handles
which handles drawing
handles drawing the
drawing the entire
list box, we're
do a bit
bit of conditional
of conditional coding
conditional coding in
coding in here
it to highlight
to highlight alternate
highlight alternate rows
see which row
which row all
row all the
all the list
list box are
box are on
are on by
on by using
by using our
our pointer again
returning the item
item number and
number and we're
and we're doing
doing a mod
a mod 2
us the remainder
remainder of that
of that value
that value divided
value divided by
divided by 2
So the result
result of that
of that calculation
that calculation is
calculation is either
is either going
0 or non-zero
us to colour
to colour alternate
colour alternate lines
So just as
use the full
full rectangle commands
rectangle commands again
time we're changing
we're changing our
changing our colour
our colour brush
colour brush to
brush to be
be the colour
the 3D face
this case the
case the default
the default value
default value would
value would be
would be grey
code now, the
will appear and
appear and when
when the results
the results come
results come in
come in, each
each alternate line
alternate line is
line is grey
is grey in
grey in colour
makes it easier
it easier in
easier in the
in the eye
the eye to
eye to see
of each line
we have done
have done today
we have taken
have taken a
taken a results
results page using
page using a
using a standard
a standard list
standard list box
We've set that
set that list
that list box
to be owner
be owner drawn
owner drawn, which
which gives us
gives us complete
us complete control
complete control about
control about what
about what happens
what happens within
happens within the
We've used that
used that to
that to display
display a bitmap
a bitmap as
bitmap as the
the first entry
first entry on
entry on each
on each line
The bitmap either
bitmap either being
either being a
being a tick
a tick or
tick or a
or a cross
a cross depending
cross depending on
depending on success
on success or
success or failure
We've also increased
also increased the
increased the height
each line to
line to make
to make them
make them larger
them larger vertically
larger vertically so
vertically so we
can actually have
actually have the
have the full
the full bitmap
full bitmap displayed
to put larger
put larger bitmaps
larger bitmaps in
bitmaps in, you
you can increase
can increase this
increase this height
this height even
height even further
have additionally coloured
additionally coloured each
coloured each alternate
alternate line a
line a grey
a grey background
grey background colour
see what happens
what happens if
happens if we
if we actually
we actually get
actually get a
get a success
a success, let's
let's just tweak
just tweak our
tweak our results
our results to
results to only
to only show
only show successes
will mark it
mark it between
it between 1
and 2 if
2 if we
run that now
And there's what
there's what you
what you will
will see as
see as an
as an overall
an overall success
You will still
will still get
still get failures
get failures but
failures but those
but those will
those will be
will be acceptable
be acceptable failures
a short introduction
short introduction to
introduction to owner
to owner drawn
your code, but
use of status
of status bars
status bars on
bars on Windows
looking at status
at status bars
are currently within
currently within the
within the PowerBasic
And the dialogue
dialogue we have
on screen has
screen has now
has now got
now got a
got a status
of the form
achieve this by
this by double-clicking
by double-clicking on
double-clicking on the
Bar Control icon
Control icon in
icon in the
in the Toolkit
This adds our
adds our status
bar to the
attempt to add
add a second
a second status
second status bar
status bar, PowerBasic
PowerBasic Forms will
Forms will tell
tell us that
us that you
that you may
you may only
may only have
have one status
one status bar
bar control per
control per dialogue
While this is
this is true
is true when
true when using
when using PB
using PB Forms
PB Forms, you
actually have a
have a second
at that shortly
that shortly in
shortly in the
So having added
having added our
added our status
status bar and
bar and clicked
and clicked Save
clicked Save, we
we'll see our
see our dialogue
our dialogue appears
the screen with
screen with the
with the status
Event Handler, and
code in to
in to populate
to populate our
populate our status
put that code
in the Initialise
the Initialise Dialogue
Initialise Dialogue event
put a piece
of text straight
text straight into
into the status
status bar, we
use the Control-Set
the Control-Set Text
Control-Set Text command
command to do
that the words
the words 'Ready
words 'Ready for
'Ready for work'
for work' appear
work' appear at
the screen within
screen within the
within the status
this works nicely
works nicely when
nicely when you
you want just
want just a
just a straightforward
of text in
status bar, there
are other things
things we can
do with the
And to do
to do those
do those, we
use the Status
Status Bar Set
Bar Set Text
set these parameters
these parameters up
parameters up as
up as local
as local variables
to change them
change them quite
them quite easily
have a variable
hold the text
the text that's
text that's going
We have an
have an item
an item, which
case is going
to be item
be item number
item number 1
number 1, and
have a style
a style which
style which we're
which we're setting
setting to 0
to 0 at
first two are
two are the
are the obvious
the obvious ones
obvious ones, the
the control we
wish to set
The next three
next three parameters
three parameters are
item number, the
the style and
style and the
and the actual
the actual text
see it does
it does exactly
does exactly what
exactly what the
what the Control-Set
Text command did
It puts the
puts the words
for work' in
work' in the
status bar can
bar can do
can do more
You can divide
can divide the
divide the status
status bar into
bar into a
into a number
number of sections
of sections, up
to a maximum
a maximum of
maximum of 32
can then define
then define these
define these sections
these sections by
sections by numbers
These quantities are
quantities are either
are either pixels
either pixels or
pixels or dialogue
or dialogue units
dialogue units, depending
on how your
how your dialogue
your dialogue has
has been specified
with this piece
of code, Status
Bar Set Parts
Set Parts, we're
we're defining that
defining that this
that this status
this status bar
status bar is
bar is going
to have four
have four sections
The first section
first section is
section is going
to be 80
be 80 dialogue
80 dialogue units
dialogue units wide
units wide, the
the next section
next section is
section is I've
is I've marked
I've marked as
marked as 9999
This is wider
than the dialogue
the dialogue units
dialogue units for
units for the
for the whole
the whole form
How this would
this would be
would be interpreted
be interpreted by
interpreted by Power
by Power Basic
Power Basic is
Basic is that
that the fourth
the fourth section
fourth section would
section would go
would go all
go all the
the way to
way to the
the right, right
right to the
of the status
text within our
within our status
we will comment
will comment out
out the original
the original piece
original piece of
will put the
the new command
new command in
command in, which
which will refer
will refer to
refer to our
our item number
it will put
put the word
the word 'first'
word 'first' in
'first' in the
see the word
word 'first' appears
'first' appears in
appears in the
first of four
of four sections
So to save
a little typing
little typing here
typing here, I'm
to put each
put each of
of these sections
these sections in
sections in with
in with the
amount of typing
we will now
will now populate
now populate the
populate the four
the four sections
four sections of
sections of our
of our status
status bar with
bar with the
with the words
the words 'first'
words 'first', 'second'
'third' and 'last'
see that these
that these pieces
these pieces of
pieces of text
of text appear
text appear in
appear in each
of the sections
the sections designated
So having the
having the ability
ability to set
to set sections
set sections on
sections on the
status bar means
bar means they
means they can
they can hold
can hold different
hold different types
types of information
for example, you
wish to track
to track the
track the user's
the user's mouse
user's mouse on
mouse on the
the screen, you
you could put
could put the
put the X
coordinates in two
in two separate
two separate sections
separate sections in
sections in your
in your status
your status bar
Or if you
if you want
want to impart
to impart some
impart some information
some information to
the user, for
for example, to
that the caps
the caps lock
caps lock is
lock is on
is on, you
you could use
could use this
use this quite
So what else
what else can
else can we
we do with
do with status
with status bars?
status bars? As
bars? As well
well as dividing
as dividing the
dividing the status
status bar up
bar up into
up into sections
into sections, what
do next is
next is to
is to use
use the Wingdings
the Wingdings font
Wingdings font to
font to put
put a symbol
a symbol in
symbol in as
in as text
new font, but
but first we
status bar commands
bar commands we've
commands we've already
we've already used
will create in
create in a
a moment, called
up our Wingdings
our Wingdings font
Wingdings font at
font at 12
at 12 point
12 point and
point and in
and in bold
get this next
this next section
next section of
code to work
to work, we're
create some local
local variables at
of our callback
static variable for
variable for the
the font handle
font handle, and
then a number
of other variables
other variables which
variables which we'll
we'll cover as
cover as we
as we get
get to them
So let's first
let's first create
first create the
create the 'makefont-ex'
the 'makefont-ex' function
of course takes
course takes the
takes the parameters
the parameters we've
parameters we've seen
we've seen before
The font as
font as a
a string, the
the point size
point size, is
is it bold
it bold, is
is it italic
it italic, is
is it underlined
it underlined, or
is it striked
it striked through?
striked through? And
through? And we're
be calling a
calling a number
of Windows APIs
Windows APIs within
APIs within this
be creating another
creating another function
function called 'inyoom-charset'
function is quite
is quite generic
quite generic and
generic and can
and can be
can be used
be used for
used for a
for a range
a range of
range of fonts
And finally in
finally in this
this function, we're
call the Windows
Windows API function
API function 'createfont'
function 'createfont', passing
it the details
the details in
details in order
order to create
to create our
create our font
our font reference
And passing the
passing the value
value back to
We have also
have also referenced
also referenced another
referenced another function
another function which
function which we'll
to create now
create now, the
This gets us
gets us back
us back the
back the type
the type of
type of the
the character set
Is it an
it an ANSI
an ANSI font
ANSI font, or
it a symbol
a symbol font?
symbol font? And
font? And in
using a symbol
a symbol font
we've created these
created these two
these two functions
two functions, we
Because we're now
to have an
have an owner-drawn
an owner-drawn area
owner-drawn area of
area of this
of this status
But first, as
as we've created
created a font
a font within
font within this
this application, we
want to destroy
to destroy it
destroy it once
it once the
once the form
the form has
form has actually
actually been completed
create a 'destroy'
a 'destroy' event
'destroy' event, which
will be triggered
be triggered when
form is closed
is closed down
the case, it
it will call
will call the
API call 'delete'
call 'delete' object
'delete' object, passing
it the font
to the owner-drawn
the owner-drawn parts
owner-drawn parts of
parts of the
will be another
be another event
another event called
event called 'drawItem'
particular application, there
only one object
one object on
on screen which
screen which we're
be using owner-draw
using owner-draw for
it's good practice
practice to actually
to actually test
actually test to
that's the one
one we're doing
You may at
may at some
at some later
some later point
later point add
point add additional
add additional owner-drawn
additional owner-drawn controls
owner-drawn controls to
controls to our
So it's important
it's important to
important to test
sure we're doing
doing the right
the right one
with a simple
a simple if
simple if statement
if statement on
statement on the
on the 'w'
the 'w' frame
'w' frame of
Does that match
that match the
match the control
do something with?
something with? In
with? In this
this case, the
have two status
two status bars
bars on the
on the control
the control, we
populate the wrong
the wrong one
For the Windows
API calls, the
status bar partCount
bar partCount is
partCount is 0
is 0 based
first item, the
first section of
bar is partCount
is partCount number
partCount number 0
can pick that
pick that up
that up from
from the 'L
the 'L Param'
'L Param' option
And since the
since the section
status bar we're
bar we're interested
interested in is
in is effectively
is effectively the
effectively the second
the second section
second section, this
this is part
is part number
part number 1
need to select
select the object
the object defining
object defining our
defining our font
our font and
font and the
and the colour
the colour and
colour and drawing
and drawing the
drawing the text
the text onto
text onto the
onto the status
have to define
to define a
define a constant
a constant here
for the character
the character within
within the Wingdings
Wingdings font that
font that we
So we'll define
we'll define that
define that at
we're using character
using character number
character number 60
number 60 to
60 to define
define the disk
the disk image
disk image in
image in the
in the Wingdings
So having completed
having completed this
completed this section
this section for
section for owner
for owner drawing
owner drawing the
drawing the part
have to actually
the event which
event which has
create another section
another section in
section in our
in our code
our code called
code called 'wmNotify'
be the notify
event in our
And again we
again we need
what it is
it is that's
is that's actually
that's actually been
actually been clicked
can use this
use this pointer
this pointer 'nmm'
pointer 'nmm' with
'nmm' with our
with our header
our header to
header to use
use the id.Form
the id.Form to
id.Form to see
if it matches
it matches our
matches our status
status bar constant
we're testing id.Form
testing id.Form for
id.Form for the
bar constant and
constant and we're
and we're testing
if the 'nmClick'
the 'nmClick' event
'nmClick' event has
event has been
So we know
know the status
clicked on but
on but which
but which part
which part of
use the item
the item spec
item spec option
spec option on
option on this
this to determine
determine which one
which one it's
one it's been
it's been done
This again is
again is zero
is zero based
zero based and
based and we're
and we're looking
looking for number
for number one
number one, which
is the second
using the variable
the variable 'warm'
variable 'warm' disk
'warm' disk as
disk as a
as a toggle
allows us in
us in the
owner draw section
draw section to
to actually change
actually change the
change the colour
the colour from
colour from red
from red to
red to grey
to grey and
grey and back
and back again
our code we'll
code we'll need
put the status
status bar 'setParts'
bar 'setParts' command
'setParts' command back
command back in
And to define
define the second
second section of
status bar as
bar as being
as being owner
being owner drawn
is our 'setParts'
our 'setParts' command
using three sections
three sections of
sections of the
One 80 dialogue
units wide, one
one 16 which
16 which is
which is where
where our icon
our icon is
icon is going
the third section
third section will
section will take
will take up
take up the
up the rest
going to print
to print the
print the words
the words 'click
words 'click disk'
'click disk' in
disk' in the
in the second
second section we're
section we're going
to make that
make that owner
that owner drawn
using this as
this as the
as the character
the character we're
character we're going
to be printing
be printing in
printing in from
in from the
from the Wingdings
see our status
bar has now
now been updated
been updated as
updated as the
as the words
have the icon
the icon on
icon on the
status bar which
bar which is
is a Floppy
a Floppy disk
on that we'll
that we'll see
that the icon
the icon turns
icon turns red
So as identified
as identified it's
identified it's been
it's been clicked
clicked on, if
on it once
once more it
more it will
will turn back
turn back to
back to grey
to grey again
can we make
we make use
of this click
this click event
click event to
event to actually
to actually perform
actually perform some
perform some function?
some function? Let's
function? Let's go
to the event
event handler again
we can put
can put a
put a test
a test to
test to trigger
to trigger when
trigger when the
when the icon
the icon is
icon is clicked
For example we
example we can
we can send
can send a
send a message
a message to
message to the
using a message
we can sleep
can sleep for
sleep for two
for two seconds
two seconds to
seconds to simulate
to simulate some
simulate some kind
kind of saving
of saving event
saving event happening
of the disk
the disk icon
disk icon back
icon back to
the control so
control so the
actually see what's
see what's happened
that code, there
is our status
on it it
it it goes
it goes red
goes red and
red and our
and our message
message box pops
box pops up
click OK it
OK it should
it should wait
should wait two
wait two seconds
two seconds and
seconds and then
and then change
of the icon
the icon back
Which it does
So we mentioned
we mentioned earlier
mentioned earlier that
earlier that it
it was possible
was possible to
possible to create
create a second
moment is at
is at the
put another status
another status bar
status bar on
bar on the
can put one
put one at
dialog was specified
was specified, we'll
do this outside
this outside the
outside the PBForms
the PBForms section
PBForms section because
section because PBForms
because PBForms only
PBForms only allows
only allows one
allows one status
is our control
our control add
control add status
add status bar
status bar command
With the option
option of CCS
of CCS top
CCS top, this
this will place
place the status
we can additionally
can additionally put
additionally put a
put a couple
of other options
other options in
Client Edge and
Edge and Static
and Static Edge
that code we'll
to specify this
specify this new
this new constant
This idc status
idc status bar
status bar 2
bar 2 at
2 at the
to run the
run the code
And this gives
gives us a
us a second
you can click
click on this
on this quite
this quite happily
happily and it
and it does
it does not
does not trigger
not trigger the
trigger the events
the events at
events at the
the bottom status
bottom status bar
They only happen
only happen when
happen when you
And if you
click on other
on other parts
other parts of
status bar, the
one that are
that are not
are not icons
not icons, nothing
have added two
added two status
status bars to
bars to our
dialog and one
and one at
we've shown you
shown you can
can actually segment
actually segment your
segment your status
bar into up
into up to
up to 32
to 32 sections
you can print
can print data
print data, either
either text or
text or numbers
or numbers, to
can be updated
be updated in
updated in your
your code at
code at any
any point within
point within the
Giving feedback to
feedback to the
user on what
application is actually
created an icon
an icon using
icon using a
using a Wingdings
a Wingdings font
Wingdings font on
font on the
to display what
display what appears
the user as
user as an
if this icon
this icon has
icon has been
on and we
the colour to
colour to give
to give feedback
give feedback to
you to have
have a hook
a hook inside
hook inside the
inside the code
code to allow
to do other
do other functions
other functions when
functions when the
clicked on one
of your icons
find this code
this code useful
code useful in
series of videos
of videos we
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
through coding and
coding and development
and development, to
to testing, using
using the Power
we will continue
will continue our
continue our project
our project to
project to create
create our own
our own web
own web browser
created a very
a very minimalistic
very minimalistic web
minimalistic web browser
This web browser
web browser supports
browser supports a
supports a number
number of HTML
of HTML tags
Principally the title
the title tag
title tag, to
show the name
of the web
the web page
web page in
page in the
in the tab
the tab, plus
plus the paragraph
the paragraph tag
paragraph tag to
tag to show
show the hello
the hello world
hello world on
world on our
on our browser
our browser control
Additionally we have
we have supported
have supported the
supported the header
the header tags
header tags, between
between header 1
header 1 and
1 and header
and header 6
header 6, to
to show a
show a range
range of different
of different font
different font sizes
font sizes on
sizes on the
We are not
going to support
to support any
support any additional
any additional tags
additional tags today
tags today, but
but we are
going to expand
to expand support
expand support on
support on the
on the tags
the tags we
tags we already
we already have
already have, plus
plus to fix
to fix a
fix a couple
of small issues
small issues with
issues with our
with our browser
The current dialog
current dialog can
dialog can be
can be resized
be resized, and
and the objects
the objects within
objects within the
dialog will resize
will resize accordingly
However as you
see it will
will not redraw
not redraw the
the control, so
so we'll tackle
we'll tackle that
tackle that first
When our control
our control is
control is redrawn
is redrawn we
redrawn we want
want to reload
to reload the
reload the web
So to make
little easier we're
easier we're going
use the substitute
the substitute command
substitute command again
command again, to
us to have
have a shorter
a shorter path
shorter path to
to our web
our web page
run the command.exe
the command.exe to
command.exe to bring
to bring up
bring up our
up our console
our console window
console window, and
if we give
we give our
give our substitute
our substitute command
substitute command the
command the two
the drive letter
drive letter we
letter we wish
wish to substitute
to substitute, and
the path we
path we wish
we wish that
wish that drive
that drive letter
drive letter to
letter to refer
Now any reference
any reference to
to the Z
the Z drive
Z drive will
drive will take
will take us
take us straight
us straight to
straight to that
to that folder
going to handle
handle the resizing
the resizing problem
callback function, we
we can find
can find the
find the wm_size
the wm_size section
a section that
section that handles
that handles when
handles when the
dialog is resized
already have logic
have logic in
here that will
that will resize
will resize the
resize the controls
the controls themselves
Now at the
the end we
end we want
want to re-render
to re-render the
re-render the page
the page content
get the URL
the URL the
URL the user
has actually entered
actually entered and
entered and store
and store that
store that in
in the URL
the URL variable
we can call
can call the
call the existing
the existing function
existing function 'Render
function 'Render the
'Render the HTML'
the HTML', passing
to the URL
the URL, the
of the tab
the tab control
this now, and
and we put
our path, and
if we resize
we resize the
resize the control
the control now
control now, we
that the webpage
the webpage is
webpage is re-rendered
is re-rendered on
re-rendered on screen
So that's one
that's one problem
one problem solved
at the paragraph
the moment we
moment we have
we have given
have given a
given a very
very short lined
short lined paragraph
give it a
it a larger
a larger paragraph
larger paragraph, we
have now added
now added a
added a paragraph
a paragraph whose
paragraph whose text
whose text is
text is much
is much longer
This text is
text is all
is all in
all in one
if we expand
we expand the
expand the size
size of notepad
we save that
save that and
that and try
that the long
the long text
long text runs
text runs over
runs over the
over the edge
we have no
have no scroll
no scroll bars
scroll bars to
bars to allow
us to scroll
to scroll and
scroll and view
and view the
view the content
If we make
we make the
make the page
the page larger
page larger, it
then be displayed
want the paragraph
the paragraph text
paragraph text to
text to occupy
to occupy only
occupy only as
only as much
as much space
much space on
space on the
on the line
the line as
line as it
as it actually
it actually needs
actually needs, and
and to fold
to fold any
fold any additional
any additional text
additional text down
text down to
to the following
the following line
make a change
a change in
in the logic
the logic of
logic of rendering
of rendering our
rendering our text
displays the dialog
the dialog, this
where we add
we add the
add the graphics
And we use
command to let
to let Power
let Power Basic
Power Basic know
Basic know that
know that all
all subsequent graphic
subsequent graphic commands
graphic commands are
to be pointing
be pointing towards
pointing towards this
towards this control
graphics control gives
control gives you
gives you some
you some very
some very powerful
very powerful functionality
And some of
some of that
of that functionality
that functionality is
functionality is to
do with word
with word wrapping
If we add
we add a
add a single
of code, graphics
graphics set word
set word wrap
This instructs Power
instructs Power Basic
Power Basic that
Basic that if
that if the
text is greater
than the space
the space available
space available horizontally
available horizontally on
horizontally on the
the control, it
it will wrap
will wrap around
wrap around to
around to the
how it works
now see our
see our long
our long piece
long piece of
of text has
text has indeed
indeed been folded
been folded down
folded down to
to the second
the second line
If we bring
we bring the
bring the size
dialog in further
in further, we
see it also
it also folds
also folds that
folds that again
So dynamically by
dynamically by adding
by adding this
adding this one
this one line
one line of
of code, it
it will quite
will quite happily
quite happily fold
happily fold the
fold the text
the text down
the dialog shorter
dialog shorter in
shorter in height
in height, then
then we're losing
we're losing some
losing some of
the text, and
see that text
So how can
how can we
can we handle
we handle that?
handle that? Well
that? Well, the
graphics control has
control has something
has something else
something else it
else it can
it can do
can do to
do to allow
And that's to
that's to set
set the size
the size in
size in virtual
in virtual mode
We already know
already know that
control is going
to be 600
be 600 wide
600 wide and
wide and 250
and 250 high
If we use
graphics set virtual
set virtual command
virtual command and
command and set
and set the
set the width
the width to
to be as
be as it
it was, and
the height to
height to be
to be multiplied
be multiplied by
multiplied by 3
by 3, this
this gives the
gives the graphics
graphics control more
control more scope
more scope for
scope for handling
for handling text
handling text which
text which disappears
which disappears off
disappears off the
off the bottom
code now, and
and you'll now
you'll now see
now have scroll
have scroll bars
scroll bars, both
both horizontal and
horizontal and vertical
our dialog shorter
dialog shorter, we
we can scroll
can scroll down
scroll down to
down to see
see the rest
If we maximize
we maximize the
maximize the screen
the screen, we
see this gives
us a bit
of a problem
Our control does
control does not
does not appear
not appear to
to have resized
have resized correctly
resized correctly on
correctly on the
We still have
still have the
the vertical scroll
vertical scroll bar
scroll bar, but
but we've lost
we've lost the
lost the horizontal
the horizontal scroll
horizontal scroll bar
So what can
we do to
do to handle
to handle this
handle this problem?
this problem? Well
problem? Well, as
this is happening
is happening within
happening within the
within the resizing
the resizing, we
at the resize
the resize controls
resize controls function
The resize control
resize control function
control function is
function is what
is what we're
what we're using
using to actually
Because we have
graphics control now
control now set
now set to
set to virtual
to virtual, before
we do any
do any resizing
any resizing, we
change that back
that back to
back to fix
to fix size
up a couple
variables to keep
track of the
of the width
And once our
once our controls
our controls are
controls are resized
are resized, we
get the current
the current size
current size of
the graphics window
we will store
will store those
store those values
those values using
values using the
the graphic get
size command into
command into the
into the wide
the wide and
wide and high
and high variables
we can again
can again use
again use the
virtual command to
our graphics window
graphics window virtually
that code once
code once more
So the HTML
the HTML page
HTML page is
page is now
is now on
now on our
we maximize, we
that our graphics
control has now
has now successfully
now successfully resized
successfully resized itself
resized itself correctly
If we minimize
we minimize it
minimize it again
it again, we'll
see that it's
that it's again
it's again displaying
again displaying correctly
have a graphics
control which emulates
which emulates word
emulates word wrapping
is resized, the
graphics control behaves
control behaves accordingly
if you've done
you've done any
done any coding
any coding using
coding using HTML
using HTML tags
HTML tags, you'll
you'll know that
number of tags
of tags which
tags which have
which have attributes
paragraph tag has
tag has a
number of optional
of optional attributes
For example, if
we put the
put the align
the align attribute
align attribute in
attribute in our
in our paragraph
our paragraph tag
paragraph tag, where
where we're printing
we're printing 'Hello
printing 'Hello, World'
World' on the
this align attribute
align attribute allows
attribute allows you
set the alignment
the alignment to
alignment to either
to either be
either be right
be right, left
left or center
Because this attribute
this attribute is
attribute is within
is within the
within the tag
the tag itself
tag itself for
itself for the
for the paragraph
the paragraph, if
the code using
code using this
using this, it
it would no
would no longer
no longer pick
longer pick up
up the paragraph
So our 'Hello
our 'Hello, World'
World' is no
no longer appearing
the very least
very least, we
to actually cope
actually cope with
cope with the
with the fact
fact that there
that there may
well be attributes
be attributes with
attributes with tags
code and set
and set it
that it will
it will cope
will cope with
cope with attributes
with attributes being
attributes being there
at the render
the render HTML
render HTML tags
HTML tags function
order to handle
to handle tags
handle tags which
have attributes, we
a change to
to the render
is our rendering
our rendering engine
to add two
two new local
new local variables
us to handle
to handle attributes
string variable to
hold the contents
the contents of
contents of the
of the attribute
the attribute, and
and a long
long variable to
contain the starting
the starting position
starting position of
the attribute command
So after we
after we pick
we pick up
up the tag
tag itself, which
which is held
is held in
held in the
the command variable
command variable, we
want to pick
of our attribute
our attribute by
attribute by getting
by getting the
getting the position
of the first
the first space
So our tag
our tag could
tag could well
could well be
well be a
be a paragraph
a paragraph tag
paragraph tag and
tag and have
and have an
have an attribute
an attribute of
attribute of align
of align equals
align equals center
use the 'inString'
the 'inString' command
'inString' command to
up the position
first space, which
which would give
would give us
give us this
us this location
this location here
value returned by
returned by inString
by inString is
inString is 0
then there are
are no attributes
value is greater
there is at
is at least
least one attribute
use a simple
if statement to
to determine that
determine that and
that and to
and to pick
in the attribute
the attribute string
using the 'mid$'
the 'mid$' command
'mid$' command to
take the command
the command string
command string and
string and start
and start it
start it at
at the position
the position we
position we have
we have determined
have determined that
determined that the
that the attribute
the attribute begins
attribute begins at
begins at, and
and then use
use a 'trim'
a 'trim' command
'trim' command to
command to trim
to trim off
trim off any
off any leading
any leading or
leading or trailing
or trailing spaces
populate the attribute
the attribute into
attribute into the
into the attributes
the attributes variable
got that far
that far, we
have to trim
to trim the
trim the attribute
the attribute away
attribute away from
from the command
command variable, to
us to return
return to just
to just having
just having the
having the 'p'
the 'p' tag
using the 'parse'
the 'parse' command
'parse' command, looking
first space from
space from the
from the left-hand
left-hand side of
side of the
the string in
string in command
us to support
to support tags
support tags which
which have more
than one character
For example, when
we get onto
get onto other
onto other tags
other tags, for
for example, the
the 'table' tag
'table' tag is
tag is comprised
is comprised of
comprised of the
of the word
the word 'table'
code now, this
display the webpage
the webpage as
webpage as designed
we're not doing
doing anything with
anything with the
with the attribute
the attribute yet
that for a
for a later
a later video
next thing I
thing I want
is to handle
handle the pulling
the pulling back
pulling back of
back of the
of the tag
the tag value
we're determining the
determining the tag
tag value in
value in three
in three lines
three lines of
of code, getting
getting the start
the end, and
and pulling back
the value from
value from our
from our HTML
our HTML, and
it into, in
this case, a
a title variable
doing this in
of places, and
and it's crying
it's crying out
crying out for
out for a
for a common
a common function
create a common
function called 'getTagValue'
called 'getTagValue', which
which will take
starting position and
position and the
and the ending
the ending tag
ending tag value
For example, for
for title, it
it would show
would show like
show like this
let's now create
Creating common functions
common functions makes
functions makes the
makes the code
the code much
code much easier
to read, and
and it's also
it's also more
also more efficient
more efficient from
efficient from the
from the point
the point of
of view of
view of maintenance
the way we
way we get
we get tag
get tag values
tag values, we
we would only
would only have
only have to
have to change
to change one
change one function
put the same
same logic as
out the starting
starting position by
position by using
using the 'InString'
We're working out
out the end
the end position
end position, again
again using InString
using InString, and
and the return
the return of
return of the
the function will
the value extracted
value extracted from
extracted from the
from the HTML
the HTML global
HTML global variable
global variable using
variable using the
'mid$' command, and
the values of
values of the
of the starting
the starting and
starting and ending
and ending position
So as we've
as we've used
we've used this
used this function
for the title
title tag, we
also use it
use it for
the paragraph start
paragraph start tag
this is replacing
is replacing three
replacing three lines
code with one
the code again
code again now
again now to
now to make
make sure it's
sure it's returning
it's returning the
returning the same
the same values
our code displayed
code displayed in
displayed in our
in our browser
our browser window
The final thing
final thing we'll
thing we'll do
we'll do today
is to amend
to amend our
amend our browser
our browser to
browser to support
to support drag
support drag and
drag and drop
One thing you
thing you can
do with a
a standard browser
standard browser is
browser is you
is you can
you can drag
can drag an
drag an HTML
an HTML page
HTML page onto
page onto the
onto the browser
the browser and
browser and it
be displayed to
can we support
we support drag
and drop on
drop on our
on our dialogue?
our dialogue? If
dialogue? If we
can add in
add in a
a new event
add in an
in an event
an event called
event called 'wmDropFiles'
be the event
the event that's
event that's triggered
that's triggered when
triggered when something
when something is
something is dragged
is dragged and
dragged and dropped
and dropped onto
dropped onto the
onto the dialogue
As it's always
it's always possible
always possible that
possible that the
the user may
user may drag
may drag more
drag more than
one file at
file at a
a time onto
time onto the
the dialogue, our
work out just
out just how
many files have
have been dragged
call called 'DragQueryFile'
of parameters and
parameters and will
and will return
have been dropped
been dropped onto
we only want
only want to
want to support
to support a
support a single
single file being
file being dropped
being dropped at
dropped at a
we'll do a
do a check
check on this
on this file
this file count
file count to
count to ensure
ensure that it
that it equals
it equals 1
the value does
value does equal
does equal 1
equal 1, we
have to call
to call another
call another API
This call will
populate a filename
a filename variable
and the filename
the filename of
filename of the
the file that
file that has
has been dropped
been dropped on
dropped on the
Since we're only
we're only supporting
only supporting one
supporting one file
one file, the
item number is
number is always
is always going
always going to
As the count
the count of
count of files
of files starts
files starts at
starts at 0
at 0 and
0 and works
and works up
Now we've created
created a couple
local variables here
variables here which
here which we
code to finish
to finish off
finish off the
off the handling
the handling of
handling of dropping
of dropping of
dropping of files
use another Windows
API call named
call named 'DragFinish'
This tells Windows
tells Windows that
Windows that the
that the drag
the drag and
and drop has
drop has now
now been completed
can now take
now take our
take our filename
our filename, which
is our URL
our URL, and
update the graphics
control with this
this single file
So we're populating
we're populating our
populating our URL
our URL variable
URL variable with
with the value
the value that
value that comes
that comes out
comes out from
out from the
from the Windows
And we're then
we're then setting
then setting the
setting the text
the URL control
URL control on
screen to be
to be that
be that value
calling the 'Render
the 'Render the
the HTML' function
HTML' function once
once more with
more with its
with its three
The URL we've
URL we've just
we've just picked
just picked up
picked up, the
and the tab
the tab value
this one section
one section in
event handler, should
should be enough
be enough to
enough to handle
to handle dropping
handle dropping of
let's create those
create those local
those local variables
local variables now
Having added this
added this event
this event into
event into the
event handler, there's
there's one more
one more change
more change we
change we have
have the dialog
dialog was set
was set up
set up in
up in the
the first place
to the PBLite
the PBLite browser
PBLite browser function
browser function, there's
there's another Windows
call which has
which has to
to be inserted
be inserted here
is the drag
the drag except
drag except files
except files command
This takes two
sets the dialog
the dialog up
dialog up to
up to accept
to accept files
accept files being
files being dragged
being dragged onto
dragged onto it
application now, and
and we move
we move the
move the application
the application up
application up, and
and we bring
we bring onto
bring onto the
the screen our
screen our HTML
our HTML page
we now attempt
attempt to drag
to drag this
drag this on
this on to
on to our
to our browser
our browser, it
it will now
will now display
now display quite
display quite happily
quite happily on
happily on screen
have enabled a
enabled a drag
a drag and
drop on the
on the browser
have also amended
also amended the
amended the paragraph
tag to allow
allow the text
to be folded
be folded round
folded round if
round if the
if the screen
the screen is
screen is not
is not wide
not wide enough
So we've achieved
we've achieved Word
achieved Word Wrap
Word Wrap, and
we have set
have set the
set the graphics
graphics window to
window to be
to be virtual
This means our
means our graphics
graphics window is
window is actually
is actually larger
actually larger than
larger than what
than what appears
So should our
should our screen
our screen be
screen be smaller
be smaller than
smaller than the
the text, we
have a vertical
a vertical scroll
scroll bar to
bar to allow
to scroll down
down to view
view the extra
the extra text
amended the resizing
the resizing events
resizing events to
events to allow
allow the graphics
graphics control, albeit
albeit virtual, to
to be resized
be resized correctly
initial design through
design through coding
and development to
development to testing
We have begun
have begun the
begun the project
the project to
create a light
a light web
light web browser
Our web browser
web browser already
browser already supports
already supports a
HTML tags, namely
namely the title
title tag and
tag and the
and the paragraph
into our sample
our sample page
sample page, drag
drag it across
it across to
across to the
to the browser
the browser, it
it will support
will support drag
and drop and
drop and display
and display the
display the HTML
HTML page in
in the browser
the browser window
In current browsers
current browsers it's
browsers it's quite
it's quite normal
quite normal to
normal to expect
to expect the
expect the user
to open a
open a number
number of tabs
of tabs, each
each tab containing
tab containing a
containing a different
a different web
different web page
be doing today
doing today, we're
be adding tab
adding tab support
tab support to
support to our
at our code
have already set
up a global
a global array
global array to
array to store
store the handle
handle of all
all the tabs
of that today
that today, and
create another global
another global array
going to keep
of the URL
the URL that's
URL that's held
that's held on
held on each
on each tab
each tab, and
call this a
this a global
global array, which
a string of
string of URLs
This will contain
will contain exactly
contain exactly the
the same number
same number of
of elements as
elements as the
as the Tab
the Tab Handles
Tab Handles array
can we facilitate
we facilitate the
facilitate the addition
addition of additional
of additional tabs
additional tabs to
tabs to the
the browser window?
browser window? Currently
window? Currently, we're
we're only showing
only showing one
showing one tab
a second tab
second tab on
tab on this
on this tab
this tab control
tab control, and
and this tab
this tab is
tab is going
be the tab
the tab the
tab the user
user will click
click on to
on to create
a new tab
new tab window
need to have
Handler of our
of our main
our main dialog
main dialog where
dialog where the
where the tab
the tab is
tab is actually
is actually created
of this Event
callback function, there's
there's an initialize
an initialize dialog
initialize dialog section
we're inserting the
inserting the tab
the tab page
This being tab
being tab number
tab number 1
and we're titling
we're titling that
titling that with
the word 'home'
We're re-dimensioning our
re-dimensioning our array
array for tab
for tab handles
tab handles to
handles to be
to be of
be of one
of one element
one element, and
populating the first
first element with
element with the
the handle we
handle we get
we get back
get back when
back when we
when we insert
we insert the
insert the tab
after we've added
we've added this
added this first
this first tab
first tab, we're
going to automatically
to automatically add
automatically add a
we are re-dimensioning
are re-dimensioning our
re-dimensioning our tab
our tab handles
handles array to
have two elements
two elements now
And our second
our second tab
second tab is
to be added
be added as
added as tab
as tab number
tab number 2
number 2, and
within that tab
that tab is
be the plus
the plus sign
a new global
new global variable
global variable to
variable to keep
the tab which
tab which is
is currently selected
This will save
will save some
save some coding
some coding later
coding later on
to impose some
impose some controls
some controls on
controls on are
on are the
are the number
of tabs the
tabs the user
user is allowed
is allowed to
allowed to create
Bousers can be
can be quite
be quite hungry
quite hungry beasts
hungry beasts when
beasts when it
when it comes
it comes to
comes to the
to the resource
the resource on
resource on your
on your computer
your computer, so
the moment we're
set a maximum
of tabs that
tabs that the
user can open
can open up
can always increase
always increase this
increase this value
this value later
value later, but
but we will
value to be
to be initially
be initially for
initially for 10
for 10 tabs
creating a constant
constant called 'maxTabs'
called 'maxTabs' to
'maxTabs' to contain
contain the value
the value 10
value 10, and
and we're creating
creating a global
global variable for
for the tab
the tab currently
tab currently selected
create one additional
one additional variable
additional variable for
variable for a
for a global
a global handle
global handle for
any further, let's
the application to
application to see
see if our
if our second
second tab appears
We can switch
can switch between
switch between the
between the first
the first tab
first tab, which
which is labeled
is labeled Home
labeled Home, and
the second tab
second tab, which
is labeled Plus
The idea behind
idea behind the
behind the second
tab is to
on it, and
and when they
when they click
they click on
on it, we
we want a
want a new
new tab inserted
tab inserted between
inserted between the
between the Home
the Home tab
Home tab and
tab and the
and the Plus
the Plus tab
We will then
will then want
then want Focus
want Focus shifted
Focus shifted to
shifted to the
the second new
second new tab
new tab, so
so the sole
the sole purpose
sole purpose of
purpose of the
of the Plus
Plus tab is
on it to
it to create
in there to
there to pick
pick up when
up when the
on the Plus
since we've limited
we've limited the
limited the user
user to having
to having only
having only 10
only 10 tabs
10 tabs, we'll
need to dimension
dimension our URLs
our URLs array
URLs array to
array to be
in the PB
the PB main
PB main function
And we're again
we're again using
again using the
using the Max
the Max Tabs
Max Tabs constant
Tabs constant to
constant to set
of 10 elements
order to pick
up the detection
the detection of
detection of clicking
of clicking on
clicking on this
this tab, we'll
put some more
some more logic
more logic inside
logic inside our
inside our callback
a new section
new section within
section within this
within this Event
Event Handler logic
Handler logic called
logic called 'wmNotify'
This will handle
will handle our
handle our notifications
our notifications on
notifications on the
on the tab
a new local
new local variable
local variable to
track of what
of what has
what has been
And our pointer
our pointer header
pointer header is
header is actually
is actually picking
actually picking up
up the L
the L parameter
We're testing that
testing that to
that to see
see which control
which control this
control this came
this came from
came from, and
we're testing on
testing on Tab
on Tab of
Tab of the
tab control itself
then test all
test all the
all the particular
the particular event
particular event we're
event we're looking
this case, it's
it's a TCN
a TCN Selection
TCN Selection Change
Selection Change Event
This triggers once
triggers once the
once the user
clicked on a
This will trigger
will trigger when
trigger when any
when any tab
any tab has
tab has actually
for the last
the last tab
last tab in
tab in the
the row, the
up the top
the top page
top page number
page number by
number by using
using the 'youbound'
the 'youbound' command
'youbound' command to
to tell us
tell us the
us the largest
the largest bounding
largest bounding of
bounding of the
use the 'tabgate
the 'tabgate select'
'tabgate select' command
select' command to
up the tab
tab which has
And we're storing
we're storing that
storing that in
that in our
in our global
our global variable
global variable 'tabSelected'
we have those
have those two
those two values
the upper bounding
upper bounding of
of the tabs
the tabs and
tabs and the
actually selected, we
can perform a
perform a test
If the page
the page number
page number equals
number equals the
equals the top
page number, we're
on the last
the one with
one with the
And as long
as long as
long as that
as that number
that number is
number is less
is less than
less than the
than the maximum
of tabs, then
can go ahead
go ahead and
ahead and create
and create a
So to do
going to increment
increment the top
page number to
number to advance
to advance it
advance it by
it by one
use the 'tabset'
the 'tabset' text
'tabset' text command
command to create
new tab, and
going to title
to title that
title that tab
that tab with
tab with the
the word 'new'
we can insert
can insert a
insert a brand
brand new page
new page onto
page onto our
onto our tab
our tab control
tab control, which
be our plus
our plus page
plus page, the
the last page
last page in
that we've added
added a brand
brand new tab
new tab, we'll
need to re-dimension
to re-dimension our
re-dimension our tab
populate the last
the last element
last element in
element in tab
in tab handles
tab handles with
handles with the
of the page
the page we
page we have
have just added
is a brand
new tab, we
want to ensure
We could quite
could quite easily
quite easily create
easily create a
a new graphics
graphics control for
control for each
for each tab
that would take
would take up
take up a
up a significant
a significant amount
significant amount of
amount of resource
of resource, especially
especially if we're
if we're looking
looking at having
at having ten
having ten separate
ten separate tabs
do is we're
reuse the existing
existing graphics control
graphics control, so
so there will
there will only
will only be
only be one
be one graphics
one graphics control
graphics control in
control in the
in the entire
the entire application
that we've made
we've made visible
user the new
the new tab
we will clear
will clear the
clear the content
the content of
content of the
As we'll be
we'll be doing
doing this possibly
this possibly in
possibly in a
of places, we'll
a new common
new common function
common function to
function to clear
clear the graphics
the URL text
URL text box
box to blank
will create this
new function in
but for now
for now we
now we will
will continue the
continue the coding
the coding in
coding in this
this particular section
particular section to
section to handle
handle the other
the other options
We have tested
have tested to
tested to see
Are we on
we on the
on the very
very last tab?
last tab? The
tab? The if
The if block
if block we're
block we're currently
we're currently inside
currently inside is
inside is the
one that tests
that tests where
tests where the
where the page
page number is
that is not
not true, we
want to handle
to handle and
handle and set
set the focus
the focus back
focus back to
to the previous
the previous tab
page number does
number does not
does not equal
not equal the
equal the top
page number, then
then some other
some other tab
other tab has
tab has been
been selected, so
up the URL
URL that's been
that's been stored
been stored in
in our URLs
can populate that
populate that value
that value in
box to show
show the URL
the URL to
URL to the
can then clear
then clear our
clear our graphics
using the new
function we're about
about to create
to create, and
we can render
can render the
render the HTML
the HTML using
HTML using the
using the existing
a few variables
few variables we
variables we need
to create at
create at the
have created our
created our header
our header variable
header variable as
as a pointer
a pointer, we've
created the page
page number and
and the top
now create the
create the clear
the clear graphics
clear graphics control
graphics control function
small function, using
command to change
change the background
the background of
background of the
control to white
to white, and
then to perform
perform a graphics
redraw to display
and we click
plus tab, we're
we're now getting
now getting a
getting a new
new tab appearing
tab appearing in
appearing in the
the middle between
middle between the
the home and
home and the
we'll get new
get new tabs
new tabs appearing
tabs appearing right
appearing right up
to the point
the point where
point where we
where we get
to the maximum
that point, it
it will create
will create no
create no new
no new more
new more tabs
more tabs, so
now have ten
have ten tabs
ten tabs on
tabs on screen
have successfully given
successfully given the
user a way
way of creating
of creating new
creating new tabs
And in each
of these tabs
these tabs, they
they can quite
quite happily drag
happily drag over
drag over or
over or browse
or browse to
browse to a
a new webpage
the tab, it's
it's not redrawing
not redrawing the
redrawing the page
put an automatic
an automatic redraw
automatic redraw function
redraw function in
function in when
in when they
when they select
they select a
select a tab
other thing we
thing we need
is to store
store the URL
the URL in
URL in our
our global array
the event handler…
event handler… …and
handler… …and in
…and in our
event handler, we
have an OK
an OK section
OK section of
of that code
here is where
where we render
we render the
add a little
a little piece
little piece of
of code onto
code onto this
onto this to
this to select
select the tab
the tab and
tab and store
and store the
we also need
also need to
to put this
put this logic
this logic into
logic into the
into the drag
and drop section
the same two
same two lines
of all, selecting
selecting the tab
the tab number
tab number and
number and then
and then populating
then populating that
populating that element
that element within
element within the
within the global
the global array
global array with
array with the
with the URL
add a few
a few new
few new tabs
new tabs and
tabs and then
and then drag
then drag in
drag in one
of our pages
our pages, go
to the homepage
the homepage and
homepage and drag
and drag in
drag in another
in another page
another page, and
to the other
the other demo
other demo page
demo page, which
which should now
should now display
now display, and
the new ones
new ones will
ones will show
will show as
show as blank
as blank because
blank because they
because they have
have no URL
But the demo
the demo page
demo page ones
page ones are
ones are now
are now correctly
now correctly populating
have now achieved
now achieved the
achieved the ability
ability to add
to add new
add new tabs
tabs and have
and have them
have them populated
them populated, and
application will remember
will remember the
remember the URL
the URL for
URL for that
for that page
So as well
well as adding
as adding new
adding new tabs
new tabs, we
need to give
user a mechanism
by which they
which they can
they can remove
can remove a
remove a tab
a tab, close
close a tab
a tab down
perform this function
this function, there
ways of actually
of actually doing
actually doing it
We could use
could use a
use a menu
a menu option
menu option, but
but in this
this case, I'm
to keep it
keep it simple
it simple and
simple and I'm
create a brand
brand new dialogue
new dialogue, albeit
albeit a very
very small dialogue
small dialogue with
dialogue with no
with no caption
no caption bar
It's very small
very small and
small and it
and it contains
it contains only
contains only one
only one button
the test, we
is all that
all that we'll
that we'll show
we'll show to
on screen, a
small dialogue containing
dialogue containing a
containing a single
a single button
the styles for
styles for this
for this, we
see the only
the only thing
only thing we've
thing we've actually
we've actually got
actually got selected
got selected is
selected is clip
is clip siblings
The caption, sys
sys menu and
menu and minimize
and minimize ones
minimize ones are
ones are all
are all unticked
have this new
this new dialogue
new dialogue created
dialogue created, how
can we call
we call this
call this from
this from inside
from inside the
inside the application?
the application? As
application? As always
As always, there
today is I'm
is I'm going
control up to
up to support
to support right
support right clicks
right clicks on
And when right
when right click
right click is
click is clicked
is clicked, the
the new dialogue
new dialogue will
dialogue will appear
will appear, showing
showing the user
user the small
the small dialogue
dialogue with the
with the single
the single button
single button to
button to allow
to allow them
them to close
to close the
close the tab
order to support
to support that
support that, I'm
set up another
up another global
another global variable
And this we're
this we're going
to call old-graphic-proc
This will hold
will hold the
hold the old-graphics-control
the old-graphics-control callback
old-graphics-control callback details
order to set
this up, we
some more code
more code in
in the initialize
the initialize dialogue
initialize dialogue section
dialogue section of
of the event
callback function of
function of our
our main dialogue
So we're setting
we're setting a
setting a static
static variable up
variable up called
up called graphic
called graphic to
graphic to hold
hold the handle
call called setWindowLong
called setWindowLong to
setWindowLong to pick
up the code
the code pointer
to our new
our new callback
new callback function
going to get
to get a
get a new
function called graphic-proc
And since we've
since we've set
we've set this
this up, we'll
to handle when
handle when the
dialogue is destroyed
we'll put a
put a new
a new destroy
new destroy section
destroy section in
dialogue is about
to be destroyed
will call that
that function again
put back the
the value we've
value we've stored
we've stored in
stored in old-graphic-proc
that we've set
set that up
that up, we'll
to create this
new function, graphic-proc
new function, taking
taking the parameters
the parameters that
parameters that our
that our callback
our callback requires
looking for specifically
for specifically the
specifically the right
the right button
right button up
button up event
This will get
will get our
get our mouse
our mouse coordinates
mouse coordinates when
coordinates when the
the user lets
user lets go
lets go of
go of the
the right mouse
right mouse button
mouse button, having
having pushed it
pushed it down
we're testing a
testing a global
the one we
one we populated
we populated with
with the currently
the currently selected
currently selected tab
selected tab number
the moment, I've
I've got it
got it set
it set so
set so that
so that only
that only works
only works for
works for tabs
for tabs other
tabs other than
than the first
we can avoid
can avoid the
avoid the user
the user deleting
user deleting the
deleting the first
this will call
will call our
call our new
new dialogue, tabClick
I'm leaving these
leaving these in
these in place
in place, although
although we're not
not actually using
actually using them
using them at
them at the
the moment, as
we may well
may well need
well need to
to know where
know where on
where on the
the screen the
screen the user's
user's mouse is
populate the callback
for our new
our new small
new small dialogue
is the callback
for the new
And we already
already have a
have a section
a section set
section set up
set up for
up for the
for the clicking
on the Close
the Close Tab
Close Tab button
is to close
close the current
the current tab
current tab, but
but we'll need
that the tab
the tab selected
tab selected is
selected is not
is not beyond
not beyond the
beyond the last
last element of
use the tab
the tab Delete
tab Delete command
Delete command and
command and our
and our global
for the payment
the payment handle
payment handle to
handle to delete
to delete the
delete the tab
we have deleted
have deleted the
deleted the tab
the tab, we
do some tidying
some tidying up
tidying up of
up of our
of our arrays
have two global
two global arrays
The first holding
first holding the
holding the tab
the tab handle
The second holding
second holding the
holding the URL
the URL that
URL that that
that that tab
tab is currently
is currently pointing
currently pointing at
want to delete
to delete those
delete those entries
those entries in
use the Array
the Array Delete
Array Delete command
Delete command for
Delete command will
command will remove
remove that entry
that entry and
entry and shuffle
and shuffle all
shuffle all the
the values above
values above that
above that in
the array down
array down one
This leaves a
leaves a blank
a blank entry
blank entry at
entry at the
order to remove
to remove that
remove that, we
can do a
do a Redim
a Redim with
Redim with the
with the Preserve
the Preserve option
This will effectively
will effectively remove
effectively remove this
remove this last
this last entry
last entry completely
So our array
our array now
array now matches
now matches the
matches the number
of tabs we
tabs we have
the tab that's
tab that's been
that's been deleted
been deleted is
deleted is now
is now completely
now completely removed
we have removed
have removed a
removed a tab
a tab, we'll
actually set the
set the tab
tab selected by
selected by reducing
by reducing it
reducing it by
can now reset
now reset to
reset to the
to the new
the new Focus
new Focus tab
Focus tab by
tab by using
using the Tab
the Tab Select
Tab Select command
And then set
the URL coming
URL coming from
coming from the
from the global
our final task
final task would
task would be
would be to
be to clear
Control and re-render
and re-render the
re-render the HTML
Using the two
the two functions
two functions we
functions we have
have already created
already created and
created and used
and used before
we've completed that
completed that, we
can now close
now close down
close down the
down the dialog
let's see if
if our application
our application performs
application performs as
performs as expected
add a couple
couple of extra
of extra tabs
extra tabs and
and then right-click
then right-click, our
new dialog is
dialog is appearing
is appearing, however
it's down below
down below the
below the application
We'll want this
want this new
this new dialog
new dialog appearing
dialog appearing up
appearing up here
up here in
here in the
to use those
use those X
coordinates to position
to position our
position our dialog
the code once
in the X
couple of new
of new local
local variables for
variables for our
for our Parent
our Parent dialog
Parent dialog location
dialog location, as
we may not
may not actually
not actually need
actually need these
need these two
two values passed
values passed in
the dialog get
dialog get Parent
get Parent value
Parent value to
value to populate
to populate these
populate these PX
these PX and
and PY variables
set the dialog's
the dialog's location
dialog's location by
location by using
by using 'dialog
using 'dialog set
'dialog set location'
we move our
move our window
our window up
window up, add
of new ones
new ones, and
if we right-click
we right-click, we
see the Close
Close tab is
tab is appearing
is appearing very
appearing very close
close to where
to where we've
where we've clicked
click on 'Close
on 'Close Tab'
'Close Tab', the
new tab disappears
So to test
this out properly
out properly, I've
created an extra
an extra HTML
extra HTML page
we bring in
bring in the
first one and
second one, we
have two demo
two demo pages
demo pages –
pages – Demo
– Demo Page
Demo Page 2
Page 2 and
2 and Demo
and Demo Page
Demo Page 1
And we still
still have our
have our homepage
our homepage blank
go to Demo
to Demo Page
Page 2, right-click
the tab, Demo
Page 2 has
2 has disappeared
has disappeared, but
but Demo Page
Page 1 is
1 is still
is still there
we right-click on
right-click on the
on the homepage
the homepage, it
will not show
not show the
show the pop-up
the pop-up, but
it will do
will do it
do it on
it on all
on all other
all other pages
set the browser
the browser up
browser up to
to support multiple
support multiple tabs
user can now
can now add
now add up
add up to
up to 10
to 10 tabs
10 tabs at
tabs at any
at any one
any one time
one time on
time on the
the browser control
They can also
can also close
also close each
close each of
of those tabs
those tabs down
tabs down, but
it will always
will always keep
always keep the
keep the first
first tab and
plus tab visible
tab visible to
the user, and
we're storing the
storing the URL
URL for each
each tab in
tab in a
of videos, we
using the PowerBasic
web browser, by
by adding image
adding image support
We have made
have made a
made a start
a start on
start on creating
on creating our
creating our own
our own light
own light browser
The browser currently
browser currently supports
currently supports a
It also supports
also supports tabs
supports tabs on
tabs on the
browser control itself
We can support
can support now
support now up
now up to
today's video, we're
do what is
what is common
is common with
common with each
with each release
going to review
to review the
review the previous
the previous release
previous release, to
to fix any
fix any bugs
any bugs or
bugs or features
or features that
features that have
have been encountered
been encountered, and
to add something
add something new
There's something new
something new we're
new we're going
today is the
ability to support
to support the
support the image
the image tag
image tag, so
so the images
the images, JPEGs
JPEGs and PNG
and PNG files
PNG files can
files can be
be displayed on
to support this
support this new
this new functionality
new functionality, we're
going to bring
to bring in
bring in some
some more library
more library files
One to handle
to handle common
handle common strings
common strings and
strings and one
to load JPEGs
load JPEGs or
JPEGs or PNG
or PNG files
PNG files into
files into our
into our graphics
these are new
are new include
new include files
include files added
files added into
added into the
cover the functions
functions within these
within these files
these files when
files when we
of all, I
want to fix
to fix something
fix something with
something with the
with the tab
the tab controls
application and click
plus tab, add
add some new
some new tabs
can add up
up to of
to of them
of them are
them are of
are of use
of use to
use to the
the user, the
the 10th tab
10th tab being
tab being the
being the plus
As we said
we said, we're
user to use
to use 10
use 10 tabs
want to increase
to increase the
increase the number
of tabs by
tabs by one
easily by increasing
by increasing the
increasing the constant
the constant we've
constant we've got
we've got that
got that controls
that controls the
controls the number
now we support
we support 11
support 11 tabs
10 the user
user can access
can access and
access and one
to add additional
add additional tabs
Once the number
of tabs on
on screen reaches
screen reaches 11
reaches 11, no
no more tabs
more tabs can
tabs can be
can be added
One thing we
thing we did
last video was
video was to
was to redimension
to redimension arrays
have a fixed
can access, we
can set this
set this right
this right when
right when the
when the program
the program begins
program begins to
begins to have
have a maximum
maximum of 11
of 11 tabs
in the pb_main
pb_main function, we'll
we'll see here
see here this
here this is
where we're dimensioning
we're dimensioning the
dimensioning the URLs
the URLs array
the array that
array that holds
holds the URL
have a tab
a tab handles
handles array, so
same with it
We will redimension
will redimension that
redimension that array
that array to
be the number
of tabs set
tabs set in
set in our
in our max
our max tabs
look in our
event handler, in
here we had
we had a
had a line
a line of
code which is
which is redimensioning
is redimensioning the
redimensioning the tab
to be two
be two elements
Since we've now
we've now dimensioned
now dimensioned this
dimensioned this to
be the full
the full number
full number of
of tabs, we
we no longer
no longer need
longer need this
need this line
So by forcing
by forcing the
forcing the array
of elements, we've
we've eliminated one
eliminated one line
In the drag
drop section of
section of our
of our event
there's a piece
of code we'll
need to move
control with the
has been dragged
been dragged in
dragged in to
in to our
to our graphics
is done using
done using the
using the render
the render the
the HTML function
And having rendered
having rendered the
rendered the HTML
the HTML, we
we then store
then store the
in our URL
our URL array
to amend this
amend this slightly
this slightly so
slightly so that
that we store
we store the
the URL before
URL before we
before we render
render the page
up the path
the path of
path of any
of any image
any image file
image file that
file that the
user has within
has within the
within the HTML
the HTML file
we will move
will move this
move this section
this section up
section up above
up above this
above this section
make a call
a call in
call in here
here to the
to the clear
This function clears
function clears out
clears out the
out the graphics
graphics control ready
control ready for
ready for new
for new content
And it's ideal
it's ideal to
ideal to do
do this before
this before re-rendering
before re-rendering a
re-rendering a page
and we add
we add some
add some more
some more tabs
more tabs, we
we find we
find we have
a problem here
tab is not
is not adding
not adding a
adding a new
new tab control
is because we
because we now
of tabs in
tabs in the
the tab array
need to amend
amend our code
our code to
code to cope
to cope with
cope with this
will be in
be in the
tab control selection
control selection change
change event within
event within our
within our event
event handler our
handler our callback
In here, currently
currently we pick
pick the top
number by the
by the upper
bounding of our
of our tab
Since we now
now have our
have our tab
handles array set
array set to
set to be
to be 11
be 11 elements
11 elements, this
this will always
will always return
always return the
the value 11
this will need
What we can
can do though
do though is
though is use
is use the
the tab get
tab get text
the text of
text of the
tab is a
is a plus
a plus sign
plus sign, then
then we're obviously
we're obviously clicking
obviously clicking on
is our line
our line of
code to pick
up the title
the title on
title on the
on the currently
if it's the
it's the value
the value plus
to test if
test if we
we add one
add one to
current tab number
tab number, will
will this be
this be greater
be greater than
greater than or
than or less
or less than
So we also
also have to
have to add
to add an
add an extra
an extra variable
created a tab
a tab title
tab title variable
So we'll add
we'll add that
add that at
before we test
we test this
this out, there's
other changes I
changes I want
to the events
the events in
events in here
We've already put
already put one
put one call
one call to
couple other places
other places that
places that this
that this will
will be needed
at the size
the size event
size event, before
before we re-render
we re-render the
the HTML, we'll
want to run
to run clear
run clear graphics
And also within
also within the
within the ID
the ID OK
ID OK event
OK event, we'll
the same before
same before we
let's try rerunning
try rerunning the
rerunning the application
see if we've
if we've fixed
we've fixed our
fixed our problem
the plus now
plus now, we're
now getting the
getting the new
the new tabs
new tabs being
tabs being created
We go right
go right to
the end, we
now have 10
have 10 usable
10 usable tabs
usable tabs for
tabs for the
the user and
user and one
and one plus
one plus tab
plus tab at
tab at the
the end, which
user can no
can no longer
no longer click
longer click on
if we right
we right click
right click on
the tabs, we
can close it
close it down
it down quite
down quite happily
Until we get
to the home
we now appear
now appear to
to have fixed
have fixed that
fixed that issue
to make changes
make changes to
changes to support
the image control
will need an
need an HTML
HTML page, which
which has an
has an embedded
an embedded image
So within our
within our HTML
our HTML pages
HTML pages folder
pages folder, I've
I've added two
added two additional
two additional files
additional files, a
a page three
page three HTML
three HTML file
HTML file and
file and a
and a PNG
a PNG file
The PNG file
PNG file is
file is showing
showing a small
a small image
click on page
on page three
page three to
three to open
to open up
open up in
up in a
in a browser
a browser window
that this is
this is what
is what we
to display inside
display inside our
inside our browser
the text page
text page three
page three at
three at the
the top, followed
by the image
the image and
image and followed
and followed by
by the remainder
we support this
support this within
this within our
within our code?
our code? If
code? If we
at the text
text in notepad
in notepad, we
is our image
our image tag
image tag, followed
followed by SRC
by SRC for
SRC for source
for source, and
and then just
then just the
just the name
of the PNG
will see, we
have just given
just given the
given the name
is no pathing
no pathing embedded
pathing embedded within
embedded within it
We'll cover pathing
cover pathing in
pathing in a
in a later
file is in
folder as the
as the HTML
need to add
to add support
add support for
support for IMG
for IMG tags
thing we haven't
we haven't set
haven't set up
so far is
far is to
where the current
the current position
current position of
thing to be
to be printed
be printed on
printed on the
browser control is
This is something
is something we'll
something we'll need
to do at
do at some
So we may
we may as
may as well
as well do
well do it
do it now
added two new
two new global
new global variables
global variables along
variables along X
along X and
X and along
and along Y
These are going
be our X
and Y print
Y print locations
before we support
we support the
image tag, let's
let's remove a
remove a couple
a couple bits
couple bits of
bits of debug
of debug code
When we run
the application at
we're getting two
getting two lines
lines of debug
debug code at
of our browser
The words return
words return pressed
return pressed and
pressed and the
path and HTML
and HTML formatting
HTML formatting okay
going to remove
remove that from
that from the
code so those
so those no
those no longer
no longer print
longer print out
in the render
the moment, we'll
we'll just come
just come in
come in this
in this line
Should the HTML
the HTML be
HTML be invalid
be invalid, we'll
leave this command
And while we're
while we're in
we're in here
in here, before
before we load
we load the
load the HTML
HTML file, we'll
we'll make another
make another call
another call to
call to our
to our clear
our clear graphics
is the heart
the heart of
heart of a
of a render
a render engine
render engine that
engine that handles
of the tags
of the HTML
the HTML tags
HTML tags is
tags is handled
is handled within
handled within this
to add on
add on a
a new case
new case statement
statement to support
support the IMG
the IMG tag
start of the
of the image
image tag, we're
sure we're inside
we're inside the
inside the body
the body section
body section of
The attributes available
attributes available should
available should already
should already have
already have been
tab get select
get select command
So as this
is something new
something new, we're
allow the display
of this image
this image on
image on the
function called display
called display image
it the dialog
attributes we have
have already populated
already populated, and
created the skeleton
We'll need a
variables here to
here to keep
And this function
use of one
of one of
within the libraries
the libraries we
have added today
The image we're
image we're attempting
we're attempting to
attempting to load
to load is
load is a
is a PNG
But PNGs cannot
PNGs cannot be
cannot be directly
be directly loaded
directly loaded into
loaded into a
into a graphics
need to convert
to convert them
convert them to
them to a
to a bitmap
the function within
function within our
within our new
our new library
new library will
library will perform
will perform that
perform that for
that for us
within our attributes
our attributes is
attributes is the
is the src
the src equals
src equals command
equals command, giving
giving us possibly
us possibly the
possibly the path
path and definitely
and definitely the
definitely the name
So we'll first
we'll first work
first work out
out its starting
its starting position
starting position just
position just so
just so we
can get the
get the path
can work out
starting position using
position using the
using the in
the in string
in string command
using a temporary
a temporary variable
temporary variable to
variable to be
to be populated
be populated using
populated using mid
using mid dollar
up the actual
final task is
populate the src
the src variable
src variable using
parse command to
get the content
the content within
content within the
within the double
the double quotes
I said earlier
said earlier, the
the image path
image path may
path may be
may be relative
be relative to
to the HTML
later video, but
moment we just
just want the
want the ending
the ending part
ending part of
of our path
our path, the
So our next
up the full
the full HTML
full HTML path
HTML path of
now getting that
getting that out
that out of
of the URLs
the parse count
parse count command
count command to
command to count
to count how
count how many
how many slashes
many slashes are
slashes are in
are in the
in the path
Now this at
the moment assumes
moment assumes that
assumes that the
that the path
the path is
path is a
is a local
a local one
local one to
to the user's
the user's machine
We'll be handling
be handling paths
handling paths on
paths on web
on web pages
web pages separately
pages separately in
separately in another
in another video
Then we're decrementing
we're decrementing this
decrementing this value
this value by
value by one
by one and
one and we're
and we're picking
up the last
last part, which
which cases the
cases the name
the file, which
this case should
case should be
should be nas.png
be nas.png, so
use the funload
the funload image
funload image file
image file command
file command in
command in our
in our new
new library to
library to load
this into a
into a bitmap
name of our
we are passing
are passing back
passing back from
this function the
function the width
we're also passing
also passing back
back the handle
the bitmap we
bitmap we have
there's one thing
one thing we'll
thing we'll have
have to watch
to watch in
watch in here
Because the function
the function load
function load image
load image file
image file is
file is redirecting
is redirecting graphics
redirecting graphics operations
graphics operations using
operations using the
command to the
the bitmap, we
have to reattach
to reattach to
reattach to a
to a graphics
Otherwise nothing will
nothing will appear
we have reattached
have reattached to
reattached to our
graphics control, we
can now copy
now copy the
copy the populated
the populated bitmap
populated bitmap to
bitmap to our
to our screen
So the question
question is, where
where exactly on
exactly on our
on our graphics
graphics control do
control do we
do we position
we position this
position this bitmap?
this bitmap? As
bitmap? As you
As you may
you may remember
may remember earlier
remember earlier, we
we created two
created two global
two global variables
global variables, longX
longX and longY
to be set
be set for
set for the
the next available
next available position
available position for
position for printing
will use those
use those two
those two variables
two variables to
variables to position
position our graphic
our graphic on
graphic on the
copy command and
and our X
coordinates as parameters
So having positioned
having positioned our
positioned our graphic
where the next
available position is
graphic get pause
get pause command
populate the global
the global X
global X and
to add onto
add onto the
onto the Y
coordinate the height
of our image
So the X
and Y now
Y now point
now point to
point to the
next available space
can then free
then free up
free up the
up the space
the space used
space used in
in the bitmap
the bitmap and
bitmap and we
can redraw the
redraw the graphics
see how close
how close we
close we are
you will remember
will remember, page
page three is
three is the
with the embedded
the embedded graphics
embedded graphics control
have a graphic
a graphic on
the screen but
screen but it's
but it's appearing
it's appearing at
appearing at the
corner and it's
and it's overwriting
it's overwriting some
overwriting some of
text that was
that was originally
was originally there
have a little
more work to
work to do
set the X
Y coordinates having
coordinates having printed
having printed the
printed the graphic
the graphic on
haven't set the
Y coordinates anywhere
coordinates anywhere else
anywhere else in
else in the
Specifically for the
text that's appearing
that's appearing on
and set that
there's a function
a function within
function within the
the application called
application called print
called print data
print data where
data where we're
we're printing text
printing text to
is a line
which is printing
is printing text
control and another
and another line
another line further
line further down
further down doing
down doing exactly
the same job
same job where
job where there
where there were
there were no
were no line
no line breaks
do in this
section is determine
is determine the
determine the position
the position to
position to print
to print to
print to set
set it and
it and then
then to get
the value after
value after it's
after it's been
it's been printed
graphics set position
set position command
position command to
to print printing
print printing the
printing the text
the text and
text and then
and then getting
then getting the
the position and
position and storing
and storing the
storing the values
values in the
in the global
we'll do exactly
same logic in
section here which
here which handles
which handles where
handles where there
where there are
are no line
So that should
that should complete
should complete this
complete this function
function for printing
for printing text
is one further
one further change
further change we'll
change we'll need
the user loads
user loads a
loads a new
a new HTML
new HTML file
HTML file they
file they may
they may well
well be loading
be loading it
loading it into
into a tab
a tab which
tab which had
which had a
had a file
a file before
need to reset
to reset those
reset those X
Y coordinates back
coordinates back to
back to zero
As when the
new HTML page
HTML page we
page we call
call the clear
graphics control command
is a logical
a logical place
logical place to
place to put
put this piece
we are resetting
are resetting the
resetting the global
X and global
and global Y
global Y values
Y values to
values to zero
we do our
do our final
our final testing
final testing there's
testing there's one
there's one further
to make when
make when the
the user closes
user closes a
closes a tab
As in our
in our previous
our previous video
previous video we
video we were
we were doing
were doing a
doing a ReDim
a ReDim preserve
ReDim preserve command
preserve command to
command to read
to read dimension
read dimension arrays
dimension arrays every
arrays every time
every time the
the user removed
user removed a
function of the
of the very
the very small
small dialogue that
dialogue that handles
that handles the
handles the closed
the closed tabs
piece of logic
of logic that
logic that we'll
that we'll need
is a logic
a logic which
logic which handles
which handles clicking
on the closed
the closed tab
closed tab button
in here this
where the arrays
the arrays are
arrays are re-dimensioned
These two lines
of code need
code need to
need to come
to come out
tab selected test
selected test up
test up here
up here needs
here needs to
to be changed
be changed to
changed to test
to test on
test on the
on the max
the max tab
max tab constant
So with all
more to see
we've fixed all
fixed all the
all the problems
Well if we
if we drag
we drag in
drag in page
in page 3
page 3 we
3 we can
getting the page
the page 3
page 3 header
3 header, the
image and the
and the rest
in page 2
page 2 on
2 on top
top of it
of it it
it it displays
it displays quite
displays quite happily
And let's add
let's add a
a new page
new page and
page and drag
in page 1
page 1, add
now see it's
see it's supporting
it's supporting HTML
supporting HTML files
HTML files with
files with both
with both images
both images and
images and no
and no images
no images in
images in place
the very beginnings
very beginnings of
beginnings of image
of image handling
We're not at
not at the
the moment supporting
moment supporting any
supporting any additional
any additional attributes
additional attributes, for
for example height
example height and
height and width
and width on
width on the
on the image
But we'll do
by adding browser
adding browser history
have done in
done in previous
previous videos, the
of this video
this video will
video will cover
will cover fixing
cover fixing bugs
fixing bugs or
bugs or problems
or problems that
problems that have
that have occurred
have occurred from
occurred from the
from the previous
the previous video's
previous video's code
The second part
second part of
of the video
the video will
video will involve
will involve enhancing
involve enhancing the
enhancing the application
the application further
Today's enhancement is
enhancement is going
be the addition
addition of browser
of browser history
user can currently
can currently access
currently access up
access up to
10 tabs on
the browser, and
and I want
I want each
want each of
these tabs to
tabs to have
to have its
have its own
its own history
to move backwards
move backwards and
backwards and forwards
and forwards in
forwards in the
in the history
So firstly let's
firstly let's have
at the bug
the bug we've
bug we've discovered
we've discovered in
discovered in the
we open up
open up two
up two additional
two additional tabs
additional tabs, so
have three tabs
three tabs on
and we drag
of the pages
And we'll drag
we'll drag in
in page two
page two, and
to the final
the final tab
final tab we'll
tab we'll drag
in page one
now have three
three tabs, each
each populated with
populated with a
a different webpage
demo page two
page two, the
the middle tab
middle tab, and
we right-click and
right-click and close
and close the
the tab, this
this should leave
should leave demo
leave demo page
demo page three
page three and
three and the
and the first
the first demo
first demo page
demo page enabled
Which it appears
it appears to
appears to do
to do, however
however if we
click on demo
on demo page
demo page, it's
it's showing page
showing page two
So it has
it has not
has not correctly
not correctly deleted
correctly deleted page
deleted page two
And we've lost
we've lost page
lost page one
So that's a
that's a bug
a bug we
bug we need
need to fix
to fix in
fix in today's
in today's work
before we get
we get into
get into the
the code, let's
look at how
at how we're
how we're going
going to design
to design this
design this browser
this browser history
Now in order
order to design
design this history
this history, we
at our tabs
have in total
in total 10
total 10 tabs
10 tabs that
actually use, from
from tab one
tab one to
one to tab
to tab number
tab number 10
There is an
is an 11th
an 11th tab
11th tab, but
but that's purely
that's purely for
purely for adding
for adding additional
adding additional pages
So while we
while we have
we have 10
have 10 tabs
10 tabs, we
need to keep
to keep a
keep a separate
a separate history
separate history for
history for each
tab one all
one all the
way to tab
to tab 10
So how many
how many histories
many histories do
histories do we
do we want
want to keep?
to keep? Let's
keep? Let's start
Let's start with
start with a
with a list
list of 10
of 10 histories
10 histories per
histories per tab
So each tab
each tab will
tab will maintain
will maintain a
maintain a historical
a historical list
historical list of
list of the
of the 10
the 10 last
10 last pages
last pages visited
pages visited by
visited by the
user can put
number of pages
of pages and
pages and then
use the forward
the forward and
forward and back
and back buttons
back buttons to
buttons to go
back and forward
and forward in
forward in that
in that history
they have only
have only put
only put in
put in three
in three pages
three pages, then
then they can
they can go
can go no
no further forward
further forward than
forward than the
than the third
the third page
But they can
can go all
the way back
way back to
So this list
this list will
will be kept
be kept separately
kept separately for
separately for each
So having 10
having 10 tabs
10 tabs and
tabs and 10
and 10 histories
10 histories, we
we will keep
will keep a
keep a total
a total of
total of 100
of 100 URLs
100 URLs in
URLs in our
in our history
our history log
let's now have
we can implement
can implement this
implement this design
In an application
an application, the
the current bug
current bug involves
bug involves the
involves the deletion
the deletion of
deletion of a
of a tab
This is handled
is handled in
handled in its
in its own
its own form
the dialog which
dialog which handles
which handles the
handles the tab
the tab click
is actually deleted
And while the
while the tab
is actually being
actually being deleted
being deleted, the
the problem occurs
problem occurs when
occurs when we
when we try
we try to
try to click
on another tab
The wrong details
wrong details are
details are being
are being shown
is because we're
because we're not
we're not removing
not removing the
removing the information
the information from
information from one
from one of
of the arrays
number of arrays
of arrays within
arrays within the
application which are
which are global
are global, and
be adding to
adding to those
to those arrays
those arrays today
The issue resolves
issue resolves around
resolves around the
around the global
global array which
array which is
which is holding
is holding the
As we've deleted
we've deleted the
need to delete
delete the entry
the URL global
URL global array
creating a history
a history for
history for all
the tabs, we're
going to wrap
to wrap this
wrap this up
this up in
in a common
function to remove
to remove tab
remove tab history
we'll be calling
be calling it
calling it in
section here in
in the w
the w command
w command section
command section when
section when the
when the close
tab button is
function called remove
called remove tab
tab history whose
history whose task
whose task in
task in life
in life it
life it will
be to remove
to remove the
remove the tab
the tab history
tab history and
history and cure
and cure this
cure this issue
our new remove
new remove tab
tab history function
history function, taking
taking its single
its single parameter
is the tab
user for deletion
is to delete
delete the current
the current URL
current URL from
URL from the
that entry in
the array and
array and shuffle
all the other
the other entries
other entries up
entries up one
up one to
one to fill
fill the gap
And the last
the last entry
last entry in
the array will
array will be
a zero end
zero end string
end string, which
we try rerunning
try rerunning our
rerunning our application
now and dragging
and dragging in
dragging in pages
in pages, and
we'll create two
create two additional
two additional pages
additional pages, and
we will drag
will drag in
drag in a
in a page
a page two
page two and
two and a
and a page
a page one
have a page
page three, a
If we delete
we delete page
delete page two
two and go
back to page
to page one
page one, we
we are now
now correctly holding
correctly holding the
holding the values
the values for
values for page
for page three
three and page
and page one
And page two
page two is
two is now
is now no
now no within
no within sight
So we've cured
cured that single
that single bug
we can push
can push on
push on and
on and add
and add the
add the code
code to our
our application to
application to allow
to do browser
do browser histories
So once more
once more, back
So as I
said earlier, we're
be adding some
adding some more
some more global
more global arrays
is to keep
of the URL's
the URL's history
URL's history for
new global arrays
global arrays, one
one called URL
called URL history
URL history and
history and one
and one called
one called latest
called latest slot
The URL history
URL history, as
probably guess, is
is to maintain
to maintain history
maintain history for
second one, called
latest slot, is
an array to
array to hold
hold the latest
the latest slot
latest slot number
slot number for
number for each
That way, if
if there are
there are always
are always three
always three entries
three entries, the
the value for
value for the
the tab will
tab will be
will be three
be three, as
as it's the
it's the latest
the latest entry
let's now dimension
now dimension these
dimension these in
these in our
in our PB
our PB main
our new arrays
URL history array
history array is
two-dimensional array, comprising
comprising the maximum
of tabs and
tabs and a
and a new
new constant called
constant called maximum
called maximum history
And the latest
latest slot is
slot is a
a single dimension
single dimension array
dimension array for
So the maximum
amount of history
of history we're
history we're going
to do for
do for this
this particular browser
particular browser is
browser is ten
So a user
a user will
user will in
will in theory
in theory be
theory be able
able to go
go back ten
back ten pages
ten pages in
pages in any
in any tab
new constant at
the top, called
called max history
max history, and
value of ten
Storing these as
these as constants
as constants means
constants means that
means that should
that should you
should you require
you require to
require to increase
to increase these
increase these numbers
these numbers, it's
it's very easy
easy to do
do at the
beginning of your
of your code
have two browser
two browser buttons
browser buttons on
the dialog, one
it to go
go back a
back a page
a page and
page and one
one to go
to go forward
go forward, we
know what the
what the current
the current slot
current slot number
slot number is
number is for
is for each
So we've created
created a new
variable called current
called current slot
is the currently
currently selected history
selected history slot
history slot on
slot on the
we will handle
will handle when
the user drops
user drops a
drops a file
a file onto
file onto the
at the drop
the drop files
drop files event
files event, so
after we have
have populated the
populated the global
global array for
array for URLs
for URLs, we're
increment the latest
latest slot value
slot value, based
on the page
page number selected
number selected by
And we'll also
we'll also store
also store the
store the new
the new URL
new URL as
URL as the
as the latest
the latest webpage
latest webpage for
webpage for this
for this tab
that by creating
by creating a
brand new function
On that new
new function, we're
to call storeURLHistory
call storeURLHistory, taking
the page or
page or tab
or tab number
and the URL
the URL string
first create this
up the current
current slot by
slot by looking
at the global
for the latest
latest slot and
slot and passing
and passing it
it the page
us the current
current slot for
slot for this
this particular tab
then using that
using that value
that value and
value and feeding
and feeding it
feeding it in
it in to
to our global
for the URL
two parameters of
and the current
we're making that
making that equal
that equal to
the URL which
URL which the
user has dropped
has dropped on
since the user
has dropped this
dropped this in
this in, I've
I've checked with
checked with other
with other browsers
When a user
a user actually
user actually loads
actually loads one
loads one of
of these pages
these pages in
pages in, anything
anything above this
above this in
the history is
history is blanked
is blanked out
got a small
a small for
small for next
next loop to
loop to look
to look from
look from the
from the current
current slot plus
slot plus one
plus one to
of the history
the history and
history and making
and making everything
making everything after
everything after that
after that blank
to reset the
reset the back
the back or
back or forward
or forward buttons
Currently in our
our code, the
the back and
and forward buttons
forward buttons are
buttons are automatically
are automatically disabled
But these buttons
buttons will have
have to be
to be enabled
be enabled based
enabled based on
on the information
the information the
information the browser
the browser holds
user is on
the very most
very most recent
most recent webpage
recent webpage of
webpage of this
particular tab, then
then the forward
the forward button
forward button will
button will be
will be disabled
be disabled and
disabled and the
and the back
the back button
back button will
will be enabled
is going backwards
going backwards in
backwards in the
the history, then
then once they
once they get
they get to
first entry for
entry for this
then the back
and the forward
are additional pages
additional pages the
pages the user
user can view
So that's another
that's another new
to create, to
set the back
So the logic
the logic within
logic within this
be quite straightforward
If the URL
URL history pointed
history pointed to
pointed to plus
to plus one
plus one is
one is equal
equal to an
an empty one
empty one string
one string, then
then the next
the next slot
next slot is
slot is blank
is blank and
blank and we
we can turn
can turn off
turn off the
off the forward
we enable the
enable the forward
the control, disable
disable and enable
and enable commands
If the current
current slot is
slot is slot
is slot number
slot number one
number one, then
then there's only
there's only one
only one slot
one slot, so
so at that
that point we
point we can
off the back
enable the back
So that's the
that's the logic
the logic for
logic for the
for the backward
the backward and
backward and forward
determine whether our
whether our code's
our code's going
code's going to
be working correctly
working correctly or
correctly or not
or not, we
put some debug
some debug code
debug code in
the things that
things that you
that you can
do with Power
with Power Basic
Power Basic for
Basic for Windows
for Windows is
Windows is to
use the text
will display a
display a text
a text window
text window which
window which you
you can send
can send information
send information to
And this can
can be turned
be turned off
turned off later
off later, once
once the program
the program goes
program goes into
goes into production
called display history
function will take
will take a
take a single
is the page
page number we're
number we're on
on the current
And within this
this function, I'm
I'm creating a
creating a static
static variable called
variable called Win
be the Windows
the Windows handle
Windows handle of
handle of this
If the window
the window is
window is zero
using a text
text window command
window command to
command to open
open a brand
brand new text
new text debug
text debug box
we're calling that
calling that URL
that URL history
we're clearing the
clearing the value
the value out
value out within
out within that
within that text
that text box
then we're printing
we're printing out
printing out the
out the tab
then we're doing
doing a loop
a loop to
loop to print
to print out
print out all
out all the
all the history
the history for
history for that
that particular tab
particular tab coming
tab coming from
now is find
is find some
find some way
some way of
of actually triggering
actually triggering the
triggering the call
call to this
this function so
function so we
we can display
can display the
display the history
we have events
have events for
events for the
for the back
back button, the
forward button and
and the home
the home button
We're not commonly
not commonly using
commonly using the
using the home
home button and
button and won't
and won't be
won't be populating
be populating it
populating it within
it within this
within this video
to put our
put our code
the event for
event for this
for this button
This is purely
is purely for
purely for debug
the call for
call for display
for display history
We are first
are first getting
first getting the
getting the tab
been selected, putting
putting that into
that into the
into the page
page number, which
which passes as
passes as a
as a parameter
a parameter to
parameter to our
So at any
any point we
we can press
can press that
press that home
that home button
button and get
and get a
get a message
a message displayed
message displayed on
to show us
show us what
us what the
what the history
the history of
history of each
the tabs is
now and click
on the home
the home page
home page, we
get a debug
a debug coming
debug coming up
coming up, giving
us a list
history for this
the moment it
moment it has
it has no
has no history
So the debug
the debug code
debug code is
code is working
is working fine
code and add
and add in
in a few
a few more
few more functions
user actually deletes
actually deletes one
deletes one of
the tabs, then
have to clear
clear the history
the history out
history out for
out for that
for that tab
need a clear
a clear history
clear history for
history for tab
for tab function
here is that
is that new
it's nothing particularly
nothing particularly special
It then runs
then runs through
runs through the
through the global
array for URL
for URL history
history and erases
and erases each
erases each entry
each entry for
entry for that
that particular page
particular page number
sets the current
slot number in
number in the
in the latest
latest slot array
slot array to
array to zero
to zero, and
we're now disabling
now disabling the
disabling the back
As I mentioned
mentioned earlier, we're
to make an
make an addition
an addition to
to that new
function we added
we added to
added to remove
Since we've added
added new arrays
new arrays, we're
have to handle
to handle purging
handle purging those
purging those as
those as well
So first we're
first we're doing
we're doing an
doing an array
an array delete
array delete on
delete on the
on the latest
slot array, removing
removing the current
current tab selected
next loop from
loop from the
from the tab
tab selected to
selected to the
tabs and from
and from one
from one to
to the max
the max history
to copy down
copy down values
down values in
history array so
array so that
so that all
that all the
all the entries
the entries for
entries for the
for the tabs
the tabs above
tabs above are
above are actually
are actually copied
actually copied down
copied down by
down by one
by one tab
then the very
very last entry
last entry is
entry is to
is to purge
to purge the
purge the last
last tab to
tab to ensure
that it is
it is indeed
is indeed blank
So one other
one other small
other small change
small change I
change I want
code is in
Within here, if
if the program
the program decides
program decides that
decides that the
that the HTML
the HTML is
HTML is not
is not formatted
not formatted correctly
formatted correctly, it
it prints out
prints out the
out the words
the words 'invalid
words 'invalid HTML
'invalid HTML formatting'
It also prints
also prints all
prints all of
the HTML to
HTML to that
to that control
to take that
take that out
that out just
out just in
in case the
case the user
the user drags
user drags something
drags something like
something like a
like a JPEG
a JPEG or
JPEG or an
or an EXE
an EXE into
EXE into the
into the window
to display all
display all that
all that on
So all the
all the new
the new functions
new functions we've
functions we've created
we've created, one
one of them
of them is
them is clear
is clear history
put this in
this in at
in at one
at one point
one point in
code where the
user selects a
selects a new
plus tab, they're
they're adding a
adding a brand
that the data
the data for
data for that
tab is cleared
is cleared out
the section where
section where the
the tab selection
tab selection has
selection has been
has been changed
add a call
our clear history
for tab, passing
it the tab
tab number, the
this will clear
will clear out
clear out any
any data sitting
data sitting in
the array for
user picks some
picks some other
other tab, then
current slot based
slot based on
based on that
the URL from
from the URLs
to amend that
amend that slightly
that slightly, and
reset the forward
So now we're
now we're picking
current slot from
slot from the
from the latest
setting the URL
from the URL
calling a new
a new set
new set back
set back and
forward buttons function
buttons function to
set the disable
the disable or
disable or enable
or enable properties
enable properties on
properties on those
on those two
those two buttons
logic in the
in the back
forward buttons, so
the user decides
user decides to
decides to click
click on them
on them, the
application will actually
will actually do
actually do something
the moment, there
is no code
no code whatsoever
code whatsoever except
whatsoever except a
except a message
box in both
in both of
of these events
of all, to
a page, we
tab handle using
handle using the
the tab gate
tab gate select
gate select command
set the current
slot for that
that tab by
tab by pulling
by pulling back
pulling back from
global array the
array the value
the value held
within the latest
can then decrement
then decrement that
decrement that value
that value by
by one, and
URL history the
history the value
value that is
that is obtained
is obtained is
obtained is not
is not blank
not blank, then
the page to
page to the
box on the
the URL and
URL and then
and then call
then call a
call a common
common function or
function or enter
or enter the
enter the HTML
store the current
number in our
in our latest
our latest slot
we can enable
can enable the
And this should
this should complete
should complete the
complete the logic
logic for clicking
on the back
And next, we
very similar for
similar for the
for the forward
forward button when
button when it
when it becomes
it becomes clicked
out the current
need to increment
to increment that
increment that value
that value, and
the URL is
URL is not
then again, we
the page, setting
the dialog, calling
calling the render
HTML function and
function and storing
storing the current
slot number within
number within the
And then setting
setting the back
The only other
only other change
other change we
we need make
need make is
make is when
is when the
the user enters
user enters a
enters a URL
a URL in
URL in that
in that text
when you press
you press the
press the enter
the enter button
enter button, it
will then call
then call the
call the id
ok event within
callback function or
function or event
or event handler
which is down
is down here
And what we
here is much
is much the
much the same
same as we've
as we've done
we've done further
done further up
further up in
increment the slot
the slot number
slot number, store
URL and render
and render the
we are advancing
are advancing the
advancing the latest
slot array, storing
history and re-rendering
and re-rendering the
re-rendering the URL
we should have
should have completed
have completed all
completed all the
all the coding
do a little
bit of testing
is our browser
our browser, and
drag in some
in some of
some of our
of our webpages
created a webpage
a webpage 4
webpage 4 to
4 to give
give us more
us more pages
more pages to
pages to work
to work with
in page 4
page 4, then
then page 3
page 3, then
then page 2
page 2, and
then finally page
finally page 1
So we should
have a history
a history of
history of 4
of 4 pages
4 pages on
pages on this
click on our
on our little
our little debug
little debug button
debug button and
button and have
a look, we
we do indeed
do indeed have
indeed have 4
have 4 entries
The most recent
most recent one
recent one is
one is page
is page 1
We have page
have page 2
page 2, page
page 3 and
3 and page
and page 4
back button is
is currently enabled
If we press
we press the
press the back
back button, it
it should take
should take us
take us to
us to page
to page 2
then to page
to page 3
3 and finally
and finally page
finally page 4
And on page
on page 4
page 4, you
you cannot go
cannot go any
But you can
you can go
can go forward
go forward again
forward again to
again to page
page 3, page
2 and page
and page 1
page 1 when
1 when the
is now disabled
for tab number
we do the
same for a
for a second
a second tab?
second tab? So
tab? So for
for the second
second tab, we'll
we'll put the
put the values
in the other
the other way
other way round
We'll go for
go for page
for page 1
page 1, then
page 2, then
at the history
for tab 2
tab 2, tab
tab 2 is
2 is showing
is showing pages
showing pages 1
pages 1, 2
3 and 4
So the history
the history appears
history appears to
be working well
add a third
a third and
third and final
and final page
in page number
page number 2
and forward for
forward for each
the tabs, showing
showing the page
the page it
page it currently
it currently has
currently has as
has as current
If we then
we then attempt
attempt to delete
delete the second
second tab, it
it should delete
should delete, and
and page 2
page 2 is
2 is now
now showing as
showing as the
as the second
So that appears
that appears to
is to fix
fix a bug
added more global
global arrays to
arrays to allow
user to have
to have browser
have browser history
browser history for
the 10 tabs
10 tabs, allowing
allowing them up
them up to
to 10 pages
10 pages in
pages in the
the browser history
There is of
course a great
deal more to
more to do
to do, but
web browser by
browser by adding
by adding support
adding support for
support for hyperlinks
for hyperlinks on
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
ability to link
to link to
link to other
to other files
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
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
support a number
of tags within
tags within the
the HTML document
Today we'll be
we'll be adding
be adding support
support for the
for the Anchor
the Anchor tag
Anchor tag to
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
this new Anchor
new Anchor tag?
Anchor tag? The
tag? The first
at is when
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
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
to be stored
be stored within
stored within the
the application so
application so that
user clicks with
clicks with the
with the left
mouse button anywhere
button anywhere on
anywhere on the
control we can
can determine whether
whether the user
has indeed clicked
clicked on an
on an image
an image which
image which has
has an underlying
an underlying Anchor
underlying Anchor linking
Anchor linking it
linking it to
it to another
to another document
create a user
defined type called
type called Image
called Image Tag
This will store
will store the
right hand corners
hand corners of
corners of any
of any of
of these linked
these linked zones
linked zones and
zones and we
create a global
store this information
our new type
new type called
type called udt
called udt image
udt image tag
This has a
It stores an
stores an x
y coordinate for
coordinate for the
for the top
It also stores
also stores the
stores the bottom
corner of that
of that image
us to define
define the area
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
is the URL
URL that once
that once the
on this zone
this zone we
zone we will
we will link
will link to
link to and
to and we
we have dimensioned
have dimensioned a
dimensioned a global
global array called
array called URLs
array of this
of this user
So having this
having this global
this global array
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
to allow in
allow in this
in this array?
this array? How
array? How many
How many zones
many zones are
zones are we
to click on?
click on? So
on? So we've
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
our HTML document
Should you find
you find 100
find 100 links
100 links is
links is too
is too small
too small you
small you can
always increase the
increase the value
of the constant
the constant and
constant and within
within our pb_main
pb_main function we
function we can
we can dimension
can dimension this
dimension this array
have our global
global array of
array of URLs
of URLs dimensioned
URLs dimensioned for
dimensioned for the
we have somewhere
have somewhere to
somewhere to store
store the information
information we next
we next need
next need to
pick the information
the information up
information up from
to do let's
do let's launch
let's launch the
launch the browser
the browser as
browser as it
currently stands and
stands and we're
going to drag
to drag our
drag our index
our index document
index document into
document into that
into that browser
that browser and
browser and as
have the four
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
handle the anchor
anchor tag when
tag when the
when the document
the document is
document is read
tags function to
function to add
support for anchor
for anchor tags
is our render
our render HTML
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
our list currently
list currently is
currently is the
is the image
image tag which
tag which is
which is testing
is testing to
testing to ensure
to ensure we're
ensure we're inside
the body of
body of the
of the document
the document before
document before we
before we display
we display the
let's first put
first put a
couple of case
of case statements
case statements in
statements in to
in to handle
handle the beginning
the beginning and
beginning and the
and the end
of the anchor
the anchor tags
are the two
two new tags
new tags the
tags the beginning
anchor tag and
set a new
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
a tag and
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
and as we're
as we're handling
we're handling clicks
handling clicks on
clicks on images
on images today
images today we
today we can
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
So since the
since the value
value of ref
of ref tag
ref tag is
tag is true
is true we
true we know
we know we're
know we're inside
we're inside a
inside a reference
a reference tag
within the block
the block which
block which is
is the anchor
store the link
the link which
link which has
on the URL
this point we
point we need
to have already
have already stored
already stored the
stored the value
URL variable and
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
we're looking specifically
looking specifically for
for the equal
the equal sign
equal sign and
sign and we're
and we're taking
taking the second
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
the moment this
moment this should
should give us
us the direct
the direct path
direct path, albeit
albeit in the
the same directory
same directory, to
wish to link
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
the code our
code our strURL
our strURL variable
strURL variable will
So where are
where are we
populate the details
the details of
details of this
of this image?
this image? The
image? The display
The display image
display image command
image command is
one that loads
that loads the
the image up
image up from
up from file
to pass a
pass a user
type to that
to that to
that to allow
us to pass
pass back the
back the x
of the top
corners of the
of the rectangle
use a new
local variable which
defined type we
type we declared
we declared at
declared at the
be a local
variable to this
the function and
function and declare
and declare the
declare the local
the local variables
local variables we're
variables we're going
be needing to
needing to do
to do all
do all this
our new variables
using the ref
the ref tag
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
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
url in the
in the link
the link and
link and we're
using another variable
another variable which
a long as
long as the
as the last
the last populated
last populated url
will have up
have up to
10 tabs usable
tabs usable within
usable within the
within the browser
browser and we
and we load
we load each
load each one
each one up
one up dynamically
up dynamically each
dynamically each time
on a tab
Therefore we need
track of a
of a number
of these URLs
these URLs as
URLs as the
user can step
can step back
step back and
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
well as resetting
as resetting this
resetting this tag
this tag we
tag we need
need to pass
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
on and put
put the rest
If ref tag
is true then
true then we're
then we're inside
inside a anchor
The url has
url has already
has already been
already been populated
been populated so
populated so we
increment the pointer
to our url
our url position
determine the place
the place in
in the urls
populate the link
the link from
link from the
Inside our user
our user defined
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
the array of
array of user
defined types based
types based on
the url long
url long variable
to the display
we have changed
have changed the
changed the number
of parameters it's
parameters it's now
it's now accepting
until now it's
now it's taken
it's taken only
taken only three
only three parameters
parameters the dialog
dialog handle the
handle the attribute
attribute string and
string and the
the tab that
tab that has
Now we're passing
we're passing an
passing an additional
an additional value
additional value which
value which is
further down this
down this code
this code we
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
image width and
and the image
the image height
image height which
height which are
are the key
the key bits
key bits of
bits of information
of information we
information we need
store in our
in our user
So after our
after our copy
our copy command
copy command we
we can store
can store the
store the location
using the prefix
command to prefix
to prefix the
prefix the name
of our user
defined type before
type before each
before each of
of the elements
y coordinates using
coordinates using our
using our global
our global x
storing the bottom
hand corner by
corner by taking
by taking the
taking the global
the global and
global and adding
and adding on
on the width
width of that
that image and
the bottom y
bottom y coordinate
coordinate is the
is the global
the global y
global y coordinate
y coordinate plus
coordinate plus the
plus the height
have now stored
now stored the
stored the x
and y location
y location of
location of both
of both the
both the top
the top and
top and left
and left and
corners of our
our image and
image and this
this is passed
is passed back
passed back to
calling routine to
routine to be
to be passed
be passed into
passed into the
into the global
that we've stored
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
they click with
click with the
mouse button it
button it will
it will load
will load up
Well we've already
we've already got
already got a
got a function
a function which
function which allows
us to right
to right click
control we merely
we merely need
merely need to
add to that
to that the
that the ability
ability to trap
to trap left
trap left clicks
left clicks as
clicks as well
as well and
well and that
that is within
within the graphic
the graphic proc
graphic proc function
is our graphic
our graphic proc
which is called
is called when
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
up to handle
handle the right
mouse button at
add a condition
a condition for
condition for the
for the left
statement to handle
When that button
that button is
button is released
is released we
released we will
populate the URL
the URL with
URL with an
with an empty
length string and
string and at
moment we will
display a message
message box on
screen to prove
to prove that
prove that we've
we've actually trapped
actually trapped the
trapped the left
now and if
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
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
function called isLink
parameters the x
the x the
x the y
y coordinate and
coordinate and the
URL is going
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
an embedded link
I said this
said this function
take the three
the return value
return value which
value which will
be a URL
loop here to
here to step
through each element
of the global
the global URLs
global URLs array
is quite a
quite a simple
a simple function
So for each
for each element
element of this
of this global
global array we're
array we're testing
testing the x
y coordinates against
coordinates against the
against the values
the values stored
values stored within
than the top
the top x
top x but
x but less
but less than
than the bottom
the bottom x
bottom x and
the top y
top y and
y and less
and less than
is all true
all true then
true then we
are indeed within
indeed within a
within a zone
a zone which
zone which holds
which holds a
holds a link
URL from that
from that by
using the trim
the trim command
trim command to
to trim it
trim it down
it down from
down from the
from the extra
the extra spaces
extra spaces at
spaces at the
then return the
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
value returned is
returned is false
us a mechanism
by which when
which when the
can determine if
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
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
link to the
let's create a
new function which
function which can
which can do
do that for
for us and
us and we'll
that function process
function process a
process a URL
new function process
a URL taking
URL taking its
the URL itself
be using some
using some common
some common code
common code we
determine the existing
the existing path
existing path of
the URL we're
URL we're currently
get that from
text box which
which is on
Eventually we're going
have to support
to support documents
support documents which
documents which are
which are on
are on a
on a web
a web server
web server as
server as opposed
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
go through a
through a number
number of iterations
of iterations as
iterations as we
we move down
move down that
down that path
that path but
path but for
take the value
the value that's
value that's in
that's in the
the URL at
URL at the
the path relative
path relative to
relative to where
where the existing
the existing URL
existing URL actually
URL actually is
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
wide web and
web and as
we're handling everything
handling everything locally
everything locally we're
locally we're taking
taking the last
of the end
of the path
the path replacing
path replacing that
replacing that with
with the file
file we've just
we've just loaded
just loaded up
loaded up the
URL and we're
and we're launching
we're launching from
launching from there
using an inbuilt
inbuilt function in
function in our
in our file
our file handling
handling routines library
routines library which
library which is
is called start
called start range
start range parse
takes the path
path the delimiter
the delimiter and
delimiter and the
the end element
have determined the
determined the end
end element using
element using the
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
up with a
with a path
a path which
path which is
the folder but
folder but not
but not the
not the file
the file itself
We then add
then add on
add on the
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
this far we
far we now
series of steps
of steps to
steps to actually
actually set values
set values on
values on the
dialogue and to
and to handle
handle the population
population of our
are first going
first going to
graphics control routine
control routine and
routine and then
the text at
text at the
dialogue to be
be the URL
URL we're about
about to link
can then store
global array by
array by determining
by determining the
determining the tab
user has currently
has currently selected
currently selected and
selected and using
and using that
using that to
that to store
to store it
it in the
our final stage
final stage is
stage is to
is to increment
slot array and
array and then
and then store
history and then
then finally render
finally render the
the HTML itself
HTML itself using
itself using our
using our existing
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
this far how
far how close
how close is
close is our
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
text for the
for the href
the href on
href on the
we go over
go over page
over page one
page one and
one and click
on it we
it we are
are indeed getting
indeed getting a
getting a link
link to page
go to page
to page two
page two we're
two we're getting
we're getting page
getting page two
However we need
need to get
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
So printing to
printing to the
control of plain
of plain text
plain text is
text is done
is done in
done in a
function called print
This determines the
determines the position
to print and
print and prints
and prints text
prints text using
text using the
the graphics print
graphics print command
are storing the
storing the value
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
an image source
image source command
source command then
command then it's
then it's an
it's an embedded
to test and
test and bypass
and bypass that
bypass that if
that if that's
is our test
our test for
for the embedded
the embedded link
string command to
command to look
to look for
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
greater than zero
than zero then
zero then it's
position we are
we are on
are on screen
We can print
can print a
print a blank
a blank line
blank line and
line and we
can then repopulate
then repopulate the
repopulate the global
drag in our
our index page
index page and
page and we
are now missing
now missing the
missing the text
the text we
text we had
But the links
the links will
links will still
will still work
we can have
history and we'll
and we'll see
we'll see we
have our index
page and page
So all appears
all appears to
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
and page three
page three gives
three gives us
us page three
If however we
however we scroll
we scroll down
scroll down the
down the virtual
the virtual graphics
virtual graphics control
control and click
on page four
page four it's
four it's not
it's not giving
not giving us
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
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
clicked on page
on page four?
page four? The
four? The reason
for this is
is the graphics
control is virtual
As we scroll
we scroll up
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
of the current
the current part
current part of
of the window?
the window? So
window? So if
on page two
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
way of handling
of handling when
handling when the
has actually scrolled
actually scrolled down
scrolled down to
to a lower
a lower part
lower part of
the graphics page
code and fix
and fix that
fix that problem
So when the
user actually clicks
actually clicks on
on the left
mouse button we
button we need
y coordinates but
coordinates but we're
using a virtual
a virtual window
get the beginning
of this window
this window and
window and Power
Power Basic provides
Basic provides a
provides a graphic
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
to use two
use two new
two new variables
new variables which
our function as
have now done
us to correctly
to correctly pick
up where we
where we are
we are actually
are actually clicking
clicking on and
on and get
and get coordinate
get coordinate system
coordinate system we
system we can
actually use with
use with a
with a global
our index, we
on page one
three and if
scroll down if
down if we
page four it
four it has
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
set the location
the location back
location back to
So there's one
However the ability
ability to click
on each of
the pages is
pages is working
working quite nicely
once more back
more back to
there are several
are several places
code we could
we could probably
could probably put
probably put this
put this change
However the render
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
put this single
set up details
up details for
details for the
We do a
do a clear
a clear command
clear command, we
set the colors
the colors, we
set the phone
the phone, we
going to enter
enter a new
a new line
new line of
in here and
here and that's
that's to use
the graphic set
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
once more, bring
bring in our
index page, scroll
scroll down, select
select page four
page four and
four and go
now going back
going back to
the page which
page which is
we can link
can link to
link to each
the pages quite
pages quite successfully
quite successfully regardless
successfully regardless of
regardless of the
can make our
make our browser
our browser larger
browser larger to
to accommodate all
accommodate all four
all four links
four links and
links and we
can link quite
link quite easily
quite easily between
easily between each
between each of
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
we have trapped
have trapped the
trapped the coordinates
coordinates of in
of in order
make the anchor
the anchor link
anchor link work
link work correctly
new html command
html command, the
us to wrap
to wrap around
wrap around the
around the image
image tag and
tag and make
and make the
make the image
the image a
image a clickable
a clickable link
user when they
on this image
this image can
image can then
can then link
then link to
to the image
image and then
and then link
link to another
using this technique
this technique we
technique we can
can actually connect
actually connect together
connect together a
together a large
number of documents
of documents and
documents and as
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
deal of flexibility
more to be
to be done
be done with
done with anchors
with anchors and
anchors and links
and links in
links in general
for today, thank
to testing using
testing using the
hyperlinks on text
on text and
text and other
and other enhancements
other enhancements to
enhancements to the
to the existing
the existing code
have our experimental
our experimental browser
experimental browser set
browser set up
set up so
up so we
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
on the hyperlink
the hyperlink and
hyperlink and go
and go to
to a number
number of underlying
of underlying pages
ability to have
a text hyperlink
I've prepared a
prepared a second
a second index
second index page
index page to
page to demonstrate
to demonstrate how
how this is
what we're aiming
we're aiming for
aiming for I'm
for I'm going
use a chrome
a chrome browser
chrome browser and
browser and we're
drag this new
this new index
new index page
index page onto
page onto that
onto that browser
what we're after
The four links
four links as
links as we
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
of the underlying
the underlying hyperlinks
underlying hyperlinks, the
the mouse cursor
mouse cursor changes
cursor changes from
changes from a
from a pointer
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
going to implement
to implement that
implement that functionality
that functionality in
functionality in our
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
in the existing
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
text and a
and a graphic
graphic has no
has no underlying
no underlying hyperlink
Yet when we
when we go
we go on
the graphic and
graphic and click
it's taking us
taking us to
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
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
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
So we go
two and we
we click up
click up near
up near the
near the top
It will go
will go back
that's the first
the first bug
first bug we
function called render
called render the
HTML tags, which
is triggered each
triggered each time
time we load
we load a
load a new
make the one
the one line
one line code
line code change
code change to
change to fix
are now in
now in the
before we step
we step through
the tags within
want to reset
reset the contents
which contains the
contains the URLs
using the reset
the reset command
reset command, followed
by the name
array we wish
wish to reset
we drag our
our index onto
index onto that
onto that and
that and click
the image it
image it is
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
see that each
of the graphical
the graphical images
graphical images is
images is still
is still appearing
still appearing as
appearing as normal
the text link
the page going
page going to
going to a
new page five
page five is
five is only
is only appearing
only appearing as
appearing as text
we're not handling
not handling this
handling this particular
this particular type
type of tag
of tag just
tag just yet
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
handle this particular
type of text
of text hyperlink
tags function is
is our engine
our engine to
engine to handle
handle all HTML
all HTML tagging
look further down
further down on
down on that
on that, we'll
we'll see these
see these are
these are all
are all the
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
add some extra
some extra functionality
extra functionality to
functionality to these
to these to
these to allow
it to perform
the data inside
data inside the
inside the tag
from the index
the index to
index to HTML
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
the go to
to page five
five is not
is not currently
not currently picked
currently picked up
But we have
have a function
used to pull
to pull that
pull that information
that information back
information back called
back called get
called get tag
get tag value
tag value, which
which is exactly
is exactly what
exactly what we're
So the return
function will return
return the text
to display on
here we need
need to differentiate
to differentiate between
differentiate between the
between the graphical
the graphical image
graphical image, which
which is within
is within this
within this tag
this tag and
text which is
easy way to
look for the
for the equals
the equals sign
If it contains
it contains an
contains an equals
an equals, then
is a graphical
a graphical image
graphical image we're
attempting to show
If it does
does not contain
not contain an
contain an equals
it's not an
not an image
image source, but
but plain text
can test for
test for this
for this by
set a variable
variable to say
to say image
say image is
image is false
can be tested
be tested elsewhere
tested elsewhere in
is to reset
to reset our
reset our tag
our tag user
tag user defined
So the reset
reset command can
command can reset
can reset this
reset this user
We're incrementing the
incrementing the URL
URL itself in
itself in our
defined type, as
as the URL
the URL was
URL was picked
was picked up
picked up previously
up previously in
previously in the
this far, we
need to print
to print this
print this text
this text onto
onto the graphical
the graphical canvas
print data whose
data whose job
is to perform
change the existing
the existing print
existing print data
print data command
data command to
command to accept
to accept additional
accept additional parameters
to pass ref
pass ref tag
ref tag and
tag and we're
to pass our
pass our user
tag is either
to be true
be true or
used to store
store the hot
the hot zone
hot zone, which
the URL, just
we did for
did for the
for the graphical
to the print
the print data
print data function
data function and
function and add
and add these
add these extra
these extra parameters
the two extra
two extra parameters
extra parameters for
parameters for this
for this function
ref tag variable
tag variable and
Print data is
data is called
called from elsewhere
from elsewhere in
have to ensure
ensure that everywhere
that everywhere it's
everywhere it's called
it's called, these
these two additional
additional parameters are
parameters are included
on a couple
of extra local
extra local variables
These I'm going
to call image
call image width
width and image
and image height
We're creating these
creating these two
variables to contain
contain the width
of our text
our text hyperlink
information is needed
is needed as
needed as we
as we need
this information in
information in the
we know whether
know whether they've
whether they've clicked
they've clicked on
on a hot
a hot zone
will trigger a
trigger a call
to a hyperlink
do that, we'll
to change this
change this line
This is looking
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
embedded image or
image or a
or a hyperlink
Y positions of
positions of the
But before this
before this section
determine the height
the height and
and width of
done by testing
by testing our
testing our ref
our ref tag
If the ref
is true and
true and the
str data is
data is not
is not an
not an empty
length string, then
we know it's
know it's a
it's a text
a text URL
out the height
do this quite
using a new
a new command
new command called
command called graphics
called graphics cell
graphics cell size
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
worked out the
out the width
height of a
standard character, we
can then multiply
then multiply the
multiply the width
by the number
number of characters
adding a little
a little to
little to the
to the height
the height just
height just to
make it slightly
it slightly bigger
us the values
values we can
can now store
now store in
and Y as
Y as the
as the top
top X and
X and top
and top Y
that the width
and height for
height for the
for the bottom
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
still have to
have to declare
to declare, at
of the render
So while we're
while we're adding
we're adding this
adding this variable
this variable I'm
variable I'm going
We currently have
currently have a
have a command
a command variable
command variable that
variable that stores
that stores the
stores the current
the current command
some of these
of these tags
these tags are
tags are going
to be nested
be nested, we'll
what the previous
the previous command
previous command was
the last command
we'll also create
also create a
a couple more
couple more boolean
more boolean variables
One to keep
of the fact
the fact is
fact is it
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
inside a paragraph
a paragraph or
paragraph or not?
or not? This
not? This will
us more flexibility
more flexibility for
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
of code we're
code we're picking
Before we populate
we populate this
populate this we'll
this we'll want
last command variable
command variable we
Now that that
that that is
that is stored
is stored we
stored we can
quite happily go
happily go ahead
ahead and populate
and populate the
populate the command
see we make
we make other
make other calls
other calls to
to amend each
amend each call
each call to
to this print
this print data
data function to
to add these
Additionally in the
in the paragraph
the paragraph section
paragraph section we're
setting the paragraph
the paragraph boolean
be true since
true since we
since we know
we know at
know at this
point we are
are inside a
And here are
are our extra
our extra parameters
extra parameters to
data function call
And we've now
added the population
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
drag in index
in index 2
now got go
got go to
to page 5
page 5 at
5 at the
However is it
it a hyperlink?
a hyperlink? If
hyperlink? If we
on it it's
it it's indeed
it's indeed taking
indeed taking us
we've achieved the
to have hyperlinks
have hyperlinks which
hyperlinks which go
which go directly
go directly to
directly to the
to the page
the page regardless
page regardless if
regardless if they
if they are
they are images
are images or
images or text
However what we
need to tackle
to tackle next
tackle next is
next is we
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
have a callback
a callback function
callback function which
function which handles
handles the mouse
the mouse movement
mouse movement on
movement on the
screen to pick
up the left
and right mouse
right mouse clicks
is the graph
the graph proc
graph proc function
are currently handling
currently handling two
handling two events
mouse button going
button going up
going up and
up and the
and the right
to handle a
handle a new
new event in
event in here
to handle mouse
handle mouse move
will trigger every
trigger every time
time the mouse
the mouse is
mouse is actually
is actually moved
variable to allow
us to store
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
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
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
is a hot
hot zone containing
zone containing a
containing a hyperlink
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
it's not populated
not populated we're
populated we're then
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
set the cursor
the cursor to
cursor to that
to that particular
that particular one
we're now displaying
now displaying index
displaying index two
move the mouse
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
it changes to
changes to a
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
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
we are over
are over the
over the hyperlink
have successfully implemented
successfully implemented the
implemented the ability
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
have not done
not done yet
done yet is
yet is to
is to change
text on our
on our text
text hyperlink to
hyperlink to a
different color and
color and mark
it as underlined
This would normally
would normally indicate
normally indicate to
user that this
is a text
We won't do
won't do that
in this video
this video we'll
video we'll do
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
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
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
one and page
page two links
two links appear
links appear below
appear below each
below each other
If we take
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
the same paragraph
this and copy
and copy this
copy this back
this back into
into our browser
our browser we'll
browser we'll see
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
of these images
these images which
images which is
is quite odd
quite odd as
odd as it
as it has
it has what
has what appears
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
do in our
our browser is
browser is to
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
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
will remember earlier
remember earlier on
earlier on we
on we made
we made some
made some changes
some changes to
to the paragraph
paragraph start and
start and paragraph
and paragraph end
paragraph end tags
variable called paragraph
called paragraph either
paragraph either to
either to be
use this to
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
if the last
last command was
command was the
was the closing
closing a tag
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
the case then
case then we
we can reset
can reset the
reset the global
global x coordinate
x coordinate to
coordinate to be
and the calculation
the calculation of
calculation of the
of the y
y coordinate will
coordinate will involve
will involve the
involve the current
the current value
current value plus
value plus the
plus the bottom
bottom y minus
y minus the
minus the top
the location where
location where the
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
pass this to
function which displays
which displays the
displays the images
is an additional
an additional variable
additional variable we're
variable we're adding
And having passed
having passed this
passed this variable
this variable to
can test it
test it within
within the function
is our function
function and we'll
and we'll add
we'll add on
this extra parameter
down the function
function where we're
where we're updating
we're updating the
updating the global
the global position
global position we
position we can
can take out
graphics get position
get position command
position command as
command as this
is determined further
determined further up
further up anyway
So this line
code is no
no longer needed
test the in
in paragraph tag
If the in
paragraph tag is
width of our
our graphical image
graphical image to
If it is
it is false
is false then
false then we're
then we're resetting
we're resetting the
resetting the x
coordinate to 0
y coordinate can
coordinate can be
can be the
be the y
with that logic
that logic in
logic in place
let's try recompiling
try recompiling which
recompiling which recompiles
which recompiles quite
recompiles quite cleanly
And we'll try
we'll try running
our application and
application and we'll
we'll see if
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
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
page one it
one it takes
it takes us
takes us to
page two it
two it will
it will take
Page three still
three still works
four and the
and the link
link which is
the text URL
text URL to
URL to page
page five also
five also works
And our history
our history is
history is working
done today we
today we have
have enabled our
enabled our browser
to support text
support text hyperlinks
have also allowed
also allowed the
allowed the cursor
the cursor on
cursor on the
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
to do but
do but we'll
that for later
for later videos
by completing the
completing the work
the work on
work on text
on text hyperlinks
text hyperlinks and
hyperlinks and adding
and adding support
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
us to drag
to drag HTML
drag HTML pages
HTML pages onto
pages onto the
then displays our
displays our HTML
HTML page to
on any one
the image hyperlinks
image hyperlinks, it
take us in
us in to
in to the
the next page
next page, including
including the display
display of graphics
also have headers
have headers and
headers and text
and text which
which is paragraphed
is paragraphed, and
text URL at
bottom of our
of our index
moment this text
this text URL
text URL is
is not underlined
not underlined, which
which is more
is more or
or less the
less the standard
the standard for
standard for all
for all text
all text URLs
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
of the underline
underline tag in
tag in HTML
in HTML can
HTML can be
to mark a
mark a section
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
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
do to achieve
have two globals
two globals at
globals at the
our code, one
for the default
the default font
default font and
font and one
one to contain
contain the handles
the handles for
handles for the
for the array
array of fonts
of fonts we
fonts we are
we are using
add two more
two more globals
more globals to
globals to this
this list, one
the default underline
default underline font
underline font and
one for an
for an array
array of underline
of underline fonts
us to maintain
to maintain an
maintain an array
underline fonts, which
can use at
use at any
to create and
create and also
and also destroy
also destroy fonts
destroy fonts when
fonts when the
the program starts
program starts and
starts and when
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
one called unload
called unload fonts
to the create
the create fonts
create fonts function
fonts function first
In here, we
our array as
array as having
as having six
having six elements
add a command
same for our
for our underline
our underline fonts
It allows us
store the handles
handles for each
for each font
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
added a font
a font new
font new command
new command to
create our default
our default font
default font, which
case is set
is set for
set for option
for option five
option five, which
to have bold
have bold underline
And in our
in our for
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
this time set
time set with
set with the
with the underline
the underline flag
we've created our
created our fonts
our fonts, we
have to unload
to unload the
unload the fonts
the fonts when
the application completes
at the unload
the unload fonts
unload fonts function
fonts function, it
will quite simply
quite simply need
simply need two
need two font
two font end
font end commands
end commands, one
end the default
to end each
end each of
of the fonts
the fonts referenced
fonts referenced in
referenced in our
handle the underline
underline tag when
tag when we
is our tagging
our tagging engine
function and make
make the necessary
the necessary changes
end of our
of our select
our select statement
select statement, we're
to put two
put two more
two more case
more case statements
statements in, one
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
HTML document, we
set our graphic
our graphic font
graphic font to
font to the
to the default
graphic set font
font command, using
the underline bold
underline bold handle
the data after
data after the
after the underline
underline tag by
tag by using
using the function
function we created
we created in
created in our
previous video, the
the get tag
tag value, giving
giving the long
the long start
long start variable
start variable and
and the underline
the underline end
underline end tag
can go to
print data statement
data statement, which
which will print
will print our
print our data
our data to
data to the
with the end
the end underline
end underline tag
underline tag, we
reset the font
the font back
font back to
to the global
the global handle
global handle of
of the default
see how far
how far we've
far we've got
we've got with
got with the
change to one
to one of
of our web
our web pages
amend the index
to HTML document
beneath the section
section which is
to be hyperlinked
be hyperlinked, we
have a new
a new paragraph
new paragraph, which
is a test
test for our
have the word
the word 'test'
word 'test' and
'test' and a
of text after
text after that
after that, which
which is not
to be underlined
let's run our
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
word 'test' marked
'test' marked 'underlined'
the tag is
tag is still
is still visible
still visible on
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
is more to
We'll need now
need now to
now to have
at the print
the print function
print function, which
which prints data
prints data to
data to our
we handle all
all the text
text that has
that has to
on the HTML
HTML page for
page for the
and our underlined
our underlined tags
underlined tags are
tags are, in
in fact, embedded
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
code that tests
that tests for
tests for an
for an embedded
currently looking for
the href equals
href equals text
equals text to
text to determine
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
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
an embedded underlined
embedded underlined tag
underlined tag, we're
we're exiting the
do not print
running it again
it again and
again and see
we get this
get this time
And now it's
now it's looking
it's looking slightly
looking slightly better
getting the word
word 'test' underlined
'test' underlined, but
but we're missing
we're missing the
the text after
little more to
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
So again, back
when you're developing
you're developing applications
developing applications, you'll
you'll find you
find you may
through a great
of iterations to
iterations to edge
to edge towards
edge towards the
towards the eventual
eventual application that
application that you
wish to use
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
we're in this
add the color
the color and
the underline to
underline to our
to our hyperlinks
true and our
and our strDataViable
our strDataViable is
strDataViable is populated
is populated, then
we know this
know this is
all we really
we really need
really need to
to add color
add color to
color to the
to the foreground
and background of
background of our
of our font
font and set
the font to
font to be
with our simple
our simple two
simple two commands
two commands, we
should have now
have now handled
now handled the
handled the underlining
underlining of our
of our hyperlinks
if we've achieved
there we do
do have a
have a go-to
a go-to page
go-to page 5
page 5, which
which if we
on it, will
achieved the coloring
the coloring and
coloring and the
and the underlining
underlining of a
of a text
you can now
see the confusion
the confusion that
confusion that using
underline tag can
tag can give
can give to
give to a
have two pieces
of text, one
one saying go
saying go to
which is indeed
indeed a hyperlink
can see, if
the mouse over
mouse over, it
to the hand
the hand symbol
But the word
word 'test', which
which is also
is also underlined
also underlined, is
not a hyperlink
But to a
a user, it
it could give
could give the
give the illusion
the illusion that
illusion that it
tag is now
is now discouraged
The one piece
one piece of
piece of functionality
of functionality we
functionality we still
to have on
have on the
screen is to
have the text
text after the
after the ending
the ending of
ending of the
not underlined', which
which follows the
follows the word
if we can
we can tidy
can tidy that
tidy that up
where there is
of text with
text with no
with no line
to check in
check in this
this section to
section to see
is a reference
And if it
it is true
is true a
true a reference
reference tag, we
reset the default
font and color
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
set the foreground
the foreground back
foreground back to
back to black
to black and
black and the
the background to
background to white
couple more changes
more changes we'll
make to this
to this code
this code to
code to fully
to fully support
fully support the
support the underline
the underline, we
see if we're
if we're actually
we're actually inside
actually inside a
paragraph or not
this by testing
by testing the
testing the 'inParagraph'
the 'inParagraph' variable
If that's true
that's true, then
are indeed inside
indeed inside a
be some text
some text still
text still to
still to print
that up using
up using the
using the 'getTag'
the 'getTag' value
'getTag' value, looking
for the end
of the paragraph
And then calling
then calling the
calling the 'printData'
the 'printData' function
'printData' function to
function to print
to print that
print that out
we've got our
got our extra
our extra text
extra text now
we're edging closer
We do actually
do actually have
have the extra
extra text, but
but it's on
it's on the
on the next
next line down
it's treating the
treating the text
the underline 'endingTag'
underline 'endingTag' as
'endingTag' as a
line of data
code and sort
and sort that
sort that out
at the 'printData'
'printData' function, we'll
we'll see there's
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
the string, which
which we do
do not in
not in fact
in fact want
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
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
up the start
start of paragraphs
can call from
call from different
from different parts
different parts of
this function 'printBlankLine'
function 'printBlankLine' and
'printBlankLine' and its
and its job
its job will
job will be
move the text
next available line
our new 'printBlankData'
new 'printBlankData' function
It has always
has always three
always three commands
three commands –
commands – one
– one to
one to set
of the x
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
get the new
the new position
new function from
function from within
from within the
within the 'renderHTMLTags'
the 'renderHTMLTags' function
have the call
have we now
we now done
now done enough
done enough to
enough to make
to make our
make our HTML
HTML document properly
document properly shown
properly shown on
shown on screen?
on screen? If
screen? If we
in our index2
our index2 document
index2 document, and
that the problem
the problem we
problem we had
we had with
had with the
underline tag has
tag has now
now been resolved
have the link
the link to
link to go
page 5, we
have the underline
the underline text
underline text which
which is 'test'
is 'test', and
and the remainder
the line is
line is showing
is showing as
showing as not
as not being
not being underlined
still have operational
have operational links
operational links to
links to each
it's always a
good idea to
idea to compare
to compare our
compare our browser
our browser with
browser with a
double-click on our
on our index2
index2 document and
document and bring
and bring up
bring up a
up a Chrome
Chrome browser, and
if we compare
we compare that
compare that with
our browser, we'll
see we're fairly
we're fairly close
We're missing an
missing an extra
an extra line
extra line at
end of each
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
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
the global coordinates
global coordinates for
coordinates for X
for X and
take this line
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
section which handles
which handles text
handles text which
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
and we appear
we appear to
have it for
for the images
the images as
images as well
compare that against
that against a
against a standard
standard browser, we
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
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
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
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
indeed a URL
obviously there is
is a great
of this project
this project is
project is to
is to cover
to cover areas
cover areas of
areas of Power
of Power Basic
Basic that we
that we may
we may never
may never have
never have covered
have covered before
covered before, allowing
pick up new
up new skills
[Music] Welcome! In
at the resource
the resource management
resource management of
management of staff
of staff in
staff in Teams
So what is
what is resource
is resource management?
resource management? Resource
management? Resource management
Resource management is
management is the
is the practice
the practice of
practice of planning
of planning, scheduling
scheduling and allocating
and allocating people
allocating people, money
money and technology
and technology to
technology to a
to a project
a project or
project or program
As such, for
for large teams
large teams of
teams of staff
of staff it
staff it can
it can be
a complicated business
complicated business, which
which is important
is important to
important to have
a good grasp
good grasp of
grasp of to
of to allow
to allow your
allow your project
your project to
project to prosper
Your resources are
resources are likely
to be limited
be limited and
limited and the
and the demand
the demand for
demand for them
for them to
them to be
to be high
this video we
video we will
not be looking
looking at any
at any code
any code, but
but we'll be
looking at an
an application I
application I created
I created to
created to do
to do simple
do simple resource
simple resource management
We'll delve into
delve into the
code in part
in part 2
do we track
we track resources
track resources and
resources and in
and in how
in how much
how much detail?
much detail? When
detail? When looking
When looking at
looking at tracking
at tracking it's
tracking it's important
important to keep
keep a sense
a sense of
sense of balance
of balance and
balance and not
not to micromanage
to micromanage your
micromanage your resources
Tracking every moment
every moment of
moment of every
of every day
every day for
day for your
for your staff
your staff would
staff would be
would be both
be both counterproductive
both counterproductive and
counterproductive and overly
and overly onerous
overly onerous on
onerous on the
on the staff
There are many
are many commercial
many commercial products
commercial products that
products that can
that can be
used to keep
of what your
what your staff
your staff resources
staff resources are
resources are doing
can use something
use something as
something as simple
as simple as
simple as a
as a whiteboard
a whiteboard and
whiteboard and a
and a handful
a handful of
handful of dry
of dry wipe
dry wipe markers
So what are
what are the
are the requirements
the requirements for
requirements for the
for the simple
the simple application
simple application to
application to track
to track team
track team resources?
team resources? Multiple
resources? Multiple teams
It must be
must be able
able to handle
to handle more
handle more than
than one team
Adding and removing
and removing of
removing of staff
It must allow
must allow adding
allow adding, amending
removing staff within
staff within a
within a team
must allow a
allow a display
display of up
of up to
up to 6
to 6 months
6 months ahead
months ahead and
ahead and allow
and allow tasks
allow tasks or
tasks or activities
or activities to
activities to be
to be allocated
be allocated to
allocated to staff
to staff in
staff in time
in time slots
time slots within
slots within each
within each month
must be easy
be easy to
easy to grasp
to grasp the
grasp the activities
the activities at
activities at a
at a glance
Publishing the resource
the resource plan
The visual plan
visual plan must
plan must be
able to be
to be published
be published to
published to allow
to allow other
allow other members
other members of
members of the
of the team
the team and
team and other
and other teams
other teams to
teams to see
the application we've
application we've created
we've created to
created to monitor
to monitor and
monitor and control
and control our
control our team's
our team's resources
application has menus
The standard file
standard file menu
file menu to
menu to exit
to exit from
exit from the
from the application
A resource menu
resource menu to
menu to add
a new resource
new resource, amending
amending an existing
an existing resource
existing resource or
resource or to
or to delete
to delete a
delete a resource
a resource from
resource from a
from a team
We've also built
also built in
built in a
in a security
a security module
set up security
up security so
security so that
that only certain
only certain users
certain users can
users can amend
can amend the
amend the records
of the users
the users will
users will be
will be read
be read only
read only and
only and we've
and we've also
in a help
a help file
This help file
help file is
file is a
is a guide
a guide for
guide for users
for users on
users on how
on how to
how to use
use the application
main screen is
screen is divided
is divided into
divided into three
into three parts
The top part
top part is
part is the
is the list
list of resources
The application manages
application manages one
manages one sheet
one sheet for
sheet for each
for each month
each month for
month for the
the next six
next six months
as we're recording
we're recording this
recording this in
this in February
in February The
February The bottom
screen is an
is an embedded
an embedded browser
embedded browser control
browser control, which
which you'll see
you'll see what
what it's used
it's used for
used for shortly
the third part
third part is
list of tasks
let's go ahead
create a team
a team and
team and then
and then add
then add some
add some resources
some resources to
resources to it
So we'll call
call this the
this the support
the support team
support team and
team and we're
have two resources
two resources within
resources within this
within this team
in and add
and add a
add a brand
brand new resource
behind the head
the head count
head count field
count field is
field is that
is that not
that not all
not all staff
all staff will
staff will be
will be full
be full time
If the member
the member of
member of staff
of staff is
staff is full
is full time
full time, then
then the head
head count will
count will be
will be one
of staff works
staff works less
works less than
less than full
than full time
you can reduce
can reduce the
reduce the value
value of head
of head count
now added John
added John Smith
John Smith, our
our new resource
new resource, to
to our team
can see, it
it has added
has added five
added five lines
five lines of
lines of data
of data to
the grid for
grid for team
for team resource
As you cannot
you cannot expect
cannot expect to
expect to get
to get full
get full utilization
full utilization of
utilization of any
of any resource
any resource, there
there is always
be some time
some time that
time that the
that the resource
the resource is
resource is not
is not working
not working on
working on your
on your projects
We've allocated four
allocated four weeks
four weeks on
weeks on each
on each month
each month and
month and five
and five days
five days in
days in each
in each week
you to give
give a rough
a rough estimation
rough estimation of
estimation of a
of a resource
a resource utilization
a second resource
two resources in
resources in the
in the team
look at allocating
at allocating tasks
The unallocated means
unallocated means that
means that this
this particular member
particular member of
staff is not
is not allocated
not allocated on
allocated on that
on that particular
that particular day
particular day of
day of that
of that particular
that particular week
now add some
add some tasks
some tasks that
tasks that can
can be allocated
allocated to the
to the members
the members of
members of staff
the tasks or
or activities that
activities that staff
that staff will
staff will do
do is have
is have holidays
set up holidays
up holidays first
holidays first of
Holidays generally are
generally are planned
are planned, so
so you should
you should know
should know when
know when your
when your staff
your staff are
staff are actually
are actually going
be on holiday
So let's say
let's say John
say John Smith
John Smith is
Smith is going
on holiday in
holiday in week
in week two
week two of
two of February
select the whole
the whole of
whole of week
of week two
week two, right
click and then
then set as
set as the
as the task
the task currently
task currently selected
And that slots
that slots in
slots in holidays
And we'll say
we'll say James
say James Smith
James Smith is
Smith is on
is on holiday
in week three
now we set
set the holidays
the holidays up
holidays up for
for the month
click the save
the save button
save button, this
will save the
save the data
the data and
data and will
and will generate
will generate the
generate the HTML
the HTML web
HTML web page
web page at
page at the
This at a
a glance can
glance can let
can let you
let you see
you see all
all the members
members of your
of your team
your team and
team and what
and what their
what their activity
their activity currently
activity currently is
currently is for
is for all
for all six
all six months
With a key
a key at
key at the
This web page
web page is
page is also
is also published
also published out
published out to
to a file
you can then
can then push
then push onto
push onto a
onto a web
web server for
server for easy
for easy display
easy display of
of this data
a new task
Let's say the
say the staff
the staff need
staff need to
do two days
two days a
days a week
a week support
we can allocate
can allocate two
allocate two days
two days for
days for John
for John Smith
And the following
the following week
following week will
week will allocate
will allocate that
allocate that to
that to Jane
can save that
that and it
will automatically update
automatically update our
update our chart
our chart at
chart at the
can then go
then go through
go through and
through and actually
and actually allocate
actually allocate time
allocate time for
time for each
tasks you know
you know that
know that are
that are going
So once we
once we have
we have completed
have completed data
completed data for
data for the
the first month
first month, we
can go on
on to subsequent
to subsequent months
subsequent months and
months and fill
and fill them
fill them in
them in as
in as well
And save that
that and they
and they will
they will appear
will appear in
appear in March
set up eleven
up eleven tasks
eleven tasks and
tasks and one
one for unallocated
So at a
a glance anywhere
glance anywhere where
anywhere where it
where it shows
it shows as
shows as unallocated
as unallocated, you
see the staff
the staff is
not currently marked
currently marked as
marked as resource
as resource for
resource for a
a particular project
particular project or
project or task
can then rerun
then rerun the
rerun the application
application and load
and load up
up the team
the team data
on the load
the load team
load team, select
select the team
team and the
the data will
data will come
will come up
come up quite
up quite happily
now go in
and add another
add another resource
we have Tom
have Tom Jones
Tom Jones added
Jones added to
can select a
select a task
a task and
task and bulk
and bulk allocate
bulk allocate them
allocate them for
them for that
for that for
for the entire
the entire month
that and you
and you appear
you appear down
appear down in
in the bottom
the bottom chart
we now look
at the security
the security tab
security tab and
tab and we
we can amend
amend the security
the security on
security on the
on the team
to be designated
be designated as
designated as the
as the owner
can also add
also add additional
add additional users
can make Tom
make Tom Jones
Tom Jones read
Jones read and
read and write
All other users
other users would
users would be
would be by
be by default
by default read
default read only
This would allow
would allow them
them to load
load the team
the team resource
team resource file
resource file, but
but they would
they would not
would not be
not be able
able to save
to save any
save any amendments
a fairly basic
fairly basic application
basic application, it
track of resources
of resources over
resources over a
over a six
a six month
six month period
The system runs
system runs on
runs on a
on a rolling
a rolling six
rolling six month
six month calendar
the application in
application in March
in March, then
then any data
any data that
data that was
that was in
was in February
in February will
February will be
will be dropped
be dropped off
dropped off the
off the system
it will generate
will generate a
generate a new
a new spreadsheet
new spreadsheet and
spreadsheet and a
new set of
set of columns
of columns for
columns for August
So what we'll
what we'll do
we'll do in
we will delve
will delve into
Basic Code to
how we created
we created and
created and maintain
and maintain this
maintain this application
application to help
to help track
help track resource
track resource management
last video on
video on resource
on resource management
resource management, we
we demonstrated an
demonstrated an application
This application takes
application takes quite
takes quite a
a simple approach
simple approach to
approach to keeping
to keeping track
of the resources
the resources within
resources within your
within your team
other words, the
the time that
that the staff
the staff spends
staff spends on
spends on different
on different tasks
different tasks or
The application can
application can support
can support multiple
support multiple teams
team data, select
select our team
our team, then
then the information
the information will
information will come
come up on
have two parts
two parts of
the screen holding
screen holding the
holding the task
the task information
top part shows
part shows a
shows a grid
a grid, showing
showing six months
six months worth
months worth of
worth of information
When we recorded
we recorded the
recorded the last
last video, it
it was in
now in March
in March, the
information for February
for February has
February has been
has been removed
been removed, and
we're now showing
now showing the
showing the four
the four weeks
four weeks in
weeks in March
in March and
March and all
the way up
way up to
up to August
have not saved
not saved the
saved the information
information for March
for March yet
March yet, the
the information in
in the detailed
the detailed section
detailed section below
section below is
below is still
is still showing
still showing the
showing the February
the February information
is a bonus
a bonus, as
can always refer
always refer back
refer back to
back to it
to it when
it when populating
when populating the
populating the March
the March information
we put some
put some holidays
some holidays in
holidays in for
for the staff
the staff, for
for example, on
on John Smith
John Smith, we'll
we'll put Week
put Week 2
Week 2 in
2 in as
in as holiday
as holiday, setting
setting that to
to the task
For Jane Smythe
Jane Smythe, we
will mark Week
mark Week 3
for the final
the final member
final member of
member of the
the team, we'll
we'll mark them
mark them in
them in Week
in Week 4
Having populated some
populated some information
some information, we
can now save
now save this
the Save and
Save and Generate
and Generate HTML
Generate HTML button
HTML button, it
it will regenerate
will regenerate the
regenerate the bottom
the bottom grid
bottom grid is
grid is an
an embedded HTML
embedded HTML control
This now shows
now shows the
shows the updated
the updated information
updated information for
information for the
the second week
second week in
week in March
in March, third
third week in
in March, and
the final week
final week in
In addition, what
what I didn't
I didn't show
didn't show in
show in the
video was clicking
was clicking on
on the Summary
the Summary radio
Summary radio button
radio button gives
button gives you
you a breakdown
a breakdown per
breakdown per member
per member of
This differentiates between
differentiates between allocated
between allocated and
allocated and unallocated
and unallocated time
can see for
see for the
the first week
first week in
in March, we
we have certainly
have certainly some
certainly some time
some time allocated
time allocated for
allocated for John
John Smith, but
but none for
none for Jane
for Jane or
Jane or Tom
a team leader's
team leader's perspective
leader's perspective, allows
allows them to
them to see
to see over
see over the
over the next
six months when
months when there
when there are
there are gaps
are gaps, when
when there is
there is free
is free resource
free resource that
resource that could
that could be
could be allocated
allocated to a
to cover in
cover in this
this video is
video is how
how we achieve
this in code
This is within
Windows compiler, so
from the beginning
the application, we
number of include
of include files
The bulk standard
bulk standard Windows
32 API, common
controls and pbforms
and pbforms, fairly
fairly standard for
standard for a
for a pbforms
a pbforms application
we're pulling in
pulling in my
little grid include
grid include file
include file and
and the static
link library that
library that encompasses
that encompasses my
encompasses my little
link library is
library is used
used to create
create the grid
the grid at
grid at the
also using another
using another static
another static link
link library, which
one that is
that is used
generate the spinning
the spinning gear
spinning gear wheels
Just to indicate
user that something
something is happening
is happening in
happening in the
We have five
have five other
five other files
other files which
which are included
button plus, which
which is used
used to put
the graphics on
graphics on the
on the buttons
Tool tips, which
which as the
as the name
the name suggests
name suggests is
suggests is to
you to generate
to generate tool
generate tool tips
tool tips on
tips on objects
on objects on
have an HTML
an HTML help
have two additional
two additional include
additional include files
include files, which
used to help
to help display
help display the
display the embedded
the embedded HTML
look at pbmain
command in pbmain
in pbmain is
pbmain is the
is the pbforms
the pbforms initialize
pbforms initialize controls
used for applications
for applications whose
applications whose dialogues
whose dialogues have
dialogues have been
have been generated
been generated by
generated by pbforms
We're dimensioning a
dimensioning a global
using to keep
track of our
of our staff
This I have
I have coded
have coded up
coded up to
up to keep
track of 200
of 200 staff
If this number
this number is
number is too
too small, just
just increase it
increase it to
number of staff
staff in your
in your team
We then have
then have three
have three functions
three functions called
One to generate
generate the months
the months for
months for the
One to prep
to prep the
prep the task
the task colours
function that prepares
that prepares the
prepares the task
are the colours
the colours used
colours used within
used within the
are all using
all using the
using the inbuilt
the inbuilt RGB
inbuilt RGB colour
RGB colour constants
These I have
I have matched
have matched to
matched to the
to the colours
the colours for
colours for HTML
for HTML to
HTML to get
get the best
the best match
best match between
match between the
between the colours
the colours so
colours so that
that they will
will appear as
appear as close
as close as
close as possible
as possible to
possible to each
to each other
that the green
the green showing
green showing for
showing for unallocated
for unallocated in
unallocated in the
the grid matches
grid matches the
matches the color
color of each
of each other
Matches the green
green showing in
showing in the
in the HTML
the HTML control
HTML control at
control at the
then we go
the code are
code are two
are two lines
These are key
are key to
key to being
to being able
being able to
able to allow
to display an
display an HTML
an HTML control
HTML control, an
an embedded web
embedded web page
The first, the
the OCX name
OCX name, we're
we're having a
having a shell
a shell explorer
Then we're initialising
we're initialising ATL
We'll see more
see more on
more on this
on this further
this further down
Next we're doing
we're doing our
doing our initialisation
our initialisation of
initialisation of the
of the mylittlegrid
the mylittlegrid grid
mylittlegrid grid control
Then the usual
the usual dialog
usual dialog new
dialog new, followed
followed by all
by all the
the objects that
objects that appear
that appear on
have specified all
specified all the
the controls that
controls that appear
on the pbforms
the pbforms, we
then have the
have the calls
the calls to
calls to button
to button plus
display the icons
the icons on
icons on our
on our buttons
is the specification
the specification of
specification of mylittlegrid
of mylittlegrid, where
where it appears
it appears on
on screen, how
how many columns
many columns it
columns it has
it has and
has and how
how wide each
wide each column
each column is
have the embedded
the embedded browser
This control add
control add statement
add statement is
the command which
command which adds
which adds our
adds our embedded
our embedded control
embedded control to
to do then
do then is
then is to
is to capture
to capture the
capture the handle
of that control
Then we're calling
we're calling two
calling two routines
two routines within
routines within the
within the include
the include library
One to get
get the control
control and one
one to make
make it dispatch
This populates this
populates this variant
this variant variable
variant variable, which
which we're then
then using for
using for this
for this set
this set command
Then all we
is to specify
specify the URL
URL which we
to display in
display in that
in that page
the program loads
program loads, it's
it's loading a
loading a blank
a blank resource
blank resource management
resource management page
management page, which
is held within
the data folder
data folder, resource
resource manager blank.htm
When a team
a team is
team is loaded
is loaded and
loaded and the
and the html
html control is
control is regenerated
is regenerated, these
these are saved
are saved out
saved out to
out to these
to these files
these files and
files and then
and then displayed
then displayed inside
displayed inside the
inside the html
you to publish
to publish these
publish these html
these html files
html files to
files to any
to any website
any website you
website you wish
final command that
command that navigates
that navigates to
navigates to and
to and displays
and displays on
displays on screen
screen the webpage
webpage is this
one here, this
this object call
we're doing some
doing some finishing
some finishing up
finishing up on
up on the
of the worksheets
this case since
case since we
have six months
six months, we
have one worksheet
one worksheet for
worksheet for each
We're then adding
then adding the
adding the name
of the worksheet
the worksheet using
worksheet using this
is a month
a month name
month name which
name which was
which was generated
was generated right
generated right at
right at the
our code when
code when we
when we called
we called the
called the generate
the generate months
generate months routine
We're defaulting to
defaulting to the
to the very
very first tab
first tab on
tab on the
user would want
would want to
start at the
at the current
the current month
putting the headers
the headers in
headers in for
in for each
the columns within
columns within each
within each of
of the grids
And finally we're
finally we're setting
up the color
the color slots
When dealing with
dealing with a
with a myLittleGrid
a myLittleGrid, you
you will need
need this local
this local variable
local variable set
variable set up
a pointer at
of your function
This is then
is then referred
then referred to
referred to in
to in the
in the notification
the notification section
notification section to
section to pick
pick up which
up which events
which events have
events have occurred
have occurred within
occurred within the
right click to
click to pick
up the little
the little menu
little menu and
menu and the
and the setting
the setting of
setting of allocated
of allocated tasks
And within the
within the wm-size
the wm-size event
wm-size event is
event is the
which handles when
when the screen
screen has been
has been resized
been resized, maximized
minimized or just
or just generally
just generally made
generally made bigger
we're calling this
function to resize
to resize our
resize our screen
on the scale
the scale, I
I make it
make it bigger
it bigger or
bigger or smaller
or smaller or
smaller or moving
or moving for
moving for the
for the buttons
the buttons, vertical
vertical and horizontal
calling the repaint
the repaint as
repaint as the
Then in our
in our initialize
our initialize dialog
initialize dialog function
dialog function is
set up all
up all the
all the tooltips
have the wm-notify
the wm-notify event
where we handle
we handle the
the events on
events on the
on the myLittleGrid
We can check
can check to
make sure which
sure which grid
which grid is
actually being clicked
being clicked on
particular application there
only one grid
But this allows
you to differentiate
differentiate between perhaps
between perhaps Grid
perhaps Grid 1
Grid 1 and
1 and Grid
and Grid 2
Grid 2 if
2 if you
if you had
you had two
had two grids
two grids on
grids on the
And like many
like many other
many other things
other things, each
of these has
these has a
a particular event
a multi-cell change
multi-cell change where
change where the
user has multi-selected
has multi-selected cells
For example, they've
they've selected all
selected all the
all the weeks
the weeks or
weeks or all
or all the
the weeks in
weeks in a
in a month
a month and
month and you
and you wish
wish to do
do something for
something for the
the whole section
up the column
the column selected
column selected, double
double selected and
the end row
end row and
row and end
and end column
end column selected
set a number
number of cells
of cells at
cells at one
We have other
have other events
other events to
events to handle
handle a column
a column selection
column selection change
selection change and
change and a
and a row
a row selection
row selection change
is a right-click
a right-click menu
picks up when
user has right-clicked
has right-clicked on
right-clicked on the
up which menu
which menu item
menu item they
item they pick
they pick, what
what column the
column the mouse
actually in and
in and what
and what row
what row the
row the mouse
This is followed
is followed by
by the code
which handles what
handles what goes
what goes in
goes in to
to the cell
the cell or
cell or cells
or cells in
cells in the
in the myLittleGrid
to be unallocated
be unallocated or
unallocated or is
is it being
it being allocated
being allocated to
to a task?
a task? When
task? When the
on the Save
Generate HTML, at
this point it
point it looks
it looks through
looks through each
through each cell
each cell in
It is then
is then going
going to generate
to generate from
generate from scratch
from scratch an
scratch an HTML
page to match
to match what
match what we
what we see
we see up
see up here
very straightforward HTML
straightforward HTML document
HTML document and
document and we're
using the background
of the cells
the cells in
cells in a
in a table
a table to
table to set
to set match
set match the
match the colors
the colors in
colors in the
in the top
the top grid
we have menus
have menus on
menus on the
have a resource
resource menu which
menu which will
you to add
an extra resource
other words, another
another member to
member to your
to your team
also have an
have an option
option to delete
So if, for
for example, Tom
Tom Jones leaves
Jones leaves the
leaves the team
the team, we
we can apply
can apply that
apply that change
This would then
would then mark
then mark him
mark him as
him as deleted
we save and
and generate the
the HTML, that
that would remove
would remove the
remove the user
the user entirely
user entirely from
entirely from the
top grid and
grid and from
from the bottom
bottom grid as
grid as well
The additional menu
additional menu item
menu item is
item is security
idea behind this
behind this is
the team to
team to have
to have write
have write access
write access to
access to this
application loads, it
it picks up
up the sign
the sign on
sign on name
on name by
name by whoever
by whoever you
whoever you signed
you signed on
signed on to
to the domain
the domain as
So if one
of the members
the team is
team is acting
is acting as
as a delegate
a delegate for
delegate for the
for the team
the team leader
team leader, you
to add them
add them to
them to this
this list and
list and change
and change their
change their permission
their permission level
permission level to
level to read-write
the team will
team will be
will be able
able to actually
to actually run
actually run the
application and to
and to load
the team document
team document, but
will be read-only
So the code
the code sections
code sections to
sections to handle
to handle what
handle what we
what we just
we just looked
just looked at
looked at are
at are down
are down here
have the load
the load data
you to load
to load up
team data based
data based on
based on what
the inbuilt display
inbuilt display open
open file call
select a team
a team file
team file from
file from a
from a specific
a specific folder
have this call
this call here
call here to
to the spinner
the spinner initialization
This displays the
displays the gear
the gear wheel
gear wheel while
wheel while the
while the data
the data is
data is being
is being loaded
always good to
good to give
give a user
a user some
user some kind
kind of feedback
of feedback on
feedback on the
to indicate that
indicate that the
that the application
doing something and
something and has
and has not
has not actually
not actually hung
the last event
last event we
event we will
at is the
one that generates
that generates the
generates the HTML
very first thing
first thing it
thing it does
it does is
does is to
is to save
to save the
save the configuration
the configuration information
configuration information locally
information locally by
locally by calling
calling the save
the save config
save config function
Following that, there
is a genimate
a genimate page
genimate page function
This genimates the
genimates the HTML
We then reload
then reload the
reload the data
data and recursively
and recursively regenerate
recursively regenerate to
regenerate to pick
pick up any
up any deleted
any deleted resources
And we generate
we generate both
generate both the
both the page
the page and
page and the
and the summary
the summary page
summary page at
the team, and
and then save
then save and
see the detail
the detail or
detail or the
or the summary
the summary straight
summary straight away
There's no delay
no delay in
delay in generating
in generating it
generating it because
it because these
because these files
these files have
files have already
have already been
already been manufactured
I will be
will be including
be including the
including the source
the source file
source file on
file on the
on the zip
the zip on
zip on the
on the website
free to download
to download it
download it and
it and try
and try the
try the application
the application out
fairly simple application
allow a team
a team manager
team manager to
manager to keep
of the team's
the team's resource
team's resource and
resource and to
them to identify
to identify gaps
identify gaps where
gaps where the
where the team
team is not
is not fully
not fully deployed
it only keeps
only keeps track
keeps track of
track of up
up to six
to six months
worth of data
could be extended
be extended to
extended to go
to go beyond
go beyond that
beyond that quite
we will begin
will begin our
begin our project
project to look
use of text
of text prediction
text prediction software
are starting a
starting a new
a new project
I've wanted for
wanted for some
for some time
time to do
do a project
a project on
project on artificial
on artificial intelligence
artificial intelligence and
intelligence and machine
and machine learning
And today we're
to dip our
dip our toe
our toe in
toe in the
in the waters
the waters of
waters of machine
of machine learning
machine learning with
learning with predictive
with predictive text
Most people will
people will have
will have used
have used smartphones
used smartphones to
smartphones to send
to send text
send text messages
And one of
of the features
the features of
features of sending
of sending text
sending text messages
text messages is
messages is predictive
is predictive text
predictive text, where
application will predict
will predict the
predict the next
the next word
next word you
word you could
could use in
use in your
in your text
your text message
in this project
this project we're
project we're going
look at what's
at what's needed
what's needed to
create a predictive
a predictive text
predictive text system
Windows Compiler to
Compiler to do
will see on
have a fairly
This application has
has a toolbar
a toolbar which
toolbar which has
which has two
has two buttons
to add text
add text data
text data and
data and one
one to save
to save text
save text data
have two boxes
two boxes on
One a simple
a simple text
simple text box
user to type
to type text
type text in
And on the
on the right
the right we
right we have
list box into
box into which
into which are
to appear the
appear the words
the words that
words that the
that the system
the system predicts
system predicts the
predicts the user
user may use
is a machine
a machine learning
machine learning system
learning system, where's
where's our data
our data going
data going to
going to come
to come from?
come from? For
from? For the
For the great
the great many
great many videos
many videos I've
videos I've posted
I've posted on
posted on YouTube
on YouTube, the
the majority of
majority of them
of them have
them have subtitles
And it is
it is some
is some of
of these subtitle
these subtitle files
subtitle files we're
files we're going
to use to
use to drive
to drive our
drive our system
our system, to
to provide it
provide it with
it with sufficient
with sufficient data
sufficient data in
data in order
order to work
work out prediction
out prediction of
prediction of text
look at one
at one of
subtitle files, we
see it comes
it comes in
comes in a
in a series
series of phrases
These have time
have time slots
time slots to
slots to indicate
indicate where in
the video this
video this particular
this particular piece
particular piece of
text is spoken
use this data
this data, I
I wrote this
wrote this small
this small program
small program to
program to strip
to strip this
strip this data
this data out
data out to
out to leave
to leave us
leave us just
us just with
just with the
with the text
we run this
run this application
this application, it
number of text
of text data
text data files
we open these
open these up
these up, we
see this has
this has the
has the raw
the raw text
This is stored
stored in one
in one long
one long line
long line of
line of text
is the data
we take these
take these three
these three words
three words here
words here in
here in this
this series, we
will store these
store these patterns
these patterns of
patterns of three
of three words
three words inside
words inside an
inside an array
we will count
will count how
how many times
many times this
times this particular
this particular pattern
particular pattern appears
that when a
a user types
types in this
in this, we
have a probability
a probability of
probability of knowing
of knowing what's
knowing what's the
what's the next
the next most
next most logical
most logical word
logical word the
word the user
And with all
with all machine
all machine learning
machine learning systems
learning systems, we
have to feed
to feed it
feed it a
it a great
deal of data
To start this
start this off
this off, I
have created 10
created 10 of
10 of these
of these text
these text files
The files are
files are individually
are individually not
individually not very
not very large
very large, but
they do contain
do contain enough
contain enough information
enough information to
information to start
to start us
start us off
have a couple
couple of include
include files here
have a pb
a pb toolbar
pb toolbar library
toolbar library, which
using to create
create our toolbar
our toolbar at
the file handling
routines library, which
used in many
in many previous
many previous videos
previous videos, which
which contain functions
contain functions to
functions to allows
to allows to
allows to read
to read and
and write from
write from text
from text files
order to perform
perform this text
this text prediction
text prediction, we're
store the data
data in two
in two arrays
two arrays, one
one string array
string array to
the information of
information of words
of words, and
and one numeric
one numeric array
numeric array to
hold the count
count of the
of the patterns
way we can
many times a
times a particular
a particular three
particular three word
three word pattern
word pattern appears
pattern appears in
in our data
our two arrays
two arrays, word
word data and
data and word
and word count
to start these
start these arrays
these arrays off
arrays off with
off with 10,000
with 10,000 elements
This is enough
is enough to
enough to start
start off and
off and we
and we may
to increase this
I've set another
set another constant
another constant called
constant called array
called array block
array block to
block to be
of elements to
elements to expand
to expand the
expand the arrays
the arrays by
arrays by when
by when the
when the need
the need arises
application will extend
will extend these
extend these arrays
these arrays as
arrays as required
And we've created
we've created three
created three string
three string constants
string constants, word
word data, word
word count and
count and word
and word data
word data CSV
The word data
word data text
data text file
text file is
is a dump
a dump of
dump of the
within the word
word data array
The word count
word count text
count text file
data held in
in the numeric
the numeric word
numeric word count
word count array
this is once
is once we
we have trained
have trained a
trained a system
a system, we
want to save
save the information
the information so
information so that
that the next
the next time
next time the
time the application
application is run
is run, it
it can load
can load up
load up this
up this preloaded
this preloaded data
the final file
final file I'm
file I'm outputting
I'm outputting is
outputting is the
is the CSV
is a combination
a combination of
combination of the
data and the
word count arrays
us to look
at the data
data to see
see how it's
how it's progressing
our pb_main application
pb_main application, we're
going to dimension
to dimension these
dimension these two
these two arrays
two arrays, initially
initially set to
to the start
the start size
start size, which
which is 10,000
is 10,000 elements
order to provide
to provide the
provide the data
in the 10
the 10 text
10 text files
text files to
files to the
the application, we're
code behind the
behind the add
the add text
text data button
data button on
command section here
section here, we're
on the add
the add button
This uses the
uses the standard
the standard check
standard check to
has clicked the
clicked the button
command to allow
or more files
more files from
files from the
from the disk
the flags to
flags to insist
to insist that
insist that the
must exist that
exist that the
user is selecting
to allow multi
allow multi selects
multi selects to
selects to allow
to select more
select more than
a time, as
have the system
file command takes
the parent dialogue
parent dialogue, the
the title you
title you wish
to show, the
path to where
where the files
the files exist
files exist, and
and the pattern
the pattern that
pattern that you're
that you're looking
looking for anything
for anything with
anything with text
with text data
data and followed
followed by an
by an underline
an underline and
underline and they
they are all
are all text
all text files
And we're returning
we're returning that
returning that to
that to a
to a variable
called str file
And we're counting
we're counting the
counting the number
has selected as
selected as since
as since we've
set the flag
the flag for
flag for multi
for multi select
multi select, the
user can select
can select more
need to process
to process this
process this data
function called process
called process files
And to that
that function, we'll
we'll pass a
The path containing
path containing the
containing the files
the files, the
we can give
can give feedback
file count, the
way the display
file command works
command works, if
selects a single
single file, then
then the str
the str file
str file variable
contain both the
user selects more
selects more than
one file, then
str file string
file string will
string will contain
will contain a
contain a series
series of values
of values delimited
values delimited by
by a null
a null value
null value, a
a chr $0
And we'll cover
cover that within
within the process
the process file
process file command
taking its four
its four parameters
to handle multiple
handle multiple files
multiple files, we're
One called file
called file to
file to hold
hold the individual
the individual name
individual name of
file and file
and file handle
file handle and
handle and a
and a folder
file count could
count could be
could be one
be one or
one or greater
than one, we
single file we're
file we're getting
we're getting in
getting in or
in or is
to be multiple
be multiple files
it's a single
populate the file
the file variable
file variable by
variable by using
command and using
and using chr
using chr $
chr $ as
$ as our
as our delimiter
function process file
process file function
file function is
function is dedicated
is dedicated to
dedicated to processing
to processing a
processing a single
if it's going
multiple files the
the user selected
user selected, we
do this slightly
this slightly differently
up the folder
the folder as
the files string
a simple for
simple for next
loop to iterate
to iterate through
iterate through that
through that string
that string to
string to pull
out the information
be the loading
the loading file
loading file message
file message to
message to see
see which file
which file we're
file we're loading
we're loading and
loading and we
can then work
then work out
out the file
file name again
name again using
And for each
these files we'll
files we'll call
we'll call process
call process file
This way the
way the same
same function process
process file can
file can be
be used regardless
used regardless of
whether it's one
it's one file
one file or
file or multiple
or multiple files
And after we've
after we've completed
we've completed in
completed in this
in this processing
this processing, we
update the dialogue
bar to see
or files have
files have now
have now completed
now completed loading
completed loading by
loading by using
using a straightforward
a straightforward control
straightforward control set
we've completed this
completed this particular
particular function, let's
callback function as
function as there
of variables at
the function we'll
function we'll need
we have file
have file which
file which is
is the selected
the selected input
selected input file
input file, flags
flags to be
the file selection
file selection flags
selection flags to
flags to allow
And an error
an error variable
error variable which
will contain any
contain any data
any data we
data we need
back to user
to user to
what the problem
problem is when
is when something
when something has
something has failed
And file count
file count which
count which is
is a count
a count of
process the individual
the individual file
function taking in
the file, the
parent dialogue and
dialogue and our
and our status
creating a number
to be handling
be handling three
handling three words
three words at
words at a
a time, we
we have strings
have strings set
strings set up
for the word
the word, the
the second word
second word and
word and the
the third word
So first we'll
first we'll display
we'll display a
the dialogue in
dialogue in the
are now loading
now loading a
loading a file
we will dip
will dip in
dip in to
in to use
to use one
use one of
file handling library
handling library called
library called binary
called binary file
binary file a
file a string
This will load
will load the
load the entire
the entire file
entire file into
into a data
a data variable
us to manipulate
to manipulate it
manipulate it in
it in memory
And as all
as all the
all the words
the words within
words within this
within this file
this file are
file are going
to be delimited
be delimited by
by a space
a space character
space character, we
many elements we've
elements we've got
we've got, how
how many words
many words exist
words exist in
exist in that
do this using
this using the
count command and
and a single
a single space
single space delimiter
we know how
exist in the
the file, we
we can step
can step through
step through them
through them using
them using a
a standard for
standard for next
the first line
first line within
line within this
next loop is
up the word
the word we're
word we're dealing
dealing with, again
out this function
to need some
need some small
some small amount
amount of data
want to give
to give it
it a full
a full size
full size file
size file as
file as it'll
as it'll be
it'll be easier
be easier to
easier to debug
to debug it
debug it if
it if we
have a smaller
a smaller file
is the small
the small file
small file I'm
file I'm looking
I'm looking at
looking at using
It has effectively
has effectively only
effectively only three
only three sentences
One saying welcome
saying welcome and
welcome and one
and one saying
one saying in
saying in this
short videos which
videos which is
which is repeated
us an easy
an easy way
of actually picking
actually picking the
picking the information
For the structure
the structure that
structure that we
we have, if
have a sentence
a sentence which
sentence which has
which has only
has only one
only one word
one word within
word within it
within it, we're
going to ignore
to ignore this
ignore this as
this as it
as it ends
it ends in
ends in a
in a period
Therefore there is
is no text
no text actually
text actually following
actually following it
following it within
within the sentence
that in code
in code quite
code quite easily
testing the rightmost
the rightmost character
rightmost character of
character of the
there is either
is either a
either a period
a period or
period or a
or a comma
a comma, we're
we're ignoring this
ignoring this word
this word completely
our case else
case else we
else we will
will handle everything
handle everything else
get the next
next two words
two words, the
This time looking
time looking for
for the current
the current word
current word number
word number plus
number plus one
And again if
again if the
if the rightmost
of the second
second word is
word is the
the last in
last in the
in the sentence
the sentence, there
will be no
be no third
no third word
third word following
word following it
can ignore this
ignore this one
one as well
can guess from
guess from the
the code we've
code we've seen
we've seen so
seen so far
so far, we're
to do text
do text prediction
text prediction after
prediction after each
after each character
each character is
character is pressed
is pressed on
pressed on the
to use word
use word prediction
word prediction when
prediction when the
the user finishes
user finishes typing
finishes typing a
typing a word
a word and
word and presses
and presses the
presses the space
the space bar
be the trigger
the trigger to
trigger to look
the next possible
next possible word
And next we're
next we're picking
up the third
For the third
third word we
word we are
are using the
us to trim
to trim things
trim things off
things off the
the end and
end and beginning
and beginning of
And we're trimming
we're trimming either
trimming either period
either period or
period or commas
or commas off
commas off the
off the beginning
the beginning or
beginning or the
or the end
of the third
store these three
three words in
words in a
in a phrase
a phrase format
phrase format inside
format inside our
inside our array
our array, we
don't want any
want any periods
any periods or
periods or commas
or commas cluttering
commas cluttering it
cluttering it up
Next we'll have
have to double
to double check
make sure we
sure we do
a second and
second and a
a third word
easily by testing
by testing them
testing them individually
are not an
one string then
string then we
then we do
do have three
have three words
add these to
these to our
to our array
function called add
called add to
add to data
to data, passing
passing it three
it three parameters
three parameters, which
are the three
the three words
go ahead to
ahead to create
add to our
to our data
new function passing
function passing in
is to form
to form these
form these up
these up into
up into a
into a phrase
a phrase, delimited
by a single
single space character
the first, second
second and third
and third words
third words in
new variable called
variable called phrase
Next we'll need
to handle any
handle any double
double quotes within
quotes within the
within the string
is to make
it easier when
easier when we're
when we're actually
we're actually printing
actually printing information
printing information out
information out to
out to our
to our CSV
our CSV file
use a couple
couple of replace
of replace commands
replace commands to
commands to replace
to replace double
replace double quotes
double quotes and
quotes and also
and also carriage
also carriage return
return line feeds
So we'll substitute
we'll substitute a
substitute a single
a single quote
single quote for
quote for any
for any double
double quotes that
quotes that exist
that exist and
exist and an
and an empty
length string for
string for any
for any time
any time a
time a carriage
line feed appears
feed appears in
need to scan
to scan our
scan our word
our word data
data array for
array for this
for this phrase
this phrase of
phrase of three
the inbuilt array
inbuilt array scan
array scan command
a very powerful
very powerful command
can use it
use it to
it to scan
to scan through
scan through an
through an array
an array and
array and collate
and collate it
collate it on
it on uppercase
This means it
means it doesn't
it doesn't matter
doesn't matter whether
matter whether it's
whether it's uppercase
it's uppercase or
uppercase or lowercase
or lowercase and
lowercase and we're
for the phrase
the phrase variable
return a value
a value in
in the i
the i variable
a long number
If the number
the number is
number is zero
is zero then
it's not in
it is greater
zero then the
then the entry
the entry already
entry already exists
already exists in
exists in the
with the i
i variable pointing
variable pointing to
pointing to the
to the element
the element of
So if it
is already in
already in the
the array all
array all we
increment the value
in the word
This adds one
value is one
is one it
one it will
will then become
then become two
is not in
the array we'll
array we'll need
add it into
it into the
array to slot
to slot it
slot it in
to data slot
data slot which
slot which will
will take our
take our phrase
our phrase and
phrase and add
and add it
add it to
is the three
the three word
three word phrase
We should at
should at this
this point not
point not actually
not actually have
have a phrase
a phrase which
phrase which is
is an empty
one string but
string but this
but this is
is a catch-all
a catch-all just
catch-all just in
have two local
local variables one
variables one for
for the index
the index variable
index variable and
variable and one
maximum number entries
number entries in
populate this max
this max variable
max variable to
variable to get
get the upper
use a fornix
a fornix loop
fornix loop to
data array looking
array looking for
for a blank
we find an
find an empty
an empty slot
empty slot then
slot then we
ahead and add
add the phrase
So we add
the phrase to
phrase to the
data array and
array and we
set the count
the count in
count in the
count array to
array to the
the value one
function immediately coming
immediately coming out
of the for
next loop as
loop as we
we have found
have found the
found the slot
put our new
our new phrase
to be feeding
be feeding a
feeding a fair
a fair amount
fair amount of
of data into
data into these
into these arrays
these arrays we
arrays we will
will come to
point where there
is not enough
not enough room
enough room left
room left in
left in the
array for any
for any more
any more data
if we search
we search through
search through all
through all of
array and find
and find there
find there are
are no empty
no empty slots
empty slots left
slots left then
left then we
expand the array
use the redim
redim command with
you to increase
increase the size
array by a
by a certain
a certain amount
certain amount and
amount and the
and the constant
the constant we're
constant we're using
we're using array
using array block
array block has
block has a
has a value
value of 1000
If you're going
you're going to
to be extending
be extending an
extending an array
an array it's
array it's good
practice to extend
to extend it
extend it by
it by a
by a fair
a fair margin
fair margin each
margin each time
time you need
to do it
do it as
it as it
it does take
does take per
take per basic
per basic time
basic time to
time to perform
perform this extension
Therefore if you're
going to extend
extend it extend
it extend it
each time necessary
This way it
way it minimizes
it minimizes processing
So we're adding
we're adding a
adding a thousand
a thousand elements
thousand elements on
elements on to
array and now
we can slot
can slot in
slot in the
in the new
the new value
As the max
the max variable
max variable has
variable has the
has the maximum
maximum number in
the existing array
existing array before
array before we've
before we've re-dimensioned
we've re-dimensioned it
re-dimensioned it we
it we can
can just increment
just increment that
increment that number
that number and
number and slot
and slot our
slot our value
our value in
we are adding
are adding on
on the phrase
next available slot
available slot and
slot and setting
and setting the
setting the word
word count to
count to the
we've achieved so
achieved so far
far is we've
is we've allowed
allowed the system
the system to
system to pick
up a file
has selected process
selected process them
process them into
them into the
array and store
application and make
and make sure
sure it works
we've completed the
completed the add
the add to
to data function
data function let's
function let's try
now to ensure
ensure that there
are no errors
no errors so
errors so far
application runs if
runs if we
data button we
button we should
we should get
should get the
get the dialog
the dialog to
to select our
select our data
into the data
data folder and
folder and we
will pick our
pick our very
our very small
very small file
small file first
file first of
of all and
all and hit
open button and
button and it's
and it's telling
it's telling us
telling us the
us the file
the file has
file has loaded
we try it
try it from
it from multiple
from multiple files
multiple files all
files all the
files are now
are now loaded
However we can't
we can't actually
can't actually at
actually at the
the moment see
moment see the
So let's put
let's put some
put some functionality
some functionality under
functionality under the
under the save
the save text
data button so
button so we
see the values
the values we've
values we've stored
in our arrays
code and into
and into the
we're now back
now back inside
back inside our
inside our event
function and we've
new event to
handle the clicking
the clicking of
clicking of the
of the save
And when this
when this button
this button is
button is actually
is actually clicked
actually clicked we
clicked we will
function called save
called save arrays
Passing it an
it an str
an str error
str error variable
contain any error
any error that
error that occurs
that occurs during
occurs during the
during the save
save and if
if that function
that function does
function does return
does return false
return false we
false we will
will display this
display this text
this text to
the user telling
user telling them
telling them what
them what went
what went wrong
went wrong with
wrong with saving
with saving the
saving the arrays
Otherwise we will
display the words
the words files
words files saved
files saved to
saved to the
to the status
create the save
the save arrays
save arrays function
function is fairly
up the file
file name to
name to save
to save as
save as being
as being the
being the current
the current executable
current executable path
executable path plus
that the constant
constant for the
array dump function
dump function which
function which exists
which exists in
exists in our
takes a string
string array and
array and dumps
and dumps it
dumps it out
it out to
out to the
then the file
has been successfully
been successfully saved
successfully saved and
saved and then
we can define
can define the
define the name
the name for
name for the
use another function
another function within
within our file
handling library that
library that will
that will dump
will dump out
dump out our
out our long
our long array
long array as
array as a
as a one-dimensional
a one-dimensional file
it the file
file name and
and path, the
wish to dump
to dump and
dump and an
error variable should
variable should any
should any error
any error occur
that returns false
returns false then
false then we
then we report
we report what
report what the
what the error
the error is
it returns true
create a CSV
is a file
a file purely
file purely for
purely for our
for our human
our human purposes
human purposes of
purposes of seeing
of seeing what's
seeing what's in
in the database
This combines both
combines both the
both the word
word count information
function to perform
perform that called
that called dump
called dump CSV
dump CSV file
is the final
the final function
final function within
within our application
our application for
application for today's
for today's video
Built within a
within a try
a try catch
try catch loop
catch loop this
loop this attempts
this attempts to
attempts to save
to save out
save out our
out our information
our information to
information to our
Giving it two
it two columns
word phrase and
phrase and one
for the count
number of times
of times that
times that particular
that particular phrase
particular phrase appears
phrase appears in
in our database
may well have
well have many
have many blank
many blank entries
blank entries within
entries within this
within this database
this database, anytime
anytime we reach
we reach a
reach a blank
blank entry we
entry we just
we just skip
just skip over
skip over it
then we print
we print out
print out to
the file our
file our word
data and our
and our word
our word count
Well first of
of all add
all add text
text data from
from the small
open that the
file is now
is now loaded
now loaded and
loaded and we
click on save
on save text
we've now saved
now saved a
saved a file
a file back
file back to
our data folder
data folder we
have a word
a word count
we open it
it up we'll
have a whole
a whole series
whole series of
series of numbers
at the word
text file we
file we have
have four sets
four sets of
sets of three
see this quite
quite easily has
easily has a
has a count
count of two
of two for
two for each
of these three
these three sets
sets of words
So our count
our count appears
count appears to
from the phrase
the phrase column
phrase column we
column we have
we have stripped
have stripped out
stripped out any
out any commas
any commas or
commas or periods
run this for
this for all
all of our
of our data
this case we'll
case we'll pick
we'll pick the
pick the 10
the 10 bulk
10 bulk files
And click and
click and open
We're now loading
now loading those
loading those files
a few seconds
few seconds it
seconds it will
will have completed
have completed the
completed the loading
the loading and
loading and tell
and tell us
us that the
that the files
the files have
files have loaded
we are the
are the files
now loaded so
loaded so we
save the text
the text data
are now saved
into our data
folder and have
So we look
CSV file first
we have 10,000
have 10,000 records
10,000 records in
records in this
this particular series
see they have
they have a
number of large
of large counts
For example anytime
example anytime the
anytime the three
three words end
words end of
of the appears
the appears it
appears it appears
it appears 20
appears 20 times
now have some
have some data
some data which
data which we
use to work
work out probabilities
out probabilities of
probabilities of text
we open this
open this CSV
this CSV file
in a spreadsheet
a spreadsheet we
spreadsheet we can
quite easily see
easily see where
see where our
where our prediction
our prediction is
prediction is going
have three highlighted
three highlighted lines
highlighted lines of
lines of text
of text here
Starting with beginning
with beginning of
at the count
count of each
of these phrases
these phrases the
phrases the most
the most likely
most likely third
likely third word
third word is
is the word
the word 'the'
It appears 10
appears 10 times
10 times in
times in our
Closely followed by
by the word
the word 'our'
word 'our' which
'our' which appears
which appears seven
appears seven times
seven times and
times and the
the word 'a'
word 'a' which
'a' which appears
which appears only
appears only once
So although we
although we have
we have only
have only fed
only fed 10
fed 10 sets
10 sets of
sets of data
data into this
into this machine
this machine learning
learning system we
system we could
we could feed
could feed many
feed many more
The more data
more data the
data the system
the system accumulates
system accumulates the
accumulates the more
the more likely
more likely it
likely it is
have a better
a better prediction
better prediction as
prediction as to
as to the
to the word
the word that's
word that's next
that's next going
next going to
in summary in
summary in this
in this first
this first video
first video on
video on text
on text prediction
text prediction we
prediction we have
created a system
a system to
system to accumulate
to accumulate data
uses the approach
the approach of
approach of taking
of taking three
taking three words
three words as
words as a
as a phrase
a phrase and
phrase and counting
and counting the
of iterations that
iterations that the
the system finds
system finds in
finds in the
gives us two
us two arrays
two arrays one
arrays one containing
one containing the
containing the three
and one containing
containing the number
of iterations of
iterations of that
of that phrase
This data is
data is going
be used in
used in subsequent
in subsequent videos
However that's it
created a dialogue
a dialogue which
dialogue which allows
which allows a
user to add
text data to
to our text
our text prediction
text prediction database
can pick one
pick one or
Click the open
button and these
and these will
be added to
to the database
moment we only
only have a
a small number
of files to
files to feed
to feed our
feed our system
be adding considerably
adding considerably more
considerably more files
more files to
to feed this
feed this system
this system, it's
it's a good
idea to provide
provide the user
with a progress
a progress bar
progress bar to
bar to indicate
to indicate how
indicate how long
how long the
long the process
the process is
process is going
list of constants
of constants we're
constants we're going
two more objects
for the label
the label of
label of the
of the progress
the progress bar
progress bar and
bar and one
for the progress
progress bar itself
moment we set
set the starting
the starting size
starting size of
our data array
data array at
array at 10,000
at 10,000 elements
number of increments
of increments we
increments we make
we make on
make on that
on that is
that is going
is going up
going up by
up by We're
by We're going
increase these figures
these figures to
figures to allow
to allow more
allow more data
more data to
data to be
We're pushing it
pushing it up
it up to
to a start
a start size
start size of
size of 20,000
of 20,000 elements
And each time
time this needs
this needs to
to be increased
be increased we're
increased we're increasing
we're increasing by
increasing by 5,000
by 5,000 elements
which displays our
displays our dialog
add these two
two new objects
new objects, a
bar and a
and a label
And also in
also in this
this video we're
video we're going
to be allowing
be allowing our
allowing our user
to type into
into the main
the main text
main text box
Once two words
two words have
words have been
have been typed
been typed in
typed in we're
in we're going
going to research
to research on
research on the
on the database
the database to
database to pick
pick out what
what the most
word is going
And they're going
to be sorted
be sorted with
sorted with the
with the most
most likely word
likely word at
word at the
to be making
be making some
making some changes
changes to our
have the sorting
the sorting option
sorting option on
option on so
on so we're
take that off
also have multi-column
have multi-column turned
multi-column turned on
going to turn
to turn that
turn that one
that one off
one off as
off as well
in place we'll
place we'll just
the font on
font on our
on our label
our label for
place let's run
application to ensure
ensure our progress
our progress bar
progress bar appears
bar appears in
in the correct
the correct location
correct location on
location on screen
is our progress
some code into
code into the
application to update
update the progress
progress bar as
bar as files
as files are
files are loaded
function which performs
which performs the
performs the processing
the processing of
processing of files
amend that to
that to take
to take an
take an extra
an extra parameter
progress bar so
bar so that
so that this
this function knows
function knows which
knows which object
which object to
object to update
this function there
function there are
are two possibilities
Either the user
has picked a
picked a single
or the user
has picked multiple
picked multiple files
set the range
the range of
range of the
progress bar based
bar based on
based on which
on which scenario
which scenario the
scenario the user
single file to
to load into
load into the
the system then
system then we're
setting the progress
the progress bar's
progress bar's range
bar's range to
range to between
to between 0
between 0 and
0 and 1
we'll set the
set the progress
progress bar at
bar at 1
at 1 after
1 after the
after the file
add in that
in that parameter
that parameter where
parameter where the
the process files
process files function
files function is
function is actually
And having that
having that in
in place we
place we can
can now try
now try to
try to run
we pick just
pick just a
see our progress
progress bar is
bar is updating
is updating quite
updating quite happily
let's put the
the same change
same change in
change in for
in for multiple
As a single
single file loads
file loads really
loads really quickly
really quickly we
quickly we hardly
we hardly need
hardly need a
need a progress
However once the
user is loading
is loading multiple
loading multiple files
multiple files it
files it will
will take longer
take longer to
longer to process
where the progress
progress bar becomes
bar becomes useful
So for multiple
multiple files we're
files we're setting
bar's range from
range from 0
0 to the
this section we're
section we're making
we're making two
making two changes
is to the
Previously we were
we were showing
were showing the
showing the words
the words loading
words loading file
loading file and
file and we've
and we've added
added to that
that to show
show the file
the file number
Additionally we're adding
on the words
the words record
words record space
record space and
space and then
then the upper
the array into
array into which
we're putting our
putting our words
our words data
is a good
a good indication
good indication of
indication of how
of how large
how large this
large this array
array is becoming
finally we're using
using a dialogue
a dialogue redraw
dialogue redraw command
to ensure the
ensure the dialogue
dialogue is shown
So let's click
let's click on
click on add
on add text
We'll pick 10
pick 10 files
10 files and
files and we'll
we'll click open
So the progress
bar is now
now showing us
showing us the
us the indication
the indication of
indication of what's
of what's actually
what's actually happening
it's not updating
not updating the
updating the status
So we obviously
small bug in
code so we'll
so we'll look
we'll look back
look back and
back and fix
fix that now
process file section
file section here
is the offending
the offending line
offending line of
We'll just comment
just comment this
comment this one
this one out
one out for
out for the
moment and we'll
running that again
We pick our
pick our 10
our 10 files
files and we
we click open
click open and
open and it
us the space
the space in
files are loading
are loading quite
loading quite happily
Once we've accumulated
we've accumulated a
accumulated a set
a set amount
set amount of
of data in
in the system
the system we'll
system we'll need
need a nice
a nice easy
nice easy way
of actually re-loading
actually re-loading that
re-loading that the
next time an
time an application
an application loads
application loads to
loads to save
to save having
save having to
having to build
to build it
build it every
it every time
every time we
time we run
a new button
new button to
button to a
to a toolbar
a toolbar that
toolbar that allows
that allows us
load the text
text data into
change to our
to our toolbar
our toolbar include
toolbar include file
include file to
file to allow
to allow that
in our toolbar
include file we've
file we've added
is for loading
a new icon
new icon called
icon called load
called load icon
And when we
when we create
we create the
create the toolbar
the toolbar we're
toolbar we're adding
adding this on
to the toolbar
the toolbar itself
should have the
have the new
the new icon
new icon on
our new icon
new icon, load
load training data
of this icon
this icon is
icon is to
load the two
the two files
be the word
word count which
count which contains
contains the number
number of each
of the iterations
the iterations of
three word phrases
the second file
second file is
file is word
is word data
word data dot
data dot text
This contains the
contains the three
put the code
the code into
code into our
into our application
allow the load
the load training
training data to
data to function
So once again
once again back
again back to
new event into
event into our
into our event
our new event
new event, the
the ID load
is clicked then
clicked then we're
load the training
the training data
training data arrays
function called load
called load arrays
load arrays which
arrays which takes
which takes a
will contain an
contain an error
an error should
error should something
should something go
something go wrong
go wrong with
wrong with loading
with loading the
loading the files
If this function
this function returns
function returns true
will display data
display data loaded
function returns false
will display an
display an error
an error message
error message to
now create our
create our load
our load data
load data arrays
data arrays function
our new load
new load arrays
load arrays function
going to attempt
load the word
We specify the
specify the location
a constant for
for the name
We're enclosing this
enclosing this in
in a try
try catch block
catch block just
block just in
in case an
case an error
an error occurs
We're opening the
opening the file
the file from
file from input
from input, scanning
scanning the file
file for the
number of records
us to re-dimension
to re-dimension the
re-dimension the word
the word array
word array for
for the correct
the correct size
And then since
then since this
since this is
string array we
use the align
the align input
align input command
input command on
command on a
single line to
line to load
load the data
data that is
that is in
file in one
in one step
one step into
step into the
And should something
go wrong we
wrong we then
we then populate
populate the error
the error variable
error variable with
with the error
the error that
error that occurred
finally we close
we close the
close the file
load this single
Assuming that file
that file loads
file loads successfully
loads successfully we
successfully we can
load the count
the count array
With this we're
this we're doing
we're doing almost
doing almost exactly
specifying the file
name to load
to load, we're
using a try
catch block to
block to trap
to trap any
trap any errors
any errors that
errors that occur
that occur, and
and we're re-dimensioning
we're re-dimensioning the
re-dimensioning the count
count array as
array as the
as the number
of records in
records in the
For numeric arrays
numeric arrays you
arrays you have
do a for
loop to populate
populate each element
array using an
using an input
an input command
And should an
should an error
an error occur
error occur we're
occur we're populating
populating that into
into the error
error variable and
variable and passing
and passing that
passing that back
this should now
should now allow
now allow us
the data up
data up into
up into our
into our array
know there's data
there's data there
data there so
there so if
we click load
click load training
training data it
data it should
it should tell
should tell us
us the data
the data has
data has been
got the data
the data into
the system we
can go into
into the next
to type some
type some text
some text in
text in here
in here on
on the type
the type text
type text box
and to get
get a list
list of possible
of possible words
possible words appearing
words appearing in
order to trigger
to trigger this
trigger this we
this we need
put another event
another event into
callback function the
function the EventHandler
looking specifically at
specifically at the
the text input
And we're putting
we're putting in
putting in an
in an enChange
an enChange event
This will pick
pick up every
up every time
every time this
time this text
text box changes
it will trigger
the user presses
user presses a
presses a key
a key on
key on the
the keyboard while
keyboard while they're
while they're inside
they're inside this
inside this text
function called processTextChange
called processTextChange giving
processTextChange giving it
giving it three
new function processTextChange
function processTextChange taking
processTextChange taking the
As this function
function will trigger
the keyboard when
keyboard when they're
when they're inside
text box we
box we need
ensure that they've
that they've typed
they've typed at
typed at least
at least two
least two words
use a Ctrl
a Ctrl Get
Ctrl Get Text
text that's currently
that's currently in
currently in that
to replace any
replace any carriage
any carriage return
line feeds we
feeds we find
we find within
find within that
within that data
that data with
data with a
Next we're testing
character of that
of that string
not equal a
equal a space
a space then
space then we
we will ignore
will ignore until
ignore until the
until the word
the word has
word has been
has been completed
function will only
will only go
only go further
go further if
further if the
the last character
last character typed
character typed is
typed is a
is a space
up the first
the first word
first word and
are the last
last two words
two words that
has actually typed
actually typed in
parse command comes
command comes in
comes in very
in very useful
very useful here
useful here as
here as using
as using the
parse command with
command with a
with a minus
a minus allows
minus allows you
you to look
from the right
hand side of
the string going
string going backwards
So since we
we are parsing
are parsing on
parsing on a
on a space
space character the
character the minus
the minus two
minus two value
two value will
value will give
you the second
The minus three
minus three value
three value will
you the first
So if both
if both the
both the first
the first and
first and second
and second word
second word are
word are not
are not empty
not empty length
length strings then
strings then we
we can proceed
have two words
two words so
words so we
need to suggest
to suggest a
suggest a possible
a possible next
possible next word
to populate a
populate a new
new variable which
variable which we're
to call phrase
This will consist
will consist of
consist of the
first and the
second word separated
word separated by
separated by a
single space and
and then tacking
then tacking on
tacking on to
the end another
end another space
function here called
here called suggest
called suggest word
new function will
function will have
will have the
have the job
the job of
job of working
of working out
working out what
out what word
what word we
word we want
want to suggest
to suggest to
suggest to the
passing to this
new function three
function three parameters
and the phrase
the phrase we
phrase we have
have just built
just built up
skeleton of this
of this new
new function suggest
function suggest word
suggest word with
word with its
going to suggest
suggest a word
a word based
word based on
the phrase that's
phrase that's been
that's been passed
And we'll sweep
we'll sweep through
sweep through our
through our array
our array looking
looking for possible
for possible matches
case we may
we may have
may have multiple
have multiple matches
multiple matches on
matches on the
we go further
go further let's
further let's have
at the words
the words we've
words we've built
we've built up
built up so
up so far
data dot CSV
dot CSV file
is the composite
the composite file
composite file which
file which has
which has not
has not only
not only the
only the three
three words but
words but how
but how many
many times they
times they actually
they actually appear
open this up
spreadsheet we will
get our list
order to have
a good amount
good amount of
of data I've
data I've fed
I've fed the
fed the system
the system with
system with a
with a large
During this feeding
this feeding exercise
feeding exercise I
exercise I discovered
I discovered there's
discovered there's a
there's a performance
a performance problem
performance problem when
problem when you
when you feed
you feed it
it a large
The more files
more files you
files you feed
feed it the
it the slower
the slower it
slower it becomes
We'll tackle this
tackle this performance
this performance issue
performance issue in
issue in the
But we've got
we've got enough
got enough data
enough data in
data in this
this file to
to actually progress
If we filter
we filter our
filter our data
our data based
first two words
two words as
words as in
as in we
in we will
are a large
of options on
options on we
on we will
we will and
will and you
can see which
see which ones
which ones are
ones are going
be the largest
if we do
do a sort
a sort based
sort based on
on the count
We'll see which
ones are likely
likely to appear
to appear at
we have we
have we will
the very top
very top closely
top closely followed
followed by we
by we will
And we get
get a decreasing
a decreasing number
decreasing number going
number going down
going down the
down the list
a fairly common
fairly common phrase
common phrase we
phrase we want
display a limited
a limited number
limited number of
of these to
set the system
the system so
system so that
that it displays
it displays 10
displays 10 values
10 values to
values to the
the user from
user from which
from which they
they can select
So we'll keep
keep this spreadsheet
this spreadsheet open
We can refer
can refer back
to it to
it to ensure
that our search
our search process
search process is
process is actually
is actually pulling
actually pulling back
back the correct
the correct data
As spreadsheets are
spreadsheets are very
are very good
very good at
good at locking
at locking files
locking files we
files we will
have no issue
no issue with
issue with our
with our application
Because this CSV
CSV file is
file is not
not actually used
actually used by
used by the
use the two
the two text
two text files
let's first of
of all have
all have a
can pull information
out of our
I said we're
said we're going
be displaying 10
displaying 10 words
10 words to
words to the
We'll set this
set this limit
this limit in
limit in a
in a constant
is our maximum
our maximum number
number of suggested
of suggested words
suggested words constant
words constant set
constant set to
to be 10
couple of additional
of additional variables
additional variables here
One called start
called start and
start and one
one called end
These will specify
will specify the
specify the start
and end positions
end positions to
positions to scan
to scan in
scan in our
in our array
the start value
start value initially
value initially to
initially to 1
to 1 and
and the length
the length of
length of the
of the phrase
the phrase is
phrase is going
used for the
the end value
us to identify
to identify the
identify the word
the word we
We are looking
are looking for
for the words
the words we
we will followed
will followed by
want anything else
anything else that's
else that's going
appear in there
So we're searching
we're searching for
searching for this
for this number
this number of
And we're dimensioning
we're dimensioning two
dimensioning two new
These arrays are
arrays are going
hold the results
the results of
results of our
of our search
the array scan
This to scan
to scan the
scan the data
that's held in
using the from
the from command
from command to
ensure that we're
that we're only
we're only testing
only testing the
testing the first
the first few
first few characters
few characters of
characters of the
data in each
looking for we
for we will
looking for just
for just the
just the we
the we will
will and the
and the space
the space after
space after it
We're collating it
collating it to
it to uppercase
to uppercase to
uppercase to ensure
ensure we're doing
doing a case
a case independent
case independent search
And should we
should we find
we find a
find a value
a value we're
value we're passing
passing that to
variable called match
If the match
the match variable
match variable comes
variable comes back
comes back with
back with a
with a zero
a zero value
zero value then
value then we
have found no
found no matches
no matches at
matches at all
returns a number
a number other
number other than
have found a
found a match
have no matches
no matches we
matches we exit
we exit the
can display to
the user our
user our first
our first match
first task in
task in here
is to clean
to clean out
clean out our
out our list
list box using
box using the
add our first
our first result
first result to
result to our
get the word
the word out
word out of
data array by
array by using
command and looking
and looking for
last element held
element held within
held within there
can pull out
out the word
count to know
to know how
how many this
many this actually
this actually is
actually is and
is and we
to actually store
actually store that
store that information
information in our
Just to prove
to prove the
prove the logic
logic so far
far is actually
is actually working
Let's put a
put a bit
in here just
here just to
just to display
this on our
out these two
will put in
in a command
add it straight
it straight away
straight away to
away to the
We load our
load our training
our training data
data is loaded
And to test
this out we
out we will
we will type
will type in
type in the
in the words
And a space
And as soon
get the space
space bar we
bar we get
the word look
word look coming
look coming out
Now this just
this just so
just so happens
so happens to
happens to be
be the highest
the highest one
highest one on
this case that's
case that's because
that's because it's
because it's the
it's the first
first one in
one in the
the file of
file of all
all the ones
the ones we
ones we can
we've proved the
proved the logic
the logic to
logic to search
to search our
search our array
our array is
array is actually
need to push
to push on
on and we'll
of our add
our add to
word data taking
data taking four
taking four parameters
The word that
word that we
to add, the
of that word
that word and
the two arrays
These are our
are our result
our result arrays
Which are only
are only 10
only 10 elements
10 elements in
elements in size
whether the array
the array has
array has already
already been filled
Possibly we already
already have 10
have 10 values
we're testing whether
testing whether the
whether the number
the number within
within the array
the array is
array is larger
is larger or
larger or equal
or equal to
word count for
count for the
case then the
then the array
array is full
is full and
full and this
and this word
this word count
word count is
count is not
is not greater
Therefore we ignore
we ignore it
Otherwise we need
need to step
the 10 elements
elements in our
our arrays to
arrays to check
current slot has
slot has a
has a greater
a greater value
greater value than
value than the
than the current
current value coming
value coming in
coming in then
in then we
then we iterate
we iterate our
iterate our loop
So we're only
we're only wanting
only wanting to
wanting to add
add the value
our result array
result array if
array if the
that word are
word are greater
the value already
value already stored
we're testing for
testing for an
for an empty
it's an empty
empty slot we
slot we will
store the value
will check the
check the value
value held in
word count against
count against the
against the word
word count coming
count coming in
we will only
will only store
only store this
store this new
this new value
new value and
value and word
and word if
word if the
if the word
coming in is
in is greater
quite easily use
easily use the
use the useful
the useful array
useful array insert
array insert command
This will insert
will insert the
insert the value
array and push
and push all
push all the
the other values
other values down
values down by
And if there
if there had
there had been
had been a
been a value
in the 10th
the 10th element
10th element slot
element slot it
slot it would
it would drop
would drop off
drop off the
So the array
the array commands
array commands that
that are provided
are provided by
provided by Power
Power Basic are
Basic are very
are very powerful
very powerful and
powerful and save
and save a
save a great
deal of coding
this first match
first match to
match to our
our array we
array we need
look for more
for more matches
since the match
the match value
match value we've
value we've found
we've found is
found is the
the array we're
array we're just
to add one
one to it
And we'll store
we'll store that
store that as
that as previous
as previous match
while the previous
the previous match
previous match is
match is less
is less or
less or equal
to the upper
data array we
can then proceed
But only if
only if the
if the count
count of results
of results we
results we have
we have is
have is less
less than or
than or equal
the word result
words we have
not yet reached
yet reached the
reached the 10
the 10 results
can now search
now search for
search for another
for another match
another match within
match within this
within this while
this while loop
searching for the
for the same
the same information
same information but
information but we're
but we're only
we're only searching
only searching for
for the previous
previous match value
match value onwards
we will skip
will skip over
skip over everything
over everything that
everything that is
that is before
is before the
before the match
the match we
match we just
we just found
the match returns
match returns zero
zero then there
are no more
no more matches
more matches and
matches and we
exit the loop
Otherwise we want
want to record
to record this
record this new
this new find
before we will
increment the count
the count and
count and we
we will push
will push the
push the match
the match onwards
match onwards to
onwards to the
previous match minus
match minus one
So this sets
sets the array
the array index
using that we
can actually get
actually get the
the data of
data of the
the word and
And having got
having got those
got those two
two variables we
then go ahead
ahead and call
and call the
call the function
the function again
function again to
again to add
add the data
And once we've
once we've done
we've done that
set the previous
previous match to
match to be
be the long
the long match
long match plus
match plus one
once we've got
of this we
this we should
should have 10
10 values held
values held within
held within our
within our results
our results arrays
they will already
will already be
already be pre
be pre sorted
pre sorted with
the most prevalent
most prevalent word
prevalent word being
word being at
being at the
now need a
need a simple
loop to add
add them all
them all to
all to the
As possible we
possible we may
not actually get
actually get 10
get 10 values
Therefore we can
word array to
array to make
sure it's not
case we can
we can safely
can safely add
safely add it
it to our
have our code
data to load
load our data
We'll bring in
in our spreadsheet
our spreadsheet which
spreadsheet which is
which is what
what we are
we are testing
are testing against
testing against and
against and we
hit the space
we have what
have what appears
be 10 results
10 results on
results on the
first word is
word look which
look which is
the top in
top in our
our list which
list which is
the word see
word see which
see which is
the second on
second on the
But the third
the third one
third one on
the list should
list should be
the word create
word create which
create which is
is not on
not on the
do have set
have set next
set next but
next but we
the word cover
word cover which
cover which is
which is further
down so we
we are skipping
are skipping some
skipping some words
some words out
words out of
So there appears
there appears to
be a bug
bug in our
to the look
see whether a
whether a bug
a bug has
bug has occurred
So as it's
as it's appearing
it's appearing with
appearing with two
with two entries
two entries quite
entries quite correct
quite correct it
correct it may
it may well
with the position
the position in
position in the
a look where
look where we
where we actually
we actually do
do that piece
that piece of
function which does
which does the
does the suggesting
the suggesting of
suggesting of the
This is running
is running in
a loop and
loop and currently
and currently it's
currently it's looking
it's looking at
looking at this
at this condition
for the match
the match we're
match we're actually
looking at being
at being under
being under the
under the maximum
elements in the
And that the
the count number
count number is
than the word
I think this
think this is
This is limiting
is limiting the
limiting the result
the result to
result to finding
to finding 10
finding 10 values
It's quite possible
quite possible in
possible in our
our file that
that the has
the has a
has a larger
a larger word
larger word count
So having commented
having commented this
commented this line
code out let's
out let's try
our application we
application we can
training data and
data and we
we can bring
can bring in
in our test
our test data
what we're looking
we're looking to
looking to get
to get on
get on our
on our screen
our screen this
screen this 10
this 10 list
So let's type
let's type the
type the words
words we've been
we've been given
been given as
given as a
as a selection
first one on
see which appears
which appears next
word create and
create and then
the word set
the word then
word then and
then and then
two words which
words which have
which have the
the same count
same count value
Cover and declare
and declare which
declare which we
we have both
have both on
both on the
then have populate
have populate and
populate and continue
and continue which
continue which matches
which matches on
matches on our
have the final
the final 10th
final 10th value
10th value of
value of need
Need is a
value of four
number of fours
of fours on
fours on the
the list it
list it will
it will pick
will pick whatever
pick whatever one
whatever one comes
one comes first
would appear we
appear we have
have successfully managed
successfully managed to
managed to get
of 10 possible
10 possible words
Which matches the
matches the data
of our spreadsheet
is we've amended
we've amended our
amended our application
allow the loading
the loading of
loading of the
of the training
training data that's
data that's previously
that's previously being
previously being assembled
With this training
this training data
training data in
data in our
can then type
then type in
type in two
in two words
two words to
words to our
our text box
soon as the
as the space
space bar is
bar is pressed
is pressed after
pressed after the
after the second
second word it
word it will
will then search
then search out
search out 10
out 10 possible
Starting with the
most prevalent at
prevalent at the
And this matches
this matches the
the data we've
data we've got
we've got back
got back from
back from our
from our spreadsheet
So our text
prediction software appears
software appears to
be working fine
we will attempt
attempt to bulk
to bulk load
bulk load even
load even more
even more data
more data into
data into our
into our system
our system and
system and make
and make it
it more performant
Our application allows
application allows us
us to take
to take individual
take individual text
individual text data
data files and
files and accumulate
and accumulate them
accumulate them into
them into an
have an additional
an additional icon
additional icon that
icon that allows
to save that
save that text
that text data
text data file
data file back
back to disk
This comprises our
comprises our training
then load that
load that training
that training data
training data into
once we start
we start typing
start typing some
typing some text
some text, after
we have typed
have typed two
typed two words
two words, we
to allow our
allow our user
the possible words
possible words and
words and it
and it to
to be automatically
be automatically added
automatically added to
make some changes
our application today
application today to
today to allow
it to handle
to handle even
handle even more
even more bulk
more bulk data
you have an
have an application
an application that
application that has
that has a
has a dialog
a dialog and
dialog and there
there is some
is some background
some background processing
background processing happening
processing happening, you
you may well
may well find
well find that
find that while
that while the
while the background
the background processing
background processing is
processing is running
is running, the
dialog will display
will display not
display not responding
is because all
because all the
all the processing
the processing power
processing power has
power has been
been taken up
taken up by
up by the
by the backend
the backend processing
put some events
some events in
events in to
populate our dialog
our dialog progress
dialog progress bar
bar as the
application loads its
loads its data
this using a
couple of custom
of custom events
we're adding these
adding these as
as constants to
constants to our
One called progress
called progress event
progress event and
event and one
progress event completed
These custom events
custom events will
events will be
be triggered to
triggered to indicate
dialog that it
that it needs
needs to upgrade
to upgrade the
upgrade the progress
the callback event
callback event, the
can insert our
insert our new
our new custom
new custom events
These appear above
appear above our
above our WM
our WM command
command section and
section and there
are two new
two new events
new events, progress
progress event which
event which will
which will set
bar to a
to a specified
a specified value
specified value which
which is coming
is coming in
coming in with
with the cbwparam
the cbwparam and
cbwparam and it's
it's also setting
which file it's
file it's actually
it's actually loading
once the loading
the loading has
loading has been
been completed, we
can then trigger
then trigger the
trigger the progress
the progress event
It will set
set the control
set text to
text to loading
to loading completed
probably guess, we
we will also
will also need
to the process
files function to
function to trigger
to trigger these
trigger these two
When a single
single file is
file is being
is being processed
being processed, we
we can leave
can leave the
leave the code
code as is
Since the backend
backend processing will
processing will run
will run so
run so quickly
so quickly that
quickly that the
that the dialog
the dialog won't
dialog won't have
won't have time
have time to
time to time
to time out
So the change
the change needs
change needs to
to be in
be in where
in where we're
where we're processing
we're processing multiple
processing multiple files
we can remove
can remove the
remove the section
section where we're
where we're setting
bar as this
as this will
will be carried
be carried out
carried out by
out by our
by our new
our new events
can also take
also take out
code here where
here where the
bar is having
is having its
having its value
its value set
to replace that
a dialog post
dialog post event
We're still using
still using the
using the progress
the progress set
progress set range
set range command
range command to
But as each
as each file
each file has
new command, dialog
dialog post, to
dialog to that
that particular custom
particular custom event
custom event, in
this case progress
case progress event
progress event, to
to update it
update it for
value we wish
And we're sending
we're sending two
sending two parameters
file number we're
number we're handling
we're handling, and
being the upper
call a dialog
a dialog do
dialog do events
do events to
events to give
give the dialog
the dialog a
dialog a small
a small time
small time slice
time slice to
slice to actually
to actually process
actually process that
process that event
the end when
end when the
when the files
are loaded, we
can take this
code out and
out and replace
and replace it
replace it with
it with a
dialog post command
post command as
command as well
This one will
one will be
will be posting
be posting the
posting the message
the message 'event
message 'event completed'
display a progress
user and allow
allow the dialog
not to show
show the message
the message not
message not responding
Also as a
as a matter
a matter of
matter of interest
of interest, we
put some metrics
some metrics in
metrics in while
in while we're
while we're developing
This metric will
metric will tell
tell us how
us how long
how long it
long it takes
it takes to
takes to process
to process each
process each file
beginning of application
this to specify
specify the name
of a metrics
a metrics text
metrics text file
Into this metrics
this metrics file
metrics file, we
we can write
can write details
write details for
details for how
for how long
us to determine
if the time
the time taken
time taken to
taken to process
each file is
file is increasing
new constant, metrics
function that processes
that processes the
processes the files
is to erase
to erase the
erase the metrics
the metrics file
metrics file should
file should it
should it exist
can be done
be done quite
quite easily in
easily in a
the file exists
file exists, we
we delete it
delete it using
using the kill
the kill command
the file does
file does not
does not exist
not exist, then
then no error
no error will
error will be
will be generated
be generated to
generated to the
as we process
we process each
process each data
each data file
data file, we
can write to
write to this
to this metrics
this metrics text
can set up
a timer at
timer at the
the application using
application using a
using a quad
a quad variable
then update the
update the timer
the timer variable
timer variable by
variable by subtracting
by subtracting it
subtracting it from
it from the
the current timer
us the number
number of seconds
of seconds the
seconds the application
the application took
application took to
took to process
to process that
process that data
that data file
can then append
then append it
append it to
of our metrics
our metrics file
up our text
our text data
10 files, it
it open, and
and that's them
that's them processing
them processing now
So we'll let
we'll let all
let all 10
all 10 files
10 files load
files load, and
then we'll look
we'll look at
at our metrics
And there's our
there's our loading
our loading having
loading having been
having been completed
will save our
save our text
text data, and
and then come
then come out
come out of
is our metrics
our metrics text
that up, we
see the number
of seconds it
seconds it takes
So it ranges
it ranges between
ranges between less
between less than
less than one
than one second
one second to
second to a
to a full
a full three
full three seconds
as we found
we found in
found in the
last video, if
if we're processing
we're processing a
processing a large
of files, it
it can take
can take a
take a long
a long time
long time to
time to process
at the issue
the issue to
issue to see
make the application
the application a
application a little
little more performant
Since the function
the function of
of our processing
our processing is
processing is to
look for patterns
for patterns of
three words, and
these are to
the array, which
which is global
we add data
add data to
to the data
the data slot
here is this
is this function
this function taking
function taking as
taking as its
as its sole
its sole parameter
sole parameter the
parameter the three
word phrase which
which is to
is to go
our data slot
It's already been
already been checked
been checked to
checked to see
if this phrase
this phrase already
phrase already exists
this case, if
it's not found
not found in
the array, we
this function add
function add to
function is looking
is looking for
looking for an
And every time
time we wish
add to this
this list, it's
it's looking again
looking again to
again to find
to find the
find the next
is not particularly
not particularly efficient
be a better
a better way
better way of
way of working
working out where
available slot is
variable called max
called max entry
store the next
next available entry
available entry into
entry into which
So currently, we
we are working
are working out
what the maximum
array is, what
what the upper
upper bounding is
thing we have
increment the max
the max entry
max entry variable
This should take
us to the
the next empty
next empty slot
If that number
ahead and slot
and slot the
slot the data
the data straight
data straight in
straight in without
in without reading
without reading through
reading through any
through any further
any further in
our new processing
will use max
use max entry
max entry to
entry to hold
hold the value
last populated empty
populated empty slot
We'll then increment
then increment that
that value to
value to move
than the upper
the array itself
array itself, we
can put the
put the data
into the slot
the slot and
slot and then
set the word
can then exit
then exit the
If this value
this value is
value is not
not true, then
we will re-dimension
will re-dimension the
re-dimension the data
And the only
the only difference
only difference being
difference being, we
can just change
just change these
change these variables
these variables to
variables to designate
to designate the
designate the global
the global one
So a very
a very minor
very minor change
minor change to
application should make
should make it
can specify this
this new global
global variable at
And we try
we click to
click to accept
to accept our
accept our test
will see, it
it does load
does load remarkably
load remarkably quickly
can then save
then save that
now got past
got past the
past the performant
the performant problem
performant problem of
problem of our
we should be
should be able
able to feed
feed it with
with a great
deal more data
more data now
want to tackle
to tackle is
tackle is the
the data going
data going into
into the text
will see, when
the data goes
data goes in
goes in, it's
it's not folding
not folding the
folding the text
So I'd like
like to put
put something into
something into the
allow the application
application to handle
to handle that
new constant to
constant to specify
of characters after
characters after which
after which we're
going to fold
to fold down
fold down to
And I'm also
for the handle
over what happens
happens within that
text box, we're
bit of subclassing
of subclassing of
subclassing of that
look where the
where the dialogue
dialogue is specified
displays the dialogue
So we're first
we're first going
store the dialogue
dialogue handle in
handle in the
up a piece
code which allows
us to subclass
to subclass our
subclass our text
text box event
box event handler
couple of Windows
API calls here
get the dialogue
the dialogue item
dialogue item to
item to give
us the window
the window handle
window handle, giving
it the two
up this new
variable called old
called old proc
function which will
contain the code
to do our
do our event
our event handling
event handling for
handling for the
So this means
this means any
means any code
any code we
have that handles
that handles our
handles our dialogue
our dialogue handling
dialogue handling within
handling within the
within the main
callback function can
function can be
can be removed
be removed and
removed and we
now put this
put this into
this into our
into our subclass
our subclass function
will now create
create our update
our update text
update text box
text box function
As you would
you would see
would see, it
are the parameters
the parameters which
parameters which are
are used for
for the event
the window, the
the message that's
message that's been
that's been processed
the W parameter
W parameter and
parameter and the
and the L
storing in our
in our old
our old proc
old proc the
proc the value
of our old
our old process
This to handle
to handle each
handle each of
the types of
types of messages
of messages we're
messages we're going
to be getting
be getting from
getting from the
from the text
the first will
first will be
be a destroy
a destroy event
This is when
when the object
the object is
object is destroyed
is destroyed when
destroyed when a
when a dialogue
a dialogue closes
dialogue closes down
Next we're putting
putting in a
in a event
a event called
event called wmchar
called wmchar and
wmchar and we're
we're calling another
calling another Windows
API call here
here to invalidate
to invalidate the
invalidate the rectangle
we're basically doing
basically doing nothing
doing nothing on
nothing on this
on this event
this event for
event for the
The next we
actually test when
test when the
user finishes pressing
finishes pressing a
pressing a key
is the key
the key up
key up event
What's happening within
happening within this
this event will
event will look
will look familiar
calling the two
functions we did
did in our
in our original
our original callback
original callback function
doing a call
call to trim
to trim text
trim text and
text and we're
we're also calling
also calling the
calling the process
the process text
process text change
text change function
here is going
be one function
one function called
function called wmpaint
is to paint
to paint some
paint some information
some information into
information into this
into this window
this window to
window to give
the user some
user some feedback
What this function
function will do
will do will
do will put
put the words
the words type
words type in
type in here
in here in
in the very
box and it
display this in
this in gray
application now, you'll
you'll see the
see the change
the change that
change that has
has been made
here are appearing
are appearing in
appearing in gray
in gray in
gray in the
middle of our
box and once
we start to
start to type
to type they
type they will
they will disappear
will disappear and
disappear and once
and once all
once all the
the text has
text has been
been removed the
removed the words
the words will
words will pop
will pop back
pop back again
is a technique
a technique to
technique to give
to give valuable
give valuable feedback
valuable feedback to
on what to
what to do
handle the data
in the possible
possible words list
words list box
data and start
to type, we
on this and
this and actually
and actually put
actually put this
put this information
this information into
information into the
code into an
into an event
an event handler
handler and create
create the event
the event to
to handle clicks
handle clicks on
on this list
have no code
no code to
code to handle
to handle anything
handle anything that
anything that happens
that happens on
happens on the
can remove this
remove this section
code here as
here as the
as the functionality
the functionality is
functionality is being
is being handled
being handled in
handled in the
in the separate
the separate function
separate function we
created a few
a few moments
few moments ago
can take that
that out completely
the event we
event we want
handle when a
clicked on this
using the button
button click event
all we want
get the item
the item that
item that has
been selected and
selected and pass
and pass that
pass that into
that into a
call that variable
that variable item
text at that
at that item
that item and
item and pass
that to another
to another variable
variable which we'll
we'll call selected
call selected which
selected which will
be a string
that currently sits
currently sits within
sits within the
within the text
text box using
then push that
push that information
information back out
back out to
text box by
box by adding
on the selected
the selected variable
selected variable to
end of str
of str data
str data followed
data followed by
a single length
single length space
So to ensure
the data doesn't
data doesn't exceed
doesn't exceed the
exceed the width
box we can
call the trim
the trim text
trim text function
as we've now
a new word
new word onto
word onto the
onto the end
have to repopulate
to repopulate the
repopulate the list
box to get
the next set
next set of
set of words
of words that
user can click
get the str
str data value
data value coming
call the process
change function as
function as we've
we've done before
done before to
before to repopulate
to repopulate our
repopulate our list
application we have
have a few
few new variables
new variables we'll
now we try
our application let's
application let's see
let's see how
up our training
to type and
type and there
have our list
items on our
list box it
box it populates
it populates into
populates into the
of words which
words which we
can now select
now select for
select for and
for and this
this can go
go on indefinitely
Now our text
text is wandering
is wandering slightly
wandering slightly off
slightly off the
off the page
the page so
page so we
have to reduce
of characters slightly
characters slightly but
slightly but the
but the folding
the folding round
folding round has
round has actually
has actually worked
far is we
we have managed
have managed to
the text repainting
text repainting itself
Now occasionally we
occasionally we will
find that the
that the possible
possible words don't
words don't match
don't match what
want to type
to type so
type so we'll
so we'll have
have to click
to click back
click back into
box and type
and type another
type another couple
another couple of
couple of words
then the possible
possible words will
pop back up
back up again
before we complete
we complete today's
complete today's video
today's video let's
video let's look
let's look further
have generated today
of the useful
the useful functions
useful functions we've
functions we've added
added to our
text box today
box today is
is the trim
text function to
function to ensure
ensure the data
data doesn't go
doesn't go beyond
go beyond the
beyond the size
We set a
set a constant
the application for
application for 65
for 65 characters
This was a
was a rough
a rough guess
rough guess to
guess to ensure
ensure that what
that what the
user types will
types will always
always be visible
be visible to
visible to them
to them on
When making use
use of an
of an inbuilt
an inbuilt Power
inbuilt Power Basic
Power Basic command
Basic command called
command called split
called split this
split this inbuilt
this inbuilt Power
called split has
split has an
has an option
an option called
option called word
When used together
used together these
together these two
these two can
two can take
take a string
of text and
text and split
and split that
split that string
of text into
text into two
into two and
two and it
will do on
on a word
a word boundary
This means you
means you don't
don't have to
have to write
to write any
write any special
any special code
special code to
out where a
where a word
a word begins
word begins or
begins or ends
This will do
do it all
it all for
all for you
for you and
you and it
puts the value
the value into
value into two
into two variables
two variables the
variables the first
the first piece
first piece of
text and the
the second piece
second piece of
of course put
course put this
loop to go
to go down
go down a
down a large
a large piece
large piece of
and split it
split it to
it to any
to any width
any width you
width you wish
And using this
this command allows
command allows us
to actually fold
actually fold the
moment this code
this code is
code is only
is only looking
only looking at
very last line
last line of
of text within
the user go
user go further
go further up
further up the
box and decide
and decide to
decide to actually
to actually make
actually make more
make more edits
more edits including
edits including new
including new lines
new lines it
lines it would
it would only
would only work
only work for
work for the
the last line
However we may
we may actually
may actually amend
actually amend this
amend this in
The other item
other item of
item of note
of note within
note within this
use of control
of control post
This is posting
is posting a
posting a message
a message back
message back to
back to that
to that specific
that specific text
specific text box
using a selection
a selection command
put the cursor
the cursor at
cursor at the
The command can
command can also
can also be
also be used
used to highlight
to highlight a
highlight a piece
text within a
within a string
a string within
string within that
within that object
using the end
end of text
of text value
text value which
which is equal
to the length
text box it
box it automatically
it automatically puts
automatically puts the
puts the cursor
the cursor right
cursor right at
the last piece
is we've enhanced
we've enhanced our
enhanced our dialogue
our dialogue to
dialogue to fold
to fold text
fold text down
next line when
line when the
user is typing
created a subclass
a subclass function
subclass function to
function to handle
the events for
events for our
for our text
We've also allowed
box to pick
pick a word
a word to
word to add
the list and
list and once
and once that
once that word
that word has
been added we
added we re-query
we re-query the
re-query the data
held in our
our array to
possible word could
word could be
And finally we've
finally we've improved
we've improved the
improved the performance
the performance of
performance of the
application when we're
when we're adding
we're adding text
adding text data
to our database
you'll find some
find some of
of these routines
these routines useful
routines useful in
look at drop-down
at drop-down or
drop-down or combo
or combo boxes
combo boxes on
boxes on forms
on forms with
forms with the
the code file
code file we
file we were
we were using
were using in
using in the
this form we've
form we've created
created a drop-down
a drop-down list
drop-down list or
list or a
or a combo
a combo box
our Hello World
Hello World application
World application is
application is probably
is probably best
probably best having
best having its
having its executable
its executable name
executable name changed
is quite easily
quite easily done
leave the source
source code as
code as called
as called HelloWorld
called HelloWorld but
HelloWorld but we
can actually change
the name it
name it compiles
it compiles to
There we go
Just putting on
putting on a
on a optional
a optional parameter
optional parameter after
parameter after the
after the compile
the compile EXE
compile EXE means
EXE means it
means it will
it will compile
will compile to
compile to readthedata.exe
If you look
you look at
at the folder
folder we have
the moment there's
moment there's our
there's our HelloWorld
we then go
ahead and compile
and compile it
compile it and
it and have
at our file
our file there
file there is
is our readthedata.exe
using the original
the original bas
original .bas file
.bas file but
file but we're
but we're now
we're now compiling
now compiling to
compiling to a
a different executable
do we add
add a drop-down
a drop-down box
drop-down box to
box to this
to this form?
this form? Quite
form? Quite simply
Quite simply we
simply we nip
we nip up
nip up to
to the tools
the tools menu
tools menu and
menu and click
click on PowerBasic
on PowerBasic forms
PowerBasic forms which
forms which will
which will load
will load all
all the forms
the forms for
forms for our
the moment there
moment there is
only one form
one form in
form in here
here and this
this is it
Now over in
over in our
in our toolbox
our toolbox there
toolbox there are
number of tools
of tools we
tools we can
can actually bring
actually bring in
in the combo
the combo box
we bring that
bring that one
that one in
one in and
in and there's
there's our combo
our combo box
Now simple double-clicking
simple double-clicking on
on the combo
combo box lets
box lets us
lets us set
us set some
set some properties
we'll do is
do is we'll
is we'll give
we'll give it
it a name
a name CBOverComoBox
name CBOverComoBox and
CBOverComoBox and we
to be reading
be reading data
reading data we've
data we've created
created in a
call this one
this one eye
one eye color
And since it's
since it's a
it's a combo
combo box it
box it doesn't
it doesn't actually
doesn't actually need
actually need a
need a caption
Now we OK
we OK on
on that and
that and we
will change our
change our title
our title to
title to something
to something appropriate
something appropriate for
appropriate for selection
for selection of
selection of this
of this combo
So now our
now our form
our form if
form if we
we test it
test it displays
it displays select
displays select the
select the eye
the eye color
eye color and
color and there's
there's a combo
combo box which
which is populated
is populated with
populated with some
with some test
some test items
test items for
items for you
can then pick
Right so what
so what kind
kind of combo
of combo box
combo box have
box have we
have we actually
we actually selected
Well despite giving
despite giving just
giving just a
just a name
a name if
name if we
the styles we'll
styles we'll see
we'll see what
what we actually
we actually got
Now of these
of these styles
these styles these
styles these are
these are properties
are properties basically
properties basically of
basically of the
Tab stop is
stop is automatically
is automatically ticked
automatically ticked which
ticked which means
which means when
means when the
user is tabbing
is tabbing around
tabbing around the
screen it will
it will stop
will stop at
stop at this
at this control
You can turn
can turn that
turn that off
that off if
off if it's
it's not needed
are three basic
three basic types
basic types of
types of dropdown
The dropdown we've
dropdown we've got
we've got selected
got selected at
selected at the
combination of a
box and a
and a dropdown
a dropdown list
Hence combo box
What that means
that means is
means is if
is if we
we actually run
run the program
the program again
program again now
again now just
now just in
just in our
our test here
test here it
here it means
it means not
means not only
not only can
only can we
can we pick
we pick from
pick from the
from the dropdown
dropdown list but
list but we
we can type
can type in
type in to
to the dropdown
Now this may
this may be
may be functionality
be functionality you
functionality you actually
you actually want
actually want when
want when you
you want a
want a user
to actually input
actually input a
input a value
a value that's
value that's not
that's not on
want to restrict
to restrict them
restrict them so
them so they
so they can
they can only
can only pick
only pick what's
pick what's on
what's on the
the list then
list then what
then what you
what you have
do is if
is if you
at the properties
of the combo
combo box you'll
box you'll see
see that at
moment it's dropdown
it's dropdown which
dropdown which is
combination of text
of text box
box and dropdown
and dropdown list
If you pick
you pick the
the top one
top one that
one that gives
that gives you
you a combination
of a label
a label and
label and dropdown
list box controls
So we click
that and hit
and hit OK
to run that
run that one
that one now
one now that
now that still
that still gives
still gives us
a list but
list but it
but it doesn't
it doesn't give
doesn't give the
give the ability
ability to actually
to actually type
actually type anything
type anything in
you can only
only pick items
pick items which
items which were
which were already
were already on
already on the
Now for the
purposes of this
combo box that
box that will
that will do
will do nicely
The other properties
other properties you
properties you have
pre selects for
selects for sort
for sort so
sort so wherever
so wherever you
wherever you put
you put into
into that dropdown
dropdown list will
will be sorted
be sorted alphabetically
cover the other
options in a
later video but
video but for
but for today
for today this
today this is
is all we
in the form
if we quite
we quite simply
quite simply save
simply save that
save that one
down the forms
forms designer reload
designer reload the
reload the file
file and if
at our dialogue
We'll find on
find on our
on our dialogue
our dialogue there
dialogue there is
there is now
is now a
now a control
a control and
control and combo
and combo box
combo box entry
box entry at
Now though we've
though we've put
we've put this
this in here
in here if
here if we
the program in
program in here
There would be
would be nothing
be nothing on
The entries you
entries you saw
you saw in
saw in the
form designer were
designer were just
were just for
just for illustration
for illustration purposes
populate the list
the list ourselves
we do that?
do that? Well
in here at
here at the
moment this is
displays the form
the form on
form on screen
on screen now
screen now you
in theory in
theory in here
Populate the combo
combo box here
can do exactly
the initialization handler
the form which
form which is
which is basically
is basically event
basically event handler
event handler the
handler the event
the event code
event code initialized
code initialized dialogue
initialized dialogue is
dialogue is kicked
is kicked off
kicked off as
off as soon
soon as a
as a form
a form is
form is loaded
is loaded basically
loaded basically it's
basically it's an
it's an on
an on load
on load event
So we decide
we decide to
decide to in
to in here
in here populate
here populate our
populate our combo
combo box how
box how do
we do how
do how would
how would we
would we do
we do it
combo box command
box command has
command has quite
has quite a
quite a number
look at here
of these commands
these commands performs
commands performs a
performs a specific
a specific function
First one will
one will cut
will cut is
cut is the
is the reset
reset command will
command will effectively
will effectively empty
effectively empty out
empty out a
out a combo
combo box and
box and take
and take all
take all its
all its values
its values away
we know since
know since we've
since we've just
we've just created
just created the
created the form
form and we're
and we're just
we're just initializing
just initializing that
initializing that there's
that there's nothing
there's nothing in
nothing in the
But it's good
practice to make
make sure there's
sure there's nothing
in it because
it because what
because what we're
to do after
do after we've
after we've created
created these commands
these commands is
commands is we're
create a genomic
a genomic function
genomic function whose
be to populate
populate any combo
any combo box
combo box for
box for you
Now in here
in here it
here it wants
it wants the
wants the handle
the dialogue now
dialogue now we
now we don't
store this value
this value because
value because inside
because inside the
inside the event
is a reserved
Structure called CB
called CB dot
CB dot handle
dot handle which
handle which will
which will return
the value but
value but we
but we do
we do need
do need to
to know the
know the value
combo box what
box what we
we actually called
actually called it
look at a
at a dialogue
a dialogue we'll
dialogue we'll see
we'll see when
see when we
when we created
created a combo
combo box we
box we called
we called it
called it combo
it combo I
combo I color
quite simply copy
simply copy that
copy that one
That will reset
will reset the
reset the values
Now we may
add something to
to the combo
have to see
to put one
put one to
the list so
list so just
so just for
just for the
for the sake
the sake of
sake of argument
of argument we'll
argument we'll put
put that value
be the only
the only addition
only addition to
addition to the
the list if
list if we
the program now
On my list
my list there
list there is
single value blue
user can quite
happily select when
select when the
the form loads
form loads the
loads the combo
combo box is
box is not
is not pre
not pre selected
pre selected you
selected you have
have to pick
to pick what's
So if you
you were to
were to add
to add another
add another entry
another entry to
entry to that
Simply just keep
just keep adding
And since we
is a sorted
a sorted combo
sorted combo box
we put these
put these in
Effectively not sorted
not sorted green
sorted green first
green first then
first then blue
They are alphabetically
are alphabetically sorted
alphabetically sorted for
sorted for you
So that adds
that adds a
adds a couple
of small things
small things quite
things quite easily
quite easily to
easily to the
to do having
do having put
having put something
put something in
something in the
box is we
is we want
value that a
that a user
user actually picks
actually picks from
picks from it
Once they select
they select on
select on it
we look down
look down here
do is basically
is basically raise
basically raise an
raise an event
event to pick
that the users
the users actually
users actually clicked
clicked on that
Now despite the
the fact it's
fact it's a
combo box it's
box it's treated
it's treated exactly
treated exactly the
same as a
as a button
So this piece
within this if
this if statement
if statement will
statement will actually
will actually trigger
actually trigger when
when the box
box is clicked
is clicked on
box what the
what the users
users actually selected
actually selected for
selected for this
type of combo
is very easy
want the name
been selected from
selected from the
from the combo
is the icower
put it to
it to available
to available which
available which we
will now declare
now declare at
declare at the
prove that we
that we got
we got that
got that value
do a message
message box of
box of screen
So we've announced
we've announced now
box we picked
we picked green
And it's a
it's a vector
a vector we
vector we picked
we picked up
picked up the
value of actually
of actually chosen
actually chosen and
chosen and displayed
and displayed it
displayed it on
it on screen
So that's fine
that's fine for
fine for that
But what we
do is something
is something a
something a little
bit more sophisticated
of our previous
our previous videos
previous videos we
videos we actually
we actually created
actually created a
created a little
a little database
little database and
database and we're
to reuse some
reuse some of
some of those
of those files
those files now
We have icower
have icower already
icower already in
already in a
in a flat
a flat text
flat text file
text file containing
all the eye
the eye colours
eye colours in
colours in our
to do we're
do we're going
going to read
to read through
read through this
through this file
this file and
create our combo
combo box based
box based on
on the values
the values that
values that we
that we find
we find in
find in this
little function called
function called populate
called populate combo
do the population
of our combo
Obviously we're going
have to pass
to pass some
pass some parameters
And the obvious
the obvious parameters
obvious parameters to
parameters to pass
to pass will
pass will be
the window and
window and the
combo box itself
Now we also
pass some data
data which will
be an extra
we populate the
the combo we're
combo we're going
local array which
array which will
contain the data
data for combo
for combo box
create a first
a first function
first function whose
be to get
we will pass
will pass the
pass the name
we'll also want
file name which
name which contains
contains the data
Now in this
case we know
file name is
name is icar.csv
that in here
function will get
So if we'll
if we'll nip
we'll nip to
nip to the
of our program
All right we've
right we've already
already got some
got some library
some library functions
library functions which
functions which will
which will perform
will perform many
perform many of
many of the
the tasks we're
tasks we're actually
we're actually trying
actually trying to
trying to do
have a library
a library function
library function called
function called file
called file handling
So we're just
going to copy
to copy that
that and we're
going to include
to include that
include that at
And since this
since this isn't
this isn't since
isn't since this
in the libraries
bring that library
that library function
library function in
function in just
in just to
what it has
it has in
has in it
Now it has
functions and the
one we're after
we're after is
after is read
is read the
Which will quite
quite happily do
happily do what
do what we
want it to
to our original
have our file
our file name
have our array
Now this will
will handle the
handle the case
case where the
not actually there
practice to put
put it in
what this will
do this will
this will bring
will bring the
bring the file
the file straight
file straight into
straight into our
It will dimension
will dimension it
dimension it for
it for us
It will size
will size it
size it for
So there's no
there's no worrying
no worrying to
worrying to do
do with that
with that one
Now the information
the information it
information it brings
it brings in
brings in will
in will be
will be this
That will go
into the zero
the zero element
zero element which
element which we
quite happily ignore
the other elements
other elements have
elements have an
have an extra
extra parameter which
which we're not
we're not really
not really interested
of this we're
going to sweep
to sweep through
sweep through the
through the array
array and take
take all those
all those values
those values out
a little counter
little counter variable
then a for
Using the U-bound
the U-bound command
U-bound command which
command which tells
which tells us
us the top
the top entry
top entry in
do here is
here is we
we will quite
will quite cleverly
quite cleverly use
cleverly use the
use the parse
parse command which
command which we've
used in previous
previous videos to
videos to strip
to strip out
strip out the
out the data
data we're actually
we're actually after
So contained within
contained within this
within this is
this is effectively
is effectively this
And we only
want the information
the information before
information before the
before the comma
So we'll use
And our delimiter
our delimiter is
delimiter is a
a comma after
comma after the
after the first
that will sweep
will sweep through
sweep through each
the elements from
elements from one
Taking out the
out the commas
And that should
that should return
should return to
return to our
calling function a
function a list
of the six
the six eye
six eye colors
to our program
our program in
here we will
will now coming
now coming out
I'll do a
do a test
a test on
test on this
on this as
this as well
as well just
well just to
make sure this
sure this function
will only populate
only populate if
populate if it's
to pass into
pass into this
Right okay so
okay so we
function to populate
new function at
function at the
the bottom and
bottom and again
and again this
again this is
is a generic
a generic one
generic one which
one which we'll
which we'll probably
we'll probably end
probably end up
end up putting
up putting in
putting in our
Now we'll create
create a variable
a variable for
for the dialogue
the dialogue as
dialogue as a
create a long
a long for
long for the
for the combo
And our data
our data which
data which is
is coming by
coming by ref
by ref is
ref is a
that the ASTR
the ASTR data
ASTR data has
data has got
has got data
got data in
data in it
element of that
of that will
be a header
a header which
header which we
we don't necessarily
don't necessarily want
necessarily want in
want in our
in our combo
But everything after
after that we're
that we're interested
another local counter
local counter variable
And another for
This will all
will all start
all start to
start to become
to become very
become very familiar
each element inside
element inside this
inside this we
need to effectively
to effectively add
Now you saw
you saw before
saw before we
before we did
we did a
did a combo
combo box reset
box reset so
reset so we'll
we'll just do
just do that
do that again
that again in
again in here
And now we're
create another one
then we'll create
we will want
will want the
want the handle
of these we
these we want
a new entry
to add is
add is what
is what was
what was actually
was actually left
actually left in
will this do
this do what
what we want?
we want? Let's
want? Let's find
Let's find out
What have we
have we missed?
we missed? This
missed? This integration
This integration we
integration we haven't
we haven't declared
haven't declared it
I used the
used the wrong
the wrong variable
wrong variable name
All right, let's
let's try that
And we made
we made another
made another error
we haven't returned
haven't returned it
returned it as
as a long
don't need any
need any equals
any equals in
equals in there
that was our
was our wonderful
our wonderful things
that's looking clean
looking clean now
So on our
on our dropdown
our dropdown list
dropdown list, they
they we indeed
we indeed do
indeed do have
have the six
the six colors
six colors of
colors of eyes
of eyes sorted
eyes sorted alphabetically
Even though in
though in the
the file they
file they were
they were not
were not alphabetically
that is automatic
is automatic, we've
we've done a
done a sort
a sort for
sort for you
Quite happily with
happily with the
with the six
the six values
So this genomic
this genomic population
genomic population of
box is fine
we may wish
may wish to
wish to pre-select
pre-select a value
a value on
value on the
So changing this
changing this populate
this populate combination
populate combination one
combination one to
one to give
it a pre-selection
a pre-selection option
pre-selection option is
option is probably
is probably a
probably a good
not selected, then
then if SDR
if SDR selection
SDR selection is
selection is a
is a zero-line
a zero-line string
zero-line string, then
then the combo
combo box will
box will not
not be pre-selected
to test for
test for that
So basically, if
not a zero-line
zero-line string, we
want to pre-select
actually do that?
do that? If
that? If we
at the options
the options we
options we have
combo box control
box control, we
have an entry
an entry to
entry to look
look for an
for an exact
an exact match
is a one-line
a one-line after
we just paste
this in, this
going to find
to find an
find an exact
exact match for
match for something
for something we're
something we're after
put the value
value to this
to this variable
this variable over
variable over here
over here, which
we will rename
will rename to
rename to a
to a more
a more sensible
more sensible name
sensible name as
name as long
as long item
It's the item
the item and
item and we'll
and we'll declare
we'll declare that
declare that one
that one up
one up here
have the dialogue
the dialogue already
have the ID
the ID being
ID being of
being of the
item is the
item number to
number to begin
this case, we'll
we'll begin at
begin at number
at number one
for is this
is this value
this does actually
does actually find
actually find an
find an entry
an entry for
entry for the
for the thing
the thing we've
thing we've given
we've given it
given it, there
value in long
in long item
So if it's
if it's greater
it's greater than
we know we
know we have
found the item
the item we're
item we're looking
in that case
that case, what
want to select
to select that
select that particular
that particular item
particular item on
item on the
And that's done
that's done quite
done quite simply
quite simply by
simply by using
using the combo
combo box select
box select command
the dialogue variable
have the combo
the combo variable
we need the
need the item
item that is
that is actually
is actually found
to where this
where this is
this is originally
is originally used
a new parameter
new parameter, which
we put it
it in as
in as a
as a zero
a zero length
zero length string
length string, it
will run the
the program and
program and it
it will effectively
will effectively not
effectively not select
not select anything
it a color
a color we
color we are
looking for, as
as in blue
in blue, run
I've missed the
missed the contication
the contication character
Blue has been
has been pre-selected
been pre-selected, even
even though blue
though blue is
blue is not
not the first
this method, you
you can display
can display a
display a combo
combo box on
screen and you
you can populate
can populate it
populate it with
it with values
with values coming
values coming from
coming from a
from a text
you can select
can select any
select any item
any item on
the list based
list based on
based on your
on your pre-selection
your pre-selection criteria
of a code
a code, we've
we've added in
added in one
in one library
I think we
think we will
a new library
new library now
library now for
now for this
for this common
this common control
common control, since
since this common
common control can
control can quite
quite happily control
happily control anything
We'll call it
call it Windows
it Windows Control
Windows Control Library
we will take
take our code
code for populating
for populating the
populating the combo
We will cut
will cut it
cut it out
it out of
out of here
of here and
here and we
will put it
into our library
our library, since
since we intend
we intend using
intend using this
this in many
in many other
many other programs
save this one
this one now
one now and
now and we'll
call it 'BibiWinControls'
the top, and
we will include
will include it
include it as
that now, it
will run quite
run quite cleanly
quite cleanly and
cleanly and do
and do pre-selection
do pre-selection, which
which is fine
So this short
this short video
short video is
video is purely
is purely to
purely to handle
to handle combo
handle combo boxes
later videos, we'll
we'll go on
on to add
more controls so
controls so we
we can read
can read the
read the data
data we created
in our earlier
our earlier videos
look at buttons
at buttons, status
status bars and
bars and drop
and drop down
drop down or
down or combo
on forms within
forms within the
last video we
video we prepared
we prepared a
prepared a search
a search program
This search program
search program would
program would read
would read an
read an eye
an eye colour
eye colour file
colour file and
file and produce
and produce a
produce a drop
a drop down
down list with
list with a
with a pre-selected
a pre-selected item
will add another
add another drop
another drop down
down list, this
this time for
time for blood
for blood groups
blood groups and
groups and search
and search the
search the randomly
the randomly generated
randomly generated data
generated data we
data we prepared
we prepared in
prepared in an
in an earlier
an earlier video
earlier video for
video for the
for the console
the console compiler
up the PowerBasic
the PowerBasic form
PowerBasic form for
form for this
for this project
In this form
this form at
form at the
only a couple
couple of controls
have a drop
down list from
list from which
from which we
which we pick
pick the eye
the eye colour
eye colour and
colour and we
have an exit
is a couple
of extra controls
add the status
bar control which
control which if
which if you
if you double
you double click
on it puts
puts the status
status bar down
bar down at
status bar it
bar it allows
The caption of
caption of the
bar can be
be quite handy
quite handy to
handy to pass
to pass information
pass information to
the user running
user running the
running the program
the program as
program as to
as to what
what the program
the program is
program is actually
Like all controls
all controls it
controls it will
have an id
an id name
id name and
name and an
and an id
an id value
Since we always
we always plan
always plan on
plan on having
on having one
having one status
status bar in
bar in one
in one form
one form we
form we can
can just call
just call this
call this status
Keep it quite
it quite generic
Status bars always
bars always go
always go to
bottom of a
of a form
if we ok
we ok that
ok that we
that we will
that the text
status bar now
bar now says
now says the
says the word
the word 'Ready'
down list to
list to allow
do some searching
some searching how
searching how do
do that? An
that? An easy
easy way is
way is to
select the controls
the controls you
controls you have
you have already
Control C to
C to copy
copy and Control
and Control V
Control V to
V to paste
This lets you
lets you create
you create an
create an exact
an exact duplicate
exact duplicate of
duplicate of the
the control you
control you already
you already have
can then double
then double click
Now it will
will have generated
have generated a
generated a unique
a unique id
unique id and
id and id
and id value
make these quite
these quite sensible
quite sensible names
sensible names so
names so we
can refer to
refer to them
to them in
them in code
call that blood
that blood group
blood group and
group and we
leave the value
the value as
value as it
have two drop
two drop down
drop down lists
will want is
want is we
will want a
want a button
us to search
to search the
search the main
the main database
main database at
database at some
new button and
button and this
be our search
our search button
we will label
will label it
label it search
will just use
use the caption
the caption to
caption to set
set the id
the id name
Now what does
what does this
does this all
this all do
all do to
do to your
to your actual
your actual code?
actual code? Well
code? Well if
hit the save
save button to
button to save
to save it
save it into
the main code
Close our forms
forms designer down
designer down and
down and reload
and reload the
reload the bas
the .bas file
see from here
from here if
we actually go
actually go to
that there was
there was a
was a new
a new combo
new combo box
combo box added
box added which
added which we
which we forgot
we forgot to
forgot to name
go back in
back in and
will actually name
actually name that
name that combo
While we named
we named the
named the label
the label we
label we forgot
to name the
name the combo
So let's call
let's call that
call that CBO
that CBO blood
CBO blood group
group and save
and save it
save it again
Then back to
our code and
code and we
is now put
put the combo
combo box in
box in as
in as blood
as blood group
the moment our
moment our dialog
our dialog says
dialog says at
says at the
the top our
top our first
our first dialog
Which was fine
was fine for
fine for the
want to label
to label this
label this one
this one a
one a little
little more sensibly
We can either
can either do
either do this
forms designer or
designer or we
or we can
do this dynamically
this dynamically in
dynamically in the
Now after the
after the pb
the pb forms
pb forms in
forms in dialog
in dialog we
dialog we can
can put all
put all the
all the extra
the extra code
extra code in
code in we
in we want
want to rename
to rename the
rename the dialog
We do is
do is so
We are telling
are telling it
telling it we
it we want
We are giving
are giving it
it the text
run that program
that program now
It hasn't removed
hasn't removed the
removed the casing
the casing for
casing for the
It has built
has built some
built some of
some of this
of this for
this for us
Since we renamed
we renamed that
renamed that combo
box it hasn't
it hasn't taken
hasn't taken the
taken the original
the original one
original one out
we will try
will try running
It says search
says search the
search the data
in the title
The blood group
blood group combo
group combo box
is not yet
not yet populated
And the icolor
the icolor one
icolor one is
one is populated
populate the set
the set the
set the blood
blood group dialog
that the drop
down list has
list has all
values in it
in it we
Now how we
how we did
we did that
did that the
that the last
the last time
last time was
time was we
was we went
we went to
went to the
for the form
And we populated
we populated the
populated the combo
the combo using
combo using a
couple of common
of common functions
same for that
We will copy
will copy the
copy the code
code for that
paste it down
that the combo
box we are
populate is called
is called CBO
called CBO blood
case we do
put our default
our default in
of the CSV
CSV file that
file that contains
that contains that
Now it just
it just so
file from our
from our previous
previous videos called
videos called bloodgroups.csv
And this contains
this contains all
contains all the
information we want
will just change
just change the
file we want
to load to
load to blood
to blood groups
Now what do
what do these
do these functions
these functions actually
functions actually do?
actually do? There
do? There was
was a get
a get data
get data function
function and a
and a populate
a populate combo
populate combo function
The get data
data function if
function if we
into which to
which to put
It then calls
then calls the
calls the fun
the fun read
fun read the
file into array
into array which
array which basically
which basically just
basically just takes
just takes the
takes the entire
entire file verbatim
And puts it
puts it into
array we specified
We then step
then step through
each element within
And took only
took only the
only the first
element of each
each line based
line based on
on the delimiter
the delimiter being
delimiter being a
being a comma
the case of
case of the
of the blood
There is actually
is actually no
actually no delimiter
But even so
even so this
code will still
Because this piece
text here is
in the comma
the comma delimited
comma delimited array
Even though there
though there aren't
there aren't commas
So our code
our code should
code should quite
should quite happily
quite happily run
We deliberately blanked
deliberately blanked out
blanked out the
out the pre-selection
the pre-selection so
pre-selection so it's
so it's not
it's not selecting
not selecting anyone
selecting anyone by
anyone by default
But as alphabetically
as alphabetically sorted
alphabetically sorted all
sorted all the
all the blood
the blood groups
blood groups into
groups into a
into a drop
down list so
list so that
that they can
they can be
can be selected
we've got an
got an event
handler in so
in so that
that when you
on the eye
It brings up
brings up a
up a message
message box but
box but we
but we haven't
we haven't put
haven't put that
code in for
in for that
That was purely
was purely done
purely done to
done to illustrate
to illustrate the
illustrate the fact
fact that you
you can trigger
can trigger something
trigger something when
something when the
when the eye
eye colour is
colour is selected
the logic slightly
back at our
at our event
Down where the
where the search
the search box
search box at
moment has a
has a message
message box which
box which the
which the form
form designer put
designer put in
put in for
in for you
take that one
that one out
So let's already
let's already put
already put the
put the if
the if statement
if statement in
statement in to
in to see
what happens when
happens when the
in the iCarla
the iCarla we
iCarla we were
were actually pulling
actually pulling the
information out and
out and then
and then going
then going straight
going straight to
straight to there
Now what we're
do is we've
is we've given
the user two
user two drop
two drop downs
One for eye
for eye colour
eye colour, one
one for blood
for blood group
do is I
I want the
the user only
user only to
only to pick
to pick one
So if they
if they pick
they pick eye
pick eye colour
eye colour the
colour the blood
blood group one
group one will
will be unselected
be unselected and
unselected and if
they pick blood
pick blood group
blood group the
group the eye
eye colour will
colour will be
when they hit
they hit the
hit the search
the search button
search button I
button I want
I want it
it to actually
to actually do
take the get
the get text
get text feature
text feature for
feature for the
box and put
and put it
it into there
doing this for
this for both
for both combo
both combo boxes
of new variables
One called eye
called eye colour
colour and one
one called blood
called blood group
we will dimension
will dimension them
dimension them up
them up at
down to our
our code so
code so when
when the search
search button is
actually clicked it
clicked it will
pick up both
up both values
Now when the
colour is actually
is actually selected
actually selected what
selected what I
want the code
do is much
same as the
as the blood
call this event
for the blood
what are we
are we actually
we actually doing
actually doing here?
doing here? Well
here? Well when
Well when the
on the iCarla
the iCarla and
iCarla and selects
and selects something
selects something I
something I want
it to deselect
to deselect the
deselect the combo
box for blood
do something with
with the combo
the help on
help on the
of options you
options you can
actually do with
do with combo
with combo boxes
of the options
the options is
options is unselect
we put that
want to unselect
unselect any value
any value in
the other drop
other drop down
know the name
drop down is
down is that
is that and
and we know
know the dialogue
the dialogue we're
dialogue we're on
we're on is
on is CB
is CB handle
one that picks
that picks up
dialogue handle of
dialogue we happen
we happen to
happen to be
what this means
this means is
means is when
actually clicks and
clicks and picks
and picks a
picks a value
a value from
value from eye
from eye colour
eye colour drop
colour drop down
drop down it
down it will
it will unselect
will unselect any
in the blood
to take exactly
take exactly the
And unselect the
unselect the eye
So that way
user can only
only pick one
our initialization handle
initialization handle at
handle at the
code we set
drop down to
down to default
to default to
default to blue
one out so
out so that
so that neither
that neither of
neither of them
them are actually
are actually selected
And we pick
we pick something
pick something from
something from the
from the eye
then we pick
from the blood
blood group drop
group drop down
It deselects the
deselects the eye
And subsequently if
subsequently if we
we select from
select from the
eye colour it
colour it deselects
deselects the blood
So from the
the user's point
user's point of
of view it
view it is
it is physically
is physically impossible
physically impossible for
impossible for them
to select both
select both at
both at the
So having done
code we put
for the search
value in both
value to the
to the eye
colour and to
to the blood
do is having
is having done
put a select
a select statement
select statement in
Now we're testing
value of eye
of eye colour
If it's nothing
it's nothing basically
nothing basically we
basically we do
we do nothing
it is something
is something then
something then we
text to our
to our status
Which is that
is that value
that value there
it to that
Now if the
if the eye
colour is something
is something other
other than blank
than blank then
blank then we
we are basically
are basically going
basically going to
bar to searching
to searching for
And whatever eye
whatever eye colour
eye colour we've
colour we've actually
we've actually picked
On the event
event that the
that the eye
colour is blank
is blank we
blank we can
can do another
do another select
another select or
select or an
or an if
an if statement
If the blood
blood group is
group is anything
is anything other
anything other than
want to search
to search for
search for that
So we'll then
we'll then set
then set our
set our status
bar to be
Now we're not
not actually doing
actually doing any
doing any searching
any searching yet
searching yet we're
yet we're just
we're just preparing
just preparing the
preparing the screen
the screen from
screen from the
the user's perspective
we pick eye
colour and hit
Searching for error
If we change
we change it
it to blood
to blood group
group and hit
and hit search
hit search nothing
search nothing happens
let's do some
do some debug
some debug on
debug on it
it to find
to find out
find out why
out why this
why this hasn't
this hasn't worked
We stick our
stick our debug
our debug line
debug line up
line up there
up there and
there and we
we run in
run in debug
in debug mode
Now let's tidy
let's tidy our
tidy our screen
our screen a
screen a little
hit the if
the if button
if button to
button to proceed
to proceed towards
proceed towards the
towards the breakpoint
pick our amber
our amber and
amber and hit
of these by
these by setting
by setting up
setting up to
up to watch
to watch them
So amber is
amber is populated
is populated into
populated into eye
into eye colour
colour and blood
and blood group
group is blank
if we f8
we f8 through
f8 through the
through the code
And it's searching
it's searching for
searching for iCarla
for iCarla which
iCarla which is
group is also
is also be
also be set
set to amber
Why has blood
has blood group
blood group been
group been set
been set to
set to amber?
to amber? Ah
amber? Ah ha
Ah ha there's
ha there's a
there's a problem
When we did
we did the
did the getting
the getting of
getting of the
the combo boxes
combo boxes we're
boxes we're getting
we're getting both
getting both the
both the eye
eye colours into
colours into these
into these variables
What we should
have done is
done is get
is get the
get the combo
combo box value
box value for
value for blood
is the bug
the bug in
in our program
So ideally if
ideally if we
run this one
Searching for blue
Hit the blood
Searching for AB
for AB positive
So we're ready
we're ready to
ready to start
to start searching
Our screen is
screen is now
is now behaving
now behaving as
behaving as we
as we expect
now that we're
that we're ready
to do it?
do it? There
it? There are
are two points
two points here
points here where
here where we
where we have
we have decided
have decided that
decided that something
that something has
something has been
group and one
for the eye
Now one easy
actually doing this
variable called found
we'll make it
make it true
it true at
true at this
And then after
then after our
after our test
can put an
put an if
an if condition
condition in and
in and then
and then between
then between these
between these two
We will run
run the search
we actually going
to be searching
be searching for?
searching for? Ok
So let's dimension
let's dimension this
dimension this variable
this variable up
variable up at
the top first
And what we're
going to, we're
we're already going
already going to
to have either
have either the
either the eye
eye colour or
colour or the
or the blood
we'll create one
create one called
what we're searching
be searching a
searching a specific
So down here
down here where
here where we're
where we're actually
actually doing the
doing the searching
the searching as
searching as well
well as saying
as saying that
We'll say our
say our search
our search criteria
search criteria is
criteria is going
to be this
And down here
down here when
here when we're
when we're doing
doing the eye
to be eye
be eye colour
So the routine
routine which is
be doing the
to be taking
be taking a
taking a parameter
parameter of search
of search criteria
So it knows
it knows what
knows what it's
what it's going
be searching for
need to tell
to tell it
tell it the
it the column
the column we're
column we're actually
actually looking for
it contains that
contains that information
at our original
our original file
Which contains this
contains this information
And our column
our column names
column names are
names are eye
are eye colour
[typing] Let's say
Let's say eye
say eye colour1
down here we'll
here we'll make
we'll make our
make our column
our column iCarla
[typing] So our
So our second
our second parameter
second parameter can
parameter can be
be the column
column we're going
all we have
is to write
to write the
write the code
code that does
that does run
does run the
One thing to
thing to watch
to watch for
watch for when
for when you're
you're designing a
designing a Windows
a Windows application
Windows application as
application as opposed
opposed to a
to a console
a console application
Is that in
in a console
console application things
application things tend
things tend to
tend to happen
to happen sequentially
There's no user
no user interaction
user interaction other
interaction other than
other than starting
than starting the
starting the program
program in the
In a Windows
a Windows program
Windows program this
program this is
is quite different
user clicks the
clicks the search
search button the
button the program
the program may
program may be
may be of
be of any
of any way
any way in
way in searching
But there's nothing
nothing to top
to top the
top the user
user clicking in
clicking in the
in the search
search button again
So one thing
is to give
user some indication
some indication that
indication that we're
that we're actually
we're actually running
bar is called
is called idc_status_bar
And we'll just
we'll just put
just put the
put the message
the message searching
And as well
well as that
as that if
that if we
do our control
our control disable
control disable on
disable on the
on the search
Now the search
search button name
button name was
name was idc_search
was idc_search which
idc_search which we
that will stop
will stop the
stop the user
user clicking any
clicking any buttons
any buttons until
buttons until we've
until we've actually
we've actually finished
then after we've
after we've finished
we've finished from
finished from running
from running the
running the search
the search we
search we can
re-enable the button
This stops the
stops the user
the user being
user being able
to actually click
actually click on
the button after
button after it
after it started
it started the
started the search
can also do
also do other
do other things
other things like
things like put
like put some
put some kind
kind of splash
of splash screen
splash screen up
screen up some
up some kind
kind of progress
of progress bar
cover that later
code that actually
that actually runs
actually runs the
runs the search
have two parameters
two parameters both
parameters both of
both of which
which are strings
So our decision
our decision here
decision here is
is this is
the search but
search but what's
but what's it
what's it going
going to do?
to do? It's
do? It's going
to look through
look through the
through the file
file to find
to find every
find every entry
every entry that
entry that is
that is matching
is matching on
matching on the
on the criteria
do with that?
with that? Well
that? Well if
if we initially
we initially want
initially want to
want to perhaps
to perhaps populate
perhaps populate the
populate the status
see what we've
what we've found
Ideally we should
we should probably
should probably pass
probably pass the
pass the status
bar as a
And then obviously
then obviously we'll
obviously we'll need
know the handle
As a D
a D word
that's a couple
of extra ones
extra ones so
ones so let's
Now one thing
one thing you'll
thing you'll find
you'll find quite
find quite useful
quite useful in
useful in the
in the IDE
the IDE is
IDE is there
is there is
is an option
an option for
option for setting
for setting a
setting a bookmark
Set a bookmark
a bookmark and
bookmark and then
and then go
then go down
the form where
form where our
code is and
is and you
want to go
Jump to the
to the bookmark
It saves a
saves a lot
lot of time
of time running
time running around
of course actually
course actually go
to the line
line number of
the code based
code based on
the number down
number down at
the screen here
By a control
a control G
control G if
G if you
if you remember
you remember the
remember the line
the line numbers
line numbers but
numbers but it's
but it's much
easier using the
using the bookmarks
So we wanted
we wanted to
wanted to pass
pass a couple
of extra parameters
And the parameters
the parameters we
parameters we wanted
to pass were
pass were the
were the handle
Which was that
was that one
also the handle
to the form
do a search
Now the file
file itself is
itself is this
My large file
large file dot
file dot text
Now this file
this file happens
file happens to
of one thousand
one thousand records
could be a
be a lot
a lot more
lot more than
than one thousand
be a hundred
a hundred thousand
hundred thousand records
Now we could
we could read
could read the
file in line
in line by
by line and
line and actually
and actually process
actually process it
process it that
it that way
could use what
use what we
what we used
we used before
used before and
before and use
and use one
the routines which
routines which brings
which brings it
brings it in
as an array
a function in
handling routines common
routines common library
common library called
library called read
called read the
if we steal
we steal that
it in here
just to be
to be explicit
be explicit if
explicit if it's
if it's actually
it's actually getting
actually getting the
getting the file
know it's coming
it's coming from
from the EXE
the EXE path
folder as executable
give it an
it an array
So the STR
the STR works
STR works as
works as good
good as any
will dimension an
dimension an array
a string to
string to contain
to contain our
contain our file
Now the fun
into array returns
array returns either
returns either a
either a true
or false true
True for actually
for actually complete
actually complete successfully
complete successfully and
successfully and false
false if it
if it doesn't
And just in
case the file
not exist we'll
exist we'll use
use the if
the if condition
if condition to
condition to actually
actually test for
test for true
for true or
update the status
on the variables
the variables we've
variables we've actually
we've actually been
actually been given
been given in
status bar variable
the assumption we
assumption we can
can actually find
actually find the
find the file
Now we're actually
something with it
want to step
step through the
the array one
array one line
one line at
line at a
a time and
time and actually
and actually look
actually look for
look for matches
So create a
to know which
know which column
which column to
column to actually
to actually search
actually search for
the column but
column but we
but we want
want the column
can find that
find that out
that out before
out before we
before we actually
we actually start
do we set
we set that?
set that? Well
that? Well we
Well we know
that the very
first line of
line of the
the array the
array the zero
zero element contains
element contains all
all the headers
have a routine
a routine that
routine that can
that can actually
can actually pull
actually pull that
pull that back
that back quite
back quite happily
Now in our
in our common
our common routines
handling routines a
routines a parse
a parse find
parse find command
Which is designed
is designed for
designed for just
for just this
just this very
this very function
So for paste
for paste that
paste that in
that in so
in so we
know the headers
the headers are
headers are going
be the zero
zero element of
The dilemma in
dilemma in this
be a comma
a comma because
comma because it's
because it's a
it's a common
a common delimited
common delimited file
the column name
column name we're
name we're after
we're after in
after in this
case is an
is an STR
an STR column
So the long
the long column
long column is
column is going
we look to
look to our
to our file
our file then
file then because
then because we
because we know
know we're looking
looking for icolor
for icolor it
icolor it would
would be the
be the first
So that contains
that contains the
contains the column
do is our
is our for
to actually look
actually look to
of that column
that column actually
column actually is
So we pick
of the record
the record we've
record we've actually
we've actually read
actually read in
Using our ubiquitous
our ubiquitous parse
ubiquitous parse command
And along our
along our pointing
our pointing to
to the record
common delimited one
know the column
column we're looking
for is a
a long column
So we picked
in the record
the record we
record we just
we just put
just put in
want to match
to match it
match it against
it against our
against our criteria
And remember the
remember the comparison
the comparison we're
comparison we're making
we're making here
making here is
is a case
a case dependent
case dependent comparison
if you're in
you're in any
in any doubt
any doubt you
doubt you have
have to force
to force both
force both of
to the same
the same casing
same casing type
As in so
case it's probably
it's probably irrelevant
it doesn't really
doesn't really happen
really happen to
happen to put
Till we found
we found a
want to do?
to do? Do
do? Do we
want to count
to count them?
count them? Well
them? Well if
we do let's
do let's put
put a local
a local count
local count in
as we've found
we've found in
found in previous
The easiest, fastest
fastest way of
of actually counting
Is just to
just to increment
in the long
the long count
long count variable
So by the
by the time
the time we
time we finish
we finish this
finish this array
Long count will
count will contain
will contain how
contain how many
how many we
many we actually
we actually found
of course we
course we can
can put that
Into our status
And since we're
since we're putting
we're putting a
numeric value into
value into a
into a string
use the format
the format command
To convert it
convert it to
it to string
to string so
string so it
so it can
So what should
what should happen
should happen as
happen as we
as we run
we run through
run through the
through the entire
the entire array
entire array here
Is we're matching
we're matching on
the search criteria
So we find
find a match
a match we're
match we're incrementing
incrementing the counter
setting the status
to be records
be records found
records found equals
found equals that
equals that number
Assuming we've made
we've made no
made no syntactical
no syntactical errors
we pick i-color
pick i-color blue
i-color blue and
blue and hit
and hit our
hit our search
It says there's
says there's been
there's been zero
So obviously we've
obviously we've missed
we've missed something
again we're back
we're back to
back to debug
let's go down
go down here
Now the very
the very fact
very fact to
fact to put
to put records
put records found
Means it must
it must have
must have actually
So possibly we've
possibly we've done
we've done something
done something wrong
Code after that
if we clear
we clear our
clear our breakpoints
our breakpoints out
And turn a
turn a breakpoint
a breakpoint on
breakpoint on here
And run under
run under debug
And we'll hit
we'll hit the
hit the F5
the F5 button
F5 button to
button to go
to the debug
We'll select blue
We'll hit search
want to see
what we passed
we passed in
Did we pass
we pass in
pass in the
in the right
the right values
criteria is blue
is blue which
blue which is
Column is i-color
is i-color which
i-color which again
which again is
again is fine
So does parse
does parse find
parse find actually
find actually find
actually find anything
If you shift
you shift an
shift an F8
It goes on
goes on to
next line of
see what column
what column it
column it brought
it brought out
Column 0 so
0 so it
so it didn't
it didn't find
didn't find it
Not strange why
strange why didn't
why didn't it
didn't it find
it find it
find it then
looking for i-color
Now does str_work
does str_work contain
str_work contain the
value we're after
Yes it does
Ah it's not
it's not column
not column delimited
column delimited it's
delimited it's tab
it's tab delimited
is what a
what a problem
a problem is
There's a tab
a tab character
tab character between
character between each
between each field
Right well we
well we came
we came close
came close to
close to actually
to actually getting
actually getting that
getting that right
know we're dealing
with a tab
a tab delimited
tab delimited file
Which I should
I should have
should have remembered
And everything after
after that has
to be tab
be tab delimited
got that bit
that bit right
actually run our
we pick blue
we do research
It tells us
tells us 163
us 163 blue
what we got
we got for
got for gray
got for hazel
got for amber
are no ambers
That's an interesting
an interesting one
got for brown
for brown then
Let's try the
try the blood
So it is
it is actually
is actually searching
actually searching our
searching our data
And pulling information
pulling information back
information back quite
back quite successfully
Unfortunately there appear
to be no
be no people
no people with
people with amber
with amber eyes
But there you
there you go
Now of course
of course since
course since there's
since there's only
there's only a
only a thousand
a thousand records
the file we're
file we're searching
The search is
search is happening
is happening so
happening so quickly
That the values
the values appearing
values appearing back
Almost as soon
soon as you
as you press
press the button
it's not obvious
not obvious in
obvious in this
That the search
button is disabled
For the fraction
the fraction of
fraction of a
of a second
a second of
second of a
of a time
a time actually
time actually takes
actually takes to
takes to bring
to bring the
bring the values
the values back
If this was
was a million
a million records
million records we
records we were
we were searching
Then it may
it may take
may take a
take a smidgen
a smidgen longer
smidgen longer to
longer to actually
to actually find
actually find them
with this information
Well as well
well as bringing
as bringing the
bringing the number
of records back
We could display
could display a
display a grid
a grid showing
The actual records
actual records themselves
Sorry to scroll
to scroll through
scroll through to
But what we're
do something a
something a bit
bit more graphical
to our forms
And it's quite
it's quite happily
happily showing our
showing our two
our two droplets
So search button
search button and
button and our
and our exit
our exit button
Estimate things tidy
Or perhaps line
perhaps line up
line up the
up the buttons
Now you'll find
you'll find on
find on the
is a graphics
double click that
click that one
And bring it
bring it onto
it onto the
make it roughly
it roughly square
is our graphics
see that you
you can give
can give it
it a border
Which we'll do
see it on
to be where
be where we
put a pie
a pie chart
Now all this
all this does
this does at
does at the
moment is it
is it tells
it tells you
tells you the
you the name
of the graphic
Which we'll leave
we'll leave as
leave as graphic
as graphic one
graphic one for
done that if
Save our form
has added a
added a graphic
a graphic control
Control and graphic
the name graphic
name graphic one
graphic one and
one and its
and its location
its location on
it a bit
bit more information
graphic control can
control can be
used to draw
Some quite fancy
quite fancy things
fancy things on
things on the
case we want
draw a pie
Now there is
is a graphic
a graphic pie
graphic pie statement
pie statement which
statement which we're
do here having
here having created
having created the
created the graphics
going to tell
to tell the
tell the program
That this graphic
this graphic one
graphic one control
one control is
control is now
is now attached
now attached to
attached to this
to this particular
And any commands
any commands we
commands we issue
we issue to
issue to the
the graphics object
graphics object will
object will actually
will actually draw
actually draw on
draw on this
this particular one
particular one on
Now as we're
to be passing
be passing information
passing information to
is another parameter
another parameter will
parameter will be
will be wanting
be wanting to
wanting to pass
go back down
back down to
to where we
we actually ran
actually ran the
ran the code
We'll be on
be on the
the search we're
search we're going
add another parameter
be our graphic
our graphic control
look at run
at run the
the search again
There'll be yet
be yet another
yet another part
handle to our
we've done all
done all the
the information and
information and we
how many entries
many entries we've
entries we've actually
Draw the pie
the pie chart
do a pie
pie chart on
chart on the
doing a pie
information we found
we found which
found which is
which is contained
is contained in
contained in the
be a percentage
a percentage of
percentage of the
of the total
So easy thing
easy thing to
do is create
is create some
create some variables
we know one
know one total
one total is
total is going
be the total
know we put
we put all
put all our
all our data
our data into
into this array
that the upper
bounding of that
that array is
array is the
is the total
total number records
that's our total
our total number
Now the number
the number we
number we found
we found was
found was a
was a long
a long count
actually store the
store the percentage
the percentage of
it a nice
a nice round
nice round number
let's try putting
try putting in
putting in as
as a double
in case it's
very small number
And then if
then if we
if we see
Same equals the
equals the long
by the total
As a percentage
So that would
that would give
us a percentage
to display that
display that in
in a pie
Now I think
I think we'll
think we'll need
Let's call this
call this pie
this pie two
we'll say pie
say pie two
for a circle
Now touch we
touch we draw
we draw the
this case traffic
case traffic pie
sets of coordinates
Where to begin
to begin and
begin and where
and where to
where to end
end the pie
big the pie
the pie is
pie is going
be on screen
if we had
had a quick
a quick look
quick look at
dialogue that was
that was drawn
that our graphic
Is one hundred
one hundred by
hundred by one
by one hundred
one hundred units
hundred units on
units on the
Nice easy number
if we start
we start slightly
start slightly in
slightly in from
from the edge
Two by two
Don't quite go
quite go all
to the edge
the edge another
edge another side
Let's say ninety
say ninety five
To ninety five
That's a good
a good point
set the first
the first value
Starting at zero
at zero degrees
second one would
one would be
would be pie
be pie two
Multiplied by our
by our percentage
give it three
it three more
three more parameters
want to tell
tell it what
it what color
color the edge
Slice is going
Let's see we'll
see we'll make
we'll make that
make that black
of the bulk
the bulk of
bulk of the
of the filling
the filling of
filling of the
of the pie
Will make blue
to use zero
use zero for
zero for a
for a solid
if we tried
we tried running
tried running this
Let's just try
just try that
try that to
That should be
Eight times our
times our turn
Right programs runs
Let's pick blue
draw the rest
pie chart now
So when you're
when you're when
you're when you're
when you're a
you're a second
Graphics pie command
And again the
again the same
the same parameters
same parameters that
parameters that we
that we had
Because you could
you could be
could be doing
be doing more
doing more than
than one pie
one pie chart
to start from
start from where
where the last
the last one
last one finished
that would be
would be here
want to be
To complete the
complete the pie
By two times
two times one
say our outline
our outline again
outline again to
again to the
to the black
we'll say it
of the slice
the slice of
slice of the
the pie to
pie to be
to be green
make it solid
it solid for
solid for the
it solid fill
solid fill again
Right my error
my error there
error there was
there was an
was an actually
an actually the
It's not actually
not actually a
actually a percentage
It's a fraction
a fraction of
fraction of one
Since one is
one is the
is the whole
the whole circle
So I've taken
I've taken off
taken off the
off the multiply
the multiply by
multiply by a
by a hundred
We get one
get one hundred
one hundred and
hundred and sixty
and sixty three
is that slice
that slice of
we pick brown
is a slightly
a slightly smaller
slightly smaller slice
smaller slice of
A bigger slice
bigger slice of
the same goes
same goes for
goes for the
a very quick
very quick way
Of actually figuring
actually figuring out
As a slice
a slice of
of the whole
the whole pie
Any particular value
particular value actually
value actually is
That completes today's
completes today's video
I hope this
hope this has
this has given
has given you
given you an
you an insight
an insight into
With graphics controls
And also forms
will start a
start a new
new project to
use of software
of software auto
software auto forms
what are auto
are auto forms
auto forms and
forms and what
and what can
can we use
we use them
use them for?
them for? When
for? When you
you are designing
are designing a
designing a PowerBasic
Windows application, you
you can lay
can lay out
lay out your
out your form
your form with
form with controls
with controls using
controls using the
is a forms
a forms designer
forms designer application
designer application which
application which comes
which comes as
comes as part
of the full
the full PowerBasic
full PowerBasic bundle
When you decide
you decide to
decide to change
change your form
your form, you
you will load
will load it
load it back
it back into
forms designer, make
make your changes
your changes and
changes and then
and then recompile
then recompile your
recompile your application
But what if
we took the
took the definition
the definition of
definition of the
controls on a
on a form
a form out
form out of
application and treated
and treated it
treated it like
it like metadata?
like metadata? That
metadata? That could
could be loaded
be loaded in
loaded in dynamically
in dynamically at
dynamically at runtime
Could this be
this be made
be made to
made to work
to work for
work for applications
for applications that
applications that were
that were doing
were doing simple
doing simple forms
simple forms and
forms and allowing
and allowing information
allowing information to
information to be
to be gathered?
be gathered? In
gathered? In other
other words a
words a simple
a simple form
simple form entry
form entry system
we could make
could make this
make this work
this work, we
we would have
would have a
have a generic
a generic application
generic application that
application that could
be extended by
extended by just
by just amending
just amending the
amending the metadata
the metadata itself
Such metadata can
metadata can come
can come from
come from a
from a database
a database or
database or flat
or flat text
flat text files
text files, giving
giving you a
a very flexible
very flexible system
That's what this
what this project
project is going
going to explore
In these project
these project videos
project videos we'll
videos we'll be
we'll be covering
be covering a
covering a wide
a wide range
wide range of
range of techniques
of techniques for
techniques for PowerBasic
this particular project
particular project we're
creating a data
a data entry
data entry system
we want that
want that data
that data entry
entry system to
system to be
be quite generic
quite generic, so
so that once
that once we
have created and
created and compiled
and compiled our
compiled our actual
our actual application
actual application, there
be no more
no more configuring
more configuring in
configuring in the
All the detail
the detail of
detail of the
the forms will
forms will be
will be held
be held within
held within external
within external configuration
external configuration files
screen here, we
created a blank
a blank form
blank form in
form in the
This form only
form only has
has the main
the main dialogue
main dialogue itself
dialogue itself and
itself and a
and a status
During this project
be using a
using a number
number of libraries
first one we're
one we're going
is the pb
the pb file
pb file handling
a generic library
generic library to
library to allow
to do lots
do lots of
lots of operations
of operations on
operations on files
will add this
source code by
code by using
using the hash
the hash and
hash and code
and code command
And at compile
compile time this
time this library
this library will
library will be
will be compiled
be compiled in
compiled in with
in with our
application to give
us a single
a single standalone
single standalone executable
So where is
where is our
our application going
application going to
get the configuration
the configuration data
configuration data in
order to populate
to populate and
populate and to
and to control
control the forms?
the forms? I've
forms? I've created
created a small
a small configuration
small configuration file
configuration file testdemo.cfg
This file is
file is going
contain the key
the key information
key information to
information to create
create our form
our form and
form and to
and to populate
it with controls
The information within
information within this
this file will
file will be
be held in
held in a
in a CSV
a CSV format
So I've populated
I've populated the
populated the very
first line to
line to be
be the headers
the headers of
headers of each
the columns we're
columns we're going
to be populating
This config file
config file will
will be passed
be passed to
passed to the
command line as
line as a
Therefore you can
you can launch
can launch different
launch different forms
different forms by
forms by merely
by merely changing
merely changing the
changing the parameter
the parameter which
parameter which your
which your generic
your generic application
generic application is
application is about
about to receive
the first tasks
first tasks of
tasks of our
of our generic
our generic application
application is to
is to read
to read in
read in this
in this config
to the pb
main function, this
first function kicked
function kicked off
kicked off when
off when our
our application begins
hold the name
of the configuration
the configuration file
that variable by
variable by picking
by picking up
up the XA
the XA path
path which our
which our executable
our executable is
executable is currently
is currently sitting
currently sitting in
sitting in plus
in plus the
plus the command
the command dollar
command dollar command
Command dollar contains
dollar contains anything
contains anything that's
anything that's been
been passed to
So both of
of these together
these together are
together are going
us the location
of our configuration
our configuration file
then test to
test to ensure
ensure that this
that this configuration
this configuration file
configuration file exists
using the is
the is file
is file command
the file you
file you wish
wish to determine
determine whether it
whether it exists
it exists or
exists or not
this returns false
false then the
that case we
the user informing
user informing them
informing them that
them that we
have been unable
been unable to
unable to find
find a configuration
a configuration file
configuration file and
file and we
the application immediately
if we get
we get past
get past this
past this piece
of code then
code then the
then the configuration
configuration file must
load this configuration
configuration file into
file into memory
memory and we're
be loading this
loading this into
into a global
be using one
functions in the
in the library
the library we
library we added
we added a
added a few
That's the function
the function read
function read the
We'll pass this
pass this two
this two parameters
being the name
global array we
specify this array
this array in
array in the
declare two globals
two globals one
globals one being
being the global
to hold our
hold our configuration
our configuration information
configuration information and
information and the
second to be
be a handle
a handle for
the form we're
form we're going
application runs the
runs the configuration
configuration file will
try to deploy
to deploy a
deploy a test
a test compile
test compile on
compile on that
to ensure it
ensure it compiles
it compiles cleanly
compiles cleanly and
cleanly and it
in the folder
the folder where
folder where our
where our application
our application sits
application sits I
sits I have
I have a
have a subfolder
a subfolder called
subfolder called configs
called configs and
configs and this
that will contain
will contain our
contain our configuration
our configuration files
we'll just change
just change our
change our command
our command line
command line parameter
line parameter option
parameter option in
option in the
the IDE to
IDE to hold
hold a reference
a reference to
reference to this
to this file
to the run
the run menu
run menu and
and click say
click say command
say command line
command line we
line we can
then populate that
populate that with
that with configs
with configs slash
configs slash and
slash and the
application now it
it will open
will open up
open up our
Therefore we now
now have an
have an empty
an empty dialogue
empty dialogue and
dialogue and we'll
to set some
set some configuration
some configuration items
configuration items up
items up to
up to start
to start population
function for our
for our form
our form the
form the event
handler and we'll
we'll see in
initialization section is
section is currently
is currently empty
be populating that
in here a
here a call
to a function
a function who
function who will
who will populate
populate the form
the form from
form from the
from the configuration
This function needs
function needs no
no parameters as
parameters as all
the information it's
information it's going
to be accessing
be accessing is
accessing is in
array which we've
which we've already
we've already populated
to give this
give this function
this function something
function something to
something to do
to do we'll
do we'll need
put some configuration
some configuration information
configuration information into
into this configuration
our first line
line of configuration
The object we
object we wish
something with is
with is the
is the dialogue
the dialogue title
on that dialogue
that dialogue title
dialogue title to
title to the
to the words
the words first
words first form
Finally we wish
the dialogue at
dialogue at 0
at 0 screen
width to 500
to 500 and
500 and the
height to 300
I've left a
left a blank
a blank for
blank for the
dialogue itself but
itself but the
the final column
final column the
column the function
the function is
is to center
center the dialogue
will save this
this and we
now put some
code in our
in our populate
our populate form
populate form function
will create some
array and pull
of that file
number of ways
of ways we
ways we can
can actually specify
actually specify which
specify which columns
which columns are
columns are which
are which in
which in the
in the configuration
We may in
may in a
later video use
video use the
use the headers
the headers at
headers at the
top of that
that file but
file but for
the moment I'm
moment I'm going
to create an
create an enumeration
an enumeration at
enumeration at the
is an easy
way of setting
setting the value
value of constants
The first constant
first constant is
constant is going
to be ref
be ref object
ref object and
object and we're
of that to
that to be
to be 1
our first column
first column and
and the references
the references following
references following that
following that will
that will take
will take the
take the values
the values will
values will specify
specify the column
the column position
column position of
position of each
of the particular
the particular bits
particular bits of
bits of configuration
of configuration information
So going back
to the populate
the populate form
form function we
can now enter
now enter some
enter some more
want a forenex
a forenex loop
forenex loop to
through each line
each line in
line in our
That's each line
each line that
line that came
that came from
came from the
using a forenex
forenex loop going
going from line
from line number
line number 1
number 1 to
Our headers are
headers are in
in the zero
the array so
array so we're
so we're skipping
we're skipping over
skipping over those
can then take
then take the
take the data
in each line
each line and
line and put
As we only
have a title
a title object
title object in
object in a
in a configuration
configuration file we'll
file we'll do
of our first
first column by
column by using
using a simple
a simple select
simple select statement
select statement with
statement with a
with a parse
a parse command
we're looking in
looking in the
in the str
data variable and
variable and we're
pull out this
out this element
this element and
element and as
we saw earlier
saw earlier the
earlier the ref
the ref object
ref object has
object has a
setting the case
the case to
to be title
be title so
title so we're
the title in
title in the
in the object
the object column
object column and
column and we
want to pull
out the second
the second column
second column the
column the text
to set as
as the title
order to know
to know this
know this we
form is created
is created it
created it will
will be created
be created with
created with an
with an internal
an internal variable
the form creation
form creation to
creation to ensure
to ensure we've
ensure we've got
got this populated
the code the
code the hdlg
the hdlg variable
hdlg variable is
variable is populated
is populated when
populated when the
dialogue is created
populate our global
global variable with
with that variable
that variable used
variable used here
we've stored the
stored the dialogue
dialogue handle we
handle we can
now use it
use it in
in the rest
rest of our
back to populate
to populate form
populate form we
use the dialogue
dialogue set text
text command with
with our newly
our newly populated
newly populated dialogue
populated dialogue handle
handle and using
the text column
that the top
the dialogue where
dialogue where the
where the title
the title bar
title bar is
is now has
now has the
has the words
first form which
had in our
in our configuration
size and the
the dialogue with
dialogue with these
with these additional
these additional configuration
additional configuration items
configuration items and
items and we
using the dialogue
dialogue set size
up the width
application now you'll
now you'll see
dialogue is indeed
is indeed much
indeed much smaller
Additionally in this
case we wish
wish to center
the moment the
moment the dialogue
dialogue is not
is not centered
let's put an
an additional command
additional command in
command in to
in to check
if the function
the function column
function column which
column which is
is in our
configuration file is
file is set
set for center
for center or
center or not
Currently it is
it is set
the word center
to check that
check that and
that and then
set our dialogue
our dialogue accordingly
So we use
parse command again
command again to
again to look
to look in
word center is
center is present
is present we
present we want
to call something
call something which
something which centers
which centers the
centers the window
bit of API
of API code
API code in
in a subroutine
a subroutine to
subroutine to call
to call which
call which we
we can pass
can pass the
pass the parameter
the parameter of
dialogue we wish
to center on
center on the
This little subroutine
little subroutine will
subroutine will take
take the single
the single parameter
being the dialogue
handle and it
call the get
the get windows
get windows rectangle
windows rectangle API
API call and
call and then
then the get
get windows position
The effect of
effect of running
of running this
running this subroutine
this subroutine will
subroutine will be
be to center
the screen regardless
screen regardless of
regardless of your
of your resolution
that now and
now and we
our dialogue is
dialogue is correctly
is correctly centered
correctly centered on
centered on our
However there are
are no objects
no objects on
our dialogue yet
dialogue yet so
yet so we
to our configuration
configuration file to
file to put
to put these
put these objects
these objects on
example we want
couple of buttons
of buttons on
An OK button
OK button and
button and an
and an exit
exit button and
button and we
want the OK
the OK button
OK button to
button to perform
to perform some
perform some function
some function perhaps
function perhaps to
perhaps to save
the data which
data which has
has been put
been put in
our data entry
data entry screen
entry screen and
screen and the
and the exit
allow the form
the form to
form to be
to be closed
be closed and
closed and if
it is the
is the only
the only form
only form for
form for the
for the application
application to end
will add these
two lines into
lines into our
into our configuration
The object in
object in this
be a button
button is going
to be OK
coordinates are set
are set and
set and the
the button are
button are set
are set as
set as well
Additionally we're now
using the ID
the ID value
ID value to
value to set
the ID handle
ID handle of
object to be
to be 1200
exit button we're
button we're doing
doing the same
for the coordinates
coordinates and the
the size but
size but we're
but we're setting
setting the ID
the ID to
to be 1201
Additionally each of
of these configuration
these configuration items
configuration items has
items has an
has an entry
an entry in
For the OK
OK button we're
button we're going
to call it
call it save
it save and
save and for
call it exit
save that we
handle this new
to our populate
form function we've
function we've set
set up something
up something to
something to handle
to handle title
a way to
way to handle
handle the positioning
the positioning and
positioning and setting
and setting up
setting up all
up all buttons
all buttons on
have the start
the start width
start width and
and height coordinates
height coordinates of
these buttons we
buttons we can
can pull that
that information out
before we're now
now using a
a control add
button command with
with the global
the global dialog
global dialog handle
handle and pulling
and pulling out
pulling out from
out from our
from our array
our array the
array the reference
the reference ID
reference ID in
ID in this
this case button
case button the
button the x
y coordinates the
coordinates the width
Now with this
with this in
in place it
place it should
it should display
should display the
display the button
button on our
The functionality will
functionality will be
will be exactly
be exactly the
the same regardless
same regardless of
regardless of which
of which button
which button we're
button we're actually
we're actually handling
code now we'll
now we'll see
two buttons on
the screen an
screen an exit
and an OK
wish to move
to move them
move them up
them up slightly
up slightly but
slightly but they're
but they're all
they're all located
all located certainly
located certainly on
certainly on the
no code underneath
code underneath the
underneath the button
the button, nothing
handler to do
to do any
do any actions
any actions or
actions or when
something in place
in place that
place that will
will do event
do event handling
would expect we
expect we will
will go to
Normally any events
any events on
on the objects
on your screen
your screen will
will be captured
be captured within
captured within this
within this case
this case statement
is for process
for process control
notifications for example
for example when
example when buttons
when buttons are
buttons are clicked
are clicked upon
call this run
this run control
run control processes
control processes and
processes and we're
the callback handle
That's the handle
The callback control
callback control which
is the identifier
the identifier of
identifier of the
control that has
that has some
has some action
some action being
action being performed
being performed upon
performed upon it
finally the callback
callback control message
control message which
message which is
is the detail
detail of what's
actually happening to
happening to the
of the message
here to allow
allow us when
us when we
when we step
step through our
through our global
array to know
know what we're
done before we're
be using our
using our foreign
our foreign x
foreign x loop
x loop here
loop here again
here again to
look through each
through each record
each record in
record in our
up the object
object which is
is the reference
id in our
the control number
control number, the
the unique reference
unique reference to
the control on
can then compare
then compare that
that against the
against the number
number we passed
for that control
that control which
one we know
know that has
If these two
these two numbers
two numbers match
numbers match then
match then we
found a configuration
a configuration for
configuration for the
for the object
object which has
So looking again
looking again at
again at our
at our configuration
configuration file we
file we can
a match for
match for example
for example for
example for this
can now pull
now pull back
pull back this
back this value
this value in
object column to
column to see
see whether it
whether it is
is a button
a button or
button or not
can then pull
then pull back
back the data
data that's in
function column to
the application needs
application needs to
needs to do
to do when
do when this
when this event
this event has
event has occurred
So we'll pull
we'll pull back
pull back both
back both the
both the type
the type and
type and the
before we're using
using a parse
command to parse
to parse the
parse the element
the element in
the string looking
string looking for
for the column
column number designated
number designated by
designated by these
by these constants
object and one
then test our
test our object
our object type
object type and
type and use
and use a
use a case
a case statement
a button we
button we can
test the type
type of message
of message that
message that we've
that we've been
we've been passed
passed to see
to see is
see is it
it a button
a button clicked
the button has
been clicked we
clicked we can
now see which
see which function
which function it
function it is
it is we
need to perform
to perform when
perform when that
when that occurs
is the save
the save function
save function we
to do we
do we can
can put some
here that would
would allow us
perform a save
a save operation
one later on
later on when
on when we've
when we've actually
actually got some
got some objects
some objects on
However for the
the exit all
exit all we
do a dialogue
a dialogue end
dialogue end on
end on the
on the handle
we try a
try a quick
a quick compile
quick compile to
compile to make
sure it compiles
it compiles okay
compiles okay and
okay and then
and then run
then run our
there's our application
our application on
application on screen
mouse over the
over the exit
the exit one
exit one and
and click it
click it will
it will end
will end the
end the dialogue
the dialogue which
dialogue which will
which will end
end the application
a generic configuration
generic configuration file
configuration file which
file which will
which will put
will put buttons
put buttons on
and allow you
you to click
to click upon
click upon them
how you set
you set the
set the configuration
the configuration up
configuration up we
can make any
make any button
any button act
button act as
act as the
as the exit
the exit application
exit application button
that we've proved
proved that we
can put buttons
the form can
form can we
can we put
we put other
put other controls
So let's attempt
let's attempt to
attempt to put
put a label
label and a
a text control
text control onto
control onto the
we add two
two more lines
more lines to
lines to our
One where the
has a label
label and we
the word name
word name into
name into that
into that label
to set its
set its location
its location its
location its width
its width and
width and its
and its height
its height and
height and we're
it a handle
handle of 2000
a text object
text object and
to put any
put any value
any value into
value into that
into that text
that text object
text object we're
object we're going
to leave that
leave that blank
that blank to
blank to allow
user to key
to key into
key into it
location its height
and width as
width as well
well and we
we will give
will give it
it a reference
a reference of
reference of 2001
save that now
now to go
form function to
function to put
to put more
put more functionality
more functionality in
functionality in there
there to handle
to handle labels
handle labels and
labels and text
and text controls
we have entries
have entries in
entries in here
in here already
here already for
already for title
for title and
title and button
add another case
statement to allow
to do labels
the label we're
label we're going
be doing almost
same thing as
thing as we
need to pull
to pull the
pull the information
of our global
global array and
array and use
control add label
add label command
the id the
id the text
on the label
the label its
label its location
on screen its
screen its width
Additionally in these
in these forms
these forms we
forms we may
of the label
the label to
label to allow
it to stand
to stand out
stand out on
out on the
is something we
something we could
we could do
could do later
do later and
later and add
and add to
to the configuration
configuration file but
the moment we'll
moment we'll just
just put it
as the color
the color blue
now it runs
it runs quite
runs quite happily
happily and the
the label is
label is now
However the dialogue
dialogue itself is
itself is not
not particularly big
particularly big and
big and the
the objects is
objects is quite
is quite small
is a way
a way in
way in Power
Power Basic of
Basic of increasing
of increasing the
of the font
the font used
font used for
the default on
default on the
If we exit
we exit that
exit that and
and we go
code in your
in your pb_main
your pb_main function
pb_main function where
where we made
we made the
made the call
call to show
show the main
Immediately before that
before that line
of code if
code if you
if you put
you put in
in a dialogue
a dialogue default
dialogue default font
default font through
font through the
through the whole
the whole application
whole application for
application for each
of the dialogues
the dialogues you're
dialogues you're going
case we're setting
we're setting it
setting it as
it as sans
as sans serif
sans serif, 14
14 point and
point and an
and an anci
an anci character
anci character set
we just run
just run the
application now without
now without any
without any other
other changes we
changes we will
dialogue is much
is much bigger
text on each
objects is bigger
is bigger and
bigger and is
and is orientated
is orientated better
orientated better on
better on the
way of changing
changing the entire
entire application with
application with a
got a label
a label on
label on the
the dialogue let's
dialogue let's see
put a text
text box as
box as well
As we set
set the details
the details up
details up in
up in our
file we may
back and change
and change the
change the populate
the populate function
So below our
below our command
our command that
command that handles
handles the label
label we need
we need now
need now one
now one that
one that handles
that handles text
handles text boxes
text boxes and
boxes and this
one will look
will look remarkably
look remarkably similar
This time I
time I control
I control add
control add text
add text box
text box but
box but the
but the following
the following lines
following lines of
code are exactly
up the reference
reference id, the
the text, the
application now we
see we not
we not only
not only have
have a name
a name we
name we have
text box underneath
box underneath it
with these objects
can add additional
add additional labels
additional labels and
and text boxes
text boxes quite
boxes quite easily
Again without changing
without changing anything
changing anything in
anything in the
in the generic
the generic application
we add on
add on an
on an extra
extra line for
line for a
for a label
label and one
have two labels
two labels and
labels and two
and two text
two text boxes
text boxes on
save our configuration
file and then
then run an
run an application
an application once
once more again
more again a
again a new
a new object
new object and
object and its
its label have
label have appeared
have appeared on
appeared on the
we could add
could add any
add any number
any number of
of text boxes
text boxes onto
boxes onto the
screen just by
just by changing
by changing the
changing the configuration
is no focus
no focus on
focus on any
the tab button
tab button we
we can tab
can tab around
tab around and
around and see
and see who
see who has
has the focus
Ideally on a
a form entry
entry system you
system you would
you would want
would want the
want the first
the first object
first object the
object the first
the first editable
first editable object
editable object on
object on the
screen to have
have the focus
we set that
set that in
that in code?
in code? So
code? So having
So having run
having run around
run around the
around the loop
the loop of
loop of all
the objects in
objects in our
editable object that
object that appears
that appears in
appears in that
in that array
that array and
array and that's
and that's the
to set focus
set focus to
moment the only
the only editable
only editable objects
editable objects are
objects are the
are the text
the text boxes
boxes and the
and the buttons
the code we'll
code we'll see
see the very
very first one
the one our
one our program
our program is
program is going
So again another
again another for
next loop and
loop and we
the object type
type and in
case we're going
be looking just
looking just for
just for text
for text boxes
leave the buttons
buttons for later
for later and
later and we
up the control
control handle number
handle number from
number from the
from the id
the id column
id column just
column just as
we did earlier
did earlier and
earlier and we
control set focus
set focus command
focus command to
focus to that
that control and
control and once
once we perform
we perform that
can exit out
exit out the
out the for
the for loop
for loop as
focus to a
to a single
a single control
code now you'll
you'll see from
from the name
the name text
name text box
text box the
box the cursor
cursor is flashing
is flashing so
flashing so it
so it currently
currently has focus
has focus and
focus and anything
and anything you
anything you type
you type in
type in will
in will go
into that field
have taken an
taken an application
which has a
has a generic
a generic form
have populated a
populated a configuration
configuration file with
file with some
with some metadata
some metadata comprising
metadata comprising of
comprising of buttons
of buttons, labels
text controls and
controls and we've
and we've used
used this metadata
this metadata to
metadata to configure
to configure items
configure items on
the screen which
screen which our
which our user
our user can
user can type
can type into
We can control
can control when
control when a
when a button
a button is
is clicked upon
clicked upon and
upon and what
and what function
what function we
function we perform
we perform when
next video we're
take this concept
this concept even
concept even further
Ideally on these
on these entry
these entry forms
entry forms you
forms you may
you may wish
wish to have
to have things
have things like
things like drop
like drop down
down lists which
which are pre-populated
are pre-populated to
pre-populated to allow
select from them
You may also
may also want
also want multi-line
want multi-line text
multi-line text boxes
boxes and we'll
also want some
want some functionality
some functionality underneath
functionality underneath the
underneath the ok
us to call
a function, to
information the user
user has entered
has entered on
entered on screen
screen to somewhere
to somewhere on
on the system
the system either
system either in
either in 2a
in 2a database
2a database or
database or perhaps
or perhaps a
perhaps a flat
auto forms, by
by adding defaults
adding defaults to
to the controls
the controls available
our last project
last project video
project video we
video we had
we had added
had added the
added the tick
tick box control
box control to
control to our
to our configurable
our configurable auto
configurable auto forms
auto forms application
When this application
this application runs
application runs you
runs you are
you are presented
are presented with
with a select
a select a
select a form
a form dialog
appears on that
on that dialog
that dialog is
dialog is a
the configuration files
Each configuration file
is a CSV
file and contains
and contains a
contains a list
of objects which
objects which will
which will dynamically
will dynamically appear
dynamically appear on
appear on your
gives the ability
ability to create
create an application
an application with
a simple dialog
simple dialog with
dialog with controls
with controls on
can be filled
be filled in
filled in by
in by the
user and clicking
and clicking the
clicking the OK
OK button will
button will append
will append the
append the data
end of a
of a CSV
CSV file will
file will contain
will contain all
contain all the
the data keyed
data keyed so
keyed so far
However one thing
we haven't added
haven't added to
to the system
the system yet
system yet is
yet is the
set a default
a default on
default on one
of these fields
for example you're
example you're doing
you're doing a
doing a large
a large recruitment
large recruitment and
recruitment and the
and the bulk
of the staff
the staff been
staff been recruited
been recruited are
recruited are all
are all coming
all coming in
with the same
same job title
job title and
title and into
into the same
the same part
same part of
of the organization
set the form
the form up
form up so
so that some
that some of
these fields will
fields will be
will be pre-populated
do this we're
an extra column
extra column to
column to our
to our config
our config files
add a defaults
a defaults column
at the config
the config file
new test demo
test demo 3
demo 3 CSV
3 CSV file
be our third
our third config
third config file
at that config
that config file
config file we
file we will
now a new
a new defaults
new defaults column
So into this
into this defaults
this defaults column
defaults column we
column we set
a value for
for the dropdown
dropdown list of
list of finance
Finance is one
of the departments
the departments that
departments that appears
on that list
that list and
list and our
and our object
our object is
object is to
is to ensure
to ensure when
ensure when the
is loaded the
loaded the finance
the finance department
finance department is
department is pre-selected
list box we've
box we've put
we've put in
in a job
a job skill
job skill of
skill of admin
of admin assistant
admin assistant and
assistant and in
in the tick
tick box which
one that records
that records whether
records whether the
staff are full
are full or
full or part
or part time
part time we
time we put
put a value
of 1 to
to indicate we
indicate we want
we want this
want this tick
this tick box
tick box pre-ticked
box pre-ticked for
pre-ticked for the
to change in
change in our
application to support
support this additional
this additional functionality
will remember from
remember from the
last video there
video there are
are a series
series of functions
of functions that
functions that may
that may need
to be amended
be amended if
amended if we're
if we're adding
we're adding new
adding new functionality
new functionality and
functionality and that
that is this
is this list
this list here
a new column
new column to
column to the
to the config
file we need
to our enumeration
is our enumeration
our enumeration at
the moment which
moment which has
has a list
list of each
of the fields
the fields and
fields and the
and the position
in the config
a new value
new value to
value to that
added the default
default value column
using the defaults
the defaults column
column we want
want to know
to know when
know when we
when we need
need to populate
on screen with
screen with these
with these default
these default values
We obviously don't
obviously don't want
want to overwrite
to overwrite values
overwrite values that
values that the
user has already
has already entered
already entered in
entered in a
a previous form
use of a
of a function
a function we
have created earlier
created earlier but
earlier but not
but not yet
not yet used
yet used within
used within this
this application and
application and that
the reset form
first we need
at the run
the run control
run control process
control process function
is our event
handler for our
for our configurable
our configurable dialog
is the logic
logic to actually
to actually save
save a form
a form to
form to the
to the CSV
and there's already
there's already logic
already logic built
logic built in
built in here
here to work
work out are
out are we
the last form
increment the global
the global form
global form number
form number and
number and present
and present to
user a blank
make the call
to our reset
our reset form
reset form function
to the reset
form function which
which exists and
exists and see
see what changes
what changes we
changes we need
of the reset
form function there
number of declarations
of declarations of
declarations of local
variables to be
handle the defaults
defaults column and
within that column
to call these
call these variables
these variables default
variables default as
default as a
a string and
string and defaults
and defaults column
defaults column as
column as a
as a number
This last variable
last variable will
column number of
the default column
of the logic
the logic is
logic is where
where we pick
pick up these
up these column
these column numbers
going to actually
to actually add
actually add in
in a line
code to pull
back the default
default column number
This using our
our parse find
parse find function
find function just
function just as
just as we've
we've done with
done with the
the other two
other two lines
two lines object
lines object and
object and ID
Next within the
within the for
next loop we
loop we need
the actual value
actual value held
held in that
in that defaults
that defaults column
In most of
these objects there
objects there is
is no default
The default will
default will be
So we're pulling
we're pulling it
pulling it back
it back from
from the config
the config array
where we wipe
we wipe the
wipe the text
text in each
the controls either
controls either by
either by unselecting
by unselecting a
unselecting a combo
combo box or
box or setting
or setting the
text to an
text control we
use the default
default value in
in the population
the string as
string as we've
as we've currently
we've currently got
currently got an
got an empty
since the default
default value will
value will either
either be an
length string or
string or a
or a value
a value this
value this can
be quite easily
quite easily populated
For the drop
down list we
list we can
if the default
default is an
length string in
string in which
which case we
to unselect the
unselect the control
the control as
control as we
have done already
done already or
already or if
default value is
length string we
string we will
attempt to select
combo box the
box the value
value that's been
passed in as
the default like
default like so
to use exactly
same logic for
for the list
list box except
box except this
except this case
case we'll be
using the select
the select list
select list box
list box function
box function and
function and the
for the date
the date and
date and for
for the tick
in place resetting
place resetting the
resetting the form
the form should
form should now
should now populate
populate the values
the values on
on the controls
controls either with
either with an
length string unselected
string unselected or
unselected or the
or the default
handles the reset
at the form
form which fills
which fills a
fills a form
a form with
form with a
with a record
add another set
another set of
set of local
handle the default
column number plus
number plus the
plus the value
within that default
that default column
default column and
variable is to
handle a data
a data line
data line that
line that has
that has no
has no delimiters
This will mean
will mean when
mean when we
get back a
value from the
from the form
the form it
form it has
it has nothing
has nothing in
Having picked this
picked this up
this up we
can actually test
actually test it
So where we've
where we've reached
we've reached the
reached the end
the forms the
forms the str
str data contains
data contains an
contains an empty
length string so
string so we
we can mark
can mark the
mark the str
str data no
data no delimiters
no delimiters variable
delimiters variable with
value in str
in str data
Where there's some
there's some value
some value coming
coming in we'll
that's in str
str data and
data and attempt
attempt to remove
to remove any
remove any commas
any commas from
commas from it
a mechanism for
mechanism for working
for working out
whether the entire
entire data line
data line is
line is actually
is actually empty
actually empty or
empty or if
or if it's
if it's populated
it's populated at
populated at all
at all there'll
all there'll be
there'll be something
be something there
something there other
there other than
other than commas
previous function we
function we need
of the defaults
have done for
done for the
for the field
the field name
field name and
name and the
and the object
the object columns
within our for
default value to
value to pick
up the default
default value should
value should it
it exist in
exist in our
in our config
our config file
Then we get
to the bit
the bit of
bit of logic
of logic where
logic where the
the control has
control has been
has been identified
been identified and
identified and we
it with some
with some data
We're currently picking
currently picking up
from the value
value within the
the data string
data string returning
string returning from
returning from the
to test our
test our data
our data no
delimiters variable to
it is an
length string this
string this is
this is obviously
is obviously a
obviously a new
a new unpopulated
new unpopulated form
unpopulated form and
form and we
the default should
default should it
it exist from
exist from the
from the default
the default variable
And since str
since str value
str value is
value is populated
is populated the
populated the logic
the logic that
logic that follows
that follows that
follows that will
will take that
take that value
value in quite
in quite normally
And in theory
in theory that
theory that should
should be all
be all the
all the changes
the changes we
to test it
test it to
it to see
whether it's functioning
it's functioning properly
So our command
command line is
line is currently
is currently looking
at the test
the test demo3
test demo3 CSV
demo3 CSV file
CSV file which
one we have
us to form
to form 9
form 9 which
9 which is
is currently unpopulated
can see selected
see selected finance
selected finance as
finance as a
as a department
a department and
department and admin
and admin assistant
admin assistant as
assistant as the
as the skill
the skill and
skill and it
it is ticked
is ticked or
ticked or full
or full time
full time staff
very last form
last form which
which is unpopulated
is unpopulated it
unpopulated it has
it has correctly
has correctly populated
correctly populated all
populated all our
all our defaults
step back in
the forms and
forms and have
at the ones
the ones that
ones that have
that have already
is a previous
a previous one
previous one where
where the full
the full time
time staff is
is not ticked
And look at
look at form
at form number
form number seven
number seven and
seven and it's
it's a different
different department and
department and a
and a different
a different skill
at the view
the view all
view all forms
all forms we
forms we can
can see everything
see everything is
everything is populated
is populated correctly
let's try populating
try populating form
populating form number
form number nine
last form we
see the defaults
the defaults have
defaults have been
have been set
click the OK
OK button it's
button it's now
now moved us
moved us on
us on to
on to form
to form number
form number 10
number 10 and
10 and it
it has repopulated
has repopulated finance
repopulated finance admin
finance admin assistant
assistant and the
and the full
time staff tick
staff tick box
tick box is
box is ticked
to our view
our view all
see the one
one we did
we did previously
did previously has
previously has been
has been keyed
been keyed in
keyed in correctly
It's marked as
marked as finance
as finance admin
assistant and full
and full time
full time has
time has been
has been ticked
to set defaults
So should you
should you have
have a mass
a mass input
mass input of
input of new
of new staff
new staff you
staff you can
set the defaults
the defaults or
defaults or the
or the majority
majority of the
of the ones
in and see
can add a
a new form
new form and
form and change
and change one
change one of
we have full
have full time
time staff which
staff which we
we will untick
will untick and
untick and we
will pick DB
pick DB admin
DB admin instead
admin instead but
instead but we
will leave finance
leave finance pre-selected
finance pre-selected and
pre-selected and it
it will OK
It moves on
moves on to
the next form
next form which
form which has
which has pre-selected
has pre-selected as
pre-selected as finance
as finance and
finance and admin
admin assistant but
assistant but if
look at all
at all the
the forms we'll
forms we'll see
see that Jane
that Jane Jones
Jane Jones is
Jones is down
is down as
down as although
as although finance
although finance the
finance the skill
the skill is
skill is DB
is DB admin
DB admin and
admin and full
full time is
time is unticked
we exit out
exit out of
application and have
at the output
the output CSV
output CSV file
file in our
data folder there
folder there is
is our user
our user data
user data file
data file and
file and there
is our entry
we have achieved
have achieved today
we have configured
have configured the
configured the application
to support defaults
support defaults allowing
defaults allowing you
set defaults or
defaults or any
or any of
give you additional
you additional flexibility
additional flexibility when
flexibility when it's
when it's needed
your applications but
applications but that's
by adding hyperlinks
adding hyperlinks to
hyperlinks to the
last video in
video in the
in the Auto
the Auto Forms
Auto Forms project
Forms project we
project we have
have two applications
The first application
first application, Form
Form Runner, allows
These forms are
forms are configured
are configured in
configured in external
in external configuration
select the test
the test demo
test demo number
demo number 3
number 3 and
3 and click
and click Run
click Run Form
Run Form, this
this displays a
displays a form
objects in this
this form are
form are configured
are configured within
configured within the
within the configuration
configuration file, allowing
allowing you the
you the flexibility
the flexibility to
flexibility to define
to define controls
define controls to
controls to be
to be placed
be placed anywhere
placed anywhere on
the screen, without
having to change
change the application
Forms application is
application is driven
is driven entirely
driven entirely by
entirely by the
by the contents
of the config
the config folder
Within the config
config folder we
list of CSV
of CSV files
open up the
up the test
demo 3, we
can see there's
there's a list
of objects to
objects to find
to find on
find on it
on it -
it - buttons
- buttons, labels
text boxes, drop-down
drop-down lists and
lists and so
these objects has
objects has a
has a certain
a certain number
certain number of
number of properties
coordinates where you
you wish them
wish them placed
them placed on
Each object also
object also has
also has an
has an identifier
an identifier, a
a unique identifier
unique identifier for
identifier for the
the object itself
object itself used
itself used within
We have covered
have covered a
covered a range
range of controls
of controls to
controls to display
display on your
on your form
your form within
form within these
within these configuration
these configuration files
new object, in
case a hyperlink
a hyperlink or
hyperlink or URL
times in the
in the design
the design of
design of your
of your form
your form you
form you wish
put a hyperlink
a hyperlink in
hyperlink in to
in to give
option of clicking
clicking on it
on it and
it and going
and going to
to a website
a website where
website where more
where more information
more information can
information can be
can be gleaned
be gleaned for
gleaned for the
for the type
form and what
and what they
what they need
they need to
do to fill
to fill it
fill it in
it in, giving
giving the user
user the appropriate
the appropriate guidance
that's the control
the control we're
configuration file today
at the configuration
up in Notepad
in Notepad, we'll
of rows, each
each row defining
row defining a
defining a different
a different object
different object on
Since we're wanting
wanting to put
put a URL
a URL on
URL on the
the screen, we'll
we'll probably want
probably want to
add two additional
two additional lines
additional lines to
lines to this
to this configuration
One to put
screen and one
number of label
of label controls
label controls already
controls already in
already in this
this file, so
so the data
the data line
data line for
line for this
element is 'Label'
is 'Label' to
'Label' to indicate
indicate that it's
that it's a
it's a label
in a piece
of text, in
this case click
case click 'URL'
click 'URL' below
'URL' below for
below for further
for further information
further information on
information on this
next two fields
two fields are
fields are the
Y coordinates you
coordinates you wish
you wish this
wish this control
this control to
appear at, in
this case X
case X coordinate
X coordinate 20
coordinate 20 and
20 and Y
Y coordinate 180
The two fields
two fields following
fields following this
following this are
this are the
are the width
so we're marking
we're marking this
marking this one
one as 200
as 200 wide
200 wide and
wide and 10
and 10 high
The next and
next and final
and final defined
final defined column
defined column for
column for this
for this object
this object is
object is the
the control ID
control ID, and
making that 2014
define a line
a line which
line which is
which is for
new type of
type of object
call this URL
next thing will
thing will be
So for this
for this one
this one we'll
one we'll put
the URL of
URL of the
of the GSF
the GSF software
GSF software website
only other things
other things we'll
things we'll actually
we'll actually need
actually need for
need for this
particular control are
control are its
are its X
its X and
Y coordinates, its
and height and
height and the
and the unique
the unique identifier
So having put
having put these
these in, let's
let's save the
save the file
file and have
look at it
our new object
new object in
object in the
the bottom row
We're defining the
defining the object
the object as
object as a
as a URL
a URL, we've
given it a
it a URL
in the 'Text'
the 'Text' column
'Text' column and
column and we're
putting in the
in the coordinates
the coordinates for
for the location
the location and
location and the
be all we
all we actually
this particular URL
This URL is
be a rich
a rich edit
rich edit control
add one of
of the libraries
the libraries that
libraries that ships
ships with Power
Power Basic, the
the rich edit
rich edit include
edit include file
is our library
our library now
library now added
now added to
to the source
source code, richedit.include
this code work
code work, we're
need a handle
for the library
The library will
be loaded dynamically
we'll declare a
declare a global
a global further
global further down
call this library
this library g
library g for
g for global
for global, h
h for handle
for handle and
handle and lib
and lib for
lib for library
for library, defined
defined as a
as a Dword
forms application looks
application looks for
looks for a
for a value
This defines the
defines the config
config file it's
file it's going
be using to
using to display
display the form
So we've entered
we've entered into
entered into the
into the command
command line in
in our IDE
our IDE the
IDE the path
path to test
to test demo3
we'll see it
see it handles
it handles the
the label quite
label quite happily
happily and displays
and displays that
displays that on
But there's no
no code within
this new object
new object, the
handling of display
of display of
display of objects
screen is done
called populate form
look at populate
at populate form
Populate form is
form is reading
is reading information
reading information from
information from the
for the configs
the code, it's
it's stepping through
record in this
this config array
config array, looking
for the reference
the reference object
We have title
have title, we
we have button
have button, we
we have label
have label and
label and so
add a URL
a URL to
of this list
of the select
the select statement
be handling the
handling the URL
use the rich
the rich type
rich type control
type control, we
need to load
load a library
a library, one
of the Windows
the Windows libraries
So we're doing
doing a test
on the value
of our Hlib
our Hlib global
Hlib global variable
value is zero
then the library
the library is
library is not
not yet loaded
to call one
call one of
Windows API routines
API routines, load
load library, defining
defining the name
of the library
the library, riched20.dll
And we're following
we're following that
following that with
with a call
call to initialize
that we've loaded
we've loaded our
loaded our library
our library, we'll
have to set
set the styles
the styles of
styles of this
These are fairly
are fairly standard
fairly standard settings
standard settings, which
can amend later
amend later on
later on should
on should we
Next as we've
the other controls
other controls is
controls is we
control add command
add command to
add the object
object to our
going to follow
to follow the
follow the same
the same standard
same standard as
standard as we
did for all
for all the
have the global
dialogue and we
have the long
the long control
long control variable
control variable which
variable which holds
which holds the
holds the unique
unique identifier of
identifier of this
of this object
then we're specifying
specifying the x
the height, all
all coming from
coming from our
from our configuration
Followed up by
by the style
style and extended
and extended style
extended style variables
little more we
of all we'll
all we'll set
do this with
this with the
with the control
Sending the value
the value em
value em set
em set background
set background color
And then specifying
then specifying using
specifying using the
using the RGB
the RGB function
RGB function the
function the color
the color we
color we wish
want to auto
to auto detect
auto detect the
detect the fact
fact that this
Again another control
that the string
the string held
string held within
held within this
particular control is
a URL and
URL and it
and it needs
needs to automatically
to automatically detect
automatically detect which
detect which parts
which parts of
the string are
string are the
are the URL
And next we
have to prepare
to prepare the
prepare the system
system to accept
to accept events
URL and will
and will want
will want something
want something to
something to happen
So another control
This time to
time to set
set the event
the event mask
With the parameter
the parameter to
parameter to see
that it's going
be a link
Finally we need
be our URL
our URL itself
quite easily with
easily with the
this should get
should get our
get our URL
our URL displayed
URL displayed on
sure that that's
that that's worked
on screen our
screen our label
our label to
label to say
to say click
say click URL
click URL below
URL below and
below and the
the mouse hovers
mouse hovers over
hovers over the
over the URL
URL the cursor
the cursor changes
cursor changes to
a hand pointing
hand pointing at
pointing at it
on it at
the moment nothing
moment nothing happens
Because there is
is no event
no event sitting
event sitting to
sitting to handle
handle the click
is to create
create an event
for this to
this to link
to link into
link into our
We'll see where
where the form
form is populated
where the details
the details are
details are actually
are actually passed
actually passed into
passed into all
into all the
in the wm
command section there's
section there's a
there's a run
a run control
This function handles
function handles all
all the events
events when objects
when objects are
objects are clicked
However this won't
this won't be
won't be enough
handle the URL
the URL rich
URL rich edit
For this we'll
this we'll need
do that it's
that it's good
it's good to
good to remember
to remember that
remember that we've
we've actually loaded
actually loaded a
loaded a library
a library here
form is unloaded
is unloaded we'll
unloaded we'll want
want to unload
to unload that
unload that library
that library as
library as well
into our function
our function that
function that handles
handles the run
control process and
process and add
and add something
to the exit
the exit of
exit of the
in the run
control process this
process this handles
events for objects
for objects being
objects being clicked
being clicked upon
is one for
save button and
button and there
So it's within
it's within the
within the exit
exit button we'll
button we'll want
put this extra
this extra piece
extra piece of
code to unload
unload the library
library we have
the global hlib
global hlib variable
value is non-zero
is non-zero then
non-zero then the
the library has
library has been
been loaded and
need to unload
to unload it
We can unload
can unload such
unload such libraries
such libraries by
libraries by using
by using another
call called Free
called Free Library
the library itself
This will instruct
will instruct Windows
instruct Windows that
Windows that we're
that we're no
no longer using
longer using the
using the library
And once Windows
once Windows realises
Windows realises that
realises that nothing
that nothing else
nothing else is
else is using
the library it
library it will
it will unload
will unload it
unload it from
it from memory
that we need
to have another
have another look
another look now
look now at
the function show
function show dialog
show dialog main
dialog main proc
In here there
here there is
is an event
event for command
for command processes
where we run
run the control
the control process
new event called
event called wmnotify
to handle such
handle such processes
such processes called
processes called run
called run notify
run notify processes
to have more
than one URL
one URL on
pass this three
this three parameters
the dialog control
dialog control and
l parameter value
our new run
new run notify
notify processes function
be very similar
very similar in
similar in some
in some ways
some ways to
ways to the
I've set up
up the same
the same local
same local variables
local variables with
variables with the
addition of two
of two other
two other variables
string variable for
URL and an
and an nm
an nm header
nm header pointer
header pointer for
for the construct
the construct which
construct which we're
using to pull
pull back information
back information on
information on what's
on what's been
what's been clicked
config file to
file to see
This is almost
is almost identical
almost identical to
identical to what
what we did
with the run
for each entry
each entry within
entry within that
within that configuration
that configuration file
file is pulling
is pulling out
pulling out the
in the ID
is the unique
identifier of our
of our object
It's then comparing
then comparing that
comparing that against
against the control
the control variable
control variable being
variable being passed
If these match
these match then
have indeed found
indeed found the
found the object
determine the type
the type to
type to make
sure it's the
it's the type
the type we're
type we're looking
create a select
statement to look
to look just
look just for
just for URLs
case statement we're
statement we're pulling
we're pulling back
back a pointer
pointer to the
to the structure
the structure we
structure we want
URL on a
that the value
looking for, the
the actual control
then we'll do
we'll do another
statement to work
out the code
Is this a
this a link?
a link? And
link? And if
is a link
a link we
link we need
rich edit hyperlink
edit hyperlink handle
hyperlink handle URL
function is already
already in one
the libraries loaded
libraries loaded at
loaded at the
perform the hyperlinking
the hyperlinking for
hyperlinking for us
if our hyperlink
our hyperlink is
hyperlink is now
see the hyperlink
the hyperlink on
hyperlink on the
mouse over it
over it and
it and click
and click with
with the mouse
the mouse, it
will launch our
launch our URL
our URL straight
URL straight into
into the browser
have successfully achieved
successfully achieved today
a new type
type of control
of control to
to our AutoForms
our AutoForms application
can now place
now place URLs
place URLs on
URLs on the
URL is displayed
is displayed in
displayed in the
form and underlined
and underlined to
underlined to indicate
indicate that it
it is in
fact a hyperlink
on this hyperlink
this hyperlink, it
will launch your
launch your default
your default browser
default browser and
browser and display
allows you as
you as a
as a developer
a developer to
developer to keep
to keep documentation
keep documentation away
documentation away from
away from your
from your application
your application and
application and accessible
and accessible from
accessible from a
from a URL
on a website
auto forms by
forms by adding
by adding conditional
adding conditional controls
this project we
have created two
created two generic
two generic applications
purpose of these
of these applications
these applications is
applications is to
to enter data
enter data into
data into a
into a form
controls that exist
that exist within
exist within this
within this form
are configured from
configured from within
from within an
within an external
an external file
first of the
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
details of these
of these forms
forms are held
are held in
held in configuration
in configuration files
the forms folder
forms folder and
folder and into
into the configs
the configs folder
configs folder, we
are three CSV
three CSV files
CSV files –
files – TestDemo
– TestDemo, TestDemo2
TestDemo2 and TestDemo3
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
appear on this
this particular form
The title gives
title gives us
us the title
form and its
and its width
and height, and
and the fact
it is centred
is centred on
centred on the
of other objects
other objects have
objects have actually
have actually supported
actually supported, for
for example buttons
example buttons, labels
texts and so
these objects, the
coordinates are specified
are specified, the
the object, and
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
used to specify
to specify which
specify which of
the fields are
fields are output
are output to
output to an
to an external
external file when
file when the
clicks the submit
the submit button
be adding two
adding two new
two new columns
new columns to
columns to this
these two columns
two columns is
columns is to
is to mark
mark which fields
which fields are
fields are conditional
you're designing forms
designing forms, there
in your form
your form when
form when you
when you do
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
a checkbox, you
you wish another
wish another label
another label and
label and text
and text box
box to appear
to appear to
appear to elicit
to elicit more
elicit more information
more information from
from the user
Up until the
until the clicking
clicking of that
of that checkbox
that checkbox, these
these two objects
objects are invisible
are invisible and
invisible and non-accessible
and non-accessible by
non-accessible by the
that's our task
our task for
task for today
for today, to
to configure the
configure the application
to allow these
allow these to
these to exist
to exist in
changes to is
to is the
is the autoform.bas
the autoform.bas file
we go ahead
ahead and make
and make changes
to the functionality
the functionality of
functionality of this
this application to
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
if the application
application runs and
runs and the
user picks one
picks one of
the forms, if
if the output
the output for
output for that
for that form
that form does
form does not
not exist, the
application has issues
Normally for the
very first time
first time the
application runs, you
you may not
actually have an
have an output
an output file
output file, so
amend our pb_main
pb_main function to
function to cater
to cater for
cater for that
And when no
when no output
no output file
output file has
been created, it
it has the
has the job
job of creating
of creating the
creating the output
the output file
In this pb_main
this pb_main function
pb_main function, this
where the configuration
file is loaded
is loaded up
global array, and
then we populate
the form data
form data array
data array, based
the information held
information held within
output file does
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
handle that condition
function called createOutputFormData
have the task
task of creating
creating the headers
the headers for
headers for the
for the output
new function, createOutputFormData
which takes no
This will create
create a blank
a blank output
blank output form
output form, containing
containing only the
only the headers
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
that function to
to return and
return and populate
populate the output
the output variable
which returns all
returns all the
all the column
the column names
of that one
that one as
as well, to
populate the headers
the headers variable
These column names
column names do
names do include
do include the
include the very
first column, which
which is displayed
is the ID
ID column containing
column containing the
containing the form
the form number
don't need this
need this in
in our output
our output file
is to trim
to trim that
trim that off
So we're re-dimensioning
re-dimensioning the form
data array, which
is global, to
to contain two
contain two rows
A zero row
zero row, which
are the headers
the headers, and
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
result of the
the end range
end range parse
is taking all
taking all the
the headers from
headers from the
second element onwards
Having populated this
populated this array
this array, we're
existing function in
our common file
common file handling
handling routines to
routines to dump
to dump the
dump the array
array to disk
order to prove
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
file called testdemo4
called testdemo4, again
again as a
as a CSV
in this CSV
CSV file, we're
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
on this just
this just to
just to test
test it out
able to test
the forms data
forms data folder
data folder, we
see the user
the user data
user data dot
file that will
be created in
created in here
in here when
here when we
application is configured
is configured in
configured in our
to be called
be called leave
called leave data
leave data dot
this does not
does not currently
currently exist as
exist as an
as an output
get the form
the form displayed
form displayed on
screen with its
with its single
its single editable
single editable field
look back in
back in our
in our forms
our forms data
have a leave
a leave data
dot CSV, which
has a single
a single name
single name field
name field in
field in it
in it, which
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
few more objects
more objects within
objects within our
within our configuration
we save these
save these additional
configuration items, and
back and run
we're getting now
getting now more
now more objects
more objects on
have a special
a special leave
special leave type
leave type, which
be a drop
configuration file, we
see the drop
down list is
list is being
is being populated
being populated from
populated from a
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
leave types appearing
types appearing in
in the drop
want the application
application to do
now is that
is that when
that when one
when one specific
one specific item
specific item on
item on this
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
being a label
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
new objects are
objects are to
are to remain
to remain invisible
in the code?
the code? First
code? First of
of all, in
config file we're
some more objects
new objects we're
objects we're going
to add are
add are a
are a label
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
it stands, we
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
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
some changes in
changes in the
make this invisible
have two scenarios
two scenarios to
scenarios to look
The first scenario
first scenario is
scenario is when
the form first
form first loads
first loads and
loads and the
has selected nothing
The second scenario
second scenario is
scenario is where
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
This takes place
takes place in
in the populate
we go through
go through all
through all the
the entries that
entries that came
config file, currently
currently loaded into
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
see if any
if any of
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
the form, we're
that function 'HideObjects'
through each row
each row in
row in the
have a quick
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
config file conditional
file conditional and
conditional and selection
indicate that both
that both of
these objects are
dependent on object
on object 2005
object 2005, which
is the drop-down
the drop-down list
And the selection
the selection column
selection column holds
column holds the
holds the value
value we're searching
in the drop-down
drop-down list is
list is 'jury
is 'jury duty'
'jury duty', then
then these two
objects will become
will become visible
In all other
all other scenarios
other scenarios, these
these objects should
objects should be
should be invisible
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
will then check
then check the
check the default
the default values
default values to
values to see
see 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
And then next
then next it
next it will
be a standard
We're first checking
first checking to
whether the entry
the configuration array
configuration array is
array is blank
that is so
is so, then
we iterate to
the next row
We're then populating
then populating the
populating the data
data variable with
pick up three
up three pieces
three pieces of
pieces of key
of key information
reference ID, which
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
yet created, so
so we'll double
double back in
and create them
create them at
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
object is conditionally
is conditionally visible
can check the
the default selected
default selected by
selected by using
existing function to
return the field
the field value
field value from
And if these
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
the code previous
code previous, we
created the object
here we decide
whether the object
to be hidden
be hidden or
hidden or not
code and create
and create these
create these two
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
each entry in
configuration file, I've
I've set the
set the dropdown
dropdown list to
list to have
to have no
have no default
we run an
we should see
should see that
that the two
two extra fields
extra fields are
fields are initially
first scenario we
scenario we have
have now catered
now catered for
have to cater
cater for when
for when a
a user makes
user makes a
makes a change
So for example
user selects jury
selects jury duty
we want these
want these two
these two fields
two fields to
So there needs
there needs to
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
control process, our
our equivalent of
equivalent of an
of an event
control process, I'm
create two new
local variables, one
one called strData
called strData and
strData and one
one called longResult
we handle each
types of object
of object on
object on which
on which some
which some event
some event has
the moment only
moment only events
only events occurring
events occurring to
occurring to buttons
to add three
add three new
three new types
new types of
of all, dropdown
user picks from
picks from the
dropdown list and
list and picks
and picks jury
picks jury duty
want the objects
the objects to
objects to be
to be visible
they pick anything
pick anything else
anything else, we
want the two
objects to disappear
We'll also need
in for a
for a text
box and also
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
this application are
application are for
are for single
for single selects
single selects only
selects only, as
as we want
of the user's
the user's pick
user's pick and
pick and to
and to push
to push it
push it out
to the output
So we're trapping
we're trapping the
trapping the button
button click message
click message, and
this point that
point that the
has made some
made some selection
So as these
these are single
are single select
single select, we
know we can
gate text command
from the control
the control the
control the value
value and put
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
has a dependent
And this new
new function can
used for each
the other object
other object types
object types we
types we want
to do events
do events on
So we're passing
two parameters to
a control handle
the object that
object that the
clicked on, and
and the strData
the strData, the
second variable, is
value we've taken
we've taken out
taken out of
of that object
new function Has
function Has dependent
Has dependent control
our new control
We're using four
using four local
four local variables
we're doing within
doing within the
configuration file, as
as again this
again this will
be another for
pick up from
up from our
configuration file some
file some key
some key pieces
key pieces of
of information, the
the conditional value
conditional value and
value and the
a match, we
then pick up
up the selection
the selection from
selection from the
from the selection
if that match
that match is
match is the
the data being
data being passed
in for this
this function, then
we can show
can show the
show the control
the control normalize
control normalize command
And then move
then move it
move it on
we will hide
will hide the
the control using
user may move
may move around
around the form
the form quite
form quite dynamically
quite dynamically, it
well have been
been populated in
populated in a
a previous selection
if the form
form is to
is to hide
the control, we'll
we'll also blank
also blank out
we know there
know there are
be three different
three different types
types of control
of control here
There could well
text control, a
a checkbox or
checkbox or a
or a dropdown
And there need
there need to
to be different
be different commands
different commands to
commands to blank
blank out each
out each of
function to blank
to blank a
blank a control
new function blank
function blank control
blank control, giving
it three variables
object and the
and the type
a text box?
text box? Is
box? Is it
it a dropdown
a dropdown list?
dropdown list? Or
list? Or is
checkbox or tickbox?
or tickbox? And
tickbox? And this
very straightforward indeed
doing a select
case statement on
If for text
for text, we're
doing a control
for the tickbox
the tickbox, we're
control set check
set check command
dropdown list, we're
doing a combo
a combo unselect
Initially the new
we pick jury
pick jury duty
jury duty, then
then the two
two objects have
objects have now
have now appeared
now appeared and
appeared and can
can be populated
we change our
change our mind
our mind and
mind and go
back and pick
a different value
different value, they
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
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
to be controlled
be controlled by
controlled by a
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
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
the user, when
when that is
that is ticked
is ticked, to
enter a number
number of hours
of hours per
hours per day
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
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
want these extra
these extra fields
extra fields only
fields only to
when the tickbox
the tickbox has
tickbox has been
We made a
made a change
a change for
change for the
dropdown list in
list in the
equivalent of a
of a callback
back in there
in there and
there and put
in some additional
additional code to
handle these two
As we've got
got an entry
dropdown list, we
we need one
need one for
time we're looking
for the enChange
the enChange event
enChange event, in
which case we're
case we're picking
box and putting
variable and recalling
and recalling the
recalling the function
created earlier as
earlier as dependent
as dependent control
dependent control, passing
it the same
same two parameters
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
we're calling again
calling again the
again the 'hasDependentControl'
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
we select a
select a different
different value, it
it will disappear
we tick on
tick on our
on our working
our working at
at home, we
get the entry
the entry of
entry of hours
that is unticked
is unticked, the
the value will
value will disappear
as before, if
we put an
put an entry
entry in place
in place, if
untick it and
and then tick
then tick it
tick it again
it again, the
the entry is
entry is blank
is one additional
one additional change
additional change we
make to our
application to hide
hide these conditional
these conditional objects
conditional objects, and
in the 'resetForm'
the 'resetForm' function
user enters some
enters some values
...and saves them
saves them, is
that the 'resetForm'
'resetForm' function will
function will reset
reset the form
the form completely
So as working
as working at
at home is
home is not
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
and put a
put a call
call in to
function to hide
to hide objects
the change we'll
change we'll have
to make will
make will be
will be right
be right at
After the loop
the loop has
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
two fields for
fields for jury
for jury duty
jury duty should
duty should be
should be hidden
if that tests
that tests out
application now loaded
We have 'holiday'
have 'holiday' preselected
put the entry
can click 'OK'
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
now put a
new entry in
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
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
should now have
now have populated
have populated our
populated our working
our working and
working and one
one for daily
for daily hours
of that and
that and have
at our output
have a 'weave
a 'weave data.csv'
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
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
actually do on
do on forms
this code, useful
created a generic
a generic PowerBasic
generic PowerBasic Windows
Windows application, which
this dialog are
dialog are configured
are configured outside
configured outside the
outside the application
They are configured
configured in a
configuration file, in
case the test_demo_cfg
the test_demo_cfg file
As this configuration
file is indeed
indeed a CSV
CSV file, a
a comma separated
comma separated variable
separated variable file
variable file, I'm
change the extension
the extension of
extension of the
the name from
name from cfg
from cfg to
cfg to csv
will allow me
allow me to
me to use
use a small
a small application
small application which
application which I
which I created
I created in
created in PowerBasic
in PowerBasic to
PowerBasic to use
to use my
little grid to
grid to display
to see on
So the objects
the objects we
objects we have
we have defined
have defined on
defined on our
on our configurable
configurable dialog are
dialog are to
are to set
set the title
the title, to
to designate two
designate two buttons
two buttons to
buttons to appear
the dialog, for
for two labels
to extend this
extend this further
this further and
further and add
couple more objects
allow us how
us how to
how to have
down list and
list and a
and a list
Additionally we're going
up the save
save function which
when the ok
ok button is
To enable some
enable some of
new functionality I'm
functionality I'm going
library to our
our application, the
the common strings
common strings library
add this just
this just before
just before the
before the existing
the existing library
existing library that
library that does
that does the
does the file
we open our
open our CSV
CSV file up
in notepad we're
notepad we're going
some more lines
more lines of
lines of configuration
of configuration to
configuration to this
new objects, each
these objects having
objects having its
having its own
its own label
select a department
a department that
department that this
that this new
this new user
new user is
be a list
box which will
contain a list
list of skills
of all our
all our department
our department label
department label, positioning
positioning this on
screen and giving
and giving it
giving it an
it an ID
ID value of
value of Underneath
of Underneath that
Underneath that we're
set our first
our first drop
first drop down
be the combination
the combination of
a label box
label box and
and a drop
select from this
down list but
list but will
but will not
not be allowed
be allowed to
allowed to key
to key any
key any free
any free text
free text in
Additionally we will
will set this
set this so
this so that
so that it's
that it's sorted
will tackle this
tackle this one
this one first
one first and
first and then
back to do
do the list
down list needs
list needs to
needs to contain
to contain a
contain a number
number of values
Rather than store
than store these
store these within
these within this
within this configuration
configuration file I
file I have
I have designated
have designated in
designated in the
text column a
column a file
file name, department.txt
contain the list
list of departments
to keep the
keep the configuration
configuration file neat
file neat and
neat and tidy
and tidy and
tidy and to
and to hold
hold the configuration
the configuration for
configuration for this
this particular object
particular object in
a separate file
this up on
on the screen?
the screen? The
screen? The first
The first change
first change I
change I need
I need to
to make is
make is to
function that takes
that takes the
takes the information
array and will
and will position
will position the
to handle our
handle our drop
our drop down
have done before
to be pulling
be pulling the
However as we
populate the data
in this drop
down list we're
list we're going
using an array
an array as
array as well
be the str
str data array
need to configure
to configure that
configure that and
that and we'll
populate it as
it as well
Plus for this
for this combo
combo box there
box there are
are some styles
some styles we'll
styles we'll also
to populate before
populate before we
call the control
control add combo
add combo box
will set these
set these local
these local variables
local variables up
variables up at
One to dimension
to dimension the
dimension the array
the array, one
for the style
the style, one
for the extended
the extended style
style and one
for the file
contains the department
set the style
and the extended
extended style at
style at the
These define how
define how the
how the combo
combo box actually
box actually behaves
actually behaves and
behaves and looks
and looks on
looks on screen
whether the combo
box is to
be sorted or
sorted or not
function column in
column in our
That will set
set the CBS
the CBS sort
CBS sort value
sort value onto
value onto the
of the style
text column to
column to determine
determine the text
the text file
text file that
that contains all
contains all our
our department names
the other reference
other reference data
then test for
for the presence
the presence of
presence of that
If that file
file exists we'll
exists we'll use
use the function
the function in
our common library
common library to
library to read
But as you
as you all
you all have
all have noticed
have noticed there
noticed there is
new global string
global string, the
the configuration folder
configuration folder string
one that tells
that tells us
us the folder
folder that contains
that contains our
contains our configuration
set this one
this one up
using this global
this global string
string to determine
determine the location
location of all
all the configuration
configuration files as
files as there
as there will
will be more
be more of
more of them
So let's see
let's see where
see where in
go right back
right back to
to our pb_main
function we're testing
for the configuration
the one that's
one that's been
We test to
not exist and
exist and give
and give the
user a message
box to let
to let them
let them know
them know that
that the program
the program cannot
program cannot launch
cannot launch because
launch because there
is no configuration
no configuration file
put an else
an else command
else command in
here to store
store the path
library we just
we just added
just added today
is the start
the start range
range parse function
store the relative
the relative path
relative path from
path from our
from our executable
our executable folder
executable folder to
folder to the
use this later
in our function
our function we
we are picking
are picking up
the file which
file which contains
contains the text
text of all
all the departments
We're reading the
reading the file
array and we're
we're using that
using that array
array to populate
need now is
now is a
create a department
a department dot
department dot text
dot text file
text file in
in our configs
our configs folder
This contains a
contains a small
a small list
small list of
of departments and
departments and this
this should appear
should appear in
appear in our
And since our
since our configuration
our configuration has
configuration has set
has set to
set to sort
to sort this
sort this list
this list it
list it should
it should sort
should sort them
sort them into
them into alphabetical
into alphabetical order
application we'll make
we'll make sure
sure that we
have actually declared
actually declared this
declared this new
Now that's in
that's in place
place we should
able to run
our application dialogue
application dialogue on
a new department
new department drop
department drop down
on the drop
drop down we
down we will
it does indeed
does indeed contain
indeed contain the
of departments we
departments we specified
we specified in
specified in alphabetical
in alphabetical order
we've achieved setting
achieved setting up
setting up combo
up combo boxes
combo boxes which
boxes which are
which are drop
are drop downs
which will appear
will appear under
appear under the
under the skill
the skill label
So back into
into our populate
add this new
did for our
for our drop
list we're adding
case statement for
statement for the
And having set
having set the
the styles we
styles we can
now add in
add in the
in the test
the test to
using the sort
the sort option
sort option or
option or not
And the style
the style we're
style we're adding
we're adding is
adding is LBS
is LBS sort
LBS sort which
sort which is
is the style
the style for
style for list
for list boxes
And exactly as
exactly as we
did before since
before since this
since this list
is to contain
of skills it
skills it will
it will indeed
will indeed be
indeed be held
we will apply
will apply exactly
apply exactly the
the text value
will test for
presence of the
will load that
load that into
array using our
using our inbuilt
our inbuilt function
final task in
task in this
control add list
add list box
We're adding it
adding it on
with the array
the array which
array which contains
the data populating
data populating it
We see that
box is now
now on screen
The difference as
difference as you
can see between
see between a
between a list
and a combo
box is the
list box displays
box displays all
displays all the
since we added
we added the
added the sort
sort option it
option it is
it is sorted
is sorted alphabetically
added a number
of different controls
different controls to
to our form
our form what
form what we're
look at next
at next is
next is what
is what happens
on the OK
As this form
this form is
form is designed
is designed as
designed as a
as a data
data entry form
entry form what
form what we
do is when
OK button has
been clicked is
clicked is to
is to gather
to gather the
gather the information
from the objects
screen and to
and to save
that to an
Once we've established
we've established the
established the principle
the principle of
principle of saving
of saving this
saving this data
this data to
data to a
to a local
a local file
local file it
file it could
could be amended
be amended to
amended to save
the data anywhere
data anywhere else
anywhere else including
else including sending
including sending it
sending it to
it to a
to a database
new folder called
folder called data
called data and
data and it's
and it's into
it's into this
into this folder
this folder we're
folder we're going
to be saving
be saving our
saving our information
code folder we're
brand new folder
new folder and
folder and we'll
call that folder
that folder data
first thing that
thing that needs
be done is
amend our control
our control processing
control processing to
processing to handle
the OK box
function that runs
that runs and
runs and picks
and picks up
up the events
the events from
events from your
from your dialog
event which handles
handles the exit
the exit from
from the dialog
We've already prepared
already prepared an
prepared an event
event for saving
for saving data
is a one
a one we're
one we're now
new function save
function save form
save form data
function takes two
control the user
user had just
had just clicked
just clicked on
the word field
word field name
see from our
from our config
config file the
file the field
field name is
name is a
brand new column
This column is
to contain information
contain information we
information we will
actually use to
use to determine
to determine where
determine where we
So we'll see
in the OK
OK button we
button we have
in the field
field name of
name of data
of data slash
data slash user
slash user data
This is specifying
is specifying the
specifying the relative
the relative folder
relative folder path
folder path and
name of file
of file that
file that we
wish to save
Additionally the fields
the fields we
fields we wish
wish to extract
to extract the
extract the data
the data from
data from are
from are actually
are actually named
actually named in
named in the
field name column
So the text
text box that
box that contains
contains the name
the name we're
name we're going
going to save
save to a
to a column
a column in
column in the
the file called
file called name
called name additionally
name additionally for
additionally for the
for the address
the address and
address and the
and the department
the department and
department and then
then the skill
you a method
you can specify
can specify in
specify in the
file which columns
which columns need
columns need to
to be extracted
be extracted from
dialog and placed
and placed within
placed within the
within the output
this new save
new save form
form data function
is a template
a template or
template or a
or a new
being the field
field name in
name in a
configuration file that
wish to read
determine where to
pull the value
value out of
contains the path
be pulling information
pulling information out
of this configuration
configuration file for
file for a
for a few
a few entries
few entries with
entries with this
with this field
this field value
field value we
to actually create
actually create a
is to pull
information out for
out for us
for us to
us to make
easy to get
to get at
get at it
going to reference
to reference a
reference a new
use of these
of these functions
these functions makes
functions makes your
makes your coding
your coding much
coding much easier
read and much
and much easier
easier to do
new function return
function return field
return field value
It passes the
passes the two
two parameters we've
parameters we've received
we've received in
received in this
this function onto
function onto the
onto the new
new function the
function the control
and the field
field name we're
name we're interested
return a piece
of text that
text that sits
that sits in
sits in our
be in this
this case this
case this value
value here data
here data slash
same function later
function later when
later when we
to pull this
pull this additional
this additional information
additional information out
information out which
out which is
be saving to
saving to the
will return in
return in a
But we'll push
push on here
on here in
this function and
function and complete
and complete the
complete the work
is run for
run for the
first time this
time this output
this output file
output file will
file will not
will not exist
not exist we
exist we want
want to output
to output the
output the headers
the columns that
put into the
into the file
the file so
file so that
that the CSV
CSV file when
file when created
when created is
created is useful
can test using
test using the
is file function
file function to
function to see
the headers to
headers to the
But at the
moment we don't
have the headers
will do another
do another function
another function to
function to define
to define what
define what those
what those headers
those headers actually
headers actually are
pass that as
parameter to the
handling routines function
routines function a
function a pin
a pin to
pin to file
create the file
file and send
and send the
send the data
But on the
assumption that we've
got the file
the file headers
file headers we've
headers we've created
created a file
a file we
file we now
So it's going
to be yet
yet another function
which we'll write
we'll write shortly
call that get
that get form
get form data
got the form
form data into
into an str
an str data
data variable we
variable we can
then append that
append that to
that will create
create this particular
particular function but
function but we're
to create these
create these three
these three new
functions to actually
actually do the
do the work
all we'll tackle
we'll tackle the
tackle the return
the return field
field value function
these functions is
functions is going
be doing a
doing a similar
a similar task
the field we're
field we're interested
function will need
to look inside
inside the configuration
out what needs
what needs to
to be returned
using another function
another function in
our common strings
strings library called
library called parse
called parse find
parse find which
find which is
which is particularly
is particularly good
particularly good at
good at finding
at finding data
finding data in
data in strings
have in a
previous video used
video used constants
used constants to
constants to work
out which column
which column in
configuration file things
file things actually
things actually sit
actually sit in
This is fine
is fine until
fine until somebody
until somebody actually
somebody actually changes
actually changes the
changes the configuration
file to add
extra column in
we're doing now
doing now is
now is using
using a dynamic
a dynamic way
dynamic way of
way of finding
of finding out
finding out exactly
out exactly where
exactly where in
configuration file the
file the ID
ID column actually
column actually sits
makes it quite
generic and allows
and allows you
add additional columns
columns to the
configuration file without
file without having
change your code
So this parse
this parse find
find function takes
function takes three
takes three parameters
being the string
string we wish
wish to interrogate
The second parameter
second parameter is
Since this uses
uses the parse
parse command under
command under the
under the hood
the hood we're
hood we're giving
it a zero
a zero in
zero in string
in string as
string as the
as the delimiter
the delimiter which
delimiter which will
which will default
default to CSV
to CSV handling
is the column
column in which
in which we
have an interest
case the ID
number that it
that it finds
it finds this
finds this ID
this ID column
ID column in
is zero the
zero the column
the column was
column was not
was not found
the parse find
find function to
function to find
find the column
number that we're
case the field
Having determined both
determined both of
of these columns
these columns we
columns we can
can now do
now do a
do a forenex
to look around
look around every
around every entry
every entry in
config file until
file until we
until we find
we find the
find the entry
the entry for
ID column matches
column matches the
matches the control
control that we're
interested in then
then we found
found a data
a simple parse
simple parse command
from the field
the field column
This in this
this case will
case will tell
tell us exactly
us exactly what
what the name
to save actually
save actually is
And as I
said earlier we
earlier we can
use this return
this return field
value function in
function in other
in other places
other places in
places in our
set up is
up is the
the get config
get config headers
config headers function
This is doing
doing a remarkably
a remarkably similar
remarkably similar task
This takes no
no parameters and
parameters and is
and is looking
field name columns
the only objects
only objects we
objects we are
in the ones
the ones containing
ones containing user
containing user data
user data are
data are the
the text objects
text objects the
objects the dropdown
list and the
and the list
use a forenex
loop to sweep
through our config
file to pull
out and using
again to pull
if it says
it says text
says text dropdown
text dropdown list
dropdown list or
list or list
or list box
list box then
box then that's
then that's the
that's the column
the column I'm
column I'm interested
I'm interested in
then pull the
information out that
out that exists
that exists within
exists within that
that column and
can add it
add it onto
it onto our
onto our header
going to write
to write out
write out to
once we've been
we've been round
been round that
round that loop
that loop we
loop we then
we then trim
then trim off
off any trailing
any trailing commas
trailing commas and
commas and we
and we turn
we turn that
turn that to
function that called
that called this
called this function
So that completes
completes the calling
the calling for
calling for the
for the get
So our final
our final function
final function in
function in here
here is one
is one to
form data itself
get the information
has actually keyed
actually keyed in
keyed in on
in on screen
doing something very
object columns and
and the ID
object column because
column because we're
because we're only
we're only interested
interested in a
in a certain
of objects and
objects and the
ID column will
column will give
us the windows
the windows ID
windows ID of
ID of the
text that exists
that exists on
exists on the
the dialog using
dialog using that
using that information
Again another forenex
another forenex loop
use a select
statement to pick
in our object
our object column
If it's text
it's text or
text or dropdown
or dropdown list
dropdown list we
can use control
use control get
get text to
text to pull
the information off
information off the
off the dialog
it's a list
use the list
list box get
box get text
the information back
information back in
in a similar
a similar way
this is putting
is putting the
putting the information
the information into
into the str
variable we now
to add that
to the raw
the raw data
So we're building
we're building up
building up the
up the role
the role from
role from each
from each column
since the output
the output is
output is going
be a CSV
CSV file we're
file we're wrapping
we're wrapping all
wrapping all the
the text we're
text we're sending
we're sending out
sending out in
out in double
in double quotes
double quotes followed
quotes followed by
did before our
before our final
trailing commas at
commas at the
of our raw
our raw data
can return to
calling function the
function the whole
the whole string
whole string that
string that needs
to be sent
be sent out
sent out to
And that string
that string gets
string gets returned
gets returned into
returned into this
into this data
this data variable
data variable here
variable here which
here which is
is the entire
entire row to
row to be
to be written
be written to
written to the
Then our append
our append to
append to file
to file function
file function opens
function opens the
opens the file
the file sends
file sends the
sends the data
data to it
to it and
and then closes
then closes the
closes the file
the file again
should complete all
complete all the
take the information
information and use
use a keys
a keys on
keys on screen
screen and sends
and sends to
sends to our
to our output
moment our data
data folder is
folder is entirely
is entirely empty
application we'll also
we'll also have
in a list
have the department
the department file
department file in
file in there
not yet copied
yet copied in
copied in this
in this skill
this skill file
So let's paste
let's paste that
that in just
make sure that's
sure that's got
that's got all
got all the
all the skills
the skills in
skills in it
So they are
they are our
are our skills
now we should
should have both
have both the
both the departments
the departments and
departments and the
and the skills
the skills populated
is our departments
our departments and
departments and there
we can extract
can extract the
the data on
data on screen
screen and if
if it saves
it saves to
saves to the
hit the OK
OK button let's
button let's see
if that saved
that saved to
saved to our
Well we do
indeed have a
have a user
a user data
file and it
it has pulled
has pulled back
pulled back the
back the information
information on screen
The name the
name the address
the address the
address the department
department and the
and the skill
is a little
more we need
do to our
application as it's
it's a data
After having keyed
having keyed in
keyed in information
in information and
information and hit
button we would
we would expect
would expect some
expect some feedback
some feedback to
user to let
that the information
the information had
information had been
had been saved
been saved and
then to clear
clear the entries
the entries on
entries on the
allow the next
the next entry
next entry to
to be keyed
be keyed in
and put those
put those changes
those changes in
in our run
our run control
process function where
where we're handling
handling the click
the click on
the button we've
button we've got
got the save
the save form
form data for
data for some
for some reason
some reason cannot
reason cannot be
cannot be saved
be saved we
saved we need
of feedback to
feedback to say
to say there's
say there's a
But we need
we need something
need something on
something on screen
on screen that's
screen that's fairly
that's fairly obvious
fairly obvious for
obvious for the
let them see
them see that
that there has
been a problem
a problem or
problem or that
or that there
been a successful
a successful save
will add a
a new control
new control on
screen to give
user a status
a status field
a new label
new label which
label which is
be our status
our status field
status field and
field and it
it will currently
will currently say
currently say ready
color of that
that to blue
to blue and
blue and we're
make the font
the font a
font a little
bit bigger so
bigger so that
able to see
see it quite
it quite easily
in the cleanup
the cleanup section
cleanup section we're
to be deleting
be deleting the
deleting the font
the font once
font once the
once the dialog
dialog is closing
is closing down
closing down and
down and we
will also declare
also declare the
declare the font
the font at
font at the
Although I'm doing
I'm doing this
the code itself
code itself it's
itself it's probably
it's probably easier
probably easier done
easier done within
done within the
within the forms
So that gives
that gives us
us a section
dialog which will
which will feed
will feed back
feed back to
So if for
if for any
for any reason
any reason we
reason we are
we are unable
are unable to
unable to save
save the form
the form the
form the return
return from the
from the save
data function will
will be false
message on screen
on screen in
screen in that
in that new
that new status
new status field
status field to
field to say
say the form
form has not
not been saved
form has been
has been saved
been saved we
saved we can
can then tell
then tell the
tell the user
the user form
user form saved
two additional functions
additional functions here
One to reset
form to blanket
to blanket all
blanket all the
the beginning field
beginning field on
field on the
let's create first
create first of
all the reset
function will look
will look quite
look quite familiar
quite familiar to
familiar to what
to what we've
we've seen already
We'll again have
again have to
ID column from
column from our
And having picked
having picked up
picked up that
up that information
that information we're
information we're then
through a fornix
And within that
within that fornix
that fornix loop
fornix loop we're
loop we're picking
the control value
control value from
We're then testing
then testing the
testing the object
column and if
it's text we're
text we're using
text to blank
out the text
our text boxes
it's a drop
list we're using
box and select
and select to
select to deselect
to deselect any
deselect any value
any value the
value the user
user selected in
selected in the
And something very
similar for our
list box we're
box we're using
using a list
Should we add
we add any
add any more
any more controls
the system or
system or later
or later on
in the project
the project we'll
project we'll need
to handle blanking
handle blanking out
blanking out that
out that as
that as well
we have blanked
have blanked out
blanked out all
all the editable
the editable fields
editable fields on
fields on the
form we now
had a piece
previous video that
video that performed
that performed this
performed this function
going to borrow
to borrow that
borrow that code
that code and
a function of
function of its
of its own
You'll find when
find when you're
you're doing projects
doing projects that
projects that will
that will become
will become times
become times when
when you discover
you discover that
discover that you're
that you're writing
you're writing a
writing a piece
of code more
code more than
more than once
case then it's
then it's crying
That way you
way you can
you can just
just call the
call the common
the common function
common function as
function as many
as many times
many times as
times as you
as you wish
you wish in
wish in your
your code and
code and it
and it only
it only exists
only exists in
exists in one
in one place
to make change
make change to
change to that
to that common
that common function
common function it's
function it's very
easy to make
to make and
make and saves
and saves delving
saves delving through
delving through a
make the same
change in several
in several places
new function set
function set focus
focus to start
to start form
done before is
before is doing
doing a very
very similar task
similar task looking
task looking at
It's a standard
and we're interested
text that dropped
that dropped on
dropped on list
on list and
the list boxes
list boxes and
first one of
of those we
those we find
we find was
find was setting
was setting the
and then exiting
then exiting immediately
new function immediately
function immediately after
immediately after having
after having blanked
having blanked all
blanked all the
all the fields
the fields on
on the user's
the user's form
add the call
if it clears
it clears the
clears the form
form and sets
and sets the
sets the focus
have the form
the form save
form save message
save message coming
message coming up
coming up and
up and everything
and everything on
everything on screen
screen has either
has either been
either been blanked
blanked out or
out or deselected
Now this should
this should have
should have added
have added to
output file so
file so we
should have two
have two records
two records in
records in that
So let's exit
let's exit the
output file and
and there indeed
there indeed is
indeed is our
is our output
output file with
file with both
with both sets
both sets of
to our genetic
our genetic application
genetic application the
application the ability
ability to handle
to handle simple
handle simple dropdown
simple dropdown boxes
dropdown boxes and
boxes and list
and list boxes
list boxes on
on forms all
forms all configured
all configured in
in the metadata
the metadata contained
metadata contained in
the configuration CSV
configuration CSV file
Additionally when the
the OK or
OK or save
or save button
save button this
button this will
the information that's
information that's currently
the screen in
screen in the
dialog to a
to a CSV
a CSV text
CSV text file
will allow the
allow the data
to be built
be built up
built up in
up in that
that text file
text file for
file for later
processing in other
in other systems
we will allow
allow the setting
the setting up
setting up of
up of fields
of fields which
fields which are
which are mandatory
are mandatory or
mandatory or non-mandatory
can also set
also set the
set the maximum
the maximum length
maximum length of
length of text
of text fields
text fields or
fields or have
or have text
have text fields
text fields which
which are designated
are designated as
designated as being
as being numbers
being numbers only
we'll leave all
leave all that
all that for
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
project, from initial
from initial design
through coding and
coding and development
and development to
development to testing,
to testing, using
testing, using the
using the PowerBasic
the PowerBasic Windows
PowerBasic Windows Compiler
will continue our
continue our project
our project to
project to look
look at the
at the use
the use of
use of software
software auto forms.
auto forms. This
forms. This was
This was our
the end of
end of the
of the last
the last video
We have prepared
have prepared a
prepared a generic
a generic application
generic application whose
application whose dialogue
whose dialogue contents
dialogue contents are
contents are driven
are driven from
driven from a
from a metadata
a metadata configuration
metadata configuration file
This configuration file
configuration file designates
file designates which
designates which objects
which objects appear
objects appear where
appear where on
where on the
And we have
we have added
have added additional
added additional columns
additional columns to
columns to centre
to centre titles
centre titles, specify
specify which button
which button is
button is the
the save button
save button and
button and which
and which is
is the exit
the exit button
exit button from
button from the
from the application
We've also set
also set additional
set additional properties
additional properties for
properties for our
for our drop
our drop down
list and our
and our list
our list box
list box to
box to do
to do sorting
The field name
field name column
name column is
column is used
used to specify
to specify the
specify the file
the file which
which is created
is created when
created when the
when the user
the user hits
user hits the
hits the OK
It also holds
also holds the
holds the names
the columns we
columns we wish
we wish to
wish to save
to save to
save to that
to that file
going to do
to do today
do today is
today is we're
is we're going
we're going to
going to add
to add the
add the ability
the ability to
ability to have
to have fields
have fields which
Fields which the
which the user
the user must
user must fill
must fill in
fill in before
in before it
before it will
it will allow
will allow the
allow the form
the form to
Additionally we're going
we're going to
going to add
add another text
another text field
And this text
this text field
text field we're
field we're going
we're going to
to set to
set to accept
to accept numbers
accept numbers only
let's have a
have a look
a look at
look at the
to see how
see how we're
how we're going
So as we're
as we're going
to add new
add new columns
new columns to
columns to our
to our configuration
our configuration file
configuration file we're
file we're going
to expand our
expand our enumeration
our enumeration at
enumeration at the
at the beginning
the beginning of
beginning of the
One to designate
to designate a
designate a field
a field which
field which is
which is mandatory
is mandatory and
mandatory and a
a second field
second field to
field to designate
to designate the
designate the maximum
maximum number of
number of characters
of characters that
characters that will
that will be
will be accepted
be accepted on
accepted on a
on a text
And we're going
two new fields
new fields to
fields to our
to our configuration
The testdemo.csv file.
testdemo.csv file. And
file. And there
And there are
our new columns
new columns in
columns in place
A mandatory column
mandatory column and
column and a
and a character
a character limit
character limit column.
limit column. We
column. We have
We have also
have also added
also added a
new label and
and a new
a new text
new text field
text field to
field to the
to the configuration
the configuration file
We'll cover these
cover these as
these as we
So if we
if we run
we run the
run the application
the application now
application now we
will see our
see our new
our new field
The age field
age field is
field is appearing
is appearing on
appearing on the
on the screen
Just as the
as the text
the text fields
text fields we
fields we did
we did in
did in the
in the last
let's see what
see what changes
what changes we
changes we now
we now have
to make to
make to the
to the bulk
the bulk of
of the code.
the code. So
code. So let's
So let's first
let's first look
first look at
at the populate
the populate form
populate form function
is a function
a function that
function that creates
that creates all
creates all the
all the objects
the objects on
objects on the
on the dialog
to create a
create a local
a local variable
local variable here
variable here to
here to hold
to hold the
hold the value
that is the
is the character
the character limit
of characters that's
characters that's going
that's going to
going to appear
to appear in
appear in a
in a text
And I'm also
I'm also going
also going to
of the long
the long control
long control variable
control variable which
variable which we
which we created
we created in
created in the
the last video
last video but
video but didn't
but didn't populate
This is picking
is picking up
picking up the
up the reference
the reference ID
reference ID for
ID for our
for our configuration
our configuration file
This is a
is a Windows
a Windows handle
Windows handle to
control on the
on the dialog
This variable will
variable will make
will make the
make the rest
the rest of
rest of the
of the code
the code a
little easier to
We can replace
can replace this
replace this line
line of text
of text with
text with that
with that single
that single variable.
single variable. And
variable. And we
And we can
can do the
the same all
same all the
all the way
the way through
way through the
through the rest
rest of this
of this function
need to add
to add some
add some more
some more coding
more coding to
coding to support
support the new
the new functionality
new functionality for
functionality for our
for our text
our text box
This particular age
particular age text
age text box
text box is
box is to
is to accept
to accept only
accept only numbers
only numbers from
numbers from the
from the keyboard
will need to
need to conditionally
to conditionally test
conditionally test to
test to see
to see whether
see whether the
whether the function
function of this
of this particular
this particular object
particular object is
object is set
set for number
for number only
number only or
only or not
can do that
do that with
that with a
with a simple
if statement using
statement using the
using the parse
the parse command
So if the
if the value
the value in
value in the
the function column
function column is
column is number
is number only
number only then
only then we
we can execute
can execute the
execute the next
the next line
next line of
We already have
already have two
have two variables
two variables set
variables set up
set up for
and the extended
the extended style
extended style of
style of objects
So we can
we can populate
can populate those
populate those quite
those quite happily
of all set
all set the
set the default
the default value
default value for
value for both
for both the
both the long
the long style
long style and
style and long
and long x
long x style
x style variables
are the values
the values a
values a normal
a normal text
normal text box
text box will
box will have.
will have. And
have. And should
And should our
should our text
our text box
text box have
box have the
have the number
the number only
number only setting
only setting set
setting set we
set we will
we will add
will add an
add an additional
an additional property
add the ES
the ES number
ES number property
will instruct the
instruct the dialog
the dialog control
dialog control to
control to only
to only accept
only accept numbers
We may only
may only have
only have to
have to add
these two additional
two additional parameters
additional parameters to
parameters to the
end of the
of the control
the control add
control add text
text box command.
box command. So
command. So let's
So let's try
try that code
see how it
how it looks
it looks now
we get into
get into the
into the age
the age field
age field and
field and attempt
and attempt to
attempt to press
to press the
press the number
the number it
number it will
will take the
take the number
the number quite
number quite happily
If we attempt
we attempt to
attempt to press
to press the
press the letter
the letter keys
letter keys it
keys it will
will not accept
not accept the
accept the input.
the input. So
input. So we've
So we've now
we've now achieved
ability to have
to have a
have a text
a text box
box which only
which only accepts
only accepts numbers
So how do
how do we
do we limit
we limit it
limit it for
it for the
for the number
the number of
number of characters?
of characters? It's
characters? It's unlikely
It's unlikely we
unlikely we would
would have someone
have someone working
someone working for
working for the
for the organization
the organization which
organization which has
has an age
an age over
age over 100
over 100 years
100 years old
So a three
a three character
three character limit
character limit would
limit would seem
would seem quite
seem quite reasonable
quite reasonable for
reasonable for this
for this particular
this particular field
So having created
created the text
text box we
box we now
we now have
now have to
whether the char
the char limit
char limit is
limit is set
is set or
set or not
we're now populating
now populating the
populating the long
the long char
long char limit
char limit variable
This is picking
is picking up
picking up the
up the value
that's in our
in our char
our char limit
char limit column
we can see
can see from
see from our
from our config
config file for
file for this
for this particular
this particular text
particular text box
box we set
set a character
a character limit
character limit of
limit of three
of three characters
So the value
the value pushed
value pushed into
pushed into this
into this variable
this variable will
We can now
can now easily
now easily test
easily test to
to see whether
see whether the
whether the value
the value in
in the variable
the variable is
variable is greater
is greater than
than zero or
If the value
the value is
value is greater
than zero we
zero we can
we can put
can put in
a new command.
new command. This
command. This is
This is a
a control post
control post command
This sends a
sends a message
message to the
to the dialog
the dialog and
dialog and the
the control on
control on the
on the dialog
case to set
set the text
the text limit
The number of
characters that the
that the object
the object will
object will be
will be willing
be willing to
willing to accept
And we're passing
we're passing in
passing in the
in the first
the first parameter
first parameter as
parameter as being
as being a
being a three
The value within
value within the
within the char
the char limit
char limit variable
If we try
we try running
try running the
running the application
application now and
now and go
and go into
go into the
the age column
age column we
column we can
can put three
put three characters
three characters in
characters in quite
in quite happily
But as soon
as we try
we try to
try to add
to add the
add the fourth
the fourth it
fourth it will
will stop us
stop us adding
us adding any
adding any extra
any extra characters
So we've now
we've now limited
now limited this
limited this number
this number only
number only field
only field to
field to hold
to hold only
hold only three
only three characters
So our next
our next task
is to look
to look at
look at making
at making some
making some of
of the fields
the fields mandatory
look at our
at our configuration
configuration file again
file again we
again we can
can see the
see the mandatory
the mandatory column
And I've set
I've set two
set two of
the fields the
fields the name
the name field
name field and
field and the
and the department
the department field
department field to
field to be
to be mandatory
In other words
other words it
words it will
it will not
not allow you
you to attempt
attempt to save
to save the
save the form
the form without
form without those
without those fields
those fields being
fields being populated
So let's see
let's see how
see how we
So in order
in order to
order to do
to do validation
do validation on
validation on the
the form we
form we need
we need to
need to look
look at where
at where the
where the form
the form is
form is actually
is actually saved
And this is
this is in
is in the
in the run
run control process
control process function
a function that's
function that's acting
that's acting as
acting as an
as an event
handler for the
for the form
scroll down in
down in here
in here we'll
here we'll see
where the save
the save is
save is actually
is actually triggered
When the user
the user clicks
user clicks on
clicks on the
OK button this
button this is
this is where
is where the
where the save
the save is
save is actually
is actually carried
actually carried out
carried out by
out by calling
save form data
form data function
now need to
need to make
to make the
make the call
to this function
this function conditional
Prior to saving
to saving it
saving it we
it we need
we need to
need to call
to call a
a new function
new function which
function which we'll
which we'll call
we'll call validate
call validate form.
validate form. So
form. So we're
So we're going
to pass two
pass two new
two new variables
new variables to
variables to this
to this function
this function an
function an error
an error variable
error variable and
variable and a
and a field
a field variable.
field variable. So
variable. So we
So we will
will declare them
declare them at
at the beginning
the beginning of
beginning of this
of this function
So before we
before we create
we create this
create this new
this new validate
new validate form
validate form function
form function let's
function let's look
at the logic
the logic in
logic in the
the code that
code that should
that should be
should be triggered
triggered when the
when the validate
the validate form
form function returns
returns false to
false to see
to see that
see that the
that the form
form has not
has not validated
If it's field
it's field validation
field validation then
validation then we
will get a
get a value
a value put
value put into
put into the
into the error
And we want
we want to
this on our
on our status
our status bar
status bar at
of the form.
the form. This
form. This will
This will allow
the user to
user to see
to see where
see where the
where the error
the error actually
error actually is.
actually is. Additionally
is. Additionally if
Additionally if one
the fields has
fields has failed
has failed we
failed we want
to set focus
set focus to
focus to that
to that field
that field to
allow the user
the user to
user to quite
to quite easily
quite easily go
easily go in
in and amend
and amend it
So as we've
as we've done
we've done before
done before we're
before we're going
going to use
the control set
control set focus
set focus command
focus command with
with the two
two parameters of
parameters of the
of the handle
the handle for
handle for the
for the dialog
for the field
the field which
field which is
is an error
And at that
at that point
that point we
point we can
can exit the
exit the function
that we're handling
we're handling errors
handling errors we
errors we can
can now create
the new validate
new validate form
validate form function
form function with
function with its
with its two
its two parameters
here is a
is a skeleton
a skeleton for
skeleton for our
There are two
are two parameters
two parameters both
parameters both of
both of which
of which are
which are output
are output parameters.
output parameters. These
parameters. These are
These are values
are values which
values which we
which we pass
we pass back
pass back to
back to the
to the calling
the calling function
calling function to
function to provide
provide it with
it with the
with the information
the information that
information that we
that we need
we need to
to pass on
pass on to
We've created a
created a number
A loop counter
loop counter to
counter to keep
to keep track
keep track of
track of each
objects that we're
that we're looking
we're looking at
The column number
column number of
number of the
of the id
The type of
type of object
of object we're
object we're looking
looking at be
at be a
text box or
box or a
or a button
of the object
The str data
str data which
data which is
be the data
the data we're
data we're pulling
we're pulling back
pulling back from
back from the
from the object
the object on
object on screen
The mandatory column
mandatory column number
column number and
handle of the
the control on
control on the
We also have
also have the
of the field
the field which
field which in
which in this
one that may
that may have
may have failed
have failed validation.
failed validation. So
validation. So we're
going to populate
to populate some
populate some of
some of those
of those column
those column numbers
column numbers now
numbers now to
now to get
to get the
get the column
the column number
column number out
number out of
out of the
of the configuration
the configuration file.
configuration file. So
file. So we're
So we're interested
interested in three
The object column
object column, the
the id column
id column and
column and the
and the mandatory
the mandatory column.
mandatory column. As
column. As we
As we did
previous videos we're
videos we're using
we're using the
using the parse
find function which
which is in
is in one
in one of
one of our
of our libraries.
our libraries. This
libraries. This is
This is to
back the column
column number that
number that each
that each of
each of these
of these particular
these particular titles
particular titles is
titles is actually
is actually held
actually held in.
held in. The
in. The column
the object column,
object column, the
column, the id
the id column
id column and
and the mandatory
mandatory column. And
column. And next
And next we're
a for next
for next loop
next loop to
loop to look
to look through
look through each
through each of
each of the
of the records
the records in
records in our
in our configuration
our configuration array
configuration array which
has come from
come from the
from the configuration
configuration file. This
file. This will
This will look
look familiar to
familiar to one
one of the
of the functions
the functions we've
functions we've written
we've written in
written in the
in the previous
the previous video.
previous video. The
video. The for
The for next
loop is first
of all going
all going to
going to pick
to pick up
the object column.
object column. And
column. And then
And then we're
going to blank
out the str
str data variable
data variable ready
variable ready to
ready to be
to be populated
be populated by
populated by what
by what comes
what comes off
comes off the
off the screened
the screened object
As we only
we only have
only have three
have three objects
three objects on
on screen that
screen that will
that will contain
will contain any
contain any information
The text, the
text, the list
the list box
and the drop
drop down list.
down list. We
list. We can
We can test
can test on
test on those
on those conditionally
If it's not
it's not one
not one of
of these then
these then we
then we don't
we don't need
to do anything.
do anything. So
anything. So we're
So we're populating
populating the control
control number by
number by picking
by picking up
picking up the
value in our
in our config
our config file
config file from
file from the
the id column.
id column. We
column. We next
We next have
next have to
see if the
if the mandatory
mandatory column has
column has a
has a yes
a yes in
yes in it
in it or
it or not.
or not. If
not. If it
If it has
a yes then
yes then we
to check the
check the value
the value held
value held within
held within that
within that object
that object on
object on the
on the dialogue.
the dialogue. And
dialogue. And as
And as we
previous video we
video we are
we are conditionally
are conditionally checking
conditionally checking the
checking the type
type of object
of object as
object as we
as we use
we use a
a control get
text to get
to get information
get information of
information of a
of a text
a text box
text box or
box or drop
or drop down
down list. And
list. And for
And for a
for a list
using the list
the list box
list box get
box get text
get text command.
text command. Both
command. Both of
Both of these
these commands will
commands will populate
will populate the
populate the str
str data variable.
data variable. If
variable. If we
If we get
get this far
this far then
far then the
the object we're
object we're testing
we're testing has
testing has been
has been deemed
been deemed to
deemed to be
to be mandatory.
be mandatory. We
mandatory. We can
We can now
now test a
test a value
a value populated
value populated into
populated into the
into the str
the str data
data variable to
see if it's
if it's an
it's an empty
an empty length
string or not
it is an
is an empty
an empty length
empty length string
length string then
we know the
know the function
the function is
function is going
is going to
going to return
to return false
return false because
false because validation
because validation will
validation will have
will have failed
in order to
order to inform
to inform the
inform the user
user as to
as to which
to which field
which field is
field is actually
is actually failed
actually failed we're
failed we're pulling
we're pulling back
pulling back from
back from the
from the configuration
the configuration file
configuration file the
file the value
So this would
this would either
would either be
either be the
be the name
the name field
name field, the
the address field,
address field, the
field, the department
department field or
field or the
or the skill
the skill field
And as only
as only two
only two of
two of these
of these are
these are set
are set as
set as being
as being mandatory
being mandatory it's
mandatory it's either
it's either going
either going to
to return name
return name or
name or department
or department as
department as these
are the mandatory
the mandatory fields
we need to
need to do
to do now
do now is
populate the two
the two variables
two variables we're
variables we're passing
passing back to
back to the
to the calling
the calling routine
all the control
the control handle
control handle of
handle of the
of the object
the object and
object and the
and the text
put into the
into the status
the status box
status box at
box at the
at the bottom
the bottom of
bottom of the
of the user
the user screen.
user screen. So
screen. So having
So having passed
having passed back
passed back the
the information for
information for validations
for validations which
validations which has
which has failed
has failed the
failed the last
the last thing
last thing we
thing we need
function is return
is return true
having populated the
populated the variables
the variables which
variables which will
which will go
will go back
go back to
back to the
to the calling
calling routine we
routine we now
now have to
have to exit
to exit the
exit the function
function as the
as the validation
the validation for
validation for this
this particular form
particular form has
form has failed
our final act
final act in
act in this
in this function
this function is
is to return
to return true
return true if
true if all
all the validation
the validation has
validation has been
has been successful
we run our
run our application
our application now
we should get
should get the
get the form
the form on
If we just
we just hit
just hit the
hit the okay
the okay button
okay button it
it will tell
tell us that
us that one
that one of
one of the
of the mandatory
mandatory fields is
fields is actually
is actually empty.
actually empty. The
empty. The name
The name field
name field and
it has set
has set focus
set focus successfully
focus successfully to
successfully to that
to that field.
that field. If
field. If we
If we enter
we enter in
enter in the
name and then
and then attempt
then attempt to
attempt to hit
to hit okay
hit okay it
okay it will
will tell us
tell us that
us that we
that we have
not yet picked
yet picked the
picked the department
the department which
department which is
is the second
the second mandatory
second mandatory field
we pick that
pick that and
that and hit
and hit okay
hit okay the
okay the form
the form will
form will be
will be saved.
be saved. All
saved. All the
All the other
the other fields
other fields which
fields which we
which we left
we left blank
left blank are
blank are not
are not mandatory
not mandatory fields
mandatory fields in
fields in this
in this particular
this particular scenario.
particular scenario. So
scenario. So if
So if we
look inside our
inside our code
our code folder
code folder and
folder and inside
and inside the
inside the data
the data folder
data folder we'll
folder we'll see
that the user
the user data
user data csv
data csv, the
output file, has
has been successfully
been successfully populated
And there is
there is our
our new entry
new entry for
entry for Tom
for Tom Jones
Tom Jones with
Jones with the
and the department
the department being
department being populated
We left the
left the other
the other two
other two fields
two fields completely
fields completely blank
are not yet
not yet outputting
yet outputting the
outputting the age
the age field
age field so
field so let's
at the code
the code to
code to see
can set up
set up that
up that additional
that additional field
additional field to
field to come
come out on
out on our
on our csv
our csv file
So our issue
our issue at
issue at the
at the moment
the moment is
moment is we
is we don't
don't have an
have an extra
an extra column
extra column for
column for the
for the age
age field which
field which we
which we want
we want to
want to output
to output to
output to the
to the file.
the file. If
file. If we
If we have
in the save
the save form
save form data
form data function
data function we
see there's a
there's a test
a test within
test within this
this function to
function to see
to see if
see if the
if the code
the code exists
code exists or
exists or not.
or not. And
not. And in
And in there
in there we're
there we're appending
we're appending to
appending to the
to the file
the file to
file to put
to put out
put out the
out the headers
So as the
as the file
the file already
file already exists
already exists we're
exists we're not
we're not recreating
not recreating the
recreating the headers
headers of the
of the file
So one solution
one solution to
solution to that
to that problem
that problem is
problem is to
to delete the
delete the output
the output file
output file and
file and let
and let the
let the program
the program recreate
program recreate it
So adding a
a new column
new column would
column would mean
would mean you
mean you would
you would have
would have to
have to erase
to erase the
erase the text
file that exists
that exists already.
exists already. So
already. So let's
let's try that
try that logic
that logic and
logic and see
if it works.
it works. We've
works. We've now
We've now erased
now erased the
erased the file
if we try
we try running
try running an
running an application
an application now
application now and
now and we'll
and we'll put
we'll put some
put some data
some data in.
data in. So
in. So let's
So let's look
see what's appeared
what's appeared in
appeared in the
in the file
And there we
there we have
we have the
have the age
the age column.
age column. So
column. So if
So if we're
if we're going
going to dynamically
to dynamically add
dynamically add new
new columns while
columns while these
while these files
these files are
files are in
are in use
in use we
use we would
we would need
would need to
need to actually
to actually put
actually put some
additional code inside
code inside the
inside the application
the application to
application to cater
to cater for
cater for that
However we may
we may leave
may leave that
leave that for
So in summary
in summary what
summary what we've
today is we've
is we've created
we've created two
created two new
two new columns
new columns in
columns in our
in our configuration
A mandatory column
mandatory column to
column to designate
to designate which
designate which of
which of the
of the text
text fields are
fields are actually
are actually mandatory
actually mandatory or
mandatory or not
not and a
and a character
a character limitation
character limitation column
limitation column to
column to limit
to limit how
limit how many
how many characters
many characters are
characters are the
are the maximum
the maximum that
maximum that can
can be put
be put into
put into a
into a text
a text field
Additionally we've added
we've added to
added to the
function column to
column to allow
to allow text
allow text fields
text fields to
fields to contain
to contain only
contain only numbers
to ensure the
ensure the mandatory
the mandatory fields
mandatory fields are
are actually filled
actually filled in
filled in we've
in we've created
function which can
which can be
be used for
used for validation
So any form
any form which
form which fails
which fails its
fails its validation
its validation will
validation will not
not be saved
be saved to
saved to the
to the file
the file but
file but rejected
but rejected and
rejected and sent
and sent back
sent back to
back to the
the user indicating
user indicating which
indicating which field
which field is
field is an
an error and
error and setting
and setting the
setting the focus
the focus to
focus to that
to that field
that field to
field to allow
to allow the
allow the user
to enter it.
enter it. Hopefully
it. Hopefully you'll
Hopefully you'll find
this code useful
code useful but
useful but that's
but that's it
it for today.
for today. Thank
today. Thank you
Thank you for
you for watching.
videos we had
had created a
generic application called
application called AutoForm
application was to
was to allow
allow the configuration
the configuration of
configuration of a
form to exist
to exist outside
exist outside the
outside the PowerBasic
the PowerBasic application
The configuration being
configuration being held
being held in
CSV file, for
for example this
example this test
this test demo
test demo file
This file has
file has in
in it an
it an entry
entry for each
objects that's going
to be appearing
be appearing on
example the title
the title object
title object is
screen is designated
is designated with
designated with a
with a line
of data, telling
telling the text
the form, the
the control, followed
followed by its
by its control
its control number
control number and
number and other
and other configuration
other configuration information
However while this
this works very
works very well
very well, we
we still don't
still don't have
don't have a
have a mechanism
by which a
which a user
a user can
can actually run
run the form
the form without
form without having
without having PowerBasic
having PowerBasic installed
The AutoForm application
AutoForm application takes
application takes as
takes as a
a parameter the
parameter the name
create a form
a form runner
form runner application
is an application
application that when
that when run
when run will
run will interrogate
will interrogate to
interrogate to see
how many configuration
many configuration files
configuration files are
files are available
will then display
then display a
display a list
on screen listing
screen listing all
listing all those
all those files
the forms to
forms to load
The form runner
runner application will
application will then
will then run
then run the
run the AutoForms
the AutoForms application
AutoForms application with
of that form
that form as
form as a
do this I've
this I've moved
I've moved the
moved the AutoForm
AutoForm application plus
application plus the
and the configs
configs folder inside
folder inside a
inside a forms
a forms folder
the folder above
folder above we're
our form runner.exe
The layout of
layout of this
of this form
this form runner
runner application is
the form of
form of a
a list to
list to the
the user listing
user listing all
listing all the
the forms found
forms found on
found on that
on that folder
can then select
then select one
these forms and
forms and click
click the Run
the Run Form
Run Form button
doing this with
with the list
box is set
set for single
for single select
single select so
select so the
can only select
only select one
select one form
one form at
form at a
It's also set
also set to
sort the data
data into alphabetical
we've created this
created this dialogue
this dialogue let's
dialogue let's go
and see where
see where we
where we need
put our configuration
our configuration in
is the form
I've created three
created three constants
three constants at
the form folder
form folder name
folder name, the
configuration folder name
folder name and
of the app
the app we're
app we're going
going to launch
case the AutoForm
the AutoForm EXE
you to configure
to configure this
configure this at
your application so
should you wish
name of any
of these folders
these folders or
folders or executables
or executables it's
executables it's easy
it's easy to
order to load
up our forms
our forms we
forms we first
we first need
first need to
to interrogate the
interrogate the system
system to see
see which forms
which forms are
forms are available
And we'll perform
we'll perform that
that function inside
function inside the
We need a
need a function
a function whose
populate that list
called populate list
the second the
second the handle
skeleton of the
of the populate
the populate list
populate list function
list function taking
don't know at
know at runtime
at runtime just
runtime just how
how many forms
many forms will
will be available
be available, we're
use an array
an array, the
the STR forms
STR forms array
name of each
the CSV files
CSV files which
files which is
is our configuration
So our task
our task within
get that title
that title of
of the available
the available forms
available forms to
forms to display
that task in
task in a
in a sub
a sub function
sub function called
function called get
called get forms
get forms list
forms list, passing
passing the pointer
to the forms
the forms array
a moment but
moment but let's
but let's assume
let's assume that
assume that function
that function has
function has returned
has returned a
returned a populated
a populated array
populate our list
list box with
box with the
data and this
easily with a
with a for
So our for
loop is going
to go between
go between one
between one and
and the upper
upper bounding size
bounding size of
of our forms
our forms array
for each one
each one of
of these we're
these we're going
box and command
By simply using
simply using list
using list box
list box add
box add followed
add followed by
box handle itself
handle itself and
and the element
element in our
completed that let's
that let's create
create the sub
the sub function
sub function the
function the get
the get forms
the skeleton for
skeleton for that
for that function
that function passing
function passing by
passing by reference
by reference the
reference the forms
string array is
array is now
is now going
Plus the title
the form so
form so the
the user knows
user knows which
knows which form
which form they're
form they're clicking
they're clicking on
out which folder
which folder we
folder we need
So as our
as our form
our form runner
form runner is
runner is running
is running here
running here we
have a forms
forms folder underneath
folder underneath and
underneath and a
and a config
a config folder
config folder underneath
folder underneath that
the folder that's
folder that's going
to contain all
contain all our
all our CSV
our CSV files
than one entry
one entry on
entry on our
our list let's
list let's duplicate
let's duplicate the
duplicate the test
test demo CSV
demo CSV file
call that test
that test demo
test demo two
going to edit
to edit that
edit that file
that file so
that the title
the title is
title is something
other than first
than first form
call it second
it second form
second form and
form and we'll
and we'll save
we'll save that
know which folder
which folder to
folder to look
to look into
look into all
into all we
populate this array
to our configs
re-dimension the array
the array but
array but as
but as we
many files we're
be looking for
looking for we'll
for we'll start
with a value
of one hundred
one hundred elements
Should we discover
we discover there
discover there are
there are any
are any more
any more than
more than a
than a hundred
a hundred we
hundred we can
we can re-dimension
can re-dimension the
the array again
array again later
again later on
use the dir
the dir dollar
dir dollar command
to look to
see which CSV
which CSV files
CSV files exist
files exist within
exist within our
within our folder
This will interrogate
will interrogate the
interrogate the folder
folder and bring
and bring back
bring back the
back the first
the first file
first file that
file that matches
that matches a
matches a CSV
do a loop
loop to see
see if there
any more files
use the While
the While command
use a variable
variable called count
called count to
count to keep
of how many
many files we've
files we've actually
we've actually discovered
So we get
this far in
far in the
code we've discovered
we've discovered at
discovered at least
least one file
So incrementing a
incrementing a long
count will give
you the value
of one file
that we found
found a file
need to open
open up file
up file and
file and interrogate
and interrogate it
another variable called
variable called long
called long file
long file to
file to pick
up the next
next available free
available free file
free file number
next task will
be to open
to open that
open that file
that file to
file to do
to do an
do an interrogation
As there's always
there's always a
always a possibility
possibility that something
that something else
something else is
else is reading
is reading that
reading that file
that file we're
going to encapsulate
to encapsulate this
encapsulate this attempt
this attempt to
read in a
file is open
is open successfully
open successfully we
we can move
can move on
Should the file
the file actually
file actually be
actually be unable
be unable to
unable to open
open for some
some reason then
reason then we
we can catch
can catch the
catch the error
the error in
error in here
If our file
our file does
file does open
does open successfully
open successfully the
successfully the first
whether the count
the count variable
count variable is
variable is bigger
is bigger than
bigger than the
the maximum size
maximum size of
the elements within
elements within our
within our forms
case we need
need to increase
If you need
size of an
of an array
array and preserve
and preserve the
preserve the information
information in it
in it you
it you need
to use ReDim
use ReDim preserve
Increasing an array
an array by
array by one
by one element
one element at
element at a
a time is
time is a
a fairly inefficient
fairly inefficient way
inefficient way of
So here we're
here we're increasing
increasing it by
it by at
by at least
at least a
least a hundred
a hundred elements
it minimizes the
minimizes the number
number of time
of time the
time the array
the array needs
array needs to
to be re-dimensioned
can actually read
actually read the
read the first
first line in
line in to
in to a
As you'll remember
you'll remember in
remember in this
this file we
of data lines
data line we're
line we're specifically
the one marked
one marked title
marked title in
And we're wanting
wanting to pick
text from the
user in the
take the entire
the entire first
entire first line
first line and
the str field
str field variable
While we can
can make an
make an assumption
an assumption that
the title row
title row should
row should be
be the very
very first row
first row in
the file this
file this may
this may not
not be necessarily
be necessarily the
necessarily the case
the case in
case in the
in the later
the later iterations
later iterations of
rows in this
in this configuration
configuration file until
find the title
the title line
Or until we've
until we've read
we've read the
read the very
last line in
line in the
in a do
a do loop
do loop using
loop using the
using the until
the until command
until command to
that the loop
the loop will
loop will continue
will continue until
continue until these
until these conditions
these conditions are
conditions are met
The condition we're
condition we're using
using is a
is a parse
the title word
title word in
word in the
Or we're looking
end of file
of file marker
file marker to
marker to be
be true in
true in which
which case we've
case we've reached
we will execute
will execute the
execute the line
the line input
line input to
input to pull
value into the
if that happens
that happens to
to be equal
be equal to
the word title
word title then
title then we
will drop out
drop out of
to see are
see are we
are we at
we at the
file or have
or have we
actually found what
found what we're
if the end
of file is
file is false
then we must
we must have
must have got
got the title
now store the
store the title
title line and
the form in
form in our
doing this quite
this quite simply
long count to
count to point
to point to
back the second
to that in
that in brackets
in brackets the
brackets the name
file we're interrogating
a mechanism to
mechanism to record
to record the
record the name
file which we'll
In the finally
the finally section
finally section of
of the try
the try catch
catch block we
block we can
can close the
the file down
the last thing
last thing it
And having read
having read that
read that file
that file we
go on and
on and read
and read the
read the next
the dir command
dir command again
again to pick
next available file
available file name
when we drop
we drop out
of the while
the while loop
while loop we
loop we will
have an array
has been populated
been populated with
populated with all
the files we've
files we've been
we've been able
been able to
able to find
However the array
array is very
is very likely
very likely to
be larger than
than the amount
the amount of
of data contained
contained within it
As we dimension
we dimension the
array with 100
with 100 elements
there are exactly
are exactly 100
exactly 100 files
100 files found
files found then
found then that
would be fine
But it's likely
it's likely that
likely that we'll
that we'll probably
we'll probably have
probably have less
need to truncate
to truncate the
truncate the array
the array just
array just down
just down to
to the amount
of data items
data items we've
items we've actually
we've actually found
Since the count
variable is actually
is actually counting
actually counting we
counting we can
can use that
use that to
that to redim
to redim and
redim and preserve
preserve the data
variable is greater
than zero we're
zero we're redimming
we're redimming preserving
redimming preserving the
preserving the array
the array from
array from one
of elements we've
elements we've found
we've found the
found the count
return the function
the function to
function to be
Else the function
will return false
return false because
false because we
because we found
we found no
found no files
at all in
all in the
if it finds
it finds the
finds the two
the two config
two config files
config files we
files we expect
we expect it
And there on
there on our
box are the
The first form
first form and
form and the
the second form
second form with
form with the
name of their
of their files
put the functionality
the functionality under
under the run
pick up whichever
up whichever form
whichever form has
user and will
and will attempt
run the auto
the auto form
auto form application
form application with
that file as
file as a
let's look back
at our callback
callback function to
can set that
callback function there's
function there's a
there's a section
the mouse clicks
on the run
been selected if
selected if anything
that by doing
by doing the
doing the list
parameters the handle
the dialogue the
dialogue the handle
If that variable
that variable comes
back with an
string then nothing
then nothing has
the form variable
form variable has
variable has been
been populated and
populated and it's
and it's not
one string we
string we can
now select from
select from that
from that string
string the name
file in brackets
parse command using
command using the
using the any
the any option
any option in
in the parse
parse command gives
command gives you
gives you the
you the option
option of having
of having more
having more than
than one delimiter
the any command
any command within
command within parse
within parse to
parse to look
look for either
for either of
these two delimiters
two delimiters the
delimiters the open
the open bracket
open bracket or
bracket or the
or the close
the close bracket
data that's within
that's within the
within the two
the two brackets
two brackets the
got that information
that information we
information we can
can now run
now run auto
run auto form
easily using the
using the shell
the shell command
We're shelling out
shelling out to
the form application
passing a parameter
config folder plus
folder plus the
form to launch
have the two
the two forms
two forms on
forms on the
the dialogue if
dialogue if we
pick the first
form and hit
hit the run
form button it
launch our first
our first form
we exit from
exit from that
from that if
select the second
will launch the
launch the second
created a form
a form running
form running application
running application which
application which will
which will basically
will basically front
basically front end
front end the
end the auto
display to a
a user a
user a selection
selection of forms
of forms which
forms which they
they can run
all the user
the user needs
user needs to
pick the form
from the screen
the screen hit
screen hit the
form button and
and the form
form will appear
Once they're finished
they're finished with
finished with that
with that form
that form they
form they can
they can exit
can exit that
that and pick
a different form
different form or
form or just
or just exit
just exit from
next video we'll
we'll do more
do more configuration
more configuration of
configuration of auto
of auto form
auto form to
form to add
by adding tooltips
video we created
we created our
created our form
runner application, to
us to run
to run auto
run auto forms
forms by specifying
by specifying a
specifying a type
a type of
type of form
of form from
form from a
from a list
doing today is
some more functionality
more functionality to
functionality to the
to the auto
first form we
form we see
fairly basic form
basic form, comprising
comprising of a
of a drop
down list, a
box and some
and some text
some text boxes
text boxes as
boxes as well
well as two
as two buttons
to add functionally
add functionally today
functionally today are
today are tooltips
to specify in
specify in our
configuration file a
file a tooltip
a tooltip to
tooltip to place
place on a
on a particular
a particular object
particular object, so
a user hovers
hovers over such
over such an
such an object
an object, a
a tooltip will
tooltip will be
displayed to indicate
to indicate the
indicate the purpose
the purpose or
purpose or what
or what the
with that particular
that particular control
Tooltips are especially
are especially useful
especially useful as
useful as they
as they can
they can give
can give indication
give indication to
indication to the
the user what's
user what's needed
what's needed or
needed or what
or what a
what a function
function of a
of a particular
particular object is
object is, without
without you having
you having to
having to place
to place any
place any permanent
any permanent message
permanent message on
dialogue itself, thereby
thereby reducing clutter
can turn these
turn these tooltips
these tooltips on
order to add
add the tooltips
the tooltips functionality
tooltips functionality we're
functionality we're going
to include one
include one of
be the tooltips
the tooltips library
is a library
a library we've
library we've covered
we've covered previously
covered previously in
previously in a
in a tooltips
a tooltips video
make these tooltips
these tooltips conditional
tooltips conditional on
conditional on the
on the configuration
before we put
put the coding
coding in, let's
files are held
held in this
in this configs
this configs folder
at the testdemo.csv
the testdemo.csv file
testdemo.csv file, we
these columns set
columns set properties
set properties of
of the individual
the individual objects
column to this
this file called
file called tooltips
the objects displayed
objects displayed to
on screen, which
interact with, we're
put a string
in the tooltips
the tooltips column
have a tooltip
a tooltip, which
have a string
a string saying
string saying Save
saying Save the
exit button we
string saying Exit
saying Exit the
want to pop
to pop up
pop up on
on screen when
screen when the
when the user's
user's mouse hovers
over the object
the buttons, the
text boxes, the
list box all
box all have
all have tooltips
have tooltips set
tooltips set up
There's no point
no point having
point having a
having a tooltip
a tooltip on
tooltip on a
a label because
label because the
the user cannot
user cannot interact
cannot interact with
interact with a
with a label
we'll now have
have to amend
when the objects
objects are loaded
are loaded into
we pull in
pull in this
in this tooltips
this tooltips column
to change is
change is we'll
is we'll need
code to add
add on tooltips
on tooltips, as
next available column
available column to
column to pull
to pull data
pull data out
data out of
have a ref
a ref tooltips
ref tooltips constant
the routine we
routine we have
have to load
up this configuration
file will cope
with the extra
the extra column
extra column without
column without any
without any further
any further changes
What we'll need
to work on
work on is
on is the
is the populate
form function takes
function takes the
takes the global
global array, strconfig
creates the objects
once all these
all these objects
objects are created
are created, we'll
need to then
to then call
call a piece
code to populate
populate the tooltip
the tooltip for
tooltip for those
for those objects
which have been
have been defined
been defined as
defined as having
as having tooltips
the code called
code called strtooltip
contain the string
to place in
place in as
as a tooltip
tooltip on the
on the object
And as the
the last action
last action before
action before we
before we move
we move on
next entry in
config file, we
look for those
which have tooltips
information out by
out by using
This will use
will use our
use our new
new constant ref
constant ref tooltips
This will put
put the string
the string within
within that tooltip's
that tooltip's column
tooltip's column into
into the tooltip
the tooltip variable
if this string
this string is
string is not
it's populated, we
can now specify
now specify the
specify the tooltip
calling a function
our new tooltip's
new tooltip's library
is called tooltip
called tooltip set
tooltip set tooltip
first parameter is
is the Windows
API call, getDialogueItem
which takes in
takes in itself
in itself two
itself two parameters
return the Windows
Windows handle itself
handle itself, which
our first parameter
to set on
set on that
that object, which
be our tooltip
with this simple
this simple bit
simple bit of
now have tooltips
have tooltips on
tooltips on our
on our objects
application runs quite
the mouse up
mouse up to
to the name
name field, and
at the list
list box, we
have another tooltip
another tooltip, the
the department, we
have the one
for the department
the department, and
have the ones
the ones on
ones on the
the OK and
OK and the
the exit buttons
exit buttons as
buttons as well
have successfully added
successfully added tooltips
added tooltips to
tooltips to our
our application being
application being configured
being configured within
can go further
The tooltips at
tooltips at the
the moment are
moment are set
set as purely
as purely black
purely black and
black and white
But it takes
it takes on
takes on a
on a white
a white background
Can we add
we add color
to our tooltips?
our tooltips? In
tooltips? In order
to our library
our library routines
library routines, the
the tooltips include
tooltips include file
the library where
library where the
where the tooltip
the tooltip is
tooltip is set
a library, we
want to break
to break functionality
break functionality on
functionality on any
on any applications
any applications which
applications which are
which are using
are using an
using an older
an older version
older version of
version of this
of this library
the two additional
additional parameters I'm
parameters I'm going
to make as
make as optional
as optional parameters
If the parameters
the parameters are
parameters are not
are not given
not given, it
it will default
to having black
having black text
black text on
parameters are given
are given, this
foreground and the
the background colors
our two optional
two optional parameters
optional parameters, B
B color for
color for the
for the background
background color and
color and T
and T color
T color for
these are optional
are optional parameters
optional parameters, we'll
see whether these
whether these parameters
these parameters have
parameters have been
have been provided
been provided by
provided by the
by the calling
calling routine or
routine or not
set up two
up two local
local variables called
variables called background
called background color
color and text
and text color
will be what
be what are
what are used
are used within
this function itself
the inbuilt is
inbuilt is missing
is missing function
missing function to
whether the parameters
the parameters have
have been given
been given or
given or not
When calling a
calling a subroutine
a subroutine or
subroutine or function
or function with
function with optional
with optional parameters
optional parameters, if
if you designate
you designate a
designate a parameter
a parameter as
parameter as being
as being optional
being optional, then
then every parameter
every parameter following
parameter following that
following that is
that is also
is also automatically
also automatically optional
So we only
we only need
only need to
whether we've been
been given B
given B color
B color or
color or not
our new code
If the B
the B color
B color variable
color variable is
variable is missing
is missing from
missing from the
from the parameters
the parameters, then
then no optional
no optional parameter
optional parameter has
parameter has been
So we'll default
we'll default our
default our background
our background color
color to white
to white and
white and our
our text color
text color to
color to black
have the parameter
the parameter coming
parameter coming in
coming in, we
take that parameter
that parameter and
parameter and we
into the background
text color one
color one goes
one goes into
handles the parameters
the parameters in
parameters in the
to change now
change now in
allow these variables
variables to set
and background colors?
background colors? First
colors? First of
allow our tool
our tool tip
tool tip colors
tip colors to
colors to be
be used, we
to check for
check for the
for the themed
the themed dialog
call a Windows
Windows API routine
API routine called
routine called setWindowsTheme
to set colors
set colors on
colors on our
on our tool
our tool tips
tool tips, whether
whether the theme
the theme is
theme is there
is there or
there or not
And following our
following our send
our send message
send message to
message to set
set the tool
the tool tip
tool tip, we
and the foreground
this by two
by two additional
two additional send
additional send message
send message commands
color and one
foreground color, the
the text itself
The remaining piece
remaining piece of
code we need
is this call
this call to
to set window
set window theme
This set window
window theme is
theme is going
load up one
up one of
Windows libraries, this
be calling that
calling that routine
routine in that
in that library
So this completes
this completes the
completes the changes
to our tool
tool tips library
we've set two
set two optional
would appear exactly
appear exactly as
did before, because
we're not making
not making use
of the optional
the optional parameters
But it's always
a good test
good test to
that the original
the original functionality
original functionality has
functionality has not
has not broken
our application works
application works fine
works fine and
fine and the
and the tool
the tool tips
tool tips appear
tips appear as
appear as normal
call this by
this by putting
in the colors
up two new
While in this
this video I'm
video I'm going
to be hard
be hard coding
hard coding these
coding these within
function so that
that we set
the default standard
default standard for
all the tool
there's no reason
no reason why
reason why you
why you couldn't
you couldn't put
couldn't put that
put that information
that information within
That way, should
you wish it
wish it, you
you could have
could have different
have different tool
different tool tips
tool tips for
tips for different
for different types
leave that functionality
that functionality for
functionality for a
populate the default
default values of
values of our
of our background
our background and
background and text
text color variables
let's say for
example we wanted
wanted to set
of the tool
tool tip to
tip to red
to red and
two variables on
variables on to
the end to
end to our
to our call
to the tool
tool tip set
tip set tool
set tool tip
tool tip function
application will launch
will launch normally
launch normally but
normally but our
but our tool
tool tip is
tip is now
in a bright
a bright red
bright red color
This stands out
stands out more
out more than
than the straightforward
the straightforward black
straightforward black and
And gives you
setting a very
a very colorful
very colorful tool
colorful tool tip
We can alternatively
can alternatively change
alternatively change the
color to for
to for example
for example yellow
example yellow and
yellow and the
foreground color to
So we'll try
see our tool
tool tip now
tip now appears
now appears as
appears as we've
as we've defined
we've defined with
defined with a
with a yellow
a yellow background
yellow background and
background and a
and a black
a black text
you can choose
can choose whichever
choose whichever color
whichever color scheme
color scheme fits
scheme fits your
fits your application
your application better
a new include
new include library
include library to
to set tool
set tool tips
tips on selected
on selected objects
Any object which
object which the
interact with which
with which you
which you have
you have defined
have defined in
defined in the
config file as
file as having
as having a
having a tool
a tool tip
tool tip will
tip will make
make it appear
you can have
can have some
have some objects
some objects with
objects with tool
with tool tips
tool tips and
tips and some
and some objects
some objects without
by adding form
adding form navigation
this project so
project so far
so far we
far we have
generic Form Runner
Runner application when
application when run
run will display
configured in CSV
in CSV files
content of each
these files describes
files describes the
describes the layout
layout of a
If we launch
we launch our
our first dialogue
first dialogue we
dialogue we can
screen a number
of Windows Controls
text boxes, list
boxes and a
down list as
list as well
well as a
as a couple
The functionality supports
functionality supports tooltips
supports tooltips as
tooltips as well
the user entering
user entering information
entering information and
information and pressing
and pressing the
pressing the OK
forms folder is
folder is the
is the definition
definition of this
of this auto
this auto form
auto form executable
is the executable
the executable that
executable that will
that will read
will read the
read the config
is what the
has selected when
selected when they
when they wish
they wish to
wish to run
to run a
run a form
of these CSV
these CSV files
CSV files we'll
files we'll see
that it describes
it describes each
describes each of
objects that appears
dialogue itself, the
the labels, the
have the identifier
the identifier for
identifier for each
also have the
have the position
on screen defined
screen defined as
defined as X
as X and
coordinates as well
as the width
those objects the
objects the user
interact with we
with we have
have defined tooltips
text boxes we
boxes we can
of characters and
characters and we
can also specify
also specify which
the user enterable
user enterable fields
enterable fields are
fields are actually
are actually mandatory
up a configuration
configuration for each
for each new
each new dialogue
new dialogue we
wish to create
to create without
create without doing
without doing any
doing any programming
any programming at
programming at all
a user enters
user enters data
enters data into
into these fields
these fields and
fields and presses
presses the OK
OK button it
it will save
to a designated
a designated CSV
designated CSV file
file is defined
is defined on
defined on the
OK button in
button in the
the configuration field
configuration field in
field in the
at the user
user data we
data we can
is one record
one record in
is what we've
what we've completed
we've completed so
completed so far
add some form
some form navigation
form navigation buttons
navigation buttons on
on the auto
to move forward
move forward and
forward and backward
and backward in
backward in the
of forms that
forms that have
have been filled
been filled in
to navigate through
navigate through each
forms and make
and make what
make what changes
what changes they
changes they wish
wish to each
to each form
make these changes
these changes let's
changes let's have
forms application takes
application takes a
takes a command
a command line
line parameter and
parameter and that
that is defined
is defined in
defined in our
our IDE in
IDE in the
in the set
the set command
set command line
to run this
this application on
application on its
on its own
its own without
own without having
having to run
add some navigation
some navigation buttons
navigation buttons to
buttons to the
of the auto
will first need
first need some
need some icons
I've created five
created five icons
five icons to
icons to allow
navigate through the
through the list
to add five
add five resource
five resource commands
resource commands to
commands to our
to load in
load in each
of the icons
the icons that
icons that we
first one the
one the reports
the reports icon
reports icon is
to be for
be for the
The other five
other five are
five are going
new library button
library button plus
button plus dot
plus dot bas
add these controls
these controls to
to our main
main dialog and
dialog and we'll
we'll add a
add a control
add button entry
button entry for
that they appear
they appear at
to be navigating
be navigating through
navigating through each
the forms in
forms in turn
in turn we
want an indication
an indication at
indication at the
screen to see
see which form
which form we're
form we're actually
add a label
a label at
label at the
screen that tells
that tells the
tells the user
the user which
user which form
which form number
form number they're
number they're actually
they're actually on
So since we've
our dialog we
dialog we need
to declare all
declare all these
all these constants
these constants at
added our constants
our constants at
code we now
our application that
application that will
that will display
will display those
display those icons
those icons on
icons on the
on the new
the new buttons
the dialog again
to use our
use our button
our button plus
library to add
add these icons
these icons to
icons to each
of the dialogs
the dialogs in
dialogs in turn
using a prefix
a prefix command
save a bit
calling the button
button plus function
plus function with
function with a
put the icon
icon on, the
that we're adding
we're adding an
adding an icon
an icon, the
the icon we
icon we wish
to add and
add and the
the icon in
icon in pixels
we'll put an
entry in for
of our five
our five buttons
And with these
with these in
in place if
place if we
application now we'll
we'll see at
dialog we now
of large buttons
One button to
new form, buttons
the form list
form list, the
form list and
list and buttons
and buttons to
go back or
or forward one
forward one form
the label underneath
label underneath will
underneath will tell
us the form
Ideally we want
to add tooltips
add tooltips to
tooltips to these
to these two
these two to
two to indicate
user what each
what each of
the buttons will
buttons will actually
So we'll go
we'll go to
put some tooltip
some tooltip calls
tooltip calls in
So with each
of these in
tooltips on the
if we hover
we hover over
hover over one
the buttons a
buttons a tooltip
a tooltip should
tooltip should appear
first form, the
the previous form
previous form, the
next form, the
last form and
and to create
want this label
this label underneath
label underneath the
underneath the buttons
the buttons to
buttons to indicate
indicate which form
we're actually on
to be treating
be treating the
treating the form
form data slightly
data slightly differently
Since at any
in time the
user may well
well have created
have created several
created several forms
several forms already
forms already, we'll
application to load
to load these
load these forms
these forms into
forms into a
us to cycle
to cycle through
cycle through each
in turn using
turn using these
using these navigation
these navigation buttons
the application first
application first loads
first loads it
loads it will
will be sitting
be sitting on
sitting on form
on form number
be using yet
using yet another
yet another library
add the pb
the pb windows
pb windows controls
windows controls library
I'll cover the
the functions that
functions that we're
be using in
using in this
in this library
this library when
library when we
two more global
more global pieces
global pieces of
One to hold
hold the current
the current form
current form number
number and one
hold the details
details of all
forms in a
in a string
So having defined
having defined that
defined that global
that global string
global string array
string array in
array in our
main function when
function when the
the application launches
application launches we
launches we need
for the data
the data file
data file to
it has already
already been created
it does, to
data into that
into that global
create a function
populate that global
that global form
global form array
that function is
function is successful
is successful then
successful then we
form number to
to the total
number of forms
of forms held
forms held on
held on the
on the array
the array plus
array plus one
have a blank
a blank record
blank record at
record at the
create this populate
this populate the
new function takes
So until we
until we know
we know otherwise
know otherwise we'll
otherwise we'll assume
we'll assume the
assume the form
form number is
number is form
is form number
created a local
variable to store
store the name
of our input
our input file
be reading in
config file itself
So we first
to find where
find where the
where the data
data file actually
file actually exists
call another routine
another routine called
routine called return
called return save
return save file
save file value
file value which
which will give
us the path
But if that
that file does
file does exist
does exist then
exist then we
can populate our
populate our string
our string array
string array using
array using one
in our library
an array function
and the array
the new return
new return save
is to find
find the button
the button whose
button whose function
whose function is
function is save
our data file
previous videos we're
videos we're going
To find from
find from our
our config header
config header line
header line the
line the columns
the columns for
columns for object
for object, function
function and field
and field name
us which column
column we need
Then it's a
it's a simple
a simple matter
simple matter of
matter of looping
of looping around
looping around each
around each record
record in the
for one which
one which is
and one whose
one whose function
be one record
record in that
in that config
config file whose
file whose function
And having found
having found that
found that we
return the string
string in the
function is very
is very similar
very similar to
the functions we've
functions we've done
we've done previously
populated this global
now go into
into our callback
function in inside
in inside the
inside the initialize
the initialize dialog
dialog section to
section to load
up the form
the form with
within the first
the first record
So immediately after
after we call
call the populate
function which puts
which puts the
puts the objects
populate those controls
those controls on
the dialog with
dialog with data
call that fill
that fill form
fill form with
form with record
It takes three
the label that's
label that's going
contain the form
form number itself
is a skeleton
a skeleton of
the data CSV
data CSV file
file and pull
and pull the
pull the record
the record out
record out that
out that we
wish to display
display on the
need some local
track of each
and columns we're
columns we're actually
we're actually dealing
actually dealing with
variables we now
have to pull
pull the headers
headers in from
from the zero
us the name
of each column
if the record
the record number
record number we're
number we're looking
for is actually
is actually greater
actually greater than
than the number
the array then
array then we
we know we've
know we've reached
data for this
for this last
this last form
last form will
new form to
Otherwise we're just
data that exists
that exists in
array for that
for that global
that global record
And then as
then as we've
done before we
before we need
column number for
number for the
field name the
name the ID
the ID and
ID and the
the object from
object from the
done before using
before using the
So first pulling
first pulling back
the column form
column form our
form our headers
our headers variable
headers variable and
variable and now
now we'll read
we'll read each
read each row
can find a
a match in
match in order
control ID of
us the control
object and assuming
and assuming we've
assuming we've found
found the one
for we can
exit the for
if the control
control value is
then the control
it with data
with data based
it a drop
drop down list?
down list? Or
it a list
a list box?
list box? And
box? And we'll
we'll do this
this with a
the three different
of object that
object that we're
text box with
box with free
with free text
down list will
be a selection
a selection from
list box will
box will be
from the list
text box is
box is a
is a simple
simple control set
The select combo
select combo is
combo is coming
is coming from
from a new
a new windows
new windows control
control library and
library and a
and a select
a select list
list box also
box also coming
also coming from
coming from there
These will obviously
will obviously take
obviously take a
take a number
data we're wanting
put into it
pull out from
from our data
our data variable
data variable the
variable the data
that we've updated
we've updated the
updated the dialogue
the dialogue controls
dialogue controls we
controls we now
update the form
form number so
number so the
form number they've
number they've actually
they've actually loaded
we'll also display
also display a
a message in
message in the
the status box
status box to
been successfully loaded
of these using
these using the
using the simple
the simple control
I've replaced the
replaced the user
user data CSV
file to give
us a record
a record with
record with more
with more data
more data in
one now has
now has seven
has seven records
Well our application
our application loads
application loads quite
loads quite happily
happily and it's
and it's now
it's now sitting
now sitting at
sitting at form
form number eight
number eight which
eight which would
be the next
next form to
to be created
haven't added any
added any code
any code underneath
code underneath our
underneath our button
our button jet
button jet to
jet to allow
us to navigate
to navigate so
navigate so that'll
so that'll be
that'll be the
function the event
event handler we
handler we have
add an event
event for each
buttons to allow
to actually function
for example if
example if we're
adding an event
for the button
the button new
button new, the
the button the
button the user
on to generate
update the global
form number by
number by taking
taking the largest
the largest number
largest number of
of records within
records within the
array and adding
and adding one
can then re-dimension
then re-dimension our
re-dimension our global
global array preserving
array preserving the
preserving the data
within it for
the new size
we had seven
had seven records
seven records before
records before we
before we would
we would now
would now have
now have eight
created earlier to
earlier to fill
fill the form
form with data
with data for
for that record
this case has
case has clicked
the new button
new button we'll
button we'll know
we'll know that
to be empty
But our function
our function should
function should populate
should populate it
populate it quite
it quite nicely
the first button
first button to
very first form
form we know
know the form
number is going
to be form
be form number
we'll call the
call the same
the same generic
same generic routine
generic routine again
routine again to
again to populate
populate the dialog
the dialog controls
dialog controls with
controls with the
data from that
from that form
you will now
will now see
see the pattern
the pattern coming
pattern coming up
coming up here
form we then
then have to
form number being
number being the
this will go
form and again
and again call
again call the
the same routine
same routine again
the button next
button next we
next we do
number is at
is we do
is not then
not then we
then we increment
we increment the
increment the form
again to fill
with the record
the record data
our final button
final button is
button is the
is the back
back button to
number is greater
one then we
then we decrement
we decrement the
decrement the form
and then fill
then fill the
code now we're
now we're currently
we're currently sitting
currently sitting on
click the first
first form button
button it should
it should populate
should populate the
populate the first
then we should
able to step
entries for form
for form two
form two, form
form three, form
form four, form
form five, form
form six, form
try to go
go to form
to form eight
form eight it's
eight it's the
it's the blank
the blank one
blank one, the
the one at
And it won't
it won't let
won't let us
let us go
us go any
the plus to
plus to give
new form it
form it will
will move on
to form nine
updated the data
navigate through our
happens when we
the OK button?
OK button? We'll
button? We'll need
to change our
change our saving
our saving routine
saving routine because
routine because all
data is currently
currently held in
held in memory
quite easily save
easily save the
save the entire
entire array back
array back to
file to complete
complete the saving
the saving of
saving of our
event handler we'll
handler we'll find
we'll find that
find that in
callback function there
function there is
is a run
This function processes
function processes the
processes the events
for the configurable
the configurable items
configurable items on
inside this function
this function this
function this is
save is actually
is actually triggered
There's a validate
a validate form
validate form function
form function followed
function followed by
by a save
a save form
So our save
our save form
data function is
moment we'll comment
we'll comment out
out these lines
of code and
code and we'll
we'll add some
some new code
We're already in
this function working
function working out
what the output
name is actually
has just updated
just updated one
updated one form
form we first
need to save
save that form
that form to
using the get
the get form
data function which
function which already
which already exists
This pulls all
pulls all the
dialog and puts
And our next
be to insert
to insert this
insert this data
this data into
into the appropriate
the appropriate place
appropriate place in
be another new
this function insertToArray
data line to
line to insert
to insert, the
form number we're
number we're going
be saving, and
array we're going
assumption that this
true to say
say that information
that information has
successfully saved to
have to save
save it back
by using one
handling library, the
dump function, which
which takes the
takes the contents
contents of a
dimension array and
array and saves
this new insertToArray
new insertToArray function
the skeleton to
skeleton to our
our function with
data line, the
form number, and
maximum number records
number records in
it is, we
the array preserving
within it using
using the readim
the readim preserve
readim preserve command
done that, it's
matter of updating
of updating that
updating that element
that element of
the array, the
the element being
element being the
being the form
can return true
application now, it
display the last
last form, which
which is form
the beginning, there's
there's form number
the end form
end form number
data in here
in here, we'll
see that form
that form number
number seven is
seven is incomplete
back to form
populate the address
the skill for
skill for this
this particular user
particular user plus
user plus the
plus the age
OK button, and
that should save
should save it
save it to
it to disk
back and compare
and compare the
compare the new
the new data
new data with
with the old
the old data
our new data
have the address
the address, the
the skill, and
and the age
the age in
age in the
the new file
we've added navigation
added navigation tools
navigation tools to
tools to the
of our dialogue
our dialogue, allowing
and backward through
backward through the
already been keyed
Plus giving them
giving them a
them a button
button to add
new form if
form if it's
if it's required
With these tools
these tools, the
user can check
check the data
data that's been
that's been entered
been entered in
entered in each
in each form
each form and
form and make
and make corrections
make corrections where
corrections where necessary
where necessary, giving
the user more
user more confidence
more confidence in
confidence in the
data that they've
that they've actually
they've actually entered
We'll look to
look to add
add more functionality
functionality in the
of software autoforms
software autoforms by
autoforms by adding
by adding date
adding date controls
project videos we
videos we tend
we tend to
tend to go
go into a
into a little
little more detail
more detail on
detail on the
on the code
code and the
and the development
the development and
development and design
and design of
design of the
of the project
So to recap
to recap what
recap what this
this project has
project has done
has done so
done so far
so far, we
have a Form
Runner application has
application has the
task of displaying
of displaying the
displaying the types
types of forms
the project was
project was to
was to create
create a system
a system by
system by which
which the configuration
a dialogue with
dialogue with a
with a new
new application was
application was contained
was contained outside
contained outside of
outside of the
of the PowerBasic
PowerBasic application and
application and stored
and stored in
stored in a
Runner application, it
with a dialogue
dialogue with two
the two CSV
two CSV configuration
CSV configuration files
configuration files already
files already set
the form files
form files and
files and click
Run Form application
Form application, this
this launches a
launches a separate
a separate application
application is then
is then taking
then taking its
taking its data
its data from
data from a
from a configuration
for the layout
layout of the
controls you see
you see appearing
see appearing on
appearing on this
this dialogue, for
example the name
the name, the
the department, the
the skill, the
the age and
age and the
the two buttons
two buttons, are
configured within that
within that CSV
that CSV configuration
CSV configuration file
we have Form
have Form Navigation
the forms that
forms that a
user has filled
has filled in
Either one at
time or going
or going right
going right to
the end, or
or allowing you
brand new form
forms folder, this
where the AutoForm
AutoForm application resides
behind this project
project is that
is that this
that this AutoForm
this AutoForm application
AutoForm application should
application should not
should not need
not need to
Any change can
change can be
be done within
within the Configs
Configs folder holds
folder holds two
holds two CSV
two CSV files
CSV files at
files at the
Each CSV file
is the configuration
of a separate
a separate form
open up one
CSV files, this
configuration file contains
file contains 13
contains 13 rows
13 rows of
Each row defines
row defines one
defines one object
And the additional
the additional columns
additional columns specify
columns specify where
specify where on
the dialogue it
dialogue it appears
it appears, how
how big it
big it is
it is, how
it is, its
its ID number
ID number, the
the function, the
field name, mandatory
mandatory settings, character
character limits and
limits and tooltips
file is, should
should there require
there require to
require to be
be a change
the dialogue, it
done by merely
by merely amending
merely amending this
amending this CSV
look at today
at today is
appear on a
on a dialogue
from the object
the object list
object list, we
we already support
already support buttons
support buttons, labels
lists and list
add a Date
a Date Control
It's quite common
quite common in
common in applications
in applications to
applications to have
to have controls
have controls where
controls where the
user can either
can either select
either select a
a date or
date or update
or update a
update a date
we amend the
amend the Power
Basic code, let's
let's amend the
amend the configuration
open this in
this in Notepad
see the list
of the 13
the 13 objects
13 objects to
adding two more
One to be
be a label
be a actual
a actual date
actual date control
here are two
new entries on
entries on this
on this configuration
first row is
row is the
is the label
on that label
that label to
label to be
to be Start
be Start Date
Start Date, and
and its X
to be 20
be 20 by
20 by 130
to be 50
be 50 wide
50 wide and
And its unique
its unique identifier
unique identifier is
identifier is 2010
So the Date
Control itself, we're
setting the object
to be Date
We're setting its
setting its location
20 by 140
by 140, its
its height to
be 50 by
50 by 10
by 10, and
a tooltip of
tooltip of Select
of Select the
Select the Start
have specified Start
specified Start Date
Start Date as
Date as the
as the column
column heading, which
CSV file, which
is the output
from the entire
we'll just save
just save this
save this configuration
And we'll go
we'll go one
go one folder
one folder back
folder back and
back and into
Data folder contains
folder contains the
contains the user
has one entry
one entry for
wish to export
to export from
export from our
from our dialogue
be adding a
a new Start
new Start Date
Date column, we
a new header
new header to
header to this
the moment does
moment does not
does not add
not add these
add these headers
these headers automatically
looking at that
at that in
new column heading
calling that Start
that Start Date
that file now
file now, we
the new Start
this new entry
first change we'll
function that places
that places all
places all the
function is driven
is driven by
driven by a
by a global
is populated from
populated from the
file we looked
looked at earlier
will see further
see further down
further down, there's
there's a case
statement for each
types of the
the controls we're
So today we're
new control, a
case statement, and
the word 'date'
word 'date' in
'date' in our
object column of
column of the
the previous controls
previous controls, we
define the style
the style of
style of the
then we'll need
add our Date
our Date Control
the location specified
location specified in
specified in the
first we're setting
setting the style
The style is
style is fairly
is fairly standard
It's a child
a child object
child object, it's
it's visible, and
has a tab
a tab stop
Date Control, we're
setting the short
the short date
short date century
date century format
century format to
format to ensure
to ensure we
ensure we have
have a 4
a 4 character
4 character year
character year appearing
year appearing in
appearing in our
in our Date
now is always
is always exactly
always exactly like
exactly like we
like we did
the previous control
Control Add, specifying
specifying the dialogue
control number, and
and then followed
then followed by
by the location
the extended and
extended and normal
and normal styles
be using SysDate
using SysDate TimePicker32
SysDate TimePicker32 as
TimePicker32 as the
as the class
the class definition
our application has
application has now
has now run
now run, it
it has displayed
has displayed the
displayed the form
have a start
a start date
start date on
date on the
start date is
date is populated
with a date
a date already
has the date
the date of
date of the
of the 18th
the 18th of
18th of November
of November, which
which happens to
be the current
the current date
This is functionality
is functionality you
functionality you will
you will get
will get out
get out of
the box with
with the Date
user can amend
amend the control
the control either
control either by
either by changing
changing the day
the day, the
the month or
month or the
or the year
the year directly
As I am
I am in
am in the
in the UK
the UK, the
the date format
date format is
format is showing
as the UK
the UK format
free to amend
amend the code
the code if
code if your
if your date
your date format
format is the
is the US
the US format
Without adding any
adding any additional
any additional code
additional code, we
we have some
have some functionality
some functionality we
functionality we can
can use within
use within the
within the Date
The little widget
little widget at
at the side
the side of
the control allows
control allows you
display the entire
entire month, making
making date selection
date selection quite
selection quite easy
quite easy for
easy for that
for that month
go forward or
forward or back
or back months
back months using
months using the
using the little
the little widgets
little widgets at
widgets at the
on the month
the month, it
it lets you
lets you select
you select a
select a month
a month, and
on the year
the year, it
select a year
very easy for
easy for the
user to drill
to drill down
drill down to
down to find
find the date
the date they
date they want
they want to
want to enter
have this Date
this Date Control
Date Control on
add some code
some code to
code to the
it to save
the information to
the CSV output
CSV output file
amend the application
the form actually
form actually loads
actually loads, it
load that data
that data into
into the screen
of these code
these code changes
code changes is
changes is to
common functions into
functions into your
into your application
it to read
read a date
a date from
date from a
from a Date
Date Control and
Control and to
and to write
to write a
write a date
date to that
new functions –
functions – Set
– Set A
Set A Date
A Date and
Date and Get
Get A Date
first of our
our new functions
three parameters –
– the Dialog
Date Control, and
finally the date
the date we
date we want
into that control
This is being
is being passed
passed in in
in in the
in the standard
the standard UK
standard UK date
UK date format
date format –
format – Day
– Day Day
Day Day, Month
Month Month and
Month and a
and a 4
setting up two
local variables –
variables – a
– a User
is a standard
a standard System
standard System Time
System Time, and
and a Windows
Windows Handle, which
used for our
for our Date
Control Handle command
Handle command to
command to turn
to turn our
turn our Dialog
our Dialog Handle
Handle and our
and our Control
our Control Handle
Control Handle into
Handle into a
into a standard
a standard Windows
standard Windows Handle
Windows Handle so
Handle so we
can use one
populating the Month
the Month, Day
Day and Year
and Year of
Year of our
Defined Type, given
given the information
the information we've
information we've passed
the Date String
calling the DateTime
the DateTime Set
DateTime Set System
Set System Time
System Time Windows
Time Windows API
API Call, passing
it the three
the Windows Control
Windows Control, which
is our Date
Date Control, a
a GDT Valid
GDT Valid Constant
Valid Constant and
Constant and a
and a User
Defined Type containing
Type containing our
containing our Date
our Date Time
Date Time information
This will update
update the Date
Date Control with
the date we've
date we've passed
is our second
our second function
second function –
function – Get
– Get A
will use to
use to extract
to extract a
extract a date
It takes only
takes only two
only two parameters
Much as we
command to extract
extract the Windows
then using another
API function called
function called DateTime
called DateTime GetSystemTime
DateTime GetSystemTime to
GetSystemTime to extract
date from that
from that specific
that specific control
puts the information
into the User
Defined Type –
Type – UDT
that returns the
the value GDT
value GDT Valid
GDT Valid, then
the information is
information is considered
is considered valid
can then build
then build up
up our Date
our Date String
Date String by
String by slicing
by slicing up
slicing up the
up the information
within the UDT
As the values
the values coming
values coming out
coming out from
out from each
of these elements
these elements are
be numbers, we
we are turning
are turning them
turning them into
them into strings
into strings and
strings and we
we are right-justifying
are right-justifying them
right-justifying them into
them into a
into a zero-filled
a zero-filled number
the date for
date for the
for the 2nd
the 2nd of
2nd of January
of January will
January will be
will be 0201
returning the STRDate
the STRDate to
STRDate to the
The additional function
additional function I've
function I've added
I've added to
to the tail
the tail end
tail end of
application is a
function called UKDate
return the current
current date in
date in DayDay
in DayDay month-month
DayDay month-month for
month-month for character
for character year
character year format
have those basic
those basic functions
basic functions in
functions in place
can now change
now change the
change the other
the other parts
of functions we're
let's look first
look first at
first at the
at the ResetForm
the ResetForm function
function which blanks
which blanks out
blanks out the
out the form
the form ready
form ready for
ready for the
user to start
to start entering
start entering data
entering data into
into a brand
moment has entries
has entries for
entries for text
for text, dropdown
list and list
add on to
on to this
to this a
this a Date
a Date command
statement for Date
for Date, we're
call to one
these new functions
is the Set
the Set a
a Date function
Passing it 3
it 3 parameters
3 parameters, the
the Date box
Date box and
we're passing what
passing what the
current date actually
date actually is
So when a
a user goes
user goes to
goes to fill
to fill in
fill in a
new form, the
the date will
date will be
be pre-populated for
pre-populated for the
next function we're
to be changing
be changing is
changing is the
is the GetFormData
function that gets
that gets all
gets all the
form the user
has actually filled
actually filled in
function has entries
text boxes, dropdown
dropdown lists or
lists or list
or list boxes
control to this
And this Date
Date control is
use the Get
the Get a
Date function we
want to amend
to amend is
amend is the
is the FillFormWithRecord
function that populates
that populates the
populates the data
data on the
from the FormData
the FormData array
a user is
user is browsing
is browsing through
browsing through the
of forms already
forms already filled
already filled in
filled in, we
can pull the
pull the date
date of that
of that CSV
that CSV file
file and populate
populate the Date
Date control accordingly
This as before
as before has
before has a
number of entries
of entries for
entries for each
types of controls
new control here
control here, which
But to make
make the code
the code a
to follow, we're
to remove some
remove some of
of these parse
these parse commands
parse command is
command is done
is done on
done on each
the controls, so
do that up
that up front
up front at
front at the
variable called 'value'
value going to
to be put
into the field
the field in
field in question
And inside our
inside our For
Next loop, we're
set that value
that value, which
be the parse
can now replace
now replace these
replace these parse
parse commands with
commands with the
with the str
value variable, making
making the code
our entry for
is not set
not set, then
going to default
the current UK
current UK date
Date function to
we test our
test our application
few more minor
more minor changes
minor changes we
changes we want
make to tidy
to tidy up
tidy up some
up some code
the things we
things we do
we do when
do when the
user presses the
button is we
is we save
we save the
form data to
and then dump
then dump it
dump it out
So the CSV
file is always
is always up
always up to
up to date
is a call
of our common
our common functions
common functions, the
the ArrayDump function
This function does
function does have
have an optional
an optional parameter
This optional parameter
optional parameter is
parameter is either
defaults to false
we make this
make this optional
optional parameter true
parameter true, it
it will ensure
will ensure that
ensure that no
that no blank
no blank records
blank records are
records are actually
are actually saved
actually saved to
This will prevent
will prevent any
prevent any empty
any empty forms
empty forms being
forms being saved
being saved to
to the pb_main
pb_main function, we're
we're making a
making a call
call to populate
number to the
And by default
by default adds
default adds a
adds a blank
blank record to
record to the
This means every
means every time
every time you
time you run
you run the
the moment, it
it adds a
blank form to
you don't make
don't make any
make any changes
any changes, it
will be continually
be continually adding
continually adding blank
adding blank forms
blank forms to
forms to the
amend this, so
so only add
only add one
add one when
one when the
when the last
array is not
This is performed
is performed quite
performed quite easily
easily by picking
up the maximum
the maximum form
maximum form number
form number, checking
number and we
and we extend
we extend the
extend the size
I also want
add an icon
at the show_dialog_main
the show_dialog_main function
show_dialog_main function, this
dialog is defined
And before we
use a dialog
a dialog set
dialog set icon
set icon command
dialog with our
with our app
our app icon
The next change
next change we're
change we're going
make is in
in the run_control_process
the run_control_process function
for our dynamic
our dynamic dialog
In here, when
actually selected to
selected to save
the form, we
we call a
call a number
to validate the
validate the form
form and then
then to save
Assuming the form
form data has
successfully saved, we
we reset the
The reset_deform function
reset_deform function is
is what blanks
what blanks out
users may well
well be editing
be editing data
editing data in
data in forms
in forms they
forms they have
they have already
have already filled
logic slightly here
slightly here to
here to support
We'll remove the
remove the call
We'll then do
then do a
last form in
in the series
number is equal
the array, then
know we're on
can then increment
then increment the
number and redimension
and redimension the
redimension the array
form number on
number on the
dialog to be
be that form
ahead and set
this should be
the changes needed
changes needed to
needed to our
running it now
it now to
it's gone straight
gone straight to
straight to form
number So we're
So we're sitting
we're sitting on
form number 1
If we amend
amend the start
start date to
date to the
to the 27th
the 27th and
27th and click
and click OK
click OK to
OK to save
should have saved
have saved the
saved the form
the form into
form into the
into the CSV
if it's picked
it's picked up
up that change
So there's form
number 1 sitting
1 sitting with
sitting with the
with the So
the So we
populated the start
start date for
date for form
for form number
a new field
new field, although
although each of
the forms has
forms has the
has the new
the new date
new date in
date in it
in it, it's
it's because that's
because that's the
that's the default
ahead and click
OK on each
now see an
see an updated
an updated value
updated value for
value for each
of those entries
They're all sitting
all sitting as
sitting as the
as the 18th
is the current
number 1, move
move forward to
forward to form
form number 2
number 2 and
2 and we'll
and we'll change
we'll change its
change its date
we'll say we'll
say we'll pick
pick the 30th
the 30th of
30th of November
of November and
November and we'll
form number 3
3 and then
and then back
It's quite correctly
quite correctly showing
correctly showing as
as the 30th
we can still
can still go
still go to
is a blank
blank form allowing
form allowing you
you to fill
You can add
add additional blank
additional blank forms
blank forms, but
but although we
have a ninth
a ninth form
ninth form on
form on the
screen here, if
at our CSV
CSV file, we'll
see it only
it only is
only is showing
is showing 8
showing 8 records
So blank records
records are now
are now no
no longer being
longer being saved
CSV file, leaving
leaving the file
the file quite
file quite intact
have added the
added the option
option of a
of a date
allows the date
be set by
set by the
user or updated
or updated for
updated for an
for an existing
an existing form
The date is
date is then
is then pushed
then pushed out
pushed out to
to the saved
the saved CSV
saved CSV file
we can navigate
can navigate through
through the forms
the forms showing
forms showing the
showing the correct
the correct date
correct date on
date on each
on each form
We've also tidied
also tidied up
tidied up some
up some of
so that blank
that blank forms
blank forms are
forms are not
not being saved
And additionally, we've
we've added an
added an icon
will look to
look to do
video is add
is add the
ability to display
display the output
in this grid
this grid format
grid format we
format we see
would allow the
to see at
see at a
a glance what
glance what had
what had been
had been entered
been entered for
entered for all
adding a form
a form summary
form summary in
summary in a
in a given
a given format
an application run
application run by
run by Configuration
by Configuration File
to specify both
specify both the
both the layout
the layout and
layout and the
and the functionality
functionality of our
our dialog in
dialog in an
in an external
external file to
can create additional
create additional applications
additional applications by
applications by merely
by merely creating
merely creating new
creating new configuration
new configuration files
We have navigation
have navigation buttons
our dialog, allowing
has actually saved
the application currently
application currently that
currently that allows
that allows the
user to view
to view all
view all the
the forms at
forms at one
add an additional
an additional navigation
additional navigation button
navigation button at
the forms currently
forms currently created
currently created in
in a grid
a grid format
create a Grid
a Grid icon
Grid icon at
need a new
So I've copied
I've copied in
copied in two
in two icons
two icons, a
Grid icon to
icon to be
be used on
used on the
main dialog to
dialog to allow
click upon it
upon it, and
and a Cancellation
a Cancellation icon
Cancellation icon which
icon which is
be on a
new dialog will
dialog will contain
contain the Grid
the Grid, which
which will list
will list all
list all the
already entered into
we'll now reference
now reference these
reference these in
these in code
We'll add new
add new constants
new constants in
constants in, one
for the cancellation
the cancellation and
cancellation and one
Having added these
added these, we
will add additional
add additional resource
additional resource statements
resource statements to
statements to bring
to bring both
bring both of
both of those
of those icons
those icons into
icons into the
display the icon
we will position
will position this
position this new
this new icon
new icon to
side of all
all the existing
the existing buttons
set this icon
this icon up
icon up the
same way we
way we have
have the others
the others using
others using the
new button at
the top navigation
top navigation bar
be the one
using to launch
to launch our
launch our new
moment this has
this has no
has no tooltip
no tooltip, so
let's add the
add the tooltip
Event handler, where
the tooltips are
tooltips are set
set up, and
the new tooltip
new tooltip to
tooltip to say
to say 'View
say 'View All
'View All Forms'
So having made
having made the
made the changes
main dialog, we
to call our
We will center
will center this
center this dialog
this dialog on
dialog on the
screen by taking
taking the DS
the DS Center
DS Center option
Center option in
And on this
this dialog we're
dialog we're going
put two objects
be a Cancellation
a Cancellation button
Cancellation button that
button that will
take us back
us back to
There will additionally
will additionally be
additionally be a
be a Grid
a Grid control
Grid control, and
of the My
Grid control as
control as a
as a static
a static link
link library, pulling
pulling it into
application to make
use of its
of its very
its very extensive
very extensive properties
added a button
button to the
We'll further enhance
further enhance this
enhance this using
if we return
we return to
will set an
an icon on
dialog itself, and
and an icon
icon on our
on our Exit
using the DialogSet
the DialogSet icon
DialogSet icon command
icon command to
add the icon
in the icon
the icon for
icon for the
the cancellation, and
also to position
position the icon
new dialog, so
there is very
is very little
very little code
little code in
in this callback
callback function at
will first add
first add the
allow the button
button click to
click to exit
exit the dialog
dialog and return
and return to
the original form
So that allows
us to enter
to enter the
enter the new
new dialog and
dialog and to
and to exit
to exit it
into the original
the original dialog
how to call
back to its
to its callback
its callback function
see in this
is already an
already an event
an event set
event set up
the Grid button
it's just a
just a message
message box, so
take that line
code out, and
application to check
to check this
check this link
we go up
go up to
hand corner, click
and our new
is appearing, with
with the Close
the Close Grid
Close Grid button
Grid button at
on that, it
our original dialog
So all good
all good so
good so far
grid on our
do that we
need to plug
to plug in
plug in the
the MyLittleGrid static
MyLittleGrid static linked
static linked library
are three files
three files we
files we need
need to bring
to bring into
bring into our
into our code
The MyLittleGrid include
MyLittleGrid include file
include file, the
linked library, and
and finally our
finally our library
our library file
library file, the
the MyLittleGrid lite
MyLittleGrid lite utilities
lite utilities include
utilities include file
add this include
this include library
library to the
a constant to
set to 1
to 1 to
1 to let
let the system
the system know
system know that
to use MyLotoGrid
use MyLotoGrid as
MyLotoGrid as a
a static linked
linked library as
library as opposed
to a DLL
We then include
then include the
include the encode
the encode file
encode file from
file from MyLotoGrid
from MyLotoGrid, and
and we link
we link in
link in our
in our static
our static linked
And below that
below that we
have the include
the include for
include for our
for our utilities
our utilities library
utilities library to
library to make
to make MyLittleGrid
make MyLittleGrid that
MyLittleGrid that bit
that bit easier
bit easier to
easier to use
There's also a
also a constant
a constant and
and a global
a global I
global I want
up to make
use of our
our new grid
new grid control
So next on
next on our
on our to-do
our to-do list
to-do list is
to call an
call an initialization
an initialization function
initialization function for
function for MyLittleGrid
important to set
this up, otherwise
otherwise MyLittleGrid will
MyLittleGrid will not
will not function
So with the
with the groundwork
the groundwork complete
groundwork complete for
complete for MyLittleGrid
for MyLittleGrid we
MyLittleGrid we can
dialog and add
add the grid
set the dimensions
dimensions of the
the grid, where
where the grid
the grid appears
grid appears on
on screen, X
My coordinates, and
how wide and
wide and how
and how tall
how tall the
tall the grid
grid is going
added a string
string variable called
variable called menu
called menu which
menu which we
will use later
use later if
later if we
want any right
any right click
right click menus
click menus on
menus on our
on our grid
Below that is
is the actual
actual control add
add statement which
statement which adds
which adds the
adds the grid
grid to the
uses the constant
set up earlier
up earlier, MLGGrid1
and has a
These parameters at
parameters at the
moment are just
are just setting
just setting some
setting some defaults
some defaults which
defaults which we
we will override
will override later
override later on
later on, for
example the number
Next we are
we are capturing
are capturing the
capturing the Windows
of our grid
our grid control
using a macro
macro to set
the remaining parts
remaining parts of
parts of our
This saves a
saves a fair
in here which
new function we'll
to create in
a moment to
moment to get
the form title
This will pull
will pull out
file the title
form and will
and will display
will display it
the tab of
follow the format
the format we
format we have
we have followed
have followed in
followed in previous
previous videos on
videos on this
on this project
So I won't
I won't go
won't go into
into this in
this in any
in any great
any great detail
great detail as
detail as it's
as it's covered
it's covered in
covered in the
We're looking through
looking through the
through the configuration
We're primarily interested
primarily interested in
object column is
column is a
is a title
a title we're
title we're pulling
we're pulling out
text column the
text that's in
that's in that
in that column
Additionally we now
populate these two
two variables, long
long rows and
rows and long
and long columns
know the number
of rows in
rows in our
our global grid
global grid which
grid which contains
which contains all
all the form
form data we
quite easily work
easily work out
out the number
do something similar
something similar with
similar with the
with the columns
our dialog configuration
dialog configuration we're
configuration we're going
put some new
new variables in
column headers, one
for the columns
columns and one
for the rows
populate the column
column headers with
headers with a
function called getColumnNames
count the columns
column headers as
headers as it's
it's a comma
comma delimited list
And we'll count
we'll count the
of rows as
rows as the
as the upper
our form data
new function getColumnNames
Again in the
way as the
as the previous
previous function it's
function it's looking
it's looking inside
looking inside the
configuration file again
name column and
And we're principally
we're principally interested
principally interested in
interested in all
in all configuration
all configuration that
configuration that isn't
that isn't a
isn't a button
And also where
also where the
where the field
name is not
is not equal
equal to a
to a blank
a blank space
set the name
name of all
the fields that
fields that are
to be exported
be exported to
exported to the
CSV file, the
on our icon
our icon we'll
icon we'll see
see we're now
getting a grid
grid displayed on
The grid has
grid has the
has the correct
the correct number
correct number of
and the correct
yet populated the
populated the column
column headers or
headers or the
or the data
within the rows
be our next
display the grid
the user we
user we can
can go in
in and set
set the column
set the names
the columns by
columns by calling
by calling one
calling one of
My Little Grid's
Little Grid's library
Set column names
grid and the
the column delimited
column delimited list
delimited list of
list of our
of our column
our column headers
we will colour
will colour bank
colour bank the
bank the grid
grid rows, alternatively
alternatively white and
white and green
finally we will
call the GridRefresh
the GridRefresh function
GridRefresh function which
now and then
and then click
then click on
now have all
the headers correctly
headers correctly shown
correctly shown on
Plus additionally each
additionally each alternate
row is colour
is colour coded
So now all
populate this grid
this grid with
grid with our
with our actual
our actual data
to declare three
declare three new
three new variables
be an array
array and two
and two to
two to be
to be long
be long variables
Next in our
called Populate the
Populate the Grid
the Grid array
data we have
global array holding
array holding the
holding the form
will take this
take this and
this and put
dimensional array, which
which is suitable
is suitable for
suitable for putting
for putting straight
putting straight into
into our My
new function Populate
function Populate the
the Grid handle
Grid handle and
our new array
new array, the
the two dimensional
populate the two
dimensional array for
the grid from
grid from the
quite easily pick
easily pick up
up the number
of columns from
columns from there
adding an additional
an additional column
additional column on
column on the
ID column is
column is not
is not held
not held within
global array, but
want it visible
it visible as
visible as a
a number in
in our grid
entries in our
And our very
be the form
And then for
then for the
for the remaining
the remaining of
remaining of the
columns we're pulling
we're pulling the
information out using
out using a
we're putting it
of our two
our two dimensional
two dimensional grid
So since this
since this function
function will populate
populate a two
dimensional array, how
do we put
put that two
that two dimensional
dimensional array directly
array directly into
directly into our
into our grid
grid on screen?
on screen? Immediately
screen? Immediately after
Immediately after that
after that new
is called, we're
one of My
of My Little
Little Grid's own
Grid's own functions
own functions, the
the MLG Put
MLG Put EX
Put EX command
This routine takes
routine takes four
being the Grid
the grid containing
grid containing the
the grid, in
case a two
next is an
an option number
using option number
option number four
number four as
four as we
to overwrite the
overwrite the column
The second value
second value is
value is a
is a refresh
We're leaving this
leaving this as
this as zero
as zero for
zero for the
we left this
left this as
this as one
as one, this
this would refresh
would refresh the
the grid immediately
are three more
three more routines
more routines we
routines we want
call the Widen
the Widen Columns
Widen Columns in
Columns in Grid
in Grid function
Grid function, which
in our own
our own My
own My Little
This takes an
takes an optional
optional parameter, which
which is excludeColumn
want to exclude
to exclude column
exclude column number
number one from
one from this
is it sets
sets the width
within the column
It also takes
also takes into
takes into effect
into effect the
effect the width
width of any
of any headers
any headers, so
so the column
will be wide
be wide enough
wide enough to
enough to accommodate
to accommodate both
accommodate both data
both data and
data and header
We're excluding column
excluding column one
column one as
one as we
want that to
be fixed width
we're calling will
calling will mark
mark the entire
entire grid as
grid as read-only
the project, we
to actually amend
actually amend the
amend the grid
command is a
a command that
command that refreshes
that refreshes the
refreshes the grid
on the icon
the icon, we
on screen of
screen of all
ID column, the
and the start
will see, clicking
the grid, or
select a box
a box, you
you cannot edit
cannot edit it
new dialogue to
dialogue to our
has the sole
purpose of displaying
of displaying in
displaying in a
grid format all
format all the
the data the
data the user
has entered in
entered in in
in in each
allows the majority
to be seen
be seen at
seen at any
Using the My
Grid control gives
deal of functionality
can make use
use of later
of later on
later on, with
amount of effort
by adding tick
adding tick boxes
tick boxes to
boxes to the
previous videos in
videos in this
this series we
series we have
created two applications
first application has
application has its
has its task
its task of
of displaying to
displaying to the
user a list
list of configuration
of configuration files
screen here we
have a first
a first and
and second form
second form on
configuration files has
files has within
has within it
within it a
of objects, for
text boxes, drop
down lists etc
definition of all
of all these
these objects is
objects is used
used to dynamically
to dynamically build
dynamically build a
build a dialogue
a dialogue using
dialogue using our
using our second
our second application
Form button, the
the second application
second application runs
This reads the
reads the configuration
file and displays
and displays the
the form layout
form layout to
layout to the
application is completely
completely generic, driven
entirely by its
by its configuration
its configuration file
see here we
of data forms
data forms which
forms which a
held in all
in all the
new dialogue without
dialogue without having
having to do
do any coding
any coding at
coding at all
a new configuration
new configuration file
new object to
of objects you
objects you can
you can configure
can configure in
configure in these
in these files
create a tick
tick box or
box or check
or check box
check box object
wish to amend
amend the AutoForms
AutoForms application to
application to add
support for a
for a new
the dialogue, there
functions that will
that will need
to be updated
going to list
to list at
list at the
this code the
code the functions
functions that we
in this way
way if you
to add any
more controls yourself
controls yourself to
yourself to this
to this application
this application you
application you know
you know which
know which functions
which functions need
functions need to
of the five
the five functions
five functions we're
Full form with
with record, get
form data, populate
populate form, reset
reset form and
form and validate
and validate form
these functions one
functions one by
one by one
by one, adding
adding in support
in support for
support for our
for our check
our check boxes
check boxes or
boxes or tick
or tick boxes
we start amending
start amending the
amending the code
amend the test
add two entries
two entries to
entries to the
this dialogue we'll
dialogue we'll want
we'll want two
want two new
label and our
and our tick
our tick box
Since we want
want the label
label to turn
to turn red
turn red if
red if it's
it's a mandatory
a mandatory field
mandatory field, then
want to keep
to keep this
keep this separate
this separate from
separate from the
from the label
on the tick
will add first
add first of
all our label
will be supported
be supported because
supported because we've
because we've done
we've done other
done other labels
other labels before
A label in
label in this
the words full
words full time
time staff and
staff and a
and a question
a question mark
setting the X
to position it
position it on
the dialogue, 20
20 by 160
setting the width
and height to
Additionally we're setting
the ID number
ID number as
number as 2012
as 2012, making
making it unique
it unique from
unique from all
from all the
the other objects
other objects Next
objects Next we
add our tick
is an object
an object we
object we have
not yet supported
yet supported within
supported within our
So its object
its object name
object name, in
this case tick
case tick box
tick box, has
to be unique
on screen 75
screen 75 by
75 by 157
by 157, its
and height by
height by 15
by 15 by
15 by 15
Again its ID
its ID needs
ID needs to
be unique so
unique so we're
we're setting that
setting that as
that as 2013
fields we want
want to export
to export to
export to our
our output CSV
calling that column
that column full
column full time
the end we're
end we're putting
putting a tool
Tick to record
to record as
record as full
as full time
middle of this
of this I've
this I've got
I've got a
got a pipe
a pipe character
This pipe character
pipe character is
character is used
used to fold
fold the tool
tool tip in
tip in half
Basically I'd carriage
I'd carriage return
carriage return -
return - line
- line feed
line feed within
feed within the
within the tool
this and if
see the full
time staff question
staff question mark
question mark label
mark label appears
label appears on
is because labels
because labels are
labels are already
are already supported
But the tick
tick box entry
box entry has
entry has done
has done nothing
done nothing to
nothing to our
our dialog because
dialog because we
because we do
not currently support
currently support tick
support tick boxes
go into these
into these functions
these functions and
functions and make
and make amendments
So lets look
lets look at
at the first
first function, fill
function in which
which we look
at the objects
the objects, be
be they text
they text, drop
down lists, list
new entry to
entry to the
of this to
to handle tick
handle tick boxes
this particular scenario
particular scenario we're
scenario we're going
tick box having
box having two
having two values
two values, either
either ticked or
ticked or unticked
of the ticked
the ticked one
ticked one as
one as one
as one and
of the unticked
the unticked as
unticked as zero
the value variable
value variable already
variable already holds
already holds that
holds that value
that value we
value we merely
Because of the
of the value
value within this
within this variable
a string holding
string holding the
holding the value
value 1 we
1 we can
set the checkbox
the value ticked
value ticked using
ticked using the
it is anything
other than one
one then we'll
then we'll set
we'll set it
set it as
as zero which
which is unticked
will tackle our
tackle our second
second function, the
As before the
before the object
object is tested
is tested and
tested and we're
we're doing conditional
doing conditional work
conditional work depending
work depending on
depending on the
this list another
list another key
another key statement
key statement to
check command to
in our control
for the control
have done previously
this to a
called long data
we'll set str
set str data
str data to
to the string
the string version
string version of
version of that
of that variable
to declare long
declare long data
long data at
data at the
And with that
with that change
that change in
change in place
would be populate
be populate form
one that actually
that actually draws
actually draws the
draws the control
series of case
case statements handling
statements handling each
of the different
the different types
new one for
one for tick
for tick boxes
this case I'm
case I'm just
I'm just setting
just setting these
setting these to
these to be
be the standard
the standard defaults
standard defaults for
defaults for the
add statement to
statement to add
a new check
new check box
check box to
And of the
of the parameters
parameters we need
need to supply
to supply will
supply will be
be the x
coordinates of it
of it on
the variables that
variables that hold
that hold the
the style values
done before for
the other types
we've handled that
handled that function
function we move
form function that
function that blanks
that blanks out
blanks out all
is another series
another series of
case statements and
statements and we
and we merely
statement for our
for our tick
that particular tick
particular tick box
tick box to
box to not
to not ticked
And on to
to our final
final function, the
one that's used
that's used to
used to validate
to validate data
validate data on
And again there's
again there's another
there's another series
series of key
of key statements
The validate form
form function is
designed to check
objects are set
set as mandatory
as mandatory in
mandatory in your
in your configuration
your configuration file
If an object
an object is
object is mandatory
is mandatory and
mandatory and it
not been selected
been selected then
selected then the
then the application
application will not
not allow the
user to proceed
to proceed and
proceed and will
error message on
on screen highlighting
screen highlighting in
highlighting in red
in red the
red the label
label for that
for that object
the tick boxes
tick boxes we're
getting the value
in the check
the check box
check box by
zero then str
then str data
data is blank
Otherwise we're marking
we're marking str
marking str data
str data as
data as number
as number one
code that will
that will return
field value and
value and display
display the message
the message to
user that a
that a mandatory
mandatory field has
field has not
using a long
a long data
long data again
data again we'll
again we'll need
declare this at
we've made all
made all the
changes to these
to these functions
these functions have
functions have we
have we done
we done enough
enough to allow
to support tick
Well we now
objects on a
on a screen
a screen a
screen a label
label saying full
saying full time
and a tick
tick box ready
box ready to
to be ticked
our forms and
forms and tick
and tick the
tick the first
at the grid
the grid we'll
grid we'll see
have a full
a full time
full time column
time column but
not yet got
yet got any
got any values
any values within
values within it
So there's more
there's more to
be done to
done to populate
populate this last
this last column
So let us
let us have
us have a
code that populates
that populates this
populates this grid
displays this grid
this grid to
user on a
a dialogue are
dialogue are a
number of key
of key pieces
pieces of code
the things this
things this will
read the headers
headers in the
in the output
moment the headers
headers in our
output file are
file are incomplete
data CSV at
CSV at the
does not have
not have the
that up in
in notepad and
notepad and we
the new column
new column and
column and save
an application again
application again now
again now and
now and have
the grid dialogue
grid dialogue we'll
in the full
time column for
column for our
As we designated
we designated the
designated the value
value one for
one for ticked
for ticked and
ticked and zero
and zero for
zero for unticked
for unticked this
unticked this is
this is showing
showing a one
to our second
our second form
and we save
we save it
save it once
more and have
at our grid
our grid we'll
value is showing
showing as zero
The rest are
rest are blank
are blank because
blank because we
not yet re-saved
yet re-saved those
re-saved those forms
useful to see
to see a
see a one
or a zero
for a ticked
a ticked or
would be really
be really much
really much more
much more aesthetically
more aesthetically pleasing
aesthetically pleasing to
pleasing to have
have an actual
an actual tick
actual tick box
tick box in
box in the
However my little
little grid which
grid which we're
currently using can
using can define
can define one
define one of
these columns as
being a checkbox
a checkbox column
would be displayed
be displayed as
displayed as a
as a checkbox
a checkbox with
checkbox with either
with either a
either a tick
tick or no
or no tick
no tick in
tick in the
in the box
can we configure
we configure our
configure our setup
our setup to
setup to display
display this column
this column as
this grid dialogue
grid dialogue to
the user we'll
user we'll need
want to designate
to designate any
designate any of
the columns which
columns which are
which are defined
are defined as
defined as tick
as tick boxes
boxes to display
to display as
display as tick
tick boxes on
to slot this
slot this new
function in after
in after the
after the set
the set column
column names function
Like that function
that function our
function our new
new function setGridTickBoxes
function setGridTickBoxes is
setGridTickBoxes is going
list of headers
of headers that
headers that appear
that appear at
Enter here is
and the string
string of column
of column headers
be used within
file will define
will define which
define which of
dialogue is a
is a tick
at the object
to see any
see any of
any of those
which are marked
are marked as
marked as tick
column headers define
headers define the
the fields as
fields as they're
as they're going
be on our
This appears in
at each record
each record which
record which has
which has something
has something in
name column to
any of them
them have tick
have tick box
get the column
populating the field
name column variable
column variable using
the standard headers
standard headers and
headers and is
return the column
the column numbers
column numbers of
numbers of both
through our variable
our variable column
variable column headers
how many of
many of these
of these headers
these headers there
headers there actually
there actually are
up the header
the header name
header name for
name for that
for that column
that column using
column using the
got the header
header name we
name we need
So another For
Loop we can
matches our header
this does match
does match then
found a field
a field we're
field we're looking
But is it
it a tick
a tick box?
tick box? So
box? So now
check the object
if the object
column is tick
is tick box
tick box then
box then we
field which is
indeed a tick
configure the grid
grid to tell
tell it that
of the inbuilt
the inbuilt commands
inbuilt commands to
commands to my
grid to format
to format a
format a column
a column as
as a check
a check box
check box in
box in a
in a single
And that function
function is MLG
is MLG format
MLG format call
format call check
the column which
column which we
want to turn
to turn into
turn into a
into a check
As each entry
config array is
array is unique
is unique then
unique then we
we need not
need not look
not look through
can then move
then move on
the next header
using the iterate
the iterate for
iterate for command
This will skip
will skip forward
skip forward to
forward to look
the next For
next For Loop
Even if we
if we discover
we discover that
discover that the
that the field
not a tick
can use just
use just iterate
just iterate for
this function should
function should be
enough to designate
designate the columns
which are tick
are tick boxes
tick boxes as
boxes as tick
tick boxes within
boxes within the
our icon to
icon to view
forms in the
grid we can
time column is
column is appearing
is appearing as
appearing as a
as a tick
But forms 1
forms 1 and
1 and forms
and forms 2
forms 2 are
2 are showing
are showing as
showing as being
as being ticked
at form 1
form 1, form
form 1 is
1 is ticked
is ticked and
ticked and form
and form 2
form 2 is
2 is not
So there's obviously
there's obviously some
obviously some additional
some additional change
make to make
value going in
going in to
grid is correctly
is correctly interpreted
see what else
what else we
else we need
The reason my
reason my little
little grid is
grid is displaying
is displaying both
displaying both ticked
both ticked and
ticked and unticked
and unticked check
unticked check boxes
check boxes as
boxes as ticked
as ticked in
ticked in the
grid is the
is the way
way the data
data is held
held within my
within my little
Its definition of
definition of a
of a ticked
a ticked check
ticked check box
check box is
box is if
is if the
value is something
other than an
than an empty
length string is
string is unticked
is unticked and
unticked and anything
and anything else
anything else is
else is ticked
modification to our
to the getFormData
the getFormData function
getFormData function which
function which pulls
which pulls the
pulls the information
off the form
filled in and
in and saves
saves it in
Currently for the
tick box we're
box we're just
we're just picking
just picking up
picking up strData
up strData as
strData as the
value that's coming
that's coming out
If we replace
we replace that
with a test
if the data
the data equals
data equals 1
equals 1 then
1 then strData
then strData equals
strData equals 1
Otherwise it's going
an empty when
empty when string
to our first
form we will
that the first
first form is
form is ticked
second form is
form is not
at the my
little grid we'll
see the first
ticked and the
second one now
one now is
now is not
go into form
into form number
3 and tick
and tick that
tick that one
the save go
save go back
see that now
that now 1
now 1 and
1 and 3
and 3 are
3 are now
are now successfully
now successfully ticked
of object to
to the objects
the objects which
objects which can
which can exist
can exist on
exist on our
on our dynamically
our dynamically configured
dynamically configured dialogue
checkbox or tick
or tick box
As with all
with all other
all other objects
other objects we
objects we can
can define where
define where it
it is located
is located on
located on the
can also display
also display it
tick box on
box on our
on our my
little grid dialogue
grid dialogue which
dialogue which displays
which displays all
the forms on
forms on one
on one page
a good selection
good selection of
selection of objects
of objects that
objects that can
that can appear
can appear on
on your configurable
your configurable forms
having to write
write a single
will start our
start our project
project to explore
to explore designing
explore designing our
designing our own
number of very
of very well
very well established
well established web
established web browsers
web browsers in
browsers in circulation
It's not the
not the purpose
this project to
project to supplant
to supplant any
supplant any of
What we're intending
we're intending to
intending to do
is to produce
to produce our
produce our own
be as much
as much about
much about the
about the journey
the journey as
journey as it
is the destination
It's intended to
intended to be
be a learning
a learning exercise
learning exercise, to
to learn as
learn as we
we go, what
what is a
is a web
a web browser
web browser and
browser and how
and how it
So since a
since a web
web browser is
browser is a
is a client
a client application
client application running
application running on
running on a
on a computer
a computer, we
create the client
the client application
are currently sitting
currently sitting inside
sitting inside Power
inside Power Basic
Power Basic Forms
Basic Forms Designer
Forms Designer, where
to design the
design the form
user will interact
will interact with
a form which
form which we're
to centre on
centre on screen
this as thick
as thick frame
thick frame, which
which means it
be a resizable
a resizable window
give a caption
a caption and
caption and a
and a system
a system menu
able to minimise
to minimise it
minimise it as
we will centre
will centre it
centre it on
web browser will
browser will not
will not have
not have a
have a great
great deal in
deal in the
way of controls
of controls on
status bar, which
we'll just blank
just blank out
out the caption
the caption on
caption on that
up a toolbar
a toolbar or
toolbar or some
or some buttons
some buttons at
the tasks of
tasks of a
of a browser
a browser is
forwards in their
in their list
their list of
list of HTML
of HTML files
HTML files displayed
files displayed on
add a number
number of image
of image buttons
image buttons to
to go backwards
go backwards, forwards
reload the current
the current page
current page and
page and also
also to go
to a home
a home page
always add more
more functionality as
functionality as we
we go along
Another feature of
feature of current
of current Web
current Web Browsers
Web Browsers is
Browsers is the
to display more
display more than
than one page
one page inside
page inside the
inside the client
This is usually
is usually done
usually done in
series of tabs
add a tab
a tab control
tab control to
control to allow
our dialogue that's
dialogue that's going
to have all
the work done
work done on
done on it
on it will
be a graphics
So these initially
these initially are
initially are the
are the controls
the controls we
controls we will
will have on
So let's save
let's save these
save these and
these and we'll
we'll go back
add another library
another library to
to display tooltips
display tooltips to
tooltips to the
This means when
hovers over a
over a control
a control, a
a little tool
little tool tip
tip will pop
will pop up
pop up to
up to tell
user what the
what the control
control is for
of tabs we'll
tabs we'll need
we'll need something
need something to
something to keep
tab handles and
handles and the
and the pages
the pages we
pages we have
have actually stored
actually stored on
stored on screen
couple of global
of global variables
global variables to
we'll call these
call these tab
these tab count
tab count to
tabs in use
in use and
use and tab
and tab handles
tab handles as
handles as an
hold the handles
handles of each
of our tabs
our application we've
application we've got
got a number
number of named
of named constants
These to keep
status bar, our
tab control, our
text box for
box for which
for which we're
which we're allowing
we're allowing the
to key in
key in a
in a URL
and four buttons
four buttons for
for image buttons
One for back
for back, one
one for forward
for forward, one
one for reload
for reload and
reload and one
one for home
finally our graphics
our graphics area
graphics area where
area where we're
to be drawing
be drawing our
drawing our HTML
to do dynamic
do dynamic redrawing
dynamic redrawing of
redrawing of the
the screen when
the user maximizes
user maximizes or
maximizes or changes
or changes the
changes the size
We'll cover what
cover what each
of these parts
these parts does
parts does when
does when we
point of resizing
of resizing windows
Next as we
have four buttons
four buttons on
buttons on our
on our client
our client application
client application we
application we want
we want some
want some image
some image to
image to display
number of icons
application itself and
itself and also
for the home
home button, a
a back button
back button, a
a next button
next button and
button and also
a small magnify
small magnify button
magnify button to
to put on
put on the
on the redraw
the redraw button
use the resource
the resource icon
resource icon command
to pull these
pull these into
these into the
application itself at
itself at compile
As we created
created our dialogue
our dialogue in
forms designer it
designer it has
it has created
has created a
created a resource
a resource at
resource at the
the application loading
application loading in
loading in a
in a PBR
Now I'm going
to comment this
moment and all
really need is
is a manifest
put a manifest
a manifest command
manifest command in
command in at
for the XP
the XP theme
Another thing we'll
thing we'll be
we'll be wanting
wanting to use
to use in
use in our
browser is one
is one or
or more fonts
a global font
global font first
font first of
all to be
be our default
application called font
called font and
font and this
will hold a
hold a handle
a handle to
to our font
we show this
show this first
this first dialogue
first dialogue to
the user we're
user we're going
our font within
font within the
application itself by
itself by declaring
by declaring a
declaring a local
variable to set
set the point
point size and
size and then
use the font
the font new
new command allows
you to name
name the font
the font we're
font we're going
be using Courier
using Courier new
Courier new and
new and we'll
we'll set its
set its point
its point size
point size as
size as 12
as 12 point
point and the
this command goes
command goes to
goes to populate
populate the hfont
hfont variable we
variable we set
once our application
application has been
has been closed
been closed down
closed down we'll
down we'll do
do a tidy
a tidy up
tidy up to
up to delete
delete the memory
the memory used
memory used by
by the font
PowerBasic should do
should do this
this for you
for you at
you at the
the end anyway
end anyway but
anyway but it's
practice to clean
to clean up
clean up after
up after yourself
we will name
will name our
name our dialogue
our dialogue as
dialogue as pb
as pb lite
pb lite browser
go and look
display our browser
browser to the
have the function
create and display
and display our
We've placed a
placed a piece
of text pb
text pb lite
lite browser in
browser in the
title of our
our dialogue and
and our dialogue
our dialogue has
dialogue has all
all the properties
the properties to
properties to allow
user to both
to both maximize
both maximize it
maximize it, minimize
minimize it and
it and resize
and resize it
We've added the
added the status
status bar, a
url and we
four buttons, four
four image buttons
One for going
for going back
going back, one
to allow tabs
allow tabs to
tabs to appear
What we haven't
haven't added yet
added yet is
yet is our
control and we
will set our
set our graphics
control up next
set it for
it for 600
for 600 wide
These are dialogue
are dialogue units
dialogue units and
units and we
this before the
before the graphics
the graphics show
graphics show command
show command is
these are placed
are placed on
the dialogue before
dialogue before the
before the dialogue
dialogue is displayed
control add graphic
add graphic command
graphic command to
command to place
to place our
place our graphic
have to tell
to tell Power
tell Power Basic
do a graphics
Basic which graphics
which graphics control
control that all
all subsequent graphics
subsequent graphics commands
This is necessary
is necessary even
necessary even although
even although we
although we only
have one graphics
attach command and
command and we're
using the redraw
redraw option to
option to ensure
ensure that nothing
that nothing is
nothing is drawn
is drawn to
until we are
we are quite
are quite ready
see what space
what space our
space our graphics
graphics control was
control was actually
was actually taking
actually taking up
taking up on
the dialogue, we're
going to color
to color it
color it in
it in in
in a solid
a solid color
command to perform
control and set
background to black
to black in
black in color
our dialogue on
the four buttons
four buttons, we
not yet named
yet named and
named and we
control which takes
which takes up
up the remainder
remainder of our
is the basics
the basics, the
the beginnings of
beginnings of our
look at populating
at populating our
populating our image
our image buttons
use a series
series of control
of control set
control set image
set image button
image button commands
are to specify
specify the image
the image that's
image that's to
that's to be
be used with
used with each
of our buttons
are the resources
the resources we
resources we created
created earlier on
earlier on starting
on starting with
starting with 2000
with 2000 and
2000 and going
and going up
going up to
up to 2003
So let's run
application again and
see if these
if these images
these images have
images have been
have been brought
been brought in
brought in correctly
have four images
four images on
images on the
on the four
four buttons a
buttons a back
a back, a
a forward, a
a reload and
reload and a
and a home
a home button
The image in
in the home
home button is
button is not
is not taking
not taking up
taking up the
to get around
get around that
around that you
you can either
can either recreate
either recreate your
recreate your image
your image to
be the correct
correct size or
size or you
use the image
the image button
image button X
button X command
X command which
command which will
which will stretch
will stretch the
stretch the image
the image slightly
image slightly to
slightly to fit
to fit the
fit the button
set image X
image X button
X button to
button to populate
since we're using
we're using image
using image button
button X when
X when we
create the home
the home we
home we need
to use image
use image X
image X up
X up here
up here as
here as well
code again we'll
again we'll see
that the home
now correctly populated
get the tabs
the tabs visible
tabs visible on
visible on our
on our screen?
our screen? Once
screen? Once more
event handler there's
handler there's some
there's some work
some work we
put in in
initialization section at
section at the
want to insert
to insert the
insert the initial
the initial tab
initial tab page
variable to handle
handle that and
put that at
the tab insert
tab insert page
insert page command
handle the handle
tab control the
control the tab
place on that
on that tab
output from that
from that command
that command is
command is going
populate this variable
here which we've
which we've just
of that so
that so we
we can handle
can handle when
a user changes
user changes from
changes from one
from one tab
one tab to
tab to another
read in our
array we set
handles and we'll
and we'll populate
we'll populate the
value we just
just got back
got back when
back when the
when the tab
tab insert command
insert command was
command was run
our code once
we have incrementally
have incrementally moved
incrementally moved further
moved further forward
got a tab
a tab with
the word home
word home on
home on it
For the beginning
this project we'll
project we'll be
be using just
using just one
just one tab
one tab but
tab but at
but at a
at a later
a later point
later point in
project we'll allow
we'll allow the
additional tabs allowing
tabs allowing the
to have multiple
have multiple web
multiple web pages
web pages in
dialog at the
that the focus
the focus for
focus for the
the first view
first view of
view of this
dialog is on
URL control the
control the text
quite easily do
easily do that
set focus takes
focus takes only
control you wish
to have focus
I said at
said at the
the video we
video we want
want some tool
some tool tips
tool tips appearing
tips appearing on
appearing on our
on our controls
of the tooltip
the tooltip library
of typing I'm
typing I'm going
use a prefix
prefix command is
very useful, saves
you a bit
of typing, makes
the code look
tidier and at
compile time the
time the first
the prefix, this
this part here
part here, is
is prepended to
prepended to the
each line of
code that follows
So we put
put a line
in here specifying
here specifying the
specifying the handle
code now our
now our application
application will load
will load and
load and when
when we hover
hover over the
over the text
box we get
get a tooltip
a tooltip popping
tooltip popping up
of these tool
these tool tips
But additionally I
to color these
color these tool
tool tips in
tips in to
in to make
make them more
them more visible
more visible to
quite easily as
easily as there
are two optional
optional parameters that
parameters that can
of this call
this call and
call and that
and that gives
us the two
the two colors
two colors one
colors one for
one for background
for background and
background and one
one for foreground
the application one
application one more
one more time
more time the
application should load
should load and
load and we
a tooltip in
tooltip in color
in color on
color on the
So we just
we just have
just have to
of these other
these other four
other four controls
have now five
now five controls
five controls with
controls with tool
tips on them
the back, the
the forward, the
and the reload
the reload buttons
application loads for
loads for the
first time there
time there will
will be only
be only a
only a home
home page displayed
there's no need
no need for
need for the
back and the
the forward buttons
forward buttons to
buttons to be
to be activated
we will disable
will disable them
disable them initially
them initially until
initially until we
until we load
we load an
load an HTML
the control disable
control disable command
disable command which
command which takes
wish to disable
first two buttons
two buttons are
buttons are grayed
are grayed out
grayed out and
out and tool
and tool tips
tool tips will
tips will automatically
will automatically not
automatically not appear
other buttons are
buttons are still
are still fully
still fully functional
control is currently
currently sitting with
sitting with a
with a black
a black background
for this will
this will become
will become obvious
become obvious when
obvious when I
when I attempt
I attempt to
attempt to maximize
to maximize the
maximize the dialogue
has been maximized
been maximized but
maximized but each
but each of
the controls has
controls has not
not been expanded
been expanded to
expanded to make
of the space
the space gained
space gained when
gained when the
screen is maximized
using our resize
our resize code
Still within the
handler we'll need
to handle resize
handle resize events
This event is
event is called
is called WM
called WM size
first thing is
thing is we'll
is we'll put
couple of commands
of commands in
commands in, one
one to send
one to check
if the dialogue
has been minimized
been minimized there's
minimized there's no
no point in
point in resizing
in resizing anything
resizing anything because
anything because the
user cannot see
cannot see it
call our resize
our resize function
the single function
single function within
within our resize
our resize module
we first call
first call that
call that to
to be initialized
Now we'll want
to resize some
resize some controls
some controls and
controls and we'll
perform that action
call that resize
that resize controls
resize controls and
and we'll pass
we'll pass it
pass it this
it this single
this single parameter
of our resize
our resize controls
have three controls
three controls on
all the URL
Next the tab
tab control and
control and finally
finally the graphics
text control needs
control needs to
to be expanded
be expanded horizontally
expanded horizontally as
horizontally as does
as does the
does the tab
easily by a
by a call
to our resize
The first call
first call is
call is to
is to scale
to scale horizontally
scale horizontally the
horizontally the text
text URL control
URL control and
control and we're
So they should
they should expand
should expand to
expand to the
the right as
right as the
as the dialogue
dialogue is increased
is increased in
increased in size
do our graphics
control not only
only has to
has to become
to become wider
become wider, it
it has to
to become taller
become taller as
taller as well
to be scaled
be scaled both
scaled both horizontally
both horizontally and
horizontally and vertically
So these two
two commands should
commands should allow
should allow that
allow that to
that to happen
Once you have
you have resized
have resized all
resized all the
screen we need
need to repaint
to repaint the
repaint the form
done by again
by again calling
again calling resize
calling resize but
resize but this
this time passing
time passing a
to say repaint
this now our
application will run
We can maximize
can maximize our
maximize our screen
our screen and
screen and we
is now the
now the full
the full width
full width of
dialogue as is
as is the
Now the graphics
actually been made
been made larger
made larger but
larger but it's
not obvious because
obvious because we
have not colored
not colored back
colored back in
control to set
set its background
its background color
code to prove
have indeed resized
indeed resized the
resized the graphics
that by repainting
by repainting the
repainting the graphics
graphics control as
as a black
black background and
background and then
and then giving
then giving a
giving a graphic
a graphic redraw
code now if
resize the dialogue
see the graphics
now showing that
showing that it's
that it's taking
it's taking up
taking up all
all the space
the space on
we minimize again
minimize again and
again and we
use the gadgets
the gadgets to
gadgets to make
make it wider
it wider we
wider we can
will now go
now go quite
go quite happily
But the dialogue
dialogue has a
has a minimum
minimum size it
size it will
will not go
not go beyond
beyond that minimum
that minimum size
minimum size but
size but it
will go up
up to other
to other size
other size your
size your application
your application can
application can fit
can fit on
fit on your
on your current
your current screen
we've now performed
now performed the
performed the basics
the basics of
basics of getting
of getting our
getting our browser
our browser ready
have the controls
the controls to
to navigate and
navigate and we
have a URL
a URL box
URL box to
key in either
in either a
either a URL
URL to a
a website or
website or a
or a file
a file path
file path to
path to a
a file on
file on your
on your local
your local machine
tab control currently
control currently displaying
currently displaying the
displaying the word
graphics control into
control into which
into which our
which our HTML
our HTML code
to be rendered
is the absolute
the absolute basics
absolute basics of
basics of an
of an application
an application that's
application that's going
to become a
become a web
create a very
a very simple
very simple webpage
simple webpage and
webpage and we
allow our application
load this webpage
this webpage up
webpage up and
up and render
render it on
for today thank
today thank you
support for tables
have the beginnings
beginnings of a
of a web
on screen an
screen an index
index page, and
and on there
on there we
number of images
Each image links
image links to
links to a
to a separate
a separate page
have achieved the
an image and
image and use
and use it
use it as
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
of the World
Web was to
it to display
to display information
display information to
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
work on today
to extend our
extend our browser
to support table
support table tags
our code, let's
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
a title for
title for the
for the table
the table, and
couple of columns
of columns and
and one data
one data row
at the source
the source of
source of this
of this, we'll
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
of our table
our table, followed
by two rows
two rows of
row is using
using the th
the th tag
These are column
are column headers
The second row
second row is
is a data
a data row
data row using
row using the
using the td
the td tag
extend our code
support this construct
of functionality embedded
functionality embedded in
in the table
the table tags
However today we're
today we're just
to start with
with the absolute
code is look
is look at
Inside here we
is a select
select case block
we have case
have case statements
types of tag
to add table
add table to
table to the
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
a function here
Once we reach
we reach the
reach the table
table tag, we're
to read forward
read forward to
forward to the
of the table
table tag, and
do all that
function which we're
to call build
call build table
the start variable
This variable indicates
variable indicates where
indicates where in
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
one for lower
for lower case
lower case data
data variable is
variable is going
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
We'll be stepping
be stepping through
stepping through the
through the data
data string one
string one character
one character at
character at a
need a variable
of our character
our character, and
know what our
what our last
our last command
last command and
our next command
next command are
command are for
are for other
for other nested
other nested ones
nested ones in
ones in the
of variables, much
much along the
along the same
the same lines
same lines as
lines as we
These variables will
variables will allow
track of where
we are and
are and to
and to have
have a construct
a construct which
construct which is
which is very
similar to the
previous function, the
the render engine
The approach I'm
approach I'm going
to take within
take within this
is to build
build up an
up an array
will be all
all the string
the string data
string data that's
within the table
the table construct
know how wide
wide each of
columns are to
to be within
the table, we'll
to work that
work that out
how many header
many header columns
header columns we
columns we have
we have, how
how many data
many data columns
data columns, how
rows and how
create some more
some more variables
we are when
are when we're
when we're building
building up our
up our table
our table array
get the actual
the actual data
actual data between
data between the
And then populate
populate the lower
case data variable
with the lower
the function we've
function we've created
tag value variable
will return all
return all the
data we require
we require between
require between the
table tag non-exclusive
And we'll turn
we'll turn that
turn that into
into a lower
a lower case
case version by
version by using
using the L
the L case
L case dollar
case dollar command
many columns are
columns are held
are held within
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
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
number of tr
of tr tags
Power Basic has
Basic has a
has a command
a command called
command called tally
called tally, which
used to count
count these very
these very easily
we're looking inside
inside the lower
variable to look
for the th
th tag and
value returned will
returned will be
will be stored
be stored in
header columns variable
is taken for
taken for the
data columns and
the row count
possible that some
the columns may
columns may not
may not have
not have headers
is the largest
the largest of
largest of the
header columns and
columns and we
use the max
the max command
max command to
command to work
work that one
we'll populate that
populate that in
in our column
our column count
column count variable
if the header
header columns is
columns is actually
than zero and
zero and the
row count is
count is greater
greater than two
than two, then
out the column
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
rows and number
and number of
of columns we
we can prepare
can prepare our
prepare our string
So we're dimensioning
we're dimensioning from
dimensioning from one
to the row
row count and
count and from
column count in
count in a
in a two
populate that array
that array by
array by stepping
by stepping through
stepping through our
through our data
data variable one
variable one character
the render array
So we're picking
picking up one
up one character
time and we're
populating the command
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
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
next section will
be to capture
to capture attributes
We're not in
not in this
this video going
video going to
handle attributes of
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
command for that
for that matter
to be ready
be ready to
ready to do
going to capture
capture the attributes
And this code
code is taken
is taken again
taken again straight
again straight from
storing the attributes
the attributes in
attributes in an
in an attributes
an attributes variable
attributes variable and
we're trimming them
trimming them from
them from the
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
be making use
if the character
the character we
character we picked
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
we can decide
can decide what
decide what to
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
putting it in
it in anyway
in anyway because
anyway because it
it is supposed
is supposed to
supposed to be
to be supported
to pick that
that up we're
up we're going
use a function
to the get
tag value function
value function we
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
inside the table
And the lowercase
the lowercase data
lowercase data version
data version of
new function and
and we'll come
is the existing
the existing get
existing get tag
This returns the
returns the content
content of a
tag value taking
value taking the
four parameters we
parameters we have
have just specified
It looks for
looks for the
the start position
start position, the
the ending position
ending position and
position and returns
and returns the
returns the data
in our midstring
our midstring command
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
something in that
in that handles
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
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
to reuse our
reuse our get
our get table
value function here
function here to
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
can insert it
insert it quite
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
same in the
in the TD
TD tag where
tag where we
we have data
have to increment
column and populate
populate the table
the table array
to do anything
do anything at
anything at the
do have to
do it for
for the TD
for that, incrementing
incrementing the column
column number, getting
getting the data
data and storing
and storing it
storing it in
by the end
Next Loop, we
will have gathered
have gathered all
gathered all the
information that needs
needs to go
to go in
go in to
to the table
next task would
be to display
display this table
this table information
table information onto
information onto the
onto the graphics
graphics control so
create a separate
a separate function
separate function whose
display the table
call that new
new function display
function display table
display table taking
table taking three
being a pointer
table array, followed
by the value
the caption variable
caption variable and
variable and then
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
there is indeed
indeed a header
a header in
header in the
quite possible that
that some tables
some tables will
tables will not
this new display
new display table
display table function
is the header
the header of
header of our
table function with
As we enter
we enter this
enter this new
the moment no
moment no idea
no idea how
idea how big
big the table
the table is
table is going
This will depend
will depend entirely
depend entirely on
entirely on the
within our array
the character based
character based on
on the font
font we're using
the caption, the
the entire table
entire table, the
of columns in
we'll need an
need an offset
an offset to
offset to position
position the caption
Captions are generally
are generally justified
generally justified in
justified in the
in the centre
the centre of
centre of the
our array using
array using a
using a column
column and a
a row variable
U-bound command on
command on the
on the table
is a two
dimensional array we're
array we're looking
the second dimension
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
of elements matching
elements matching the
matching the number
to store how
store how wide
each column actually
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
works out how
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
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
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
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
containing the width
width of each
with the logic
We next have
see whether we
whether we have
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
we will work
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
that by the
of characters in
characters in the
in the caption
caption width is
width is less
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
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
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
this should handle
should handle printing
handle printing captions
printing captions where
captions where captions
where captions exist
we've determined the
determined the width
each column we
can now print
now print the
print the data
be a for
determine the current
the current printing
current printing position
printing position on
on the global
each record, each
each row within
row within the
are on row
on row 1
row 1 and
and the header
the header variable
header variable is
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
of fonts already
fonts already set
set up which
up which are
which are bold
So the fifth
the fifth font
fifth font is
font is going
the standard one
standard one we're
we'll create the
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
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
and Y on
Y on our
going to test
we're on column
on column 1
are on column
column 1 we're
1 we're going
put some padding
some padding before
padding before the
So the table
the table does
table does not
not appear right
appear right at
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
that Get Previous
Get Previous Columns
we'll pass that
pass that a
that a couple
couple of parameters
the Table Columns
Columns Array and
Array and one
column we're currently
back and create
set the new
new position to
position to be
the position for
position for where
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
from our Table
Table Array the
Array the actual
actual data held
held within it
within it based
it based on
our graphics print
print statement is
statement is a
is a semicolon
a semicolon which
semicolon which will
which will tell
will tell Power
Power Basic not
Basic not to
not to go
next line because
line because we
because we may
may have more
have more columns
more columns to
columns to actually
to actually print
last column in
in a row
a row we
row we then
the header being
header being true
being true or
a header then
header then we
font to normal
to normal using
normal using our
our global handle
then to finish
to finish up
finish up we're
up we're using
a graphics print
print command to
ensure we go
next line and
line and then
and then pick
the next X
next X and
that we've finished
finished the function
display our table
our table onto
table onto our
onto our graphics
control we have
couple of functions
of functions we
we have referred
have referred to
referred to which
to which we
which we still
the Get Previous
Columns Width and
Width and one
for the width
do the Previous
Columns Width first
be a fairly
a fairly straightforward
fairly straightforward function
It's taking in
two parameters we
parameters we specified
we specified, the
array of table
of table columns
table columns and
through a simple
the column before
column before the
before the one
one we're currently
And it's adding
it's adding up
adding up the
of these table
these table columns
tell us where
us where the
the column should
column should now
should now begin
final function is
is the width
width of table
of table function
one that works
that works out
of a table
a table for
table for each
again we will
will need some
the column, the
of columns, the
and the total
the total width
total width we're
width we're going
of rows based
rows based on
the array we've
array we've been
next loop, looking
looking through each
through each column
column and each
This function makes
function makes good
makes good use
good use of
of the max
which is actually
the current row
current row or
row or the
or the column
the previous row
And then in
then in the
columns array we're
array we're also
adding two extra
two extra character
extra character spaces
allow us more
us more room
data in one
in one column
one column does
column does not
does not run
not run into
run into the
the next column
have this final
this final function
final function finished
function finished let's
finished let's try
let's try and
try and compile
and compile to
sure we haven't
we haven't missed
haven't missed anything
our application compiles
application compiles cleanly
have our browser
our browser on
browser on screen
Let's just drag
just drag in
in some data
some data from
data from one
the HTML pages
screen our table
our table at
table at the
have the caption
have the title
the title columns
title columns column
columns column one
column one column
one column two
column two and
have the data
the data underneath
data underneath it
Let's try it
try it with
it with another
with another page
another page with
page with some
with some more
some more data
have another page
another page which
page which has
has one header
one header and
header and two
and two data
two data lines
can see a
see a caption
a caption is
caption is actually
is actually positioned
actually positioned in
positioned in the
have data one
data one data
one data two
data two a
two a larger
a larger data
larger data column
data column and
and a smaller
a smaller data
smaller data column
support for table
for table tags
tag we're supporting
we're supporting the
supporting the caption
caption tag which
tag which allows
put a caption
a caption above
caption above the
above the table
We have support
have support for
th tag to
to put column
put column headers
column headers in
headers in which
in which are
which are shown
are shown in
shown in bold
column is driven
driven by the
by the data
If the column
column header is
is wider then
wider then that
then that is
the data tag
data tag is
tag is actually
is actually wider
actually wider then
then that will
be the width
the very basics
very basics of
basics of the
of the beginnings
beginnings of table
of table support
There's a great
deal more in
more in attributes
in attributes you
attributes you can
do with tables
However we will
will leave that
adding support borders
support borders to
borders to tables
light browser can
browser can now
can now display
now display a
display a web
a web page
web page and
page and on
and on that
on that web
that web page
web page we
of objects, one
one of which
is a table
video we set
we set our
set our browser
our browser up
browser up so
that it could
it could display
could display multiple
display multiple column
multiple column tables
if we display
we display this
display this web
page in a
in a standard
standard browser we
has a border
a border around
border around the
around the table
table and a
and a border
border around each
around each of
source code we
code we will
see the table
table tag has
tag has border
has border equals
border equals 1
This instructs the
instructs the browser
the browser to
browser to place
to place borders
place borders around
borders around all
around all the
all the table
the table objects
is the change
the change we're
our browser today
browser today to
to allow support
allow support for
support for bordering
for bordering of
bordering of tables
we see in
in this Chrome
this Chrome browser
Chrome browser is
browser is the
standard for border
for border equals
border equals I
equals I don't
I don't really
don't really know
really know of
know of anyone
of anyone who
anyone who actually
who actually uses
actually uses the
uses the default
the default layout
They tend to
tend to use
to use cascading
use cascading style
cascading style sheets
style sheets or
sheets or some
or some other
some other method
other method for
method for making
for making the
making the borders
the borders look
borders look a
look a little
a little tidier
as we're designing
we're designing our
our own browser
own browser we
ability to make
make our borders
our borders slightly
borders slightly different
already set some
set some of
of the groundwork
the groundwork for
groundwork for this
this by working
by working out
working out how
how large our
large our table
table is and
to build on
build on today
is to place
to place a
place a border
around the entire
And to make
make this easier
this easier we're
a new user
new user defined
defined type udt
type udt object
contain two elements
Long start and
start and long
and long end
these elements is
elements is going
be a user
defined type on
type on its
The point user
point user defined
type is inbuilt
Basic and gives
you an X
a Y long
are very useful
useful as coordinates
use these objects
these objects to
objects to define
define the start
and end x
end x and
first task today
task today is
into the function
function which actually
which actually draws
actually draws our
draws our table
our table out
table out on
function is display
is display table
This function displays
function displays the
displays the table
the table actually
table actually on
actually on the
However we're going
have to backtrack
to backtrack a
backtrack a bit
a bit back
bit back to
point where the
where the table
table is actually
is actually constructed
actually constructed in
constructed in the
in the build
the build table
build table function
have been ignoring
been ignoring the
ignoring the border
the border attribute
that handles all
is the render
function there was
there was already
was already available
already available called
available called attributes
stores the attributes
attributes of each
of our tags
If the border
the border equals
border equals one
equals one attribute
one attribute exists
attribute exists for
exists for the
table tag then
tag then that
that is when
is when we
when we will
we will draw
draw the border
So the attribute
the attribute is
attribute is already
picked up for
up for each
the tags in
tags in this
So we merely
to pass that
pass that attribute
that attribute onto
attribute onto the
onto the build
So down in
down in this
of code where
have the case
table tag we
extra parameter to
to the call
call to build
to build table
And this becomes
this becomes the
becomes the second
parameter to this
to this call
start of our
of our build
our build table
table function we
added the new
the new parameter
new parameter table
parameter table attributes
table attributes as
attributes as a
we've passed this
passed this on
this function when
function when we
we call display
call display table
display table we
table we can
can pass it
pass it on
it on to
to that one
of the build
table function is
call to display
to display table
can add the
add the table
the table attributes
table attributes parameter
attributes parameter on
parameter on to
of the call
And we're forcing
we're forcing that
forcing that to
that to lower
to lower case
lower case just
case just in
user has defined
has defined our
defined our HTML
our HTML with
HTML with uppercase
with uppercase for
uppercase for the
the word border
added this new
this new parameter
new parameter we
parameter we can
of the display
the display table
So a display
a display table
display table will
table will now
will now be
now be aware
be aware of
aware of the
new parameter coming
in we'll have
few more variables
more variables to
us to track
to track where
track where the
where the boxes
the boxes need
boxes need to
go for our
for our borders
a table border
table border variable
be a true
false to define
to define whether
define whether the
whether the table
the table has
table has a
a border or
border or not
I'm also creating
also creating a
creating a user
type called table
called table which
table which we're
to use for
use for the
and end locations
end locations of
locations of the
the table itself
And I'm making
I'm making good
making good use
udt object by
object by creating
creating a temporary
a temporary storage
temporary storage for
storage for the
for the position
position and also
and also another
also another user
type to allow
vertical lines in
So if our
if our table
our table attributes
table attributes have
attributes have the
the words border
words border equals
equals one then
one then we're
setting the boolean
the boolean table
boolean table border
table border to
border to true
use this as
as a test
a test in
test in the
out whether we
whether we need
to draw borders
draw borders or
borders or not
code is the
next loop which
loop which draws
which draws each
draws each row
each row of
row of the
Prior to actually
to actually printing
actually printing data
printing data to
store the starting
the starting positions
be the starting
starting positions of
positions of our
Plus I want
to actually populate
actually populate a
variable called rows
called rows for
rows for the
the last row
last row number
So I'm using
little typing and
typing and to
code look a
making the x
x coordinate of
coordinate of the
of the start
our table equal
table equal to
the current global
current global x
global x location
x location plus
location plus the
plus the width
a character divided
character divided by
divided by three
us a small
a small border
small border and
border and the
y coordinate of
of the position
setting the rows
the rows equal
rows equal to
bounding of str
of str table
And our for
next loop can
loop can now
now quite easily
easily go between
the rows variable
end row the
row the last
last row has
row has now
now been printed
been printed on
store the ending
ending position of
out this graphic
this graphic get
graphic get position
we now know
now know the
know the starting
starting and the
the end positions
end positions of
we're now in
now in a
in a position
a position where
position where we
where we can
we can draw
can draw a
draw a box
a box around
box around the
our table border
Is it true
it true or
true or false?
or false? If
false? If the
value is true
have to draw
draw a table
takes two sets
sets of parameters
is the x
the x y
x y coordinates
of the bottom
hand corner are
corner are the
are the second
set of variables
have stored these
in a user
defined type they
type they were
they were available
were available for
available for use
in place have
place have we
enough to draw
draw a border
the table itself?
table itself? Let's
itself? Let's run
our browser and
browser and if
drag our page
our page onto
page onto it
onto it and
it and scroll
and scroll down
scroll down we
down we have
we have almost
have almost got
almost got the
got the border
the border around
border around it
not quite there
has the width
the table but
table but it's
not quite got
quite got the
got the height
move our coordinates
our coordinates for
the table down
table down by
down by what
by what looks
looks like about
like about half
about half a
half a character
after we print
we print a
print a completed
a completed line
completed line we
line we then
we then get
get the graphics
the graphics position
in here I
here I think
think we need
need to advance
to advance these
advance these values
these values very
values very slightly
in our page
our page and
the box now
box now correctly
now correctly borders
correctly borders the
borders the table
the table in
table in its
in its entirety
we have gained
have gained more
gained more vertical
more vertical room
vertical room between
room between each
the rows which
rows which will
to put horizontal
put horizontal lines
horizontal lines in
lines in next
So just to
sure this will
will work for
work for more
for more than
than one table
one table let's
table let's put
let's put in
a second table
second table after
table after the
the first to
first to ensure
ensure our coordinate
our coordinate system
coordinate system has
system has not
not been affected
a new table
new table added
table added to
to our HTML
document and some
some text after
text after it
after it to
sure we can
can still print
still print text
print text after
after the table
are quite correctly
quite correctly getting
correctly getting two
getting two tables
two tables printed
tables printed with
printed with their
with their borders
the second table
second table is
table is slightly
is slightly larger
slightly larger in
larger in its
in its last
its last row
last row therefore
row therefore the
therefore the table
will be wider
And our code
our code has
code has handled
has handled that
handled that quite
that quite nicely
have the border
table itself I
itself I want
horizontal lines after
lines after each
after each row
we have moved
have moved the
moved the position
the position down
position down by
down by half
by half a
a character we're
character we're now
we're now ready
now ready to
ready to draw
draw a horizontal
a horizontal line
horizontal line from
line from one
from one side
one side of
the table to
whether the border
border attribute has
attribute has actually
actually been set
will only need
to draw horizontal
draw horizontal lines
horizontal lines for
lines for every
for every row
every row except
row except the
except the last
Because the last
last row will
row will already
will already have
already have the
the border of
border of the
the table border
border variable to
variable to ensure
We are also
are also testing
also testing to
that the role
the role we
role we are
we are processing
are processing is
processing is not
not the final
the final role
Again like the
like the graphics
graphics box it
box it takes
takes the beginning
the ending coordinates
have the table
the table start
table start x
start x coordinate
x coordinate, the
the current y
current y coordinate
coordinate minus the
minus the one
the one third
one third step
third step to
step to handle
handle our padding
our padding of
padding of a
of a line
is the table
table width for
width for the
coordinate is identical
is identical to
identical to the
Because we're drawing
we're drawing a
drawing a horizontal
try that now
our page in
page in and
in and there
we have horizontal
have horizontal lines
So we're halfway
we're halfway there
Now comes the
comes the slightly
the slightly trickier
slightly trickier attempt
trickier attempt to
to draw vertical
draw vertical lines
Which will complete
will complete our
complete our columns
function we're already
we're already storing
already storing the
storing the width
of our columns
is the maximum
maximum width that
width that a
that a column
a column can
column can be
draw our vertical
our vertical lines
the table after
table after each
each row has
row has been
has been printed
where we drew
we drew the
drew the box
after our graphics
our graphics box
box command where
command where we
the box around
the table we
can now step
now step through
the columns one
columns one at
From column one
column one to
last column minus
column minus one
draw a vertical
a vertical line
vertical line for
line for the
last column because
column because this
because this has
this has already
already been drawn
been drawn by
drawn by the
by the border
use our vertical
vertical lines user
lines user defined
we're setting an
setting an X
coordinate to start
start the line
the line and
line and an
and an X
coordinate to end
end the line
X coordinate as
coordinate as the
table start plus
start plus the
Which is stored
we're taking away
taking away from
away from that
width of one
of one character
to get away
get away from
from the padding
the padding character
padding character we
character we put
we put at
put at the
Otherwise the line
the line would
line would go
would go beyond
beyond the edge
our Y coordinate
coordinate is quite
is quite simply
simply the Y
the end coordinate
end coordinate it's
coordinate it's the
it's the vertical
vertical lines along
lines along start
words a duplicate
a duplicate of
duplicate of this
this first line
line and table
and table end
table end is
end is used
is used as
used as the
as the end
easily use a
a graphics line
This to draw
draw our line
our line from
Y coordinate beginning
coordinate beginning to
beginning to the
Y coordinate at
coordinate at the
now have vertical
have vertical columns
vertical columns in
Based entirely on
column width is
width is based
text that it
that it holds
a column which
column which has
which has more
has more text
more text in
text in it
The column of
column of course
of course would
course would be
would be wider
we've proved we
proved we can
have a border
border around a
around a table
Can we have
a table without
table without a
without a border
we haven't made
haven't made any
made any errors
any errors in
errors in our
So let's amend
amend the HTML
HTML to add
an extra table
a third table
And we'll give
give it border
it border equals
border equals 0
we'll change some
change some of
we copy that
in and scroll
have three tables
The first table
first table has
table has the
has the borders
second table has
table has borders
the third table
third table has
has the data
the data correctly
data correctly arranged
But no borders
to have borders
have borders around
borders around your
around your tables
table itself is
itself is bordered
is bordered by
bordered by a
by a black
a black thin
black thin line
have both vertical
both vertical and
and horizontal lines
horizontal lines within
lines within that
Admittedly this is
is not exactly
not exactly the
as the standard
the standard HTML
However I think
I think it
think it looks
it looks much
looks much tidier
deal more we
that for another
for another video
our project and
project and create
by adding more
adding more functionality
functionality to tables
created a light
light browser and
process of adding
of adding table
adding table functionality
HTML pages and
pages and we
drag in an
in an HTML
HTML page, we
see the details
the details appearing
details appearing in
couple of bugs
of bugs that
bugs that appeared
that appeared after
appeared after the
after the last
the last video's
last video's recording
at the table
the table at
of this page
this page, we
see it has
it has two
has two columns
is not entirely
not entirely fitting
entirely fitting into
fitting into the
into the column
the column space
this is likely
is likely because
likely because we're
because we're using
we're using bold
using bold for
bold for the
column headers, and
and each bold
each bold character
bold character takes
character takes up
takes up slightly
up slightly more
slightly more horizontal
more horizontal space
horizontal space than
space than an
than an unbold
an unbold character
to tackle that
tackle that in
we add additional
columns to our
to our table
our table, we
can see another
see another problem
now have four
have four columns
four columns in
columns in this
in this table
problem we have
we have with
have with this
with this is
this is there
is no vertical
no vertical dividing
vertical dividing line
dividing line between
line between column
between column this
column this is
obviously a second
a second bug
we will fix
will fix these
fix these two
these two bugs
two bugs first
bugs first of
of all, and
and after we
we have corrected
have corrected those
corrected those, we're
add in another
in another attribute
another attribute for
attribute for the
of the attributes
the attributes you
can have on
have on tables
on tables is
tables is 'width'
specify the width
a table in
table in either
in either pixels
pixels or as
or as a
If you set
be the table
will be half
be half that
half that of
of the browser
the browser itself
width to width
to width of
width of your
of your table
your table will
be exactly 800
exactly 800 pixels
attempt to fix
to fix is
fix is our
is our vertical
table function, and
scroll down, we'll
bottom of that
section which draws
which draws vertical
draws vertical lines
The problem in
problem in here
is it's drawing
drawing the first
the first vertical
first vertical line
vertical line at
at the division
the division between
division between column
between column 1
column 1 and
1 and column
and column 2
For this logic
this logic, part
the vertical line
vertical line starting
line starting position
starting position is
position is always
is always the
always the beginning
the table plus
table plus the
this is always
is always drawing
always drawing the
drawing the same
the same vertical
same vertical line
needs to have
have an offset
offset to know
to know that
know that it
has already drawn
already drawn the
drawn the column
the column move
column move on
on to column
to column 2
column 2, column
we need in
need in here
here is an
is an offset
an offset value
vertical line, the
value of x
of x offset
x offset will
it will perform
will perform as
perform as it
it does now
the second iteration
second iteration, for
next column boundary
column boundary, we
do that down
that down here
down here by
here by setting
by setting the
setting the offset
the offset value
offset value to
to the starting
point of our
of our vertical
declare this variable
this variable at
is our variable
our variable declared
our page, we
should see we
a vertical divider
vertical divider between
divider between column
between column 3
column 3 and
3 and column
and column 4
So our vertical
vertical lines are
lines are now
are now working
now working correctly
have to sort
to sort out
sort out the
out the amount
amount of space
of space taken
space taken up
column header as
header as it
it is obviously
is obviously intruding
obviously intruding in
intruding in to
a character is
character is worked
is worked out
worked out by
out by the
we're using and
using and we're
using a wider
a wider font
wider font for
font for the
headers as it
it is bold
is bold, we'll
need to adjust
to adjust that
adjust that when
when the table
table is drawn
get a little
bit more control
control over our
over our dialogue
our dialogue, I'm
way the dialogue
the dialogue was
dialogue was created
When you create
you create a
dialogue using the
the dialogue new
new command and
command and do
and do not
do not specify
not specify whether
specify whether you
whether you want
to use dialogue
use dialogue units
dialogue units or
or pixels, it
default to using
to using dialogue
using dialogue units
use of dialogue
of dialogue units
dialogue units allows
units allows Power
allows Power Basic
Power Basic itself
Basic itself to
out the best
the best place
best place to
to put things
put things on
things on screen
of the time
the time this
time this works
works out fine
want a little
bit more precision
more precision on
precision on where
on where things
where things are
things are positioned
are positioned on
the dialogue, you're
you're better going
better going for
going for pixels
This does of
does of course
of course necessitate
course necessitate a
necessitate a little
bit more of
more of code
to the place
the place where
place where we
where we create
we create our
create our dialogue
So on this
on this line
this line here
line here, we
are not specifying
not specifying either
specifying either dialogue
either dialogue units
amend this and
this and use
and use pixels
now going for
going for 850
for 850 by
850 by in
by in the
I'm also increasing
also increasing the
increasing the width
while we're tidying
we're tidying up
tidying up in
particular function, there's
there's a part
a part in
part in here
in here where
of the virtual
putting a multiplier
a multiplier of
multiplier of three
of three in
three in here
Now as this
is a hard
a hard coded
hard coded value
coded value, I'd
I'd much prefer
much prefer that
prefer that this
that this was
this was in
was in as
a constant so
constant so that
code and that
will take effect
take effect through
effect through the
So that's exactly
that's exactly what
put a width
a width multiplier
width multiplier and
multiplier and a
and a height
a height multiplier
new constants at
is one other
one other function
other function which
function which has
which has also
also been hard
been hard coded
hard coded for
coded for this
for this adjustment
That's the resize
this has this
has this multiplier
this multiplier in
multiplier in place
we'll just slot
just slot in
slot in these
in these two
So that's them
that's them both
them both in
both in place
at the width
of code works
code works out
column is in
Our problem is
problem is that
is that we
have a different
a different font
different font, a
a bold font
bold font, for
for the headings
the headings of
headings of each
columns and these
these are slightly
are slightly wider
The best approach
best approach would
approach would be
be to recalculate
to recalculate the
recalculate the values
the values which
values which we're
be using here
using here for
here for the
to take a
take a slightly
a slightly simpler
slightly simpler approach
In this nested
this nested for
columns and we're
we're looking from
looking from the
second row to
in this part
this part, we're
we're ignoring the
ignoring the first
first row completely
one that holds
holds the headers
amend this to
this to look
first row and
row and we
doing the first
row and act
and act accordingly
replace this section
of all test
all test to
on row one
row one and
one and we'll
we'll also test
also test our
test our header
header variable to
if this table
this table has
has a header
If the table
a header, then
then there's no
point in continuing
want to work
our columns and
add on two
on two spaces
will add on
on two characters
two characters to
characters to the
is a bit
of a workaround
a workaround as
workaround as it
as it depends
it depends how
depends how many
many characters we
characters we have
have in each
it will get
will get us
get us past
us past this
past this particular
this particular problem
for this, we're
be quite pragmatic
For all other
all other columns
other columns, we'll
leave the calculation
the calculation as
calculation as it
other thing we're
is we're depending
we're depending on
of this variable
this variable header
is not one
the parameters coming
parameters coming in
coming in from
add that into
that into anything
into anything that
anything that calls
that calls this
calls this function
function here display
here display table
display table already
table already has
already has it
has it in
in its parameters
its parameters list
we mainly have
mainly have to
pass that on
to our called
our called function
in our HTML
our HTML file
see we appear
to have sorted
have sorted out
sorted out the
out the detail
detail of our
of our titles
lines are appearing
are appearing correctly
appearing correctly between
correctly between each
columns and our
column headers are
headers are not
not wandering in
wandering in to
I said, this
is a pragmatic
a pragmatic approach
pragmatic approach to
approach to our
to our current
our current issue
have a really
a really long
really long column
long column title
column title, this
this would probably
would probably still
probably still be
still be a
we'll move on
on to what
up a new
a new attribute
new attribute for
look at page
at page five
page five in
five in a
in a normal
a normal browser
normal browser, we'll
we'll see on
see on page
on page five
five that we
that we do
do have multiple
have multiple tables
multiple tables and
tables and the
our first table
first table is
table is 50%
is 50% of
50% of the
it is quite
is quite dynamic
second table appears
table appears to
be of fixed
of fixed width
fixed width and
width and this
is obviously set
obviously set for
set for pixels
If we view
we view the
view the source
the source for
source for this
this particular page
particular page, we
has a width
a width set
width set to
set to 50%
to 50% and
50% and the
a value set
value set for
set for 1200
we drag this
drag this page
this page into
page into our
it would not
would not pick
not pick up
the width because
width because we
have not put
not put any
put any code
handle the width
the width attribute
is our next
table function, in
in the parameters
parameters list we
list we are
are passing table
passing table attributes
table attributes to
attributes to this
So the details
details of the
the width will
width will be
within this table
this table attributes
table attributes string
have to interrogate
to interrogate it
new variable to
hold the table
table width amount
width amount and
amount and we'll
call that table
that table width
either be a
a percentage or
percentage or a
or a size
a size in
size in pixels
this variable depending
variable depending on
has actually put
actually put in
that by looking
by looking for
the words width
words width followed
width followed by
by the equal
width amount by
amount by using
parse command twice
of all using
all using width
using width equals
width equals as
equals as a
as a delimiter
a delimiter and
delimiter and then
using the space
the space as
space as a
will return either
return either 1200
either 1200 or
1200 or 50
or 50 and
50 and the
and the percentage
the percentage sign
have this information
this information we'll
information we'll need
to pass it
to the width
the table function
another parameter onto
parameter onto its
onto its parameters
there we now
width amount added
amount added on
to the parameter
So now of
of course we'll
course we'll have
table function and
add that parameter
that parameter to
parameter to its
to its list
its list of
list of incoming
of incoming parameters
two options coming
options coming in
coming in in
in in this
We're either going
fixed width or
width or we're
or we're going
have a percentage
a percentage width
Therefore we will
create another variable
will be either
be either true
either true or
be scaled, i.e
a percentage and
percentage and false
is not and
not and there
So next before
next before we
to the for
next loop we're
loop we're going
width amount is
amount is a
is a zero
string then there
is no set
no set value
set value for
table and it
will be dynamic
be dynamic based
dynamic based on
we could test
could test this
test this quite
in the variable
the variable is
variable is not
string then the
then the table
table is set
set for fixed
for fixed width
width and is
is therefore scaled
value is an
string then we'll
set this variable
test the rightmost
character of our
of our variable
If that contains
contains a percentage
a percentage sign
percentage sign then
sign then we
know the total
total width is
width is going
not the case
case then we'll
then we'll populate
populate the total
total width variable
width variable which
is an existing
an existing variable
existing variable to
what we find
find within the
For example 1200
example 1200 pixels
want the total
total width to
percentage of our
of our control
our control size
control size we
size we need
out what our
what our control
control size actually
size actually is
create a small
a small function
function is basically
is basically one
basically one line
I'm putting it
a function just
function just in
in case in
case in future
in future we
future we need
to expand upon
expand upon what
upon what this
the graphic command
the width in
width in pixels
in pixels of
pixels of our
of our size
have designated our
designated our control
our control on
dialogue as being
as being done
being done in
done in pixels
in pixels it
pixels it will
return in pixels
If a dialogue
a dialogue was
dialogue was still
was still done
still done in
done in dialogue
in dialogue units
dialogue units this
units this function
function would return
would return dialogue
return dialogue units
total width of
Inside the for
next loop this
loop this steps
this steps through
steps through each
and the existing
existing code goes
code goes ahead
goes ahead and
ahead and works
how wide the
wide the column
the column needs
column needs to
to be if
be if the
table is to
to be dynamic
be dynamic and
dynamic and controlled
and controlled by
controlled by the
the table cells
this table is
be scaled then
scaled then we
test that and
that and act
test in on
on the scaled
the scaled variable
our array of
table columns is
columns is going
total width divided
width divided by
Otherwise the table
So there's simple
there's simple test
simple test to
if we're having
having a scale
a scale table
scale table or
table or a
or a dynamic
a dynamic table
dynamic table can
table can handle
can handle both
handle both scenarios
which returns the
returns the total
the table we'll
table we'll need
kind of test
if the scale
the scale variable
scale variable is
is false and
false and if
can use our
use our existing
our existing functionality
skip over this
over this piece
code and return
return the pre-populated
the pre-populated value
pre-populated value of
have this code
in place will
place will our
will our browser
our browser behave
browser behave correctly?
behave correctly? Let's
correctly? Let's try
try running and
running and see
we bring up
up our pages
our pages and
in page five
Page five appears
five appears to
to be identical
be identical to
what we had
in our Chrome
our Chrome browser
table is half
is half the
half the width
second table extends
table extends beyond
extends beyond the
beyond the width
of a current
a current dialogue
If we stretch
we stretch our
stretch our dialogue
our dialogue we
dialogue we will
that the second
second table remains
table remains at
remains at a
at a fixed
a fixed size
However the first
first table remains
remains at 50
at 50 percent
50 percent of
percent of the
If our browser
our browser becomes
browser becomes wider
becomes wider so
wider so does
so does the
does the table
And the table
the table below
table below which
below which is
which is fixed
is fixed by
fixed by the
does not change
not change at
change at all
So we bring
bring in page
in page six
page six just
six just to
sure that still
that still works
still works and
works and it
and it stays
it stays at
stays at the
at the existing
the existing size
And page five
page five quite
five quite happily
quite happily is
happily is now
is now fully
now fully scaled
we have fixed
have fixed a
fixed a couple
of bugs in
bugs in the
in the drawing
drawing of tables
We have sorted
have sorted the
sorted the vertical
vertical lines to
lines to ensure
to ensure they
ensure they appear
they appear correctly
we have widened
have widened the
the columns to
columns to take
to take account
take account of
account of the
that the headers
headers are slightly
slightly wider because
wider because their
because their font
their font is
font is bold
added new functionality
new functionality to
functionality to support
support the width
width attribute for
attribute for tables
allow our tables
our tables to
tables to be
be of a
of a fixed
a fixed width
width or a
or a percentage
you'll find these
find these functions
these functions useful
functions useful in
of our light
our light web
As current web
web browsers are
browsers are quite
are quite complex
quite complex beasts
complex beasts, we're
starting off very
off very straightforward
straightforward and simple
and simple with
simple with our
In the theory
the theory that
theory that to
that to solve
to solve really
solve really large
really large complex
large complex problems
complex problems, you
you first break
first break them
break them down
them down to
down to much
to much smaller
much smaller and
smaller and more
and more simple
more simple problems
simple problems, and
then you solve
you solve these
solve these simple
these simple problems
simple problems one
problems one at
load up a
up a very
a very basic
very basic webpage
basic webpage into
webpage into our
have only four
only four functions
four functions within
within our current
our current application
where we're calling
we're calling our
calling our first
our first and
first and only
and only dialogue
dialogue itself puts
itself puts our
puts our controls
our controls on
And currently we
currently we are
we are clearing
are clearing out
clearing out the
be the body
body of our
browser and making
and making the
making the background
the background black
change that right
that right now
right now to
make the background
the background white
be loading a
or files, we're
is our pb_file_handling
our pb_file_handling routines
pb_file_handling routines library
in many videos
This contains some
contains some common
some common functions
common functions for
functions for loading
for loading files
And our HTML
HTML document is
document is indeed
indeed a file
that in mind
in mind, we'll
we'll need somewhere
need somewhere to
somewhere to actually
to actually obtain
actually obtain the
obtain the file
The web browser
browser will eventually
will eventually be
eventually be able
able to look
look at both
at both static
both static web
static web pages
web pages located
pages located on
located on a
on a local
a local drive
local drive to
drive to looking
to looking at
looking at websites
look at straightforward
at straightforward Flat
straightforward Flat text
text files which
files which have
which have an
an HTML extension
create a folder
a folder called
folder called HTML
called HTML pages
pages and this
and this folder
this folder will
folder will contain
contain our files
our first page
first page, page1.html
HTML or Hypertext
or Hypertext Markup
Hypertext Markup language
Markup language is
language is a
is a process
a process by
define the structure
structure of a
of a webpage
create the most
the most simple
most simple webpage
simple webpage you
webpage you have
you have ever
have ever seen
HTML tags are
tags are used
used to define
to define areas
define areas of
areas of your
of your webpage
They will always
will always start
always start with
with the HTML
the HTML tag
HTML tag which
all the structure
the structure that's
structure that's to
that's to appear
on the webpage
have a body
a body section
body section which
used to contain
all the structures
the structures and
structures and text
and text that's
text that's appear
that's appear in
in the body
is a tag
a tag called
tag called head
called head which
head which is
define the header
header of the
This can contain
can contain the
contain the title
a title in
title in and
in and we're
call this demo
this demo page
simple webpage which
webpage which only
which only contains
only contains the
the webpage which
webpage which is
is called demo
called demo page
use this one
one as a
as a starter
can support this
support this structure
of all, I'm
hold the content
the webpage we're
webpage we're going
be displaying to
use one global
one global HTML
global HTML to
HTML to contain
from the webpage
the webpage verbatim
second one I'm
one I'm going
be using for
using for storing
for storing a
storing a lowercase
a lowercase version
lowercase version of
of this webpage
us to read
read the tags
the tags more
tags more easily
more easily and
easily and disregard
and disregard the
disregard the casing
enter a URL
Once they've entered
they've entered this
entered this URL
this URL, they
they would normally
would normally press
normally press the
enter button on
able to detect
to detect that
detect that an
that an enter
an enter button
enter button has
button has indeed
indeed been pressed
been pressed and
pressed and check
and check to
see if they
they have entered
have entered a
entered a URL
we can manage
can manage that
dialogue is where
is where we'll
where we'll need
this change in
no code in
section and this
add some in
You would normally
would normally expect
normally expect to
expect to put
put a case
in to detect
to detect the
detect the text
text URL box
However what we're
is to detect
detect the pressing
the pressing of
pressing of the
of the enter
the enter key
Although there are
are no buttons
no buttons on
screen to handle
handle this, you
you could quite
easily do a
do a default
a default setting
default setting on
setting on one
the image buttons
image buttons at
However I'm not
I'm not going
do that today
that today, we're
actually use the
use the id
id ok constant
Although we don't
we don't actually
have an object
an object on
object on this
this dialogue that
dialogue that has
that has this
has this handle
this handle, it
used to pick
that the enter
enter key has
key has been
has been pressed
out is which
is which control
the dialogue last
dialogue last had
last had focus
In fact using
fact using two
using two Windows
two Windows API
first one get
one get focus
get focus which
focus which will
Windows handle and
the second call
second call will
call will turn
will turn that
into a dialogue
handle and we
will then populate
then populate a
variable called control
to set control
set control up
control up as
up as available
as available at
available at the
control up at
the top as
top as being
our control and
set a string
string variable up
variable up to
up to contain
contain the URL
the URL entered
URL entered by
entered by the
have the control
the control which
control which last
which last had
had focus, we
value we've got
got back to
back to see
it matches the
matches the handle
text box containing
box containing the
containing the URL
If that's been
that's been the
been the case
then return has
return has been
been pressed when
pressed when the
the dialogue had
dialogue had to
had to focus
to focus to
So we wish
wish to test
in to pop
to pop out
pop out when
out when the
presses the enter
hit the enter
enter key with
key with the
the control currently
control currently focused
currently focused on
focused on the
text box, we
we get our
get our message
we change the
change the focus
focus to another
to another control
another control and
control and press
and press enter
press enter, nothing
nothing comes up
So we're quite
quite happily detecting
happily detecting when
detecting when the
enter key on
key on this
on this text
very useful if
useful if you
wish to detect
to detect enter
detect enter keys
enter keys on
keys on a
boxes on a
So having picked
is to render
to render the
the HTML, passing
URL and two
and two handles
two handles, the
to the tab
up two variables
two variables here
variables here, one
hold the HTML
HTML file we're
load in and
in and one
contain the tab
tab number that
number that has
moment we're only
supporting one tab
this would always
would always contain
always contain the
value one at
keyed in a
So trimming the
trimming the value
in that variable
that variable, if
that returns an
returns an empty
user has keyed
has keyed nothing
keyed nothing relevant
nothing relevant and
relevant and we
can exit immediately
far then a
then a URL
a URL has
URL has been
has been entered
will do first
first is use
command to clear
to clear out
clear out the
default font which
font which we
up earlier and
earlier and we'll
position of our
of our graphic
graphic control to
print the word
the word return
word return pressed
has entered and
entered and then
the graphics screen
let's run that
code now to
can pick it
pick it up
it up quite
path to this
However as this
quite a long
a long path
long path and
path and to
to save us
save us some
us some time
some time typing
time typing we're
typing we're going
create a substitution
a substitution drive
a command that's
command that's been
that's been around
been around in
around in Windows
in Windows for
Windows for a
for a very
a very long
very long time
It only takes
only takes two
use and the
path we want
use for that
Once this has
has been done
been done the
done the Z
drive will now
will now show
now show us
show us directly
us directly to
directly to that
that folder and
we'll save us
save us a
us a great
deal of typing
So we've keyed
we've keyed in
URL and when
when we hit
enter button we
button we get
get the words
the path that
path that the
has keyed in
keyed in in
in in that
quite happily pick
happily pick up
load that file
that file into
called load HTML
load HTML page
said earlier there
earlier there are
are two types
two types of
types of loading
of loading we're
loading we're going
be doing here
Loading a local
local file which
which is using
using a file
file path and
path and loading
and loading a
loading a full
a full web
full web page
web page on
page on a
on a URL
So this load
this load HTML
HTML page function
page function can
used to work
out which we're
which we're doing
our second global
second global variable
global variable, the
case version, can
populated on the
the line below
single parameter as
parameter as the
we're only going
only going to
looking at local
at local files
do the web
the web files
web files later
within our common
common file library
file library to
load the file
That's the binary
the binary file
binary file as
file as string
as string function
string function taking
as its parameter
its parameter the
parameter the URL
remove any carriage
at this page
this page in
page in notepad
We'll see it's
see it's a
very straightforward page
However each line
each line has
line has a
has a carriage
line feed at
feed at the
end of it
line feeds are
feeds are not
are not displayed
not displayed on
displayed on your
on your web
your web browser
to remove all
remove all the
all the carriage
the carriage return
line feeds so
feeds so that
that we end
up with one
with one long
one long string
long string of
the string containing
string containing all
So having successfully
having successfully loaded
successfully loaded the
loaded the page
page we next
need to name
name the tab
the tab for
tab for the
for the page
have just picked
if the return
function is not
not blank we
ahead and get
get the tab
have one tab
one tab this
tab this will
return the tab
tab selected being
selected being a
being a value
the tab set
tab set text
taking the URL
and we're parsing
we're parsing it
parsing it using
it using either
using either the
either the forward
the forward or
forward or backslashes
And going from
going from the
the string backwards
string backwards taking
backwards taking the
taking the first
now and putting
and putting our
putting our page
And hitting enter
hitting enter it
enter it should
it should now
now be labeled
be labeled on
labeled on the
have just loaded
have successfully picked
successfully picked up
can we go
go further and
further and pick
and pick up
the title from
title from inside
inside the HTML?
the HTML? As
HTML? As we
created a title
a title block
title block containing
block containing the
containing the words
the words demo
words demo page
would be good
be good if
good if every
if every single
every single HTML
single HTML document
HTML document was
document was correctly
was correctly formatted
However you cannot
you cannot guarantee
cannot guarantee that
guarantee that this
we render anything
render anything to
anything to our
control we might
we might want
might want to
do a validation
a validation on
small function whose
if the HTML
the HTML validates
HTML validates and
validates and false
returns true we
true we will
we will print
will print the
the words HTML
words HTML formatting
HTML formatting OK
formatting OK and
OK and if
does not we'll
not we'll print
we'll print invalid
print invalid HTML
invalid HTML formatting
And we'll throw
we'll throw the
throw the value
the HTML variable
call the graphics
create the validate
the validate HTML
validate HTML function
command to test
HTML tag, the
the closing HTML
closing HTML tag
HTML tag and
and the body
the body and
body and causing
and causing body
causing body tags
these is not
is not found
not found we
found we will
application now, put
put our web
And it's returning
returning the value
the value HTML
value HTML formatting
We are of
of course using
course using the
control to display
information to us
to us the
us the developers
In a production
a production setting
production setting you
setting you would
you would not
would not expect
not expect these
expect these messages
these messages to
messages to be
be seen by
seen by a
by a user
But now that
that we validated
we validated the
validated the page
the page can
page can we
we pick out
out the title
the title block
if the validation
the validation returns
validation returns true
true then we'll
to start rendering
start rendering these
rendering these HTML
these HTML tags
that function render
function render HTML
HTML tags giving
tags giving it
dialogue and secondly
secondly the handle
to the heart
of our rendering
to be stepping
through the lowercase
the lowercase version
I said before
said before the
before the HTML
HTML is now
is now formatted
now formatted in
formatted in a
in a lowercase
a lowercase string
lowercase string in
string in one
in one variable
one variable and
variable and as
and as a
as a mix
a mix case
mix case string
case string in
doing a for
Looking through this
through this string
this string one
and we're pulling
pulling the character
the character value
character value out
value out and
out and putting
and putting into
putting into a
into a character
a character variable
character is a
is a less
a less than
less than sign
than sign then
sign then that's
that's the beginning
of a command
the first character
first character of
character of a
What's between this
between this less
this less than
than sign and
sign and a
and a greater
a greater than
greater than sign
needing some more
One to work
out the ending
position and a
and a string
contain the command
the command itself
command itself using
itself using the
is basically looking
basically looking to
looking to the
to the lowercase
the lowercase value
lowercase value and
the end values
populate a boolean
flag to save
to save one
save one out
one out inside
out inside a
inside a command
we're not exiting
not exiting the
exiting the command
the command at
command at the
variables will be
be more obvious
more obvious later
obvious later on
have picked up
the command we
command we now
up the end
of the command
an else here
else here as
as well to
well to pick
that the tag
the tag has
tag has ended
has ended what
ended what do
with the data?
the data? Well
data? Well we'll
Well we'll need
moment we're not
be doing anything
know it's there
it's there but
there but there's
there's nothing we
nothing we need
put a casing
a casing statement
casing statement in
statement in just
in just in
in case we
do something later
something later on
On the opening
the opening tag
opening tag for
tag for body
for body we're
body we're going
to set another
set another boolean
another boolean variable
will set that
that to false
false when the
when the body
the body tag
body tag is
tag is complete
will create all
create all these
all these variables
these variables at
our function shortly
as the body
body tag we're
for the head
the head tag
Again setting variables
setting variables to
variables to say
say that it's
that it's true
it's true that
true that we're
inside a head
a head tag
head tag and
and false to
false to see
to see we're
see we're outside
be using this
using this variable
variable here title
here title to
title to contain
within the title
place we want
title block itself
before we're picking
end positions and
positions and we're
time we're populating
we're populating it
populating it from
the main HTML
main HTML rather
HTML rather than
than the lower
The end string
end string is
string is quite
useful in that
in that you
can specify our
specify our beginning
our beginning and
beginning and ending
and ending tags
ending tags in
tags in here
in here quite
here quite nicely
with the test
that the in
the in head
in head boolean
head boolean is
boolean is true
is true this
true this ensures
ensures that we
that we won't
we won't pick
won't pick a
pick a title
a title up
title up from
up from anywhere
from anywhere else
anywhere else other
else other than
other than inside
than inside the
inside the head
the head block
once the title
title block is
block is actually
is actually closed
actually closed that's
closed that's the
that's the point
the point we
point we want
populate our tab
have the code
the code just
code just as
before to select
select the current
always be tab
be tab one
that tab using
tab using the
using the variables
variables we've passed
passed in and
in and populating
and populating it
populating it with
it with what
with what we've
what we've populated
we've populated into
into the title
title variable populated
variable populated up
populated up here
let's create all
create all the
the variables we're
be needing on
needing on top
code and then
we can try
can try running
in our web
page and hit
now that the
tab is now
showing as demo
as demo page
demo page which
HTML code within
the title start
title start and
and end blocks
So we've picked
piece of information
of information from
information from our
that we've successfully
we've successfully picked
picked up a
up a title
a title our
title our next
up a paragraph
the HTML you'd
HTML you'd expect
you'd expect a
expect a number
number of paragraphs
of paragraphs appearing
paragraphs appearing and
appearing and other
and other structures
So we'll handle
we'll handle a
handle a hello
a hello world
hello world paragraph
world paragraph in
paragraph in the
support this paragraph
this paragraph tag
is the structure
the structure for
structure for our
for our paragraph
our paragraph starting
paragraph starting tag
starting tag and
doing a check
a check to
sure we're in
we're in the
the body structure
before we're working
the end structures
end structures and
structures and pulling
and pulling it
pulling it and
it and returning
and returning the
returning the data
data within them
be doing quite
doing quite a
lot of this
of this these
this these three
these three lines
of code could
code could well
well be embedded
be embedded into
embedded into a
But we'll tackle
want to print
print this data
to our graphic
do that we'll
that we'll handle
handle the closing
the closing paragraph
closing paragraph tag
And again we'll
again we'll check
we'll check to
the body tags
do a straightforward
a straightforward graphic
straightforward graphic print
graphic print of
print of a
of a zero
create the header
the header for
header for our
for our print
our print data
Now initially we're
set this function
this function just
function just to
just to print
print out a
out a trimmed
a trimmed version
trimmed version of
And putting in
is our Hello
Hello world displayed
world displayed in
in our graphics
put a second
a second paragraph
second paragraph in
paragraph in to
see what more
what more we
new paragraph saying
paragraph saying welcome
saying welcome back
welcome back to
back to everyone
to everyone here
However this paragraph
this paragraph has
paragraph has two
has two line
two line breaks
line breaks forced
breaks forced into
forced into the
middle of it
And our paragraph
tag has to
to handle line
handle line breaks
moment our reload
our reload button
reload button is
is not functional
set up reload
up reload so
reload so we
it in action
we are back
are back in
Picking up a
up a click
a click event
click event on
event on our
on our reload
here is quite
calling the function
function we've just
Enter the URL
URL and click
click the reload
the reload button
will reload quite
reload quite happily
see this BR
this BR tag
In twice in
twice in the
of our paragraph
have some code
in place to
place to detect
detect the presence
presence of a
of a BR
a BR tag
into the render
where we call
call the print
And what we'll
in this print
function is we'll
determine if there
are any BR
any BR tags
if we populate
we populate a
populate a temporary
temporary variable with
with the lowercase
to count the
number of BR
of BR tags
BR tags we
tags we have
are no tags
no tags at
tags at all
Parse count will
count will return
will return 1
is one tag
will return 2
if the breaks
the breaks variable
breaks variable is
to be greater
the case we'll
case we'll need
loop to pull
information between these
between these tags
can populate a
populate a local
variable called text
called text using
Trimming it and
it and looking
for the BR
the BR as
BR as a
text variable is
not a zero
in string then
can print if
print if the
text is not
By using straightforward
using straightforward graphics
straightforward graphics print
print command with
with our variable
line breaks we
breaks we can
can just use
just use graphics
use graphics print
graphics print on
print on its
now create all
all the local
local variables we
we need at
need at the
have our welcome
our welcome back
So we effectively
we effectively have
effectively have two
have two paragraphs
gap between the
between the paragraphs
And a paragraph
a paragraph split
paragraph split into
split into three
into three separate
three separate lines
The next tag
next tag we're
the header tag
is actually six
actually six tags
six tags ranging
tags ranging from
ranging from H1
from H1 to
H1 to H6
Traditionally the H1
the H1 tag
H1 tag gives
tag gives you
you the largest
the largest font
largest font size
font size on
size on screen
And the H6
the H6 gives
H6 gives you
you the smallest
used to set
to set different
set different headings
different headings at
headings at the
of your paragraphs
to support six
support six separate
six separate fonts
will create these
create these at
these at the
function called create
And the single
the single font
single font we're
font we're creating
we're creating in
creating in here
the moment will
moment will take
will take out
take out and
out and put
and put into
into the new
will then unload
then unload all
unload all the
all the fonts
take this code
this code out
function to create
create the fonts
array to handle
we had to
had to create
create the default
Courier new 12
new 12 point
a little for
little for next
loop to allow
us to loop
to loop through
loop through and
through and create
and create fonts
create fonts of
fonts of different
of different sizes
Starting with 30
with 30 point
30 point and
point and working
and working down
working down four
down four points
four points at
points at a
give us six
us six fonts
fonts of decreasing
of decreasing sizes
will create an
create an unload
an unload fonts
fonts function whose
is to end
of these fonts
we'll declare our
declare our global
global array at
array at the
Just underneath the
underneath the existing
the existing font
existing font handle
place we now
handle the H1
the H1 to
to H6 tags
statement in that
that handles H1
handles H1 to
of our header
our header tag
with the case
statement in place
can determine which
determine which heading
which heading number
heading number the
actually entered by
entered by using
by using Right$
using Right$ This
Right$ This gives
us a value
a value which
value which we
use to point
to point towards
point towards the
towards the font
the font we
font we have
have set up
And use graphics
use graphics set
graphics set font
set font to
in place for
place for all
for all subsequent
subsequent graphics operations
And subsequently we
subsequently we can
up the ending
case we're now
we're now setting
now setting the
setting the font
default font we've
font we've set
in the H
the H font
H font variable
update our HTML
HTML document to
document to put
put an H1
an H1 tag
H1 tag in
to make Hello
make Hello World
Hello World the
World the largest
the largest heading
largest heading text
So we save
that and run
and run our
see the words
the words Hello
words Hello World
Hello World in
World in a
in a large
a large bold
large bold font
let's try updating
try updating our
updating our HTML
our HTML and
HTML and putting
and putting a
putting a second
a second but
second but smaller
but smaller header
smaller header tag
header tag in
have an H2
an H2 tag
H2 tag with
tag with another
with another paragraph
another paragraph with
paragraph with the
the words Data
words Data Next
that and just
and just refresh
just refresh our
refresh our page
have Data Next
Data Next as
Next as a
as a smaller
a smaller but
smaller but still
but still bold
still bold heading
taken an HTML
HTML page and
we have parsed
have parsed it
parsed it into
We have handled
have handled paragraph
handled paragraph tags
paragraph tags, header
header tags, a
a title tag
title tag to
tag to pick
the name on
name on the
And we've done
we've done some
done some simple
some simple validation
simple validation to
validation to ensure
the HTML and
HTML and body
and body tags
body tags are
tags are in
are in place
Obviously there was
was a great
deal more work
work to be
be done in
done in creating
creating a modern
a modern browser
the PowerBasic console
PowerBasic console compiler
at how we
use the console
the console commands
console commands to
commands to create
create a forms
a forms application
have in past
in past videos
past videos covered
videos covered the
covered the PowerBasic
Compiler to create
to create forms
If in your
your application you're
application you're going
doing a lot
lot of forms
of forms handling
forms handling work
handling work, the
the Windows compiler
Windows compiler is
compiler is ideal
is ideal for
ideal for this
for this purpose
if you only
you only have
only have the
have the console
console compiler, there
number of console
of console commands
console commands that
commands that can
that can assist
can assist you
assist you to
do a type
of form within
form within the
within the console
console compiler itself
application which can
used to display
display a form
form to our
to our users
Rather than to
than to design
to design an
design an application
an application specific
application specific to
specific to a
to a particular
a particular form
particular form, we're
can be driven
be driven by
by a form
a form whose
form whose definition
whose definition is
definition is held
held in an
create in Notepad
in Notepad an
Notepad an external
be the definition
definition of our
create a title
title for our
our form which
form which the
user will see
the screen, and
number of fields
of fields into
fields into which
can actually type
actually type data
with a very
very simple form
simple form with
form with only
only three fields
three fields, First
First Name, Surname
Surname and Age
In our format
our format we're
format we're using
using the square
the square brackets
square brackets to
brackets to define
define the beginning
of a field
the first name
first name and
name and surname
and surname are
surname are the
the same length
same length, and
field is just
is just three
just three characters
save this back
this back to
to our folder
our folder, and
call this file
this file form1.txt
we will define
will define a
name of this
this file, form1.txt
to put most
put most of
Normally I avoid
I avoid putting
avoid putting a
putting a great
pb_main function and
function and prefer
and prefer to
prefer to call
to call either
call either functions
either functions or
functions or sub-routines
But since this
this is just
is just a
just a demonstration
a demonstration of
demonstration of what
of what can
what can be
a console, we'll
we'll leave most
leave most of
we're first setting
first setting the
setting the colour
the colour for
for the foreground
the foreground on
foreground on our
on our console
be a light
a light green
light green colour
So we're defining
we're defining two
defining two variables
variables to determine
to determine just
determine just how
just how big
big our console
our console is
console is at
a row height
using the cons
the cons screen
cons screen command
screen command to
populate those two
want to read
just created with
created with our
with our form
our form definition
form definition into
definition into an
let's dimension that
dimension that array
then call one
common functions in
in the pb_file_handling_routines
the pb_file_handling_routines library
pb_file_handling_routines library to
file into the
So the read
the array function
array function takes
the array you
array you wish
to populate with
populate with the
data coming from
coming from that
reason we could
we could not
could not read
not read the
the file, then
then that function
that function will
return a false
have the definition
our form loaded
form loaded into
display that form
that form on
declare two more
two more variables
to say where
say where we
want the beginning
to use long_row
use long_row and
long_row and long_column
and long_column, and
we're populating those
populating those with
those with the
the values 1
values 1 and
1 and 1
be the top
of our console
can then place
then place the
place the cursor
the cursor of
cursor of the
of the console
the console at
console at that
at that location
that location using
location using the
using the con.cell
the con.cell command
So this new
array containing our
containing our data
create this function
our function taking
will first capture
first capture the
capture the size
the current console
current console using
console using the
using the con.screen
the con.screen command
con.screen command we
command we used
we used earlier
use an additional
additional variable, long_r
the rows on
rows on the
on the console
do a for_next
a for_next loop
for_next loop for
in the console
the console to
console to see
have a corresponding
a corresponding row
corresponding row in
if the row
the row we're
row we're dealing
dealing with is
with is greater
than the size
exit the for_next
the for_next loop
for_next loop because
loop because everything
because everything has
everything has been
use the con.cell
con.cell command to
cursor at a
at a specific
a specific location
specific location on
to display each
display each row
our configuration form
configuration form file
form file on
And that can
be quite simply
quite simply printed
simply printed to
printed to the
to the console
the console using
using the con.print
the con.print command
With the semicolon
the semicolon in
end to ensure
ensure we don't
we don't put
don't put a
put a newline
a newline character
newline character at
completed the display
the display form
display form function
form function, let's
the pb_main, after
after we've displayed
we've displayed the
on screen, if
do nothing else
nothing else the
else the application
the application would
application would terminate
leave it on
on screen so
screen so we
we will inject
will inject a
inject a wait_key
a wait_key command
wait_key command just
command just to
just to ensure
ensure we wait
we wait until
wait until the
until the user
see we get
Now the cursor
moment is sitting
is sitting at
sitting at the
to be entering
be entering any
entering any data
any data into
into this, we'll
cursor to the
first editable field
moment the cursor
is flashing at
flashing at the
the last data
last data we
data we displayed
we displayed on
to position this
position this cursor
this cursor at
the first field
first field on
create another genetic
another genetic function
genetic function whose
be to position
position the cursor
the cursor in
cursor in a
in a specified
a specified field
we'll declare another
declare another variable
another variable to
hold our field
our field value
set the field
field value to
value to 1
we'll call our
new function, PositionCursor
being the array
the array, and
the field we
field we wish
wish to actually
to actually put
actually put our
put our cursor
our cursor in
read through the
through the information
information that sits
array to figure
to figure out
figure out where
where the first
first field exists
will be quite
quite generic, as
put in any
in any field
any field number
to the third
the third field
third field, you
you could just
could just substitute
just substitute a
substitute a different
different value of
value of lngField
we want our
want our for
variables to help
to help us
help us keep
us keep track
track of this
our array into
array into the
into the row
the row variable
whether this has
this has got
has got a
got a field
a field in
we saw from
saw from the
from the definition
first few lines
few lines are
lines are pure
are pure text
we know each
know each of
the fields has
fields has a
has a square
a square bracket
square bracket, as
as the beginning
of the field
to see has
see has the
has the row
the row got
row got a
got a square
a square bracket?
square bracket? In
bracket? In this
this case, an
an opening square
opening square bracket
square bracket which
bracket which tells
us the position
of the beginning
this returns a
returns a value
then we've found
we've found a
can increment our
increment our field
our field counter
if that field
that field counter
field counter matches
counter matches the
matches the field
the field that
field that the
user has passed
has passed in
that matches, then
use the condot
the condot sale
condot sale command
sale command to
command to position
position our cursor
the long position
long position plus
position plus one
Long position points
position points to
points to the
to the square
the square bracket
want the cursor
cursor to appear
the right of
of the square
marking this as
this as found
looking for, there's
no point continuing
point continuing with
continuing with a
can use an
use an exit
an exit for
exit for command
for command to
command to exit
to exit out
of that loop
that loop prematurely
a possibility in
possibility in code
in code that
code that the
that the programmer
the programmer has
programmer has actually
has actually asked
actually asked for
asked for a
for a field
field which does
which does not
not exist in
in our form
set it back
assumption that whoever
that whoever designed
whoever designed the
designed the form
form has at
has at least
at least put
least put one
put one field
one field into
field into the
into the form
easily by recursively
by recursively calling
recursively calling this
this function again
in the parameter
parameter of field
of field number
field number one
completed this function
this function, this
should now position
now position our
our cursor at
can see, the
application now has
has the flashing
the flashing cursor
flashing cursor at
Our next change
next change to
it to accept
to accept keystrokes
accept keystrokes from
keystrokes from the
the user's keyboard
of these keystrokes
these keystrokes will
keystrokes will be
be to enter
user will quite
will quite obviously
quite obviously want
obviously want to
want to navigate
to navigate round
navigate round each
round each of
the fields, possibly
possibly by using
the tab key
tab key, the
the down or
down or up
or up arrow
up arrow keys
arrow keys, and
and backspace and
backspace and possibly
and possibly delete
possibly delete to
delete to edit
to edit data
From the application's
the application's point
application's point of
of view, you
the user backspacing
user backspacing over
backspacing over the
over the first
first name text
So you'll want
you'll want to
want to limit
limit the user's
the user's interaction
user's interaction to
interaction to the
to the fields
the fields themselves
how we could
we could achieve
could achieve this
have a way
way of trapping
of trapping key
trapping key presses
key presses that
presses that the
has actually made
actually made, picking
them up, decoding
decoding them and
them and acting
and acting accordingly
use the waitkey
the waitkey command
waitkey command to
command to pass
to pass its
pass its value
its value into
this will run
will run as
run as a
as a loop
waitkey command will
command will return
return the keystroke
the keystroke pressed
It will wait
will wait until
wait until that
until that happens
that happens and
happens and will
return either one
either one, two
three or four
or four characters
this video, we're
handling the first
first two characters
Characters 3 and
and 4 would
4 would be
would be if
user actually uses
uses the mouse
We'll possibly cover
possibly cover that
having populated the
populated the input
the input variable
input variable, we're
We'll handle, first
pressing of a
a single key
With any of
any of our
of our applications
our applications, we
need a way
of actually exiting
actually exiting the
exiting the application
we're first of
of all going
all going to
capture the escape
the escape button
If the escape
escape button is
button is pressed
is pressed, we
we will exit
will exit the
loop and terminate
and terminate the
terminate the application
determine the escape
escape button has
been pressed by
pressed by using
And that call
that call is
call is called
is called getAsyncKeyState
can see, is
constant called vkEscape
These constants can
constants can be
can be found
be found in
found in one
of the include
files that ships
the winuser.inc file
here the value
value of vkEscape
But having these
having these defined
these defined as
defined as constants
as constants makes
constants makes the
the code more
code more readable
more readable and
readable and saves
saves you having
out the values
the values yourself
try the code
escape button will
button will allow
application is running
we press escape
press escape, the
the application terminates
we have correctly
have correctly trapped
correctly trapped the
trapped the pressing
pressing of an
of an escape
an escape key
user presses one
presses one of
of the normal
the normal keys
normal keys in
keys in the
in the keyboard
the keyboard to
keyboard to fill
to fill data
fill data into
the field, let's
let's trap that
trap that and
that and display
and display that
display that on
that on screen
the console command
console command to
command to trap
to trap the
trap the location
You'll see why
see why we're
why we're trapping
we're trapping these
trapping these in
But just for
just for now
for now, let's
let's just print
just print the
user has put
has put in
put in on
a standard con
standard con print
con print statement
Remembering to put
put the semicolon
the semicolon at
semicolon at the
the string to
string to ensure
new line on
line on screen
is now quite
quite happily allowing
happily allowing us
to keep values
keep values in
values in on
But it's going
it's going beyond
beyond the actual
the actual form
user cannot type
cannot type beyond
type beyond the
beyond the end
of the actual
the actual field
One way of
use the conscreen
the conscreen char
conscreen char command
Y coordinate, and
return the ASCII
the ASCII value
ASCII value of
the character that's
character that's currently
that's currently sitting
sitting in that
in that position
then use chr$
use chr$ to
chr$ to turn
to turn this
turn this in
this in to
to the normal
the normal string
So using the
the key statement
look for a
a blank character
running that now…
that now… It
now… It will
will not let
not let us
let us print
us print any
print any text
any text on
on a square
square bracket because
bracket because it's
because it's not
not a space
do we navigate
we navigate around
navigate around the
around the actual
the actual forms?
actual forms? Let's
forms? Let's assume
assume that we
tab key to
key to actually
to actually move
the screen, from
from field to
field to field
with the escape
the escape key
escape key, we're
know the field
field we're in
in is in
the long field
long field variable
field variable, we
increment that, and
earlier to position
can press the
press the tab
key to cycle
Once it reaches
it reaches the
reaches the last
the last field
last field, it
will default back
default back to
you to tab
to tab through
tab through the
through the fields
the fields quite
fields quite happily
now started on
started on navigation
on navigation between
navigation between fields
So what happens
do a backspace?
a backspace? If
backspace? If we
to type something
type something in
something in and
and then backspace
then backspace over
backspace over it?
over it? Well
it? Well, we
we can trap
can trap the
trap the character
character position using
using the con.sale
the con.sale command
con.sale command, and
as we're backspacing
we're backspacing, we
quite simply decrement
simply decrement the
decrement the value
cursor at that
we try that
can type some
type some characters
some characters in
characters in, and
as we backspace
we backspace, it
it moves the
moves the cursor
the cursor back
we're having the
having the same
It will backspace
will backspace beyond
backspace beyond the
beyond the beginning
need to trap
to trap that
for the opening
the opening square
square bracket again
So having decremented
having decremented the
decremented the column
column position, we
the value on
value on that
on that position
that position on
not the opening
square bracket, we
we can allow
can allow the
allow the cursor
cursor to move
into that location
put the location
to where it
where it was
running that one
one now, we
we can backspace
can backspace, but
not allow us
us to backspace
to backspace beyond
we can delete
can delete information
delete information once
information once the
user has typed
has typed it
typed it in
They may want
to delete it
we can't key
can't key anything
we can extend
can extend the
extend the application
handle the delete
the delete key
delete key and
key and some
and some more
some more navigation
now into the
into the Select
the Select Statements
Select Statements Case
Statements Case 2
is our extended
our extended key
extended key section
The str input
str input has
input has returned
has returned with
returned with two
with two characters
two characters in
first one we
one we can
one of interest
up the delete
this case, this
to be value
be value 83
all we're doing
we're doing here
doing here is
here is again
is again picking
again picking up
of the cursor
the cursor currently
cursor currently, printing
printing a space
space character to
character to that
to that location
that location, and
setting the cursor
at the location
the location itself
some data in
can backspace quite
backspace quite happily
quite happily, and
use the R
the R letter
R letter, we
press the delete
value is erased
for the right
the right arrow
right arrow, again
again using this
using this same
this same approach
same approach as
approach as we've
the current location
current location, incrementing
incrementing it by
by one, testing
the character underneath
character underneath the
underneath the current
current location, making
making sure it's
not the end
can actually move
actually move into
it's not, we
will move back
And very similarly
very similarly, we
the left arrow
use the right
right arrow, which
which will not
beyond the field
use the left
left arrow, and
beyond the length
do the up
the up and
and the down
the down arrows
down arrows exactly
arrows exactly the
for the up
the up arrow
up arrow, we're
we're making sure
making sure that
that the line
the line above
line above the
above the line
the line we're
line we're currently
currently on actually
on actually has
actually has a
has a field
is a square
square bracket, then
it's a field
a field we
field we can
If there's no
there's no square
no square bracket
square bracket, we'll
keep the cursor
the cursor where
cursor where it
And we'll take
take the same
same approach for
approach for the
for the down
the down arrow
incrementing the roll
the roll pointer
roll pointer, testing
actually a cursor
a cursor on
cursor on that
on that field
that field, and
and allowing the
to move down
try running now
running now, we
use the down
down arrow to
arrow to move
move up and
down the fields
left arrow and
arrow and the
right arrow to
to move left
move left and
can type data
type data in
can backspace over
backspace over it
the delete character
functionality is still
is still missing
still missing, is
is we cannot
we cannot over
cannot over type
over type a
type a character
a character that's
character that's already
that's already there
would have to
have to press
to press the
is because in
because in the
in the section
the section that
handles the normal
the normal key
normal key presses
key presses, we're
testing for a
for a space
this to make
sure that it
that it handles
it handles in
handles in the
as the closing
the closing and
closing and opening
and opening square
opening square brackets
amend this case
handle the opening
the opening and
opening and closing
and closing brackets
closing brackets, if
we print to
print to the
us to key
key in quite
in quite happily
can move our
move our cursor
our cursor using
cursor using the
using the arrows
the arrows, or
or the tab
the tab keys
can backspace and
backspace and delete
and delete any
delete any characters
any characters we
characters we want
is we can
console compiler to
create a generic
generic form in
form in a
application and can
and can drive
can drive what
drive what appears
user can also
can also navigate
also navigate around
navigate around each
the screen, limiting
limiting their input
their input to
input to the
have trapped many
trapped many of
of the keyboard
the keyboard navigation
keyboard navigation buttons
move around from
around from field
to field, to
to backspace to
backspace to delete
to delete and
delete and to
and to overwrite
to overwrite data
overwrite data within
the field itself
This is by
is by no
by no means
no means a
means a complete
a complete form
complete form design
form design application
design application, but
it does show
does show the
show the basics
basics of how
of how this
how this could
could be achieved
at how to
how to get
to get and
get and set
the console, and
and the positioning
the positioning of
positioning of text
of text from
text from within
from within your
within your application
Console Compiler has
Compiler has a
number of commands
of commands that
that are specific
are specific to
specific to the
to the operation
the operation and
operation and manipulation
and manipulation of
the console itself
And it's those
it's those we're
those we're going
The application we
we have before
have before us
before us here
us here is
very simple PowerBasic
simple PowerBasic Console
PowerBasic Console application
of code, con.color
is setting the
and background colors
The command has
command has two
has two mandatory
two mandatory and
mandatory and one
and one optional
one optional parameter
is the color
have a choice
a choice of
choice of 16
of 16 colors
16 colors, ranging
ranging from black
from black to
black to intense
to intense white
this application, I'm
color to If
to If you
to change either
change either the
either the foreground
the foreground or
foreground or the
or the background
background color, you
use the value
the value -1
That will leave
leave the color
the color unchanged
The third and
and final parameter
final parameter for
parameter for this
for this command
command is count
This is optional
it is used
is used, it
it causes the
causes the color
the color attribute
color attribute to
attribute to be
to be applied
be applied immediately
applied immediately to
immediately to that
to that number
that number of
of characters, starting
starting at the
the current cursor
current cursor location
So this first
this first command
first command will
command will set
color to light
to light green
are then printing
then printing to
the console this
console this piece
of text 'ConsoleSizing'
application now, you
see the console
the console comes
console comes up
comes up and
and the printing
the printing is
printing is in
is in light
in light green
It's printing the
printing the words
the words 'ConsoleSizing'
words 'ConsoleSizing' and
'ConsoleSizing' and then
and then press
then press any
press any key
any key to
key to continue
Pressing any key
any key on
the keyboard will
keyboard will complete
will complete the
complete the application
of the displayed
the displayed console
displayed console is
console is dependent
is dependent on
dependent on its
on its configuration
There are commands
are commands within
commands within the
compiler to determine
determine what that
what that is
that is currently
currently set at
from the console
the console the
console the size
screen in rows
will declare two
declare two variables
variables to hold
hold that information
that information, and
will populate those
populate those variables
those variables using
variables using the
using the 'con.screen'
the 'con.screen' command
'con.screen' will first
will first populate
first populate the
populate the row
the row height
row height and
height and then
then the column
many characters will
characters will fit
will fit in
fit in to
the console and
console and the
then print that
print that information
the console so
console so we
what it's set
it's set as
set as, quite
using the 'con.print'
the 'con.print' command
see our default
our default size
default size for
size for a
for a console
a console is
console is 80
is 80 characters
80 characters wide
characters wide and
wide and 25
and 25 characters
25 characters high
this is insufficient
is insufficient for
insufficient for what
for what you
what you wish
do in your
in your console
your console application
console application, you
can increase or
increase or decrease
or decrease it
Many console applications
console applications run
applications run in
run in the
the background and
background and there
is no one
no one to
one to watch
to watch what's
watch what's happening
what's happening on
In fact, some
of these background
these background applications
background applications may
applications may be
may be run
be run without
run without a
without a console
a console at
console at all
be times, especially
especially when you're
when you're debugging
you're debugging the
debugging the application
the application, that
that it's useful
it's useful to
useful to put
to put information
put information out
console so you
application is currently
for a client
a client facing
client facing console
facing console application
you will want
to give some
give some feedback
user to indicate
to indicate what
indicate what the
also to give
give some indication
some indication of
long it is
will now set
now set the
the console from
console from 80
from 80 characters
characters wide to
wide to 100
to 100 characters
100 characters wide
that quite simply
'con.screen' command, which
be printing out
the console, let's
a little macro
little macro to
macro to save
Macros are a
are a very
very useful construct
useful construct, usable
usable in both
in both the
both the console
console compiler and
compiler and the
and the Windows
compile time, any
to the M
the M console's
M console's size
console's size will
size will be
will be replaced
be replaced by
replaced by these
by these three
of code before
code before it
before it compiles
this to print
to our console
our console the
our console itself
that it's telling
telling us that
that the console
the console is
console is 100
that in changing
in changing the
changing the size
our console, it
it is effectively
is effectively blanked
effectively blanked out
blanked out what
out what was
what was originally
was originally on
originally on the
a delay in
delay in the
the code between
between the time
the time when
time when we
when we printed
we printed out
printed out the
the original size
original size of
and the time
when we resized
we resized it
resized it, if
run that application
that application now
see it prints
size of 80
of 80 by
80 by 25
by 25, and
and then two
then two seconds
seconds later, the
console is redrawn
is redrawn, made
made larger and
larger and then
then set on
set on screen
to show 100
show 100 characters
characters wide by
wide by 25
by 25 characters
important to note
to note if
note if you're
the console, expect
expect what's on
on the previous
the previous console
previous console to
console to be
to be erased
this command pulls
command pulls back
pulls back the
back the console
the console size
console size in
size in the
in the number
can also pull
also pull back
the console in
console in pixels
If we define
we define two
define two variables
two variables for
variables for the
and Y size
Y size, and
use the con.size
the con.size command
con.size command to
to send the
send the value
value in pixels
in pixels to
pixels to these
two variables, we
print out those
out those values
those values on
see here that
here that the
console is currently
is currently 1733
currently 1733 pixels
1733 pixels wide
wide and 939
and 939 pixels
939 pixels high
we do more
do more with
more with the
with the console?
the console? Obviously
console? Obviously, the
console is limited
is limited by
limited by the
by the physical
the physical size
physical size of
size of your
of your monitor
The size we're
size we're showing
we're showing at
the moment of
moment of the
size of this
of this monitor
If I want
make it larger
it larger, we
in a virtual
a virtual console
The virtual console
virtual console will
console will support
will support multiple
support multiple lines
multiple lines beyond
lines beyond the
of the physical
the physical window
physical window, and
and will automatically
will automatically give
automatically give you
give you vertical
you vertical scrollbars
vertical scrollbars or
scrollbars or horizontal
or horizontal scrollbars
horizontal scrollbars to
scrollbars to support
up a virtual
a virtual size
virtual size console
we'll dimension two
dimension two variables
two variables, one
for the low
the low height
going for 100
for 100 columns
100 columns wide
columns wide and
wide and 100
and 100 rows
100 rows high
And the console
the console set
console set virtual
virtual command will
command will take
will take these
take these two
two variables and
variables and set
and set your
set your console
your console accordingly
up another little
another little macro
macro to print
print out the
virtual console, which
a different command
is using con.virtual
using con.virtual to
con.virtual to pull
the size, row
row and width
and width height
width height for
for the virtual
we'll use that
that to print
print out on
out on our
size of a
a new virtual
new virtual console
is our virtual
our virtual console
virtual console, 100
and 100 characters
100 characters high
we have 100
have 100 rows
100 rows of
rows of information
of information, as
will see, there
now a scrollbar
a scrollbar on
scrollbar on the
the console, which
used to scroll
scroll down and
down and up
have a virtual
virtual console much
console much larger
much larger than
than the standard
the standard 25
standard 25 rows
And if you're
if you're putting
you're putting a
putting a large
amount of information
of information to
the console, it
will allow your
allow your user
your user to
user to scroll
to scroll forward
scroll forward and
and back to
to see information
see information that
information that has
So having set
having set our
set our virtual
virtual console, can
can we now
we now print
now print some
print some data
some data out
to the console?
the console? When
console? When you're
you're using the
con.print command, it
it will print
will print a
a line out
line out to
console and then
and then will
then will print
will print on
print on the
next line after
should get line
get line one
line one and
one and line
and line two
line two on
two on two
on two separate
two separate lines
will see line
see line one
line two are
two are printed
are printed out
printed out to
wish to print
to print line
print line two
two on the
same line as
line as line
as line one
line one, simply
simply place a
place a semicolon
a semicolon at
code now, you
would see line
two are now
are now on
The semicolon forces
semicolon forces the
forces the application
not to put
put a carriage
when you wish
to print on
print on a
the screen rather
screen rather than
rather than on
than on the
set this in
the application by
application by using
We've created two
created two local
local variables, row
and column, to
hold the values
setting the row
the row to
to be row
be row ten
ten and the
the column to
we're using con.cell
using con.cell with
con.cell with those
with those two
set our location
our location to
location to row
to row ten
ten and column
and column one
print some new
some new data
new data to
console at this
at this location
And I'm using
using the semicolon
our command to
that the carriage
line feed is
feed is not
is not executed
not executed at
executed at the
of the print
the print statement
code now, as
the words new
words new data
new data are
data are now
now on line
on line number
line number ten
As we put
put a semicolon
of that print
that print command
print command, the
the next text
next text to
be printed at
printed at the
at the console
the console will
console will be
will be printed
Removing the semicolon
the semicolon would
semicolon would allow
can print to
print to any
to any location
any location on
screen by the
by the X
and Y character
Y character coordinates
character coordinates, we
now print on
on a line
a line before
line before line
before line ten
can print on
print on line
on line nine
line nine and
nine and column
that now, you
we're getting old
getting old data
old data on
data on line
line nine, new
new data on
on line ten
line ten, and
and the press
the press any
key to exit
to exit is
exit is appearing
is appearing here
appearing here on
here on line
As that's where
that's where the
current cursor is
cursor is now
is now located
also take the
take the opportunity
the opportunity for
opportunity for printing
for printing further
printing further along
further along on
along on line
color we print
we print with
print with quite
with quite easily
using the con.color
the con.color command
we are printing
are printing to
printing to row
to row nine
row nine, column
column number ten
And we're printing
we're printing the
the words extra
words extra data
extra data, but
but we're printing
we're printing it
printing it in
it in color
in color number
color number five
the text extra
text extra data
extra data is
data is now
is now printed
now printed in
printed in a
in a magenta
a magenta color
And every piece
every piece of
of text generated
text generated after
generated after that
after that will
the same color
want the press
to exit to
exit to appear
a line below
line below all
below all the
the text we've
text we've currently
we've currently done
currently done, we
column position to
be row twenty
row twenty and
twenty and column
and column number
the color back
color back to
back to green
we have it
taken our standard
our standard console
standard console and
console and we
have amended its
amended its size
have also set
also set up
virtual console to
console to allow
to allow scroll
allow scroll bars
bars to be
to be initiated
be initiated, so
can scroll up
and down within
down within the
So a large
amount of text
of text can
text can be
can be maintained
be maintained on
maintained on screen
on screen for
screen for the
user to peruse
have also used
also used the
used the cell
the cell command
cell command to
command to target
to target the
target the area
the area to
area to which
print on any
on any row
any row and
row and any
and any column
any column and
amend the color
the color that
color that appears
using this approach
this approach, you
can have complete
have complete control
complete control over
over what is
what is printed
is printed on
console and where
and where on
screen it appears
would allow a
allow a console
a console screen
console screen to
screen to maintain
to maintain a
maintain a report
a report of
report of real-time
of real-time data
real-time data generated
data generated during
generated during the
during the running
running of your
are many more
many more other
more other console
other console commands
console commands which
commands which we
use to manipulate
to manipulate the
manipulate the console
look at commands
at commands for
commands for the
be looking specifically
specifically at commands
at commands used
commands used within
And the commands
the commands we're
commands we're going
at are those
are those directly
those directly associated
directly associated with
associated with the
with the console
There may come
may come a
wish to monitor
to monitor a
monitor a background
a background application
would be a
be a console
console application which
application which is
which is running
is running with
running with no
with no user
This process can
process can be
can be processing
be processing data
processing data into
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
may want a
want a quick
a quick and
quick and easy
and easy way
way to monitor
to monitor what
monitor what the
Something simpler than
simpler than monitoring
than monitoring log
monitoring log files
can do within
do within the
The Windows console
Windows console can
console can be
be quite flexible
do first of
all is to
is to designate
designate the number
and columns that
columns that are
up two constants
two constants, one
in our console
our console we're
console we're going
to have 25
have 25 rows
25 rows and
rows and 80
and 80 columns
The console can
can be set
be set up
set up within
up within PowerBasic
within PowerBasic as
PowerBasic as a
as a virtual
Hence you can
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
the console you
console you can
have a range
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
of those colours
those colours is
colours is allocated
is allocated by
allocated by using
make our code
to read, we're
global string which
string which will
contain the text
text of each
of these colours
For example red
example red, blue
blue or green
to designate a
designate a colour
a colour we
colour we can
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
the number to
call this global
global array 'colours'
do some preparatory
some preparatory work
preparatory work to
work to set
our application, to
use these colours
these colours and
colours and to
and to prep
to prep our
prep our screen
be displaying some
displaying some random
some random data
random data on
the screen, just
use the randomise
randomise command to
up the random
the random number
have dimensioned our
dimensioned our global
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
going to 15
to 15, which
which will encapsulate
will encapsulate all
encapsulate all 16
all 16 colours
16 colours that
colours that we
can use in
use in the
in the basic
function called 'prepcolours'
will set up
up our colours
our colours in
colours in the
we will prepare
will prepare that
prepare that function
that function now
very simple function
simple function with
function with effectively
with effectively only
effectively only one
only one line
using the array's
the array's 'sign'
array's 'sign' command
'sign' command to
command to assign
to assign a
assign a value
value to each
the elements of
elements of our
from black all
black all the
the way through
way through to
through to intense
So having prepared
having prepared our
prepared our array
our array with
array with colours
with colours, we
need to prepare
prepare the console
the console screen
single parameter to
this new 'prepscreen'
new 'prepscreen' function
the name we
name we want
we want on
want on the
the console window
console window itself
create the function
function to prepare
to prepare our
prepare our screen
is our 'prepscreen'
our 'prepscreen' function
'prepscreen' function taking
be the console
the console name
console name of
console window on
window on the
on the monitor
the monitor screen
Using pixel coordinates
pixel coordinates from
coordinates from the
using the 'con.loc'
the 'con.loc' command
'con.loc' command to
going for 50
for 50, 50
use the virtual
the virtual option
virtual option to
set the number
and columns on
columns on our
allows you, should
you need a
need a larger
a larger console
larger console window
console window, to
set it quite
easily using this
the two constants
two constants we
constants we created
created earlier for
earlier for rows
Next we can
the title quite
title quite easy
quite easy using
easy using the
using the 'caption'
the 'caption' command
will put a
a caption on
caption on the
on the window
the window of
window of the
use the 'color'
the 'color' command
'color' command to
the default foreground
default foreground and
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
are two parameters
two parameters on
parameters on this
on this command
is the foreground
foreground color, which
we're setting as
setting as green
is the background
If you use
you use a
use a -1
a -1 it
-1 it will
it will leave
value to whatever
to whatever it
whatever it is
it is currently
Console windows default
windows default to
default to a
to a black
put a 'wait'
a 'wait' command
'wait' command in
in our pb_main
and have it
have it display
it display on
on screen long
screen long enough
long enough for
enough for us
actually see what
see our console
console window appears
It's got 'monitor
got 'monitor display'
'monitor display' as
display' as the
window and if
the keyboard, the
screen will close
have successfully set
successfully set up
need to clear
clear the screen
the screen at
screen at any
point in your
your application, you
use the 'cls'
the 'cls' command
'cls' command, which
console commands, to
clear the console
console window completely
to display some
display some information
information to a
a user, there
be some headers
some headers or
headers or default
or default data
default data to
on this type
display these headers
will be text
be text, which
which is non-changing
create a display
a display headers
display headers function
headers function to
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
to print onto
print onto the
onto the console
doing a fair
bit of printing
of printing to
console window, so
common function whose
be to print
to print information
print information to
information to that
to that window
first we want
the location to
location to which
This is counted
is counted from
of our window
our window, so
setting to row
to row two
row two and
two and column
and column two
print to this
to this window
this window a
window a piece
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
Via four parameters
four parameters, the
text we wish
to print, and
the colour we
colour we wish
to print it
create this print
this print to
print to console
to console function
four parameters being
parameters being passed
being passed to
passed to this
The last parameter
parameter is set
is set as
set as optional
My idea behind
this is if
not specify the
specify the colour
the colour, it
will not change
not change the
in to test
whether this optional
parameter is present
is present or
present or not
This tests whether
tests whether the
whether the optional
the optional parameter
parameter has actually
So if is
if is missing
is missing is
missing is false
is false, then
know that a
that a colour
a colour parameter
colour parameter has
has been given
get the colour
the colour number
colour number associated
number associated with
associated with that
with that colour
that colour name
a little embedded
little embedded function
embedded function in
in here called
here called get
called get colour
return the colour
colour number that
that the colour
the colour command
colour command needs
command needs to
needs to use
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
particular application I'm
application I'm leaving
I'm leaving the
leaving the background
the background colour
colour as black
the get colour
get colour function
colour function in
push on to
on to do
do the last
the last couple
last couple lines
couple lines of
the colour should
colour should the
should the parameter
the parameter have
parameter have come
come in, we
we want next
want next to
next to do
do the setting
setting of the
of the location
location to print
use the cell
cell command for
for that, as
have the row
the location we
location we wish
print to, we
use the print
the print command
command to print
to print our
print our text
case the print
print command is
command is followed
by the variable
containing the text
the text you
text you wish
you put a
the line, it
it means it
will not put
not put a
Which would automatically
would automatically push
automatically push the
push the cursor
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
straightforward function whose
be to return
of the associated
the associated colour
associated colour name
have all of
of these colour
these colour names
colour names in
names in a
global array, we
do a for-next
a for-next loop
for-next loop to
each element while
element while looking
while looking for
for a match
going for the
for the zero
zero element to
element to the
The UBOUND command
UBOUND command will
command will quite
will quite easily
quite easily return
easily return the
return the maximum
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
come in with
with the parameters
the parameters against
parameters against the
against the colour
the colour held
colour held in
using the U
the U CASE
U CASE command
CASE command to
of these strings
these strings to
strings to uppercase
This avoids having
avoids having a
having a problem
a problem where
problem where the
has actually coded
actually coded this
coded this with
this with lowercase
with lowercase for
lowercase for the
of the colour
colour and our
and our array
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
returning the element
the element number
element number of
is the colour
colour number, and
the function at
function at that
get the first
our first piece
of text on
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
can put additional
put additional pieces
additional pieces of
of information in
information in to
in to put
to put text
put text on
will be additional
be additional pieces
text which will
not change during
change during the
first of these
these is the
the word polling
be a section
to indicate whether
indicate whether polling
whether polling is
polling is active
active or inactive
row number to
be row number
row number 4
number 4 and
4 and the
column number to
column number 2
And we're displaying
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
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
in one row
Displaying on row
on row 8
row 8 starting
8 starting at
starting at column
at column 2
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
color and then
and then CPU
then CPU load
CPU load, CPU
CPU response time
response time and
time and user
and user count
all the fixed
the fixed pieces
fixed pieces of
text that will
that will not
not change within
change within our
loop which we're
which we're about
about to do
So I'm adding
adding a number
and a count
use the count
count variable for
of times we
times we run
we run round
run round this
round this loop
time we pass
we pass through
pass through this
through this loop
this loop we
Once the count
count variable reaches
variable reaches This
reaches This means
longer need the
need the wait
the wait key
wait key at
can now start
now start to
start to put
put the information
to populate first
populate first of
all the system
the system polling
system polling and
polling and we'll
to return that
return that value
These functions of
functions of course
of course are
course are just
are just dummy
just dummy functions
you were writing
were writing this
writing this for
this for real
for real each
real each of
these functions would
functions would perform
would perform whatever
perform whatever is
whatever is needed
is needed to
needed to get
information that you
So this again
again is a
simple function just
just to demonstrate
to demonstrate different
demonstrate different text
different text appearing
text appearing on
using the random
number generator here
generator here to
here to generate
generate a number
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
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
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
put in within
in within this
this loop are
loop are of
are of the
word inactive in
inactive in first
in first and
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
would not overwrite
not overwrite the
overwrite the last
last two letters
two letters of
letters of inactive
we make them
make them all
them all the
all the same
same length that
length that will
not be a
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
Otherwise the loop
loop will run
run so fast
so fast you'll
fast you'll hardly
you'll hardly see
hardly see anything
see anything on
So we're putting
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
see it displays
it displays inactive
displays inactive and
inactive and active
and active randomly
then after 10
after 10 iterations
10 iterations of
the loop the
loop the program
program will terminate
some more printing
more printing in
Again specifying the
specifying the row
text is to
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
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
quite easy to
easy to discern
to discern on
discern on the
we'll put two
two more pieces
more pieces of
of information on
information on our
the additional bits
additional bits of
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
number generator to
generator to go
to go from
go from a
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
be two characters
two characters it
characters it won't
it won't cause
won't cause a
cause a problem
in this bottom
this bottom one
bottom one where
one where we're
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
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
be in a
in a 5
a 5 character
5 character limit
the text will
text will be
will be pushed
be pushed to
pushed to the
Therefore nothing will
nothing will be
will be left
be left on
left on screen
on screen from
the previous iteration
getting the polling
the polling, the
CPU load, the
the response time
time and the
the user count
user count quite
count quite successfully
quite successfully appearing
successfully appearing on
quite easily build
easily build up
build up information
up information on
the screen using
screen using only
using only a
only a very
a very few
very few console
few console commands
is we've used
we've used console
used console commands
commands to set
up a console
a console of
console of a
fixed size, make
it a virtual
a virtual screen
virtual screen to
us to increase
to increase it
increase it should
it should we
should we wish
We have prepared
have prepared our
prepared our screen
our screen, used
used the clear
the clear screen
clear screen command
to display static
display static headers
static headers and
headers and we've
we've used a
used a loop
loop to display
display information using
information using a
using a delay
a delay on
delay on the
our user in
user in different
in different colors
different colors using
colors using a
a standard, generic
generic print to
to console command
specify the row
and column, the
text to display
With these few
these few commands
few commands you
commands you can
compiler to display
a user quite
user quite easily
easily to allow
them to monitor
to monitor some
monitor some background
some background process
Power Basic console
Basic console compiler
again at commands
created a console
application which displays
which displays information
displays information to
from the start
of code at
the beginning which
beginning which define
which define two
define two constants
In the pb_main()
the pb_main() function
pb_main() function, we
we make a
to a prep
a prep screen
prep screen function
This prepares our
prepares our console
our console for
console for use
a command which
command which sets
which sets the
sets the size
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
80 columns, which
is the standard
the standard console
standard console size
is to increase
our console, to
to go up
up to 50
to 50 rows
50 rows and
rows and 100
and 100 columns
further changes, we
but you will
you will also
will also see
also see we
now have horizontal
have horizontal and
and vertical scroll
vertical scroll bars
scroll bars, which
which allow us
move up, and
and right on
right on the
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
flexibility for what
console compiler for
to change today
change today is
code that displays
that displays information
displays information on
have this at
the moment inside
moment inside a
inside a Do
take this section
code and move
and move it
move it into
own function, and
that function display
function display screen
Having these lines
code in its
own function will
function will make
will make our
make our PB
main function much
function much tidier
code just pasted
just pasted in
clear our console
our console screen
console screen, we
display the headers
and we jump
we jump into
jump into the
into the Do
the Do loop
Do loop to
see it behaves
it behaves exactly
behaves exactly as
It runs through
through the loop
the loop, and
the loop, it
it will terminate
will terminate the
have removed that
removed that code
that code from
code from our
from our PB
main function, there
are some declares
some declares at
declares at the
function that we
that we no
longer need, so
will just take
just take those
take those out
features of the
the console within
console within Power
Power Basic, you
have not one
not one, but
but eight consoles
eight consoles available
consoles available, and
can switch quite
switch quite easily
between each console
Only one console
one console can
console can display
one time, but
having these eight
these eight separate
eight separate consoles
separate consoles gives
consoles gives us
of flexibility for
flexibility for how
for how our
how our application
our application operates
the display screen
display screen section
screen section, there's
there's a call
to a underlying
a underlying function
underlying function called
called display headers
This displays basically
displays basically a
basically a template
a template on
template on screen
can use later
use later on
are the headings
console compiler keeps
compiler keeps track
track of both
both the active
the active console
active console page
console page and
and the visible
the visible console
visible console page
important to differentiate
differentiate between these
The active page
active page is
page is the
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
can guess, the
visible page does
page does not
does not necessarily
not necessarily have
necessarily have to
as the active
of the active
active page and
of the visible
visible page for
page for our
for our console
add another local
variable called status
be a static
I intend to
intend to use
the console pages
console pages as
pages as a
as a template
a template so
template so that
application runs, it
create a template
template on the
on the eighth
the eighth console
eighth console page
be used as
used as a
a template to
template to copy
to copy into
copy into any
into any of
the other pages
other pages we
pages we wish
create this template
this template once
of code can
code can be
copy that eighth
that eighth console
console page to
page to any
to any other
any other page
other page of
page of the
our status variable
status variable is
we have or
have or haven't
or haven't yet
haven't yet created
yet created that
created that template
use of two
of two additional
two additional console
additional console commands
Con page active
page active, which
determine what is
what is the
is the active
active page, and
and con page
con page visible
page visible to
visible to determine
determine which is
These will populate
will populate these
two variables, which
value within our
status variable will
variable will determine
whether the template
the template has
template has already
been created or
created or not
If the template
been created, we're
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
new constant in
constant in a
moment to hold
the value 8
will be template
be template page
we are copying
are copying the
copying the eighth
eighth console to
console to the
to the currently
the currently active
currently active console
determine which console
which console page
console page we're
page we're actually
actually on, let's
let's print something
print something to
see which console
console page is
page is in
is in use
print to row
to row 1
row 1, column
column 2, and
print function we
created in the
print the visible
visible page number
the page, in
in the cyan
the cyan colour
once that has
that has completed
If the status
the status variable
is false, it
it means our
means our template
our template has
template has not
not yet been
yet been created
use the code
the code that's
code that's about
that's about to
about to follow
to follow this
follow this to
create our standard
our standard template
set the status
status variable to
all the code
the code after
need not change
This will print
will print to
print to whatever
to whatever the
whatever the active
console page actually
page actually is
copy the active
active page back
page back to
to the template
an application, we'll
new constant, this
this template page
template page constant
page constant at
So we'll be
using the eighth
console page as
page as our
as our template
with the page
page number now
number now displayed
now displayed at
displayed at the
our console page
console page, we
now try running
have page 1
page 1 at
1 at the
have this multiple
this multiple console
multiple console ability
console ability set
ability set up
up within our
our application, how
use of it?
of it? So
it? So let's
pb_main function, we
we prepare the
prepare the screen
and we display
display the screen
of the con
the con scroll
con scroll commands
you to scroll
scroll up, down
Scrolling up on
console will move
the text effectively
text effectively downwards
I will put
put a waitkey
a waitkey command
waitkey command after
command after that
after that so
can still see
still see it
the screen after
screen after the
after the application
application completes that
completes that command
display the information
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
to which you
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
a little interactive
little interactive with
the console here
create three new
three new local
One for input
for input, one
one for page
for page, both
both string and
string and number
using a Do
Do loop here
will first position
first position the
cursor at row
at row 2
row 2, column
colour to black
to black with
black with a
with a white
use the con
the con input
con input command
input command to
user for a
for a response
So giving the
giving the text
the text, do
do you wish
wish to exit
to exit yes
exit yes or
yes or no?
or no? And
no? And whatever
And whatever the
whatever the user
user types and
types and then
and then presses
then presses enter
presses enter, we
will store into
store into the
into the input
you to get
to get interactive
get interactive with
interactive with your
with your user
of that input
that input variable
I'm forcing the
forcing the input
input variable to
variable to uppercase
uppercase to test
the word yes
word yes has
yes has been
it has, we're
we're then exiting
then exiting our
exiting our loop
If we're not
exiting the loop
the loop, I'm
going to ask
to ask the
ask the user
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
to prompt them
prompt them for
them for an
for an input
variable called page
can then transfer
then transfer the
transfer the value
that string variable
variable to a
to a numeric
a numeric variable
numeric variable using
using the VAL
the VAL command
of that page
that page variable
page variable to
if it's either
it's either value
either value 1
value 1 or
1 or 2
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
the same value
same value, you
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
you have different
have different functionality
different functionality in
functionality in mind
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
user using our
our existing display
existing display screen
display screen function
resetting the color
to green with
green with a
background and calling
and calling display
calling display screen
And then scrolling
then scrolling up
scrolling up 10
up 10 lines
10 lines, as
once we exit
we exit this
exit this loop
can then, for
this application, re-display
re-display each of
console pages to
pages to the
For example pages
example pages 1
pages 1 and
1 and pages
and pages 2
do this, all
all I need
page visible command
visible command to
the page I
page I wish
using a waitkey
it to remain
to remain on
remain on screen
see it before
it before going
before going to
the next console
next console page
how it goes
So the application
runs and we're
we're displaying the
displaying the information
information on page
on page 1
page 1 to
this is completed
is completed, we
scroll down 10
down 10 lines
10 lines and
lines and we
and we prompt
we prompt the
see whether they
whether they wish
yes or no
this case, let's
the value no
value no in
no in and
in and press
and press the
It's now asking
now asking which
asking which console
console page we
page we actually
we actually want
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
it's now displaying
now displaying console
displaying console page
page 2 to
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
we'll say yes
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
last data appearing
appearing on page
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
wait key command
what was in
was in page
enter button once
once more, the
application will complete
we have extended
have extended our
extended our console
our console beyond
console beyond the
beyond the allowing
the allowing us
to have scroll
scroll bars, vertical
have taken information
taken information on
console screen and
screen and saved
and saved it
saved it to
to a template
a template console
template console screen
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
easily to switch
to switch between
switch between them
between them, using
using the visible
visible and active
and active commands
have displayed information
displayed information on
the first page
first page to
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
been completed, when
user decides they
decides they wish
to exit, then
then we're showing
we're showing each
showing each page
each page to
to have 8
have 8 console
8 console pages
console pages and
pages and to
user to switch
between them, and
also to copy
to copy information
copy information from
the other, gives
of flexibility in
flexibility in your
your console applications
own applications, but
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 PowerBasic
used PowerBasic before
PowerBasic before or
before or even
or even considered
even considered taking
considered taking up
taking up programming
look at Object-Oriented
at Object-Oriented Programming
what is Object-Oriented
is Object-Oriented Programming?
Object-Oriented Programming? Object-Oriented
Programming? Object-Oriented Programming
Object-Oriented Programming or
Programming or OOP
or OOP for
OOP for short
for short is
short is a
is a computer
a computer programming
computer programming model
programming model that
model that organizes
that organizes software
organizes software around
software around objects
around objects instead
objects instead of
instead of functions
functions and procedures
The concept of
concept of OOP
of OOP is
OOP is not
is not new
not new and
new and has
and has been
has been around
been around since
around since the
since the mid
the mid has
mid has garnered
has garnered both
garnered both supporters
both supporters and
supporters and detractors
and detractors for
detractors for the
for the concept
Like any programming
any programming module
programming module it
module it has
it has advantages
has advantages and
advantages and disadvantages
And the model
the model breaks
model breaks down
breaks down to
down to four
to four basic
four basic principles
basic principles or
principles or pillars
Inheritance and Polymorphism
back to these
to these but
these but first
but first let's
first let's look
at the advantages
the advantages and
are the advantages
the advantages of
advantages of adopting
of adopting OOP?
adopting OOP? Modularity
Your code is
code is contained
contained in objects
in objects, allowing
allowing new applications
new applications to
applications to be
to be constructed
be constructed from
constructed from pre-built
from pre-built modular
pre-built modular building
modular building blocks
Once objects have
been created they
created they can
can be reused
be reused in
reused in future
in future projects
future projects without
projects without recoding
without recoding them
Objects can be
can be replaced
be replaced easily
replaced easily if
easily if the
if the interface
the interface to
interface to that
to that object
that object is
object is maintained
Once the interface
interface to an
to an object
object is documented
is documented it
documented it becomes
it becomes easier
becomes easier to
easier to maintain
Provision of features
of features that
features that help
that help protect
help protect data
protect data and
data and control
and control access
control access to
access to it
to it improve
it improve your
improve your security
OOP is widely
is widely adopted
widely adopted in
adopted in many
in many programming
many programming languages
are the disadvantages?
the disadvantages? The
disadvantages? The learning
The learning curve
learning curve can
curve can be
can be challenging
be challenging for
challenging for those
for those new
those new to
new to object-oriented
to object-oriented programming
is not always
not always suitable
always suitable for
suitable for all
for all types
all types of
types of problems
In some situations
some situations it
situations it can
it can consume
can consume more
consume more memory
more memory and
memory and CPU
and CPU resources
There are often
are often more
often more lines
code in an
in an OOP
an OOP program
OOP program which
program which can
can be daunting
be daunting to
daunting to new
to new programmers
some situations programs
situations programs can
programs can take
can take longer
longer to run
Extra Design Effort
More time is
time is required
is required to
required to design
design an object-oriented
an object-oriented program
While spending more
spending more time
more time on
time on design
on design is
design is not
not always a
always a bad
a bad thing
bad thing, it
to be factored
be factored in
factored in to
in to your
to your project
are the main
the main building
main building blocks
building blocks of
blocks of object-oriented
of object-oriented programming?
object-oriented programming? Classes
A class is
class is a
is a blueprint
a blueprint for
blueprint for creating
for creating objects
It provides the
provides the initial
the initial value
initial value for
value for states
for states and
states and implementations
and implementations of
implementations of behaviour
The class defines
class defines the
defines the nature
the nature of
nature of a
of a future
a future object
You can interpret
can interpret a
interpret a class
a class as
class as a
as a concept
a concept where
concept where the
is the reality
the reality or
reality or the
or the embodiment
the embodiment of
embodiment of that
of that concept
object is a
a data field
data field with
field with unique
with unique attributes
unique attributes and
attributes and behaviour
These are instances
are instances of
instances of a
of a class
a class created
class created with
created with certain
with certain data
Objects have the
have the flexibility
flexibility to correspond
to correspond to
correspond to real-world
to real-world objects
real-world objects or
objects or abstract
or abstract entities
A method defines
method defines the
defines the behaviour
the behaviour of
behaviour of the
the objects created
objects created from
created from the
from the class
The method is
method is an
is an action
an action that
action that an
that an object
an object can
object can perform
are basically functions
basically functions defined
functions defined inside
defined inside a
inside a class
a class that
class that determine
that determine what
what the object
the object can
object can do
are the characteristics
the characteristics of
characteristics of the
of the class
the class that
class that aids
that aids in
aids in differentiating
in differentiating it
differentiating it from
it from other
from other classes
other classes and
classes and makes
and makes it
makes it unique
it unique and
unique and identifiable
are the four
the four pillars
four pillars of
pillars of object-oriented
object-oriented programming? Encapsulation
A foundation pillar
foundation pillar that
pillar that protects
that protects data
protects data from
data from unauthorised
from unauthorised access
important to hide
to hide away
hide away data
away data and
data and code
and code and
code and separate
and separate it
separate it out
Encapsulating data within
data within objects
within objects safeguards
objects safeguards it
safeguards it from
it from unauthorised
allows a child
a child class
child class to
class to have
its own unique
own unique behaviour
unique behaviour while
behaviour while still
while still sharing
still sharing the
sharing the same
the same methods
same methods as
methods as its
as its parent
its parent class
This allows for
allows for class-specific
for class-specific behaviour
class-specific behaviour and
behaviour and more
and more reusable
more reusable code
Where classes can
classes can inherit
can inherit properties
inherit properties and
properties and methods
and methods from
methods from other
The class from
class from which
from which you
which you inherit
you inherit is
inherit is called
is called either
called either the
either the base
the base or
base or parent
or parent class
a process of
process of focusing
of focusing on
focusing on the
on the essential
the essential features
essential features of
features of an
of an object
an object while
object while hiding
while hiding the
hiding the details
It's a key
a key concept
key concept in
concept in object-oriented
in object-oriented programming
object-oriented programming and
programming and helps
and helps reduce
helps reduce complexity
reduce complexity and
complexity and increase
and increase efficiency
look at Encapsulation
is a fundamental
a fundamental concept
fundamental concept in
object-oriented programming that
programming that combines
that combines data
combines data and
data and methods
and methods into
methods into a
a single unit
single unit called
unit called a
called a class
Encapsulation has several
has several benefits
several benefits which
benefits which include
which include maintaining
include maintaining data
maintaining data integrity
The protective layer
protective layer around
layer around the
around the data
the data prevents
data prevents unauthorised
prevents unauthorised access
unauthorised access, presenting
presenting a consistent
a consistent interface
Developers can present
can present a
present a consistent
consistent interface that
interface that is
that is independent
is independent of
independent of its
of its internal
its internal implementation
internal implementation, enforcing
enforcing rules and
rules and validations
The class can
class can enforce
can enforce its
enforce its own
its own rules
own rules and
body of a
of a car
a car or
car or automobile
or automobile houses
automobile houses the
houses the engine
the engine, transmission
transmission and brakes
you can interact
with the car
the car using
car using its
using its controls
its controls without
controls without needing
without needing to
needing to understand
to understand how
understand how these
how these underlying
these underlying parts
underlying parts actually
parts actually function
is a feature
a feature of
feature of object-oriented
of object-oriented programming
object-oriented programming languages
That allows a
allows a specific
a specific routine
specific routine to
routine to use
to use variables
use variables of
variables of different
different types at
types at different
at different times
Polymorphism in programming
in programming gives
programming gives a
gives a program
a program the
program the ability
ability to redefine
to redefine methods
redefine methods for
methods for derived
for derived classes
Inheritance is where
is where classes
from other parent
other parent or
parent or base
or base classes
Inheritance allows for
allows for code
for code reuse
code reuse and
reuse and establishes
and establishes relationships
establishes relationships between
relationships between classes
The derived class
derived class can
class can extend
extend the functionality
functionality of the
of the base
the base class
base class from
from which it
which it is
it is derived
is derived by
derived by adding
by adding new
adding new features
new features or
features or overriding
or overriding existing
overriding existing ones
This approach can
approach can speed
can speed up
speed up development
up development when
development when used
when used correctly
used correctly, but
but does involve
does involve planning
involve planning out
planning out each
of the classes
the classes and
classes and ensuring
and ensuring that
ensuring that any
that any change
any change you
change you make
you make to
to a base
a base class
base class doesn't
class doesn't have
doesn't have an
have an adverse
an adverse effect
adverse effect to
effect to the
to the derived
Some years ago
years ago I
ago I was
I was told
was told a
told a story
a story about
story about a
about a military
a military helicopter
military helicopter flight
helicopter flight simulator
flight simulator in
simulator in use
in use in
use in Australia
in Australia, and
and the developers
the developers were
developers were asked
were asked to
asked to enhance
to enhance it
enhance it as
it as the
as the helicopter
the helicopter crews
helicopter crews were
crews were firing
were firing at
firing at anything
at anything seen
anything seen moving
seen moving on
moving on the
on the ground
the ground, as
as they were
they were obviously
were obviously the
obviously the enemy
So the developers
the developers added
developers added wildlife
added wildlife by
wildlife by creating
a new class
new class for
class for kangaroos
for kangaroos to
kangaroos to make
make the simulator
the simulator more
simulator more realistic
Flight crews then
crews then had
then had to
had to identify
to identify what
identify what was
what was moving
was moving on
the ground before
ground before engaging
before engaging it
On its first
its first use
first use, the
the crew ignored
crew ignored a
ignored a group
a group of
group of kangaroos
of kangaroos and
kangaroos and flew
and flew on
flew on, and
and then were
then were most
were most annoyed
most annoyed when
annoyed when one
when one of
of the kangaroos
the kangaroos pulled
kangaroos pulled out
pulled out a
out a weapon
a weapon and
weapon and shot
and shot them
shot them down
The new kangaroo
new kangaroo class
kangaroo class had
class had been
had been inherited
been inherited from
inherited from the
from the 'Soldier'
the 'Soldier' class
'Soldier' class, and
and a developer
a developer had
developer had forgotten
had forgotten to
forgotten to override
to override the
override the parts
the parts of
class that handled
that handled weapons
Abstraction Abstraction is
Abstraction is a
is a core
a core concept
core concept and
concept and is
and is a
a process for
process for hiding
for hiding the
hiding the internal
the internal data
internal data and
data and implementation
and implementation from
implementation from outside
allows the programmer
the programmer to
programmer to concentrate
to concentrate on
concentrate on a
on a reduced
a reduced set
reduced set of
set of data
of data and
data and functionality
and functionality by
functionality by creating
by creating application
creating application components
are the building
the building blocks
An object contains
object contains some
contains some properties
some properties and
We can hide
can hide them
hide them from
from the outer
the outer world
outer world through
world through access
through access modifiers
can then provide
then provide access
provide access only
access only for
only for required
for required functions
required functions and
functions and properties
and properties to
the other programs
is the general
the general procedure
general procedure to
procedure to implement
to implement abstraction
implement abstraction in
abstraction in object-oriented
types of abstraction
of abstraction –
abstraction – data
– data abstraction
data abstraction and
abstraction and process
and process abstraction
the object data
object data is
is not visible
to the outer
outer world, it
it creates data
creates data abstraction
If needed, access
access to the
to the object's
the object's data
object's data is
data is provided
is provided through
provided through some
through some methods
some methods or
methods or properties
need to provide
to provide details
provide details about
details about all
about all the
all the functions
the functions of
functions of an
When we hide
hide the internal
the internal implementation
internal implementation of
implementation of the
the different functions
different functions involved
functions involved in
involved in a
a user operation
user operation, it
it creates process
creates process abstraction
in conclusion, is
is object-oriented programming
object-oriented programming right
programming right for
right for one
of your projects?
your projects? We
projects? We have
We have looked
have looked at
and disadvantages of
disadvantages of using
of using object-oriented
using object-oriented programming
it will depend
will depend on
depend on the
on the project
the project you
project you are
you are working
are working on
working on, the
the number and
number and skills
and skills of
skills of your
of your developers
your developers, whether
whether a switch
a switch from
switch from procedural
from procedural code
procedural code is
code is a
Object-oriented programming is
programming is well-suited
is well-suited for
well-suited for large
for large, complex
complex systems with
systems with multiple
with multiple entities
multiple entities and
entities and interactions
If your application
your application is
application is likely
be used only
used only once
only once, then
then a procedural
a procedural code
procedural code base
code base is
base is likely
be the best
It's also worth
also worth considering
worth considering a
considering a programming
a programming language
programming language that
language that can
that can support
can support both
support both objects
both objects and
objects and procedural
and procedural code
procedural code within
the same project
Basic is one
of those languages
you have found
have found all
found all this
this information useful
information useful, but
never used Power
used Power Basic
Power Basic before
Basic before or
look at code
at code libraries
What are they
are they and
they and what
and what benefits
what benefits could
benefits could they
could they bring
they bring to
bring to programming?
to programming? So
programming? So what
So what types
what types of
types of library
of library are
library are there?
are there? Well
there? Well there
Well there are
Include files, dynamic
dynamic linked libraries
linked libraries and
libraries and static
and static link
static link libraries
advantages of using
of using libraries?
using libraries? When
libraries? When you
When you start
you start coding
start coding and
coding and you
and you write
you write more
write more and
more and more
and more programs
more programs you
programs you will
you will discover
will discover that
discover that there
are some common
some common pieces
common pieces of
code that appear
that appear in
appear in multiple
in multiple programs
These common code
common code sections
code sections can
sections can be
can be placed
be placed in
placed in one
in one or
or more libraries
when you write
you write the
write the next
the next program
next program you
program you can
can just reference
just reference code
reference code that
code that has
that has already
already been written
been written and
written and tested
Thereby saving you
saving you time
you time and
time and effort
If you are
you are programming
are programming as
programming as part
part of a
of a group
group of developers
of developers you
developers you should
you should be
able to benefit
to benefit from
benefit from code
from code that
code that others
that others have
others have already
have already written
Thereby shortening the
shortening the time
taken to develop
to develop a
develop a new
a new program
new program or
program or application
can guess there
guess there needs
be some documentation
some documentation of
documentation of these
these libraries and
libraries and the
and the code
the code they
code they contain
they contain to
contain to ensure
ensure that you
can use them
use them correctly
Think of libraries
of libraries as
libraries as tools
you are repaying
are repaying a
repaying a garden
a garden fence
garden fence you
fence you don't
you don't run
don't run off
run off and
off and design
design a hammer
a hammer and
hammer and nails
Instead you use
you use tools
use tools that
tools that someone
that someone else
else has already
has already developed
at what kinds
what kinds of
kinds of library
of library PowerBasic
library PowerBasic supports
How you use
you use them
use them and
them and how
how they change
they change the
the way you
you can develop
can develop code
look at include
at include files
we will explore
will explore the
explore the uses
the uses of
uses of dynamic
of dynamic linked
linked libraries, DLLs
look at static
at static link
link libraries, SLLs
With include files
include files you
files you can't
you can't build
can't build up
build up a
up a library
a library of
library of common
common functions and
and procedures and
procedures and simply
and simply use
simply use the
use the include
the include statement
include statement to
add that functionality
that functionality to
functionality to your
to your application
in your new
your new application
new application you
application you create
you create code
create code that
code that you
that you think
you think may
think may be
be of use
of use in
use in future
in future applications
future applications then
applications then placing
then placing it
placing it in
its own include
own include file
include file will
file will give
give you that
you that option
When PowerBasic links
PowerBasic links in
links in all
in all your
all your include
your include files
include files and
files and performs
and performs a
performs a compilation
a compilation then
compilation then only
then only functions
only functions and
and procedures that
procedures that you
that you reference
you reference are
reference are included
are included in
in the executable
This is known
is known as
known as dead
as dead code
dead code removal
code removal and
removal and allows
to have small
have small executables
small executables as
executables as only
as only code
only code that
code that is
that is needed
is needed is
needed is included
Once compiled then
compiled then the
then the code
the code from
code from the
from the include
include files is
files is fixed
is fixed inside
fixed inside the
inside the executable
the executable making
executable making it
making it quite
it quite standalone
Having built up
built up a
library of useful
of useful functions
useful functions in
functions in your
in your inclu
your inclu de
inclu de files
de files you
files you can
can then reuse
then reuse your
reuse your code
your code by
code by simply
by simply including
simply including those
including those files
those files in
files in applications
in applications developed
applications developed in
developed in the
Of course you
course you have
have to take
to take care
take care not
care not to
not to amend
amend the interface
interface to common
to common functions
For example adding
example adding or
adding or taking
or taking away
taking away the
away the parameters
parameters of a
a function inside
inside the include
the include file
include file as
file as this
as this would
this would cause
would cause any
cause any future
any future compilation
future compilation of
compilation of older
of older applications
older applications depending
applications depending on
depending on that
on that interface
linked libraries are
libraries are another
are another way
another way to
way to produce
to produce common
produce common libraries
These are compiled
are compiled like
compiled like applications
like applications to
applications to produce
to produce a
produce a binary
a binary file
binary file with
the file extension
file extension of
extension of DLL
The DLL will
DLL will have
list of exported
of exported functions
exported functions and
procedures that will
that will form
will form the
form the interface
the interface between
interface between the
between the DLL
the DLL and
DLL and your
and your application
Like applications DLLs
applications DLLs are
DLLs are formed
are formed of
formed of code
of code files
code files and
files and it
and it can
it can of
of course make
course make use
use of include
Windows compiler can
compiler can produce
can produce XEs
produce XEs, DLLs
DLLs and SLLs
While the console
console compiler can
can produce EXEs
produce EXEs and
EXEs and SLLs
With a DLL
a DLL your
DLL your code
code is external
is external to
external to your
application and as
and as such
as such the
such the DLL
the DLL could
DLL could be
could be referenced
be referenced by
referenced by many
by many separate
many separate applications
separate applications at
applications at the
The Windows operating
Windows operating system
operating system keeps
system keeps track
of applications referencing
applications referencing a
referencing a DLL
a DLL and
DLL and will
and will only
will only unload
only unload it
from memory when
memory when nothing
when nothing is
nothing is left
is left referencing
left referencing it
your application you
application you can
can either reference
either reference the
reference the DLL
the DLL by
DLL by early
by early or
early or late
or late binding
In late binding
late binding you
binding you can
you can check
check to ensure
ensure the DLL
the DLL is
DLL is present
is present before
present before loading
before loading it
loading it but
it but you
but you need
need to free
to free the
free the library
the library before
library before your
before your application
your application ends
In early binding
early binding you
binding you merely
you merely reference
merely reference the
DLL by name
by name and
and the functions
the functions or
functions or procedure
or procedure you
procedure you wish
wish to call
this case if
case if the
if the DLL
DLL is not
is not present
not present a
present a Windows
a Windows error
Windows error message
error message will
message will pop
pop up and
up and your
your application will
application will terminate
As the libraries
the libraries can
libraries can be
can be common
be common you
common you can
you can update
can update an
update an application
an application or
application or many
or many applications
many applications by
applications by simply
by simply rolling
simply rolling out
rolling out one
out one or
or more updated
more updated DLLs
example if you
in a DLL
a DLL that
DLL that performs
that performs some
performs some computational
some computational intensive
computational intensive process
intensive process and
process and you
and you have
you have now
have now discovered
now discovered a
discovered a more
a more efficient
more efficient way
efficient way to
way to code
to code it
code it then
it then recompiling
then recompiling your
recompiling your DLL
your DLL and
DLL and releasing
and releasing it
releasing it to
it to overwrite
overwrite the existing
the existing DLL
existing DLL, will
will upgrade the
upgrade the application
the application or
application or other
or other applications
other applications using
applications using it
As always with
always with updating
with updating files
updating files the
files the DLL
the DLL cannot
DLL cannot be
cannot be in
be in use
in use when
use when you
when you attempt
you attempt to
attempt to overwrite
to overwrite it
link libraries have
libraries have in
in a sense
a sense somewhere
sense somewhere between
somewhere between include
between include files
files and DLLs
Like DLLs they
DLLs they are
they are compiled
are compiled binaries
compiled binaries but
binaries but like
but like include
like include files
include files they
files they can
added to your
to your applications
your applications at
applications at compile
Having compiled an
compiled an SSL
an SSL you
SSL you can
use the link
the link command
link command in
command in your
in your source
your source code
source code to
the code pre-compiled
code pre-compiled in
pre-compiled in your
in your static
your static linked
of course give
course give this
give this static
link library file
library file to
file to other
to other developers
other developers who
developers who can
who can then
then add the
add the file
file into their
into their applications
their applications without
applications without them
without them having
them having access
having access to
source code that
code that made
that made it
made it in
Both SQL tools
SQL tools and
tools and my
little grid took
grid took this
took this approach
this approach allowing
approach allowing developers
allowing developers to
developers to boost
to boost the
boost the functionality
functionality of their
of their applications
to note that
note that if
that if your
if your static
linked library source
library source code
source code has
code has for
has for example
for example 100
example 100 functions
100 functions within
functions within it
within it then
it then when
then when the
when the library
library is compiled
is compiled all
compiled all 100
all 100 functions
100 functions will
functions will be
will be contained
be contained within
So when linked
when linked in
linked in with
in with your
with your application
your application even
application even if
even if you're
not using some
these functions the
functions the code
the code will
will still be
still be in
be in your
This will make
will make your
make your EXE
your EXE larger
EXE larger than
larger than it
than it would
it would have
would have been
have been if
been if just
if just include
just include files
include files had
files had been
had been used
But PowerBasic does
PowerBasic does produce
does produce small
produce small binary
small binary files
binary files anyway
files anyway so
anyway so it's
not a major
a major issue
As these static
these static link
link libraries are
libraries are pre-compiled
are pre-compiled they
pre-compiled they can
can be given
be given or
given or even
or even sold
even sold to
sold to other
to other development
other development teams
development teams to
teams to encode
to encode in
encode in their
in their applications
applications without having
having to supply
to supply them
supply them with
them with the
with the original
the original source
original source code
is the best
the best approach?
best approach? What
approach? What is
the best to
best to use?
to use? The
use? The quick
The quick answer
quick answer to
answer to this
to this is
this is that
is that it
that it depends
it depends on
depends on your
on your applications
your applications and
applications and the
way you release
you release updates
release updates to
updates to them
Some applications will
applications will make
include files, static
link libraries and
libraries and DLLs
and DLLs and
DLLs and others
and others may
others may not
may not use
not use any
use any of
Whatever works for
works for you
for you PowerBasic
you PowerBasic provides
PowerBasic provides you
provides you with
you with many
with many tools
many tools to
tools to create
to create applications
create applications which
which are limited
are limited only
limited only by
only by your
by your imagination
at the concept
concept of Parallel
of Parallel processing
what is Parallel
is Parallel computer
Parallel computer processing?
computer processing? To
processing? To quote
To quote from
quote from Wikipedia
from Wikipedia, Parallel
Parallel computing is
computing is a
is a type
type of computation
of computation in
computation in which
in which many
which many calculations
many calculations or
calculations or processes
or processes are
processes are carried
are carried out
carried out simultaneously
Large problems can
problems can often
can often be
often be divided
be divided into
divided into smaller
into smaller ones
smaller ones which
ones which can
then be solved
be solved at
solved at the
So what does
what does that
does that actually
that actually mean?
actually mean? Let's
mean? Let's give
Let's give some
give some real
some real world
real world examples
you are in
in the business
the business of
business of producing
of producing wood
producing wood or
wood or lumber
or lumber for
lumber for building
for building or
building or manufacturing
or manufacturing, you'll
you'll need a
need a certain
certain amount of
amount of it
of it to
make the business
the business viable
Say you planted
you planted a
planted a single
a single tree
single tree and
tree and waited
and waited until
waited until it
until it was
it was 15
was 15 feet
15 feet across
feet across and
across and this
and this approach
this approach would
approach would produce
would produce a
produce a lot
lot of wood
of wood it
wood it will
take a very
time to grow
Alternatively you could
you could plant
could plant hundreds
plant hundreds or
hundreds or thousands
or thousands of
thousands of trees
of trees and
trees and let
let them all
them all grow
all grow at
grow at the
is in parallel
in parallel to
parallel to produce
to produce the
produce the amount
amount of wood
of wood you
wood you would
you would need
would need much
need much faster
To give another
give another example
another example say
example say you
say you and
you and your
and your neighbour
your neighbour need
neighbour need to
need to dig
to dig drainage
dig drainage ditches
drainage ditches in
ditches in your
in your gardens
your gardens or
gardens or backyards
each of you
of you employs
you employs one
employs one worker
one worker to
worker to start
start the work
Then you notice
you notice your
notice your neighbour's
your neighbour's worker
neighbour's worker is
worker is getting
is getting through
getting through the
through the task
the task faster
task faster than
faster than yours
So you go
you go out
go out and
out and you
and you buy
you buy your
buy your worker
your worker a
worker a bigger
a bigger shovel
bigger shovel and
shovel and some
and some energy
some energy drinks
energy drinks to
drinks to speed
to speed the
speed the worker
the worker along
Happy that the
that the work
work in your
in your garden
your garden is
garden is going
is going faster
going faster you
faster you relax
you relax for
relax for a
for a while
Then later notice
later notice that
notice that your
that your neighbour's
your neighbour's garden
neighbour's garden is
garden is being
is being worked
being worked on
worked on even
on even faster
even faster still
The neighbour has
neighbour has now
has now employed
now employed two
employed two additional
two additional workers
additional workers and
workers and those
and those workers
those workers are
workers are working
are working in
working in parallel
in parallel with
parallel with the
with the first
first to storm
to storm through
storm through the
how do computers
do computers manage
computers manage this?
manage this? What
this? What trick
What trick do
trick do they
do they employ
they employ to
employ to do
to do more
do more work?
more work? The
work? The programs
The programs or
programs or applications
or applications you
applications you run
you run on
run on your
your computer or
computer or even
or even your
even your phone
your phone are
phone are made
are made up
made up of
up of code
of code running
code running on
running on the
on the processor
the processor and
processor and accessing
and accessing memory
In the early
the early days
early days of
days of computers
of computers these
computers these processors
these processors could
processors could only
could only run
only run one
run one such
one such program
such program at
program at a
Anything else needing
else needing run
needing run would
run would basically
would basically wait
basically wait in
wait in line
in line for
line for its
for its turn
its turn to
to be processed
In early attempts
early attempts at
attempts at multitasking
at multitasking where
multitasking where computers
where computers gave
computers gave the
gave the illusion
the illusion of
illusion of doing
of doing two
doing two or
two or more
or more things
more things at
things at once
at once this
once this was
this was carried
was carried out
out by starting
by starting one
starting one task
one task and
task and doing
doing some processing
some processing on
processing on it
on it then
it then pausing
then pausing it
pausing it to
it to work
work on another
on another task
another task for
task for a
a while and
while and then
and then coming
then coming back
coming back to
task to continue
to continue working
continue working on
working on it
up the time
the time allocated
time allocated to
allocated to each
to each task
each task helped
task helped to
helped to take
take the advantage
the advantage of
advantage of any
of any natural
any natural breaks
natural breaks in
breaks in the
in the information
the information flow
information flow, like
like waiting for
waiting for a
for a user
user to think
to think about
think about what
about what to
what to type
to type in
type in next
in next by
next by doing
by doing something
doing something else
something else during
else during that
during that particular
that particular time
particular time period
However with the
with the advent
the advent of
advent of multiple
of multiple processing
multiple processing cores
processing cores computers
cores computers could
computers could have
could have two
have two, four
four or even
or even eight
even eight processing
eight processing cores
processing cores which
cores which could
which could each
could each independently
each independently work
independently work on
work on different
different tasks by
tasks by dedicating
by dedicating each
dedicating each program
each program to
program to a
a different processing
different processing core
This applies to
applies to phones
to phones just
phones just as
just as much
as much as
much as laptops
Phones are of
of course computers
course computers in
computers in their
in their own
their own right
So how does
how does all
does all this
all this work?
this work? All
work? All of
of this magic
this magic is
magic is down
to the operating
the operating system
operating system, the
the collection of
collection of code
code that runs
that runs your
runs your laptop
your laptop desktop
laptop desktop tablet
desktop tablet or
tablet or phone
It decides which
decides which processing
which processing core
processing core to
core to give
to give which
give which tasks
which tasks too
tasks too making
too making the
making the best
the best use
best use of
the available processing
available processing resources
This explains how
explains how a
how a computer
a computer can
computer can run
can run lots
run lots of
lots of different
of different programs
different programs at
programs at the
same time and
time and every
and every process
every process that
process that can't
that can't get
can't get a
get a processing
a processing slot
processing slot is
slot is back
is back in
in the multitasking
the multitasking approach
multitasking approach of
approach of waiting
of waiting in
waiting in line
How can I
can I as
I as a
as a programmer
a programmer make
programmer make use
use of this?
of this? If
this? If you're
If you're writing
writing a program
a program to
program to take
to take in
take in data
in data and
data and perform
and perform some
perform some processing
it and generate
and generate an
generate an output
As the program
program will be
be running on
a single processing
single processing core
processing core the
core the speed
the speed of
speed of execution
of execution is
execution is limited
limited by how
by how much
how much time
much time your
time your program
your program gets
program gets on
gets on that
on that core
If we break
we break up
break up the
up the processing
processing of the
the data by
data by breaking
by breaking up
breaking up the
data into smaller
into smaller parts
smaller parts and
parts and giving
and giving each
giving each part
each part to
part to a
a separate process
separate process, this
is called a
called a thread
Then each of
of those independent
those independent threads
independent threads will
threads will be
will be treated
be treated as
treated as a
as a separate
separate process by
process by the
by the operating
operating system and
system and thereby
and thereby collectively
thereby collectively get
collectively get more
get more processing
more processing time
processing time on
on the computer
the main program
main program merely
program merely needs
merely needs to
needs to wait
to wait for
wait for the
for the threads
the threads to
threads to complete
to complete before
complete before reading
before reading the
reading the output
output from each
from each to
each to produce
produce the finalized
the finalized output
can guess not
guess not all
not all processing
all processing tasks
processing tasks lend
tasks lend themselves
lend themselves to
themselves to parallel
to parallel processing
parallel processing and
processing and even
and even those
even those that
those that do
that do need
to be big
big enough tasks
enough tasks to
tasks to justify
to justify the
justify the overheads
the overheads of
overheads of running
of running threads
If you're curious
you're curious just
curious just how
just how this
how this can
up in Power
Power Basic I've
Basic I've put
I've put a
a link in
link in the
description below to
below to the
to the project
the project page
project page for
page for threads
for threads which
threads which will
give you access
you access to
to the three
the three videos
three videos and
videos and code
and code for
code for these
for these projects
these projects using
projects using threads
we will introduce
will introduce Power
introduce Power Basic
Basic to those
never used it
used it before
it before, or
at just how
just how portable
how portable the
portable the Power
Power Basic development
Basic development environment
development environment actually
environment actually is
you are developing
are developing software
developing software, you
you may spend
may spend quite
spend quite some
quite some time
some time getting
time getting your
getting your development
your development computer
development computer set
computer set up
up with all
all the tools
the tools, applications
applications and other
and other programs
other programs needed
programs needed to
needed to allow
you to actually
to actually develop
actually develop code
For a developer
a developer there
developer there is
is nothing worse
nothing worse than
worse than starting
starting the day
the day with
day with a
with a development
a development computer
development computer that
computer that just
that just won't
just won't power
won't power up
Which of course
of course triggers
course triggers a
triggers a call
to get it
get it repaired
In the meantime
the meantime you
meantime you cannot
you cannot work
Unless of course
you have multiple
have multiple development
multiple development computers
In such scenarios
such scenarios it's
scenarios it's vital
it's vital to
vital to have
to have backups
have backups of
backups of both
of both your
both your development
your development environment
development environment and
environment and the
and the source
source code you
code you are
that the development
the development computer
development computer cannot
computer cannot be
cannot be repaired
be repaired, you
may be faced
be faced with
faced with the
with the joyous
the joyous task
joyous task of
task of reinstalling
of reinstalling software
So how well
how well can
well can Power
can Power Basic
Power Basic cope
Basic cope with
cope with this?
with this? In
this? In order
to demonstrate this
demonstrate this we
this we are
are currently looking
at a Power
Windows Compiler application
This as you
screen is running
is running from
running from the
from the K
the K drive
currently running the
running the Power
Windows Compiler and
Compiler and we
loaded the Form
Runner application which
of our recent
our recent projects
the screen this
screen this is
running from my
from my K
my K drive
so happens that
happens that the
that the K
K drive in
drive in this
in this instance
this instance is
instance is not
is not within
not within the
within the computer
the computer itself
It is running
running from an
from an external
an external USB
external USB drive
is a SanDisk
a SanDisk memory
SanDisk memory vault
use these memory
these memory vaults
memory vaults for
vaults for archival
for archival backup
archival backup and
backup and long-term
and long-term storage
long-term storage as
storage as they
as they come
they come in
come in a
in a remarkably
a remarkably robust
remarkably robust stainless
robust stainless steel
stainless steel casing
Unfortunately this particular
this particular model
particular model is
model is no
no longer available
It came in
came in 8GB
in 8GB and
8GB and 16GB
and 16GB varieties
16GB varieties which
varieties which is
is more than
more than enough
than enough to
enough to store
to store all
store all your
all your Power
your Power Basic
Power Basic environment
Basic environment and
environment and a
and a great
deal more besides
of course copy
course copy your
copy your Power
Basic environment onto
environment onto other
onto other USB
other USB drives
example this is
a SanDisk USB
SanDisk USB drive
USB drive which
drive which has
has a capacity
a capacity of
capacity of 128GB
of 128GB which
128GB which is
than enough for
enough for Power
Power Basic, all
all your libraries
your libraries and
libraries and probably
and probably every
probably every piece
of code you've
code you've ever
you've ever written
at the SanDisk
the SanDisk memory
memory vault to
vault to see
have stored on
stored on there
On this drive
this drive which
drive which I've
which I've said
I've said is
said is around
is around currently
around currently using
currently using only
using only about
only about the
about the project
the project we
have just been
just been looking
been looking at
looking at, all
all the Power
Power Basic libraries
Basic libraries which
libraries which have
been created and
created and Power
Power Basic folder
Basic folder I
folder I have
I have 3
have 3 versions
3 versions of
versions of the
compiler and 3
and 3 versions
compiler and some
and some additional
some additional software
While you can
you can run
can run Power
run Power Basic
Power Basic directly
Basic directly off
directly off one
off one of
of these drives
these drives it's
drives it's an
it's an ideal
an ideal environment
ideal environment for
environment for copying
for copying onto
copying onto another
onto another computer
So should your
should your primary
your primary development
primary development computer
development computer develop
computer develop some
develop some fault
some fault, either
either with its
with its hard
its hard disk
hard disk or
disk or the
or the machine
the machine, you
you can quite
quite easily take
easily take your
take your backup
your backup USB
backup USB drive
USB drive, copy
copy it onto
it onto another
onto another machine
another machine and
machine and start
and start developing
start developing again
The only change
only change in
in the Power
Basic environment you're
environment you're likely
you're likely to
likely to need
to need to
is to where
where the include
the include libraries
include libraries are
libraries are found
to the options
the options entry
options entry on
on the menu
the menu you'll
menu you'll see
has a compiler
a compiler tab
compiler tab designates
tab designates where
designates where the
where the encode
encode file paths
file paths actually
paths actually exist
the moment my
moment my primary
my primary path
primary path is
path is on
is on my
on my E
my E drive
So if I
if I wish
I wish to
run this directly
this directly off
directly off my
off my K
K drive I
drive I could
I could just
could just add
just add another
add another folder
another folder and
folder and move
move it to
if you're moving
you're moving to
moving to another
to another machine
machine and installing
and installing on
installing on a
on a different
a different drive
different drive then
drive then this
then this is
the one change
one change you
change you need
So installing your
installing your Power
Power Basic integrated
Basic integrated development
integrated development environment
development environment on
environment on another
on another computer
another computer is
computer is merely
is merely a
merely a matter
matter of copying
of copying from
copying from the
from the USB
the USB drive
USB drive onto
drive onto the
the new machine
then set up
set up desktop
up desktop shortcuts
desktop shortcuts or
shortcuts or toolbar
or toolbar shortcuts
toolbar shortcuts and
shortcuts and proceed
and proceed to
proceed to develop
to develop quite
develop quite normally
This for me
for me is
me is one
of the great
the great selling
great selling points
selling points of
points of Power
is no long
no long winded
long winded installation
winded installation to
installation to be
with all development
all development I
development I would
I would suggest
would suggest taking
suggest taking a
taking a lot
lot of backups
You can never
can never have
never have too
have too many
too many backups
many backups and
backups and you
and you never
you never know
never know when
know when you
when you might
you might need
might need them
Simulation theory, or
or simulation hypothesis
simulation hypothesis, is
is a theory
a theory that
theory that all
that all perceived
all perceived reality
perceived reality is
reality is an
is an artificial
an artificial simulation
This isn't a
isn't a new
a new idea
new idea and
idea and has
has been covered
been covered in
covered in many
in many YouTube
many YouTube videos
YouTube videos, books
books and even
and even scientific
even scientific papers
scientific papers, as
well as films
as films such
films such as
such as the
as the Matrix
the Matrix series
But today I
today I thought
I thought we'd
thought we'd take
we'd take another
take another look
another look at
at this concept
this concept by
concept by looking
looking at how
how we perceive
we perceive reality
you are watching
are watching this
watching this video
this video on
video on a
on a desktop
a desktop computer
desktop computer, laptop
tablet or smartphone
or smartphone, then
then you are
you are looking
are looking at
at a screen
a screen displaying
screen displaying the
displaying the graphics
Those graphics are
graphics are a
are a simulation
The processing chip
processing chip within
chip within the
within the device
the device you
device you are
you are using
are using is
using is converting
is converting numbers
converting numbers into
numbers into signals
into signals that
signals that are
that are interpreted
are interpreted by
interpreted by the
by the screen
the screen into
screen into something
into something your
something your eyes
your eyes interpret
eyes interpret as
interpret as moving
as moving images
So in a
in a very
a very real
very real sense
real sense, you
you are not
are not experiencing
not experiencing what
experiencing what the
what the computer
the computer is
computer is processing
is processing directly
are many layers
many layers of
layers of abstraction
of abstraction between
abstraction between you
between you and
you and what's
and what's really
what's really going
really going on
going on inside
on inside the
inside the computer
The images you
images you see
you see on
screen are an
are an interpretation
an interpretation of
interpretation of the
of the internal
the internal activities
internal activities of
activities of the
of the computer
a button, picking
picking from a
from a menu
a menu or
menu or adjusting
or adjusting a
adjusting a slider
a slider bar
slider bar on
screen will trigger
will trigger events
trigger events within
events within the
These events and
events and the
and the cascade
the cascade of
cascade of events
of events that
events that follow
that follow will
follow will respond
will respond by
respond by updating
by updating the
updating the screen
Giving yourself time
yourself time to
time to think
to think, it
it becomes obvious
becomes obvious that
obvious that the
that the button
the button you
button you clicked
you clicked on
on has no
has no physical
no physical existence
physical existence whatsoever
What does matter
does matter are
matter are the
events that you
you have triggered
have triggered by
triggered by clicking
the image of
image of the
Will this allow
this allow you
you to purchase
to purchase something
purchase something or
something or perhaps
or perhaps send
perhaps send an
send an email
an email to
email to someone?
to someone? So
someone? So what
does this concept
this concept do
concept do to
to your perception
your perception of
perception of reality?
of reality? Is
reality? Is it
Is it all
it all just
all just simulation?
just simulation? Does
simulation? Does reality
Does reality reside
reality reside in
reside in the
in the underlying
the underlying code
underlying code or
code or program
or program that
program that generates
generates the simulation?
the simulation? Or
simulation? Or is
is it solely
it solely in
solely in our
in our perception
our perception of
perception of the
of the simulated
the simulated world?
simulated world? These
world? These are
These are some
are some big
some big questions
As most of
most of you
of you watching
you watching this
this video are
video are probably
are probably either
probably either programmers
either programmers or
programmers or have
or have an
an interest in
interest in programming
in programming computers
programming computers, you
have created workflows
A workflow is
workflow is the
is the series
the series of
series of activities
of activities that
activities that are
that are necessary
are necessary to
necessary to complete
to complete a
complete a task
creating a workflow
a workflow, you
the programmer, are
are guiding the
guiding the progression
the progression of
progression of something
of something or
something or someone
or someone down
someone down a
down a path
The path may
path may have
may have decision
have decision points
decision points and
points and branches
and branches, but
but everything has
has been worked
been worked out
worked out that
out that can
that can happen
When the simulation
the simulation hypothesis
simulation hypothesis is
hypothesis is discussed
is discussed, one
of the key
the key questions
key questions regards
questions regards the
regards the concept
concept of free
of free will
Does it exist
it exist or
exist or are
or are your
are your decisions
your decisions made
decisions made for
made for you?
for you? Let
you? Let us
Let us look
us look at
look at someone
at someone using
someone using an
using an application
application that I
that I have
The application allows
application allows them
them to inform
to inform other
inform other parts
of the company
the company they
company they work
they work for
work for that
for that changes
that changes have
changes have occurred
have occurred as
occurred as regards
as regards staff
regards staff or
staff or their
or their contracts
their contracts within
contracts within the
within the company
The user filling
user filling in
filling in these
these forms has
forms has a
has a limited
a limited amount
limited amount of
amount of flexibility
flexibility in completing
in completing each
completing each form
Enough to trigger
to trigger workflows
trigger workflows to
workflows to the
to the company
the company, but
but not enough
not enough flexibility
enough flexibility to
flexibility to create
of form altogether
application has purpose
has purpose, fulfills
fulfills a need
a need and
need and provides
and provides the
provides the users
the users with
users with a
with a modicum
a modicum of
modicum of free
free will when
will when it
the form content
move down a
down a level
a level to
level to the
to the actual
the actual code
actual code used
code used to
create this application
that the programming
the programming language
programming language has
language has a
has a distinct
a distinct structure
distinct structure and
structure and provides
provides the programmer
the programmer with
programmer with a
with a greater
a greater number
greater number of
there are still
are still limitations
still limitations to
limitations to what
what the programming
programming language can
language can achieve
As it too
it too is
too is constrained
is constrained by
constrained by the
operating system, which
which in turn
in turn is
turn is constrained
by the actual
the actual hardware
actual hardware of
hardware of the
Computers have become
have become so
become so much
so much larger
much larger and
and more powerful
more powerful over
powerful over the
over the last
the last 40
last 40 years
considered top of
of the range
I now sit
now sit here
sit here using
here using a
using a computer
a computer with
computer with a
with a million
a million times
million times the
times the memory
So the realistic
the realistic simulations
realistic simulations that
simulations that can
that can now
can now be
now be run
be run on
run on even
on even home
even home computers
home computers are
computers are so
are so detailed
so detailed that
detailed that they
they have now
have now become
now become quite
become quite immersive
Perhaps reality boils
reality boils down
boils down to
down to probabilities
This epiphany came
epiphany came to
came to me
to me when
me when attempting
when attempting to
attempting to extract
extract a specific
a specific cable
specific cable from
cable from a
from a box
a box containing
box containing a
containing a multitude
a multitude of
multitude of other
of other cables
They were, of
of course, hopelessly
hopelessly entangled and
entangled and getting
and getting the
getting the cable
the cable I
cable I needed
I needed took
needed took some
took some time
I pondered on
pondered on what
on what were
what were the
were the chances
chances of just
of just once
just once getting
once getting a
getting a cable
a cable out
cable out of
the box easily
box easily without
easily without having
having to unpick
to unpick the
unpick the cable
the cable equivalent
cable equivalent of
equivalent of the
of the Gordian
the Gordian knot
Then it came
it came to
to me that
me that it
it was all
was all down
all down to
Given the range
range of possible
of possible configurations
possible configurations of
configurations of the
of the cables
the cables, it
it was more
was more likely
more likely to
to be tangled
be tangled than
tangled than not
The few scenarios
few scenarios where
scenarios where the
where the cables
the cables were
cables were untangled
were untangled were
untangled were unlikely
Of course, being
being a solution
a solution seeker
solution seeker, I
I then tidied
then tidied the
tidied the box
box and used
and used reusable
used reusable cable
reusable cable ties
cable ties so
ties so that
time the odds
the odds would
odds would be
be in my
in my favor
So in conclusion
in conclusion, while
while it may
it may be
may be impossible
be impossible to
impossible to determine
determine that we
we are or
are or are
or are not
are not living
not living in
living in a
in a simulation
a simulation, it
it is possible
is possible to
possible to use
use the concept
concept of simulations
of simulations to
simulations to understand
to understand and
understand and improve
and improve on
improve on the
on the applications
the applications and
applications and systems
and systems we
systems we create
we create as
create as programmers
as programmers and
programmers and system
and system designers
Hopefully this will
will have given
have given you
given you food
you food for
food for thought
for thought, but
it before or
at the topic
the topic of
topic of software
of software updates
When and why
and why should
why should they
should they happen
they happen and
happen and are
and are they
are they a
they a good
a good thing?
good thing? So
thing? So what
what are software
are software updates?
software updates? When
updates? When you
When you obtain
you obtain a
obtain a piece
of software, whether
it's a free
a free download
free download or
download or purchased
or purchased, it
it is likely
is likely that
likely that it
it has gone
has gone through
gone through several
through several iterations
several iterations before
iterations before the
before the version
the version that
version that you
that you now
you now have
Ideally each iteration
each iteration or
iteration or new
or new version
new version of
of the software
the software will
software will improve
will improve on
the previous version
previous version in
version in some
in some way
some way, perhaps
perhaps fixes for
fixes for some
for some functional
some functional error
functional error or
error or the
or the addition
addition of new
of new functionality
These updates can
updates can either
can either be
either be patches
be patches to
patches to parts
to parts of
of the installation
the installation or
installation or a
or a complete
a complete replacement
complete replacement of
replacement of everything
of everything that
everything that was
that was installed
But hopefully retaining
hopefully retaining whatever
retaining whatever configuration
whatever configuration changes
configuration changes you
changes you may
may have made
have made to
made to the
to the product
the product in
product in data
days of home
of home computers
home computers, prior
prior to the
to the widespread
the widespread adoption
widespread adoption of
adoption of internet
of internet connectivity
internet connectivity, updates
updates to the
operating system of
system of computers
of computers was
computers was a
was a complicated
complicated business as
business as it
as it involved
it involved replacement
involved replacement of
replacement of read-only
of read-only memory
read-only memory chips
memory chips on
chips on the
on the motherboard
Later with the
with the move
the move to
move to holding
to holding the
holding the operating
operating system on
system on hard
on hard disk
hard disk storage
disk storage, then
then such updates
such updates could
updates could be
could be applied
be applied by
applied by floppy
by floppy disk
floppy disk and
disk and later
and later CDs
Certainly at this
this point you
point you the
you the user
the user could
user could choose
could choose when
choose when to
when to apply
to apply such
apply such updates
While the internet
the internet and
internet and later
and later the
later the world
wide web did
web did bring
did bring immense
bring immense advantages
immense advantages, it
it heralded a
heralded a move
a move to
move to an
to an always
an always online
always online mindset
And for your
for your convenience
your convenience, applications
applications could check
could check online
check online to
online to see
if there was
was an available
an available update
With the latest
the latest evolution
latest evolution to
evolution to software
to software as
software as a
as a service
a service, a
a subscription model
subscription model is
model is now
is now much
now much more
much more common
This business model
business model can
model can sometimes
can sometimes mean
sometimes mean you
mean you only
you only get
only get to
get to use
use the software
the software as
software as long
long as you
as you keep
you keep paying
keep paying monthly
paying monthly or
monthly or yearly
The advantage to
advantage to the
user is said
is said to
said to be
be that you
that you always
you always have
always have access
have access to
to the latest
the latest version
latest version and
version and in
some cases this
cases this is
this is automatically
is automatically applied
Are software updates
software updates a
updates a good
good thing? Let's
thing? Let's look
at the reasons
the reasons for
reasons for making
for making changes
making changes to
changes to software
of all, fixing
extending the existing
the existing functionality
existing functionality of
functionality of your
of your software
And finally adding
finally adding new
So for fixing
for fixing bugs
fixing bugs, no
no one is
going to complain
to complain when
complain when bugs
when bugs get
bugs get fixed
Especially if the
if the bug
the bug is
bug is so
is so serious
so serious and
serious and it
and it seriously
it seriously impairs
seriously impairs your
impairs your use
your use of
of the product
can be frustrating
be frustrating when
frustrating when a
when a new
a new bug
new bug is
bug is introduced
is introduced because
introduced because of
because of some
of some new
some new functionality
new functionality being
functionality being incorporated
being incorporated into
incorporated into the
into the product
Or even worse
even worse, an
an old bug
old bug that
bug that had
that had been
had been fixed
been fixed and
fixed and subsequently
and subsequently appears
subsequently appears again
Extending existing functionality
Using a software
a software product
software product that
product that is
that is periodically
is periodically extending
periodically extending what
extending what is
what is capable
is capable of
capable of can
of can be
can be exciting
be exciting and
exciting and an
and an aid
an aid to
aid to your
to your productivity
if the extension
the extension is
extension is of
is of some
of some use
some use to
use to you
to you and
you and made
and made in
made in an
in an area
the product that
product that you
that you make
you make major
make major use
major use of
the extension doesn't
extension doesn't impinge
doesn't impinge on
impinge on what
on what you
you can currently
can currently do
currently do, then
then all is
all is well
of new parts
new parts of
parts of a
of a software
software product to
product to enable
to enable it
enable it to
to do things
do things it
things it has
it has never
has never been
never been able
able to do
to do before
do before tends
before tends to
tends to get
get a lot
lot of attention
Shiny new stuff
new stuff can
stuff can bring
bring in a
in a lot
lot of new
of new users
new users and
users and revenue
and revenue to
revenue to a
to a product
where the new
the new functionality
new functionality has
functionality has been
has been requested
been requested by
requested by the
by the existing
the existing users
existing users and
users and works
and works as
works as advertised
as advertised, then
then the new
the new release
new release can
release can be
be a big
a big success
When to stop
With any software
any software product
software product, there
there should come
should come a
when the life
the life cycle
life cycle of
cycle of that
of that product
that product has
product has reached
has reached a
reached a point
a point where
where the addition
addition of any
of any new
any new functionality
new functionality will
functionality will detract
will detract from
detract from the
the original purpose
original purpose of
Identifying when that
when that point
that point has
point has been
been reached can
reached can be
can be difficult
be difficult for
difficult for those
for those too
those too close
too close to
close to a
stopping the addition
addition of unnecessary
of unnecessary functionality
unnecessary functionality can
functionality can be
be a good
With programming languages
programming languages, one
the constant challenges
constant challenges is
challenges is the
is the urge
the urge to
urge to rewrite
to rewrite existing
rewrite existing working
existing working code
working code to
code to take
to take advantage
take advantage of
advantage of some
some new feature
new feature that
feature that has
that has just
has just been
just been introduced
Or worse still
worse still, having
having to rewrite
to rewrite a
rewrite a functional
a functional area
functional area of
area of your
your application because
application because some
because some aspect
some aspect of
aspect of the
code that built
that built it
built it has
has been defecated
been defecated and
defecated and failure
and failure to
failure to make
the change will
change will make
make your application
your application impossible
application impossible to
impossible to maintain
to maintain in
maintain in the
If the tools
the tools used
tools used to
to create software
create software are
software are constantly
are constantly changing
constantly changing, it
it makes it
it much harder
much harder to
harder to gain
to gain a
gain a high
a high level
high level of
level of expertise
of expertise in
expertise in using
in using them
As with everything
with everything in
everything in life
in life, balance
balance is important
Software updates, either
either to the
to the software
the software you
software you have
you have written
have written or
written or to
or to the
the software your
software your application
your application depends
application depends upon
depends upon, can
good thing in
thing in moderation
For programming languages
programming languages, it
can take time
take time for
time for programmers
for programmers to
programmers to learn
to learn all
learn all the
all the features
features of a
of a language
when they do
they do, they
they can produce
can produce some
produce some stunning
some stunning applications
if the language
the language is
language is constantly
is constantly changing
constantly changing, that
that point of
point of expertise
of expertise may
expertise may never
may never be
never be reached
So think carefully
think carefully before
carefully before adding
before adding to
adding to your
application and allow
and allow yourself
allow yourself the
yourself the time
the time to
time to pick
pick the point
the point at
point at which
at which you
can say that
say that it
it needs no
needs no further
no further updates
Hopefully you'll consider
you'll consider these
consider these points
these points when
points when developing
when developing applications
look at Workflow
What is it
is it and
it and how
and how can
how can you
can you make
you make use
of it in
in your Power
Power Basic applications?
Basic applications? So
applications? So what
what is Workflow?
is Workflow? If
Workflow? If you
are developing a
developing a simple
simple form application
form application to
application to record
to record information
record information, you
may not need
not need a
need a workflow
the form must
form must pass
must pass through
pass through several
through several distinct
several distinct stages
distinct stages, perhaps
perhaps for approval
for approval or
approval or refinement
or refinement, then
then knowing what
knowing what stage
what stage the
stage the form
form has reached
has reached is
reached is essential
The form may
form may pass
may pass through
pass through the
through the hands
the hands of
hands of several
of several people
several people or
people or teams
or teams, and
and those that
those that raise
that raise a
raise a form
a form would
form would be
would be keen
be keen to
keen to know
know what stage
form is currently
Think about the
about the progress
the progress of
progress of the
to be like
be like an
like an assembly
an assembly line
assembly line at
at a factory
a factory, when
when it needs
needs to follow
to follow a
follow a predefined
a predefined route
predefined route through
route through the
through the factory
the factory to
factory to be
to be successfully
be successfully completed
at just such
just such a
such a form
a form and
and what stages
what stages it
stages it might
it might progress
might progress through
Once we are
we are designing
are designing the
designing the processing
processing of a
a form through
form through a
through a system
a system, it
it always helps
always helps to
helps to document
to document this
document this process
this process right
process right from
right from the
are many tools
many tools that
tools that will
that will assist
will assist you
assist you in
you in this
in this endeavour
this endeavour, from
from mind mapping
mind mapping tools
mapping tools to
tools to flowchart
to flowchart diagramming
flowchart diagramming tools
Today I'm going
using one called
one called Knowledge
called Knowledge Base
Knowledge Base Builder
Base Builder to
Builder to allow
out the path
path of our
our form through
form through the
through the system
Let's say we
say we are
we are mapping
are mapping part
mapping part of
of the recruitment
the recruitment process
recruitment process of
process of someone
of someone joining
someone joining a
joining a large
a large organisation
large organisation, following
following the end
Once the organisation
the organisation has
organisation has established
has established who
established who the
who the job
the job is
job is to
go to and
to and when
when the start
start date will
will be, then
then a form
a form can
form can be
can be created
be created to
created to capture
to capture key
capture key details
key details of
of the equipment
the equipment they
equipment they will
they will need
to perform their
perform their role
their role in
role in the
in the organisation
likely that this
that this request
this request will
request will be
will be raised
be raised by
raised by the
by the Hiring
the Hiring Manager
Hiring Manager or
Manager or Line
or Line Manager
Line Manager of
Manager of the
Our New Start
New Start form
Start form will
form will have
number of distinct
of distinct stages
distinct stages, which
we will refer
refer to as
to as the
as the Workflow
the Workflow Status
of these stages
these stages may
stages may be
may be decision
be decision points
points and some
and some may
some may trigger
may trigger parable
trigger parable processes
parable processes with
processes with their
with their own
their own workflow
own workflow status
could be for
be for example
example to inform
to inform many
inform many teams
many teams or
teams or automated
or automated processes
automated processes to
processes to create
to create accounts
create accounts for
accounts for the
New Start, perhaps
perhaps network or
network or email
or email accounts
we will concentrate
will concentrate on
concentrate on is
is the request
the request for
request for new
for new equipment
With structured procurement
structured procurement systems
procurement systems, you'll
you'll expect those
expect those wishing
those wishing new
wishing new equipment
new equipment to
equipment to select
select from a
from a predefined
a predefined catalogue
This catalogue containing
catalogue containing all
all the types
types of equipment
of equipment that
equipment that your
that your organisation
your organisation can
organisation can successfully
can successfully support
there will need
be a way
a way for
way for staff
for staff to
staff to request
to request something
request something that
something that is
on the catalogue
This to allow
to allow purchase
allow purchase of
purchase of needed
of needed equipment
Such requests may
requests may well
well have their
their own special
own special workflow
special workflow process
workflow process and
process and stages
assume that the
that the Hiring
Hiring Manager is
Manager is going
to be requesting
be requesting something
requesting something that
that is on
the standard catalogue
Our dataset for
dataset for the
the form would
form would include
would include some
include some key
of information like
information like who
like who is
who is raising
is raising the
raising the request
the request, the
date and time
and time the
time the form
has been raised
been raised, who
who the equipment
the equipment is
equipment is for
is for, a
to the catalogue
the catalogue item
catalogue item, whose
whose budget is
budget is paying
is paying for
paying for this
for this and
this and finally
and finally a
finally a reference
the current workflow
current workflow status
workflow status of
status of the
of the request
Let's call it
call it 'Raised'
that our form
our form has
has reached the
reached the raised
the raised state
raised state, then
the next state
next state may
state may be
may be some
be some sort
some sort of
sort of business
of business approval
business approval where
approval where it
it is passed
is passed to
passed to a
to a senior
a senior member
senior member of
of staff to
staff to authorise
to authorise the
authorise the purchase
In business, such
such controls are
controls are in
place to ensure
is a business
a business need
business need for
need for such
for such items
we need two
need two additional
two additional workflow
additional workflow states
workflow states awaiting
states awaiting business
awaiting business approval
business approval and
approval and business
and business approved
business approved As
approved As the
As the form
the form reaches
form reaches each
reaches each of
of these workflow
these workflow states
workflow states, the
the form's dataset
form's dataset can
dataset can be
updated to record
record the current
and time that
the form reached
form reached each
reached each workflow
each workflow state
workflow state should
state should be
should be recorded
be recorded as
recorded as part
part of an
of an audit
an audit trail
audit trail for
trail for reporting
for reporting purposes
Following the business
the business approval
business approval, the
the next workflow
next workflow status
workflow status could
status could involve
could involve a
involve a financial
a financial approval
Here too we
too we will
will need two
workflow states, awaiting
awaiting financial approval
financial approval and
approval and finance
and finance approved
Of course there
course there is
possibility that one
that one of
of these approval
these approval steps
approval steps is
steps is denied
is denied by
denied by the
by the approver
workflow states to
states to take
take care of
care of this
of this, business
business approval denied
approval denied and
denied and finance
and finance approval
finance approval denied
Once denied, the
the workflow will
workflow will likely
will likely end
likely end and
end and the
the form raiser
form raiser will
raiser will receive
will receive the
receive the bad
the bad news
Following the finance
the finance approval
finance approval, the
form will likely
will likely pass
likely pass to
pass to someone
to someone to
someone to procure
to procure and
procure and here
here again we
again we have
two new workflow
new workflow statuses
workflow statuses, awaiting
awaiting procurement and
procurement and procured
Once procured, the
the request will
request will likely
will likely move
likely move on
to the build
the build and
build and deploy
and deploy workflow
deploy workflow status
Where assuming that
assuming that it
a computer, it
will be configured
be configured and
configured and have
and have standard
have standard software
standard software installed
Having an audit
audit trail to
trail to record
to record when
record when each
when each of
these workflow stages
workflow stages has
stages has been
been reached gives
reached gives several
gives several benefits
Firstly it allows
it allows those
allows those involved
those involved with
involved with the
with the request
the request to
request to see
see at what
at what stage
stage the request
the request is
request is currently
Secondly it allows
it allows reporting
allows reporting on
reporting on how
on how long
long the entire
the entire journey
entire journey took
journey took and
took and the
and the duration
the duration of
duration of each
of each stage
to highlight where
highlight where there
there are issues
are issues and
issues and delays
and delays in
delays in the
in the workflow
the workflow pipeline
Thinking through the
through the stages
the stages of
stages of your
of your workflow
your workflow before
workflow before starting
before starting any
starting any coding
any coding is
coding is always
always a benefit
a benefit as
benefit as you
as you end
you end up
with a good
a good understanding
good understanding of
understanding of what
of what is
what is required
As such workflows
such workflows will
workflows will involve
will involve multiple
involve multiple teams
multiple teams of
of staff spread
staff spread across
spread across several
across several departments
several departments, your
your workflow diagram
workflow diagram can
diagram can be
can be shared
be shared so
shared so that
that all of
all of those
of those involved
those involved understand
involved understand the
understand the whole
the whole process
From a developer's
a developer's point
developer's point of
of view, having
having details of
details of each
of each workflow
each workflow stage
workflow stage will
stage will allow
allow the dataset
the dataset needed
dataset needed for
needed for this
for this process
this process to
process to be
to be defined
Thus saving the
saving the issue
the issue of
issue of trying
of trying to
trying to retrofit
to retrofit a
retrofit a new
a new workflow
new workflow stage
workflow stage later
stage later on
And all this
this information should
information should form
should form the
form the cornerstone
the cornerstone of
cornerstone of your
of your documentation
your documentation of
documentation of the
of the system
the system, even
even if it
if it embodies
it embodies multiple
embodies multiple workflows
Documentation should never
should never be
never be the
the first casualty
first casualty of
casualty of development
find these concepts
these concepts useful
concepts useful in
in your development
your development work
development work, but
In this new
this new series
new series of
look at subjects
at subjects of
subjects of topical
of topical interest
at how the
how the use
use of AI
of AI will
AI will affect
will affect the
affect the task
task of programming
So will the
will the rise
the rise of
rise of AI
of AI mean
AI mean the
mean the end
the end for
end for people
for people doing
people doing programming?
doing programming? A
programming? A great
great deal has
deal has been
has been speculated
been speculated about
speculated about the
about the recent
the recent explosion
recent explosion of
explosion of access
of access to
access to AI
to AI systems
AI systems to
systems to generate
to generate or
generate or enhance
or enhance images
enhance images and
images and even
and even create
even create short
create short videos
AI is now
now being used
being used in
used in search
in search engines
search engines to
engines to find
to find better
find better answers
better answers to
answers to your
to your queries
your queries, and
of these AI
these AI tools
AI tools are
tools are being
are being used
being used to
to generate code
generate code for
if this trend
this trend continues
trend continues, will
will it end
it end up
up with no
with no more
no more need
more need for
need for coding?
for coding? So
coding? So what
is the difference
the difference between
difference between coding
between coding and
coding and programming?
and programming? Coding
programming? Coding is
Coding is a
is a subset
a subset of
subset of programming
of programming and
programming and deals
and deals with
deals with writing
with writing codes
writing codes that
codes that a
that a machine
a machine can
machine can understand
Over the years
the years there
years there have
there have been
have been many
been many tools
many tools developed
tools developed to
developed to make
make the act
the act of
act of coding
of coding simpler
coding simpler and
simpler and more
and more high
more high level
Programming is wider
is wider in
wider in scope
in scope and
scope and as
well as coding
as coding involves
coding involves planning
involves planning, designing
testing and maintaining
and maintaining software
So will AI
will AI replace
AI replace coders?
replace coders? The
coders? The short
The short answer
short answer is
answer is no
is no, but
it will change
way you work
you work and
work and the
and the tools
the tools you
tools you use
you use to
use to create
create and maintain
and maintain software
What challenges will
challenges will the
will the use
of AI bring?
AI bring? With
bring? With the
the current approach
current approach to
approach to AI
to AI, the
the systems need
systems need to
to be trained
be trained by
trained by feeding
by feeding them
feeding them with
them with very
with very large
very large amounts
large amounts of
amounts of data
These large language
large language models
language models need
models need this
need this data
this data and
data and all
all this data
this data has
data has originated
has originated from
originated from us
from us humans
us humans who
humans who have
who have written
have written code
written code previously
happens when you
when you use
you use one
use one AI
one AI system
AI system to
system to feed
to feed another?
feed another? Recent
another? Recent studies
Recent studies have
studies have concluded
have concluded that
concluded that continually
that continually feeding
continually feeding an
feeding an AI
an AI with
AI with AI-generated
with AI-generated content
AI-generated content can
content can cause
can cause its
cause its output
its output quality
output quality to
quality to decline
As the amount
amount of new
of new, non-AI
non-AI data to
data to feed
to feed these
feed these systems
these systems declines
systems declines, it's
likely that a
that a series
series of new
of new roles
new roles of
roles of AI
of AI data
AI data provider
data provider will
provider will be
created to provide
to provide this
provide this original
this original input
Such jobs are
jobs are likely
to be much
be much in
much in demand
in demand and
demand and therefore
and therefore highly
therefore highly paid
do we handle
we handle changes
handle changes to
changes to AI-generated
to AI-generated systems
AI-generated systems and
systems and applications?
and applications? As
applications? As many
As many systems
many systems are
systems are designed
are designed to
designed to be
to be client-facing
be client-facing, there
always a demand
a demand over
demand over time
over time to
time to amend
to amend them
amend them, adding
adding a field
a field here
field here or
here or a
new dialogue or
dialogue or a
or a radical
a radical change
radical change to
to the workflow
the workflow or
workflow or processing
In development terms
development terms, you
you can spend
can spend more
spend more time
more time amending
time amending an
amending an application
an application than
application than it
than it originally
it originally took
originally took to
took to create
to create it
AI currently has
currently has difficulties
has difficulties in
difficulties in coping
in coping with
coping with this
All applications can
applications can contain
can contain bugs
contain bugs, or
or as programmers
as programmers call
programmers call them
call them, unwanted
where the operation
the operation of
operation of the
the code doesn't
code doesn't match
match the requirements
As any developer
any developer or
developer or business
or business analyst
business analyst will
analyst will tell
will tell you
tell you, nailing
nailing down a
down a requirement
a requirement before
requirement before you
before you start
you start development
start development can
development can be
be a challenge
Requirements often change
often change during
change during development
during development, and
and this could
a challenge to
challenge to an
to an AI-generated
an AI-generated system
Asking current AI
current AI systems
AI systems the
systems the same
the same question
same question twice
question twice can
twice can sometimes
can sometimes generate
sometimes generate a
generate a slightly
a slightly or
slightly or radically
or radically different
radically different answer
Not ideal when
when the customer
the customer liked
customer liked most
liked most of
the system and
system and just
and just wanted
just wanted changes
wanted changes to
changes to one
to one part
The wider impact
One area that
area that hasn't
that hasn't received
hasn't received much
received much coverage
much coverage is
coverage is that
is that of
that of software
of software and
software and system
and system testing
a few companies
few companies now
companies now setting
now setting up
setting up that
up that are
that are advertising
are advertising a
advertising a comprehensive
a comprehensive set
comprehensive set of
set of test
of test automation
test automation capabilities
automation capabilities, which
which will identify
will identify issues
identify issues with
issues with your
with your systems
your systems and
systems and with
and with test
with test management
test management, performance
performance testing and
testing and data
and data integrity
data integrity aspects
AI could provide
could provide a
provide a level
a level of
level of testing
of testing and
testing and assurance
and assurance that
assurance that could
that could previously
could previously only
previously only be
only be provided
be provided by
by the largest
largest of software
of software houses
Testing of course
of course can
course can only
can only be
only be done
be done when
done when you
you have something
have something to
something to test
to test against
would be what
be what we
what we call
call a requirement
Having better tested
better tested software
tested software is
software is really
is really a
really a good
Another aspect to
aspect to consider
to consider is
consider is the
is the speed
speed of development
Over many years
many years, the
to develop complex
develop complex software
complex software has
software has come
has come down
come down, allowing
allowing faster and
faster and faster
and faster throughput
With AI, I
I see this
see this trend
this trend accelerating
trend accelerating, and
and with faster
with faster throughput
faster throughput, companies
companies producing software
producing software will
software will be
able to tackle
to tackle both
tackle both more
both more software
more software applications
software applications and
applications and more
and more complex
more complex systems
will allow their
allow their programming
their programming staff
programming staff to
staff to become
to become more
become more specialized
more specialized, and
and the need
need for coders
for coders to
coders to fix
to fix, amend
amend or even
or even understand
even understand AI-generated
understand AI-generated software
AI-generated software will
software will increase
So the conclusions
the conclusions I
conclusions I have
I have come
have come to
come to, and
and many may
many may disagree
may disagree, is
is that change
that change is
change is inevitable
is inevitable, given
given that AI
that AI is
AI is having
is having some
having some serious
some serious money
serious money invested
money invested in
invested in it
AI systems are
systems are power-hungry
are power-hungry beasts
power-hungry beasts, but
but then again
then again, so
will the first
the first mainframe
first mainframe computers
The roles and
roles and responsibilities
and responsibilities that
responsibilities that programming
that programming and
programming and development
and development staff
development staff have
staff have now
have now will
now will be
will be changing
With the increased
the increased use
increased use of
of AI systems
AI systems, code
code generation will
generation will be
will be faster
specialized roles will
roles will be
be created, increasing
increasing the number
of staff involved
staff involved in
involved in software
in software development
company was reported
was reported as
reported as 61
as 61 years
Now it is
it is less
less than 18
than 18 years
This trend is
trend is likely
likely to continue
to continue, especially
especially in computing
the time staff
time staff spend
staff spend working
spend working for
working for just
for just one
just one company
one company is
company is also
is also reducing
I suspect that
suspect that like
that like the
like the staff
the staff recruited
staff recruited to
recruited to work
work on a
on a movie
a movie, in
the future, staff
will be recruited
be recruited on
recruited on a
on a product-by-product
a product-by-product basis
product-by-product basis, with
with the best
the best and
best and most
and most skilled
most skilled niche
skilled niche staff
niche staff becoming
staff becoming highly
becoming highly sought
highly sought after
sought after and
after and therefore
and therefore well
therefore well paid
well paid for
paid for their
for their labors
Hopefully you have
you have enjoyed
have enjoyed this
enjoyed this video
this video, but
at topics of
topics of topical
use of Copilot
of Copilot Plus
Copilot Plus and
Plus and Windows
and Windows Recall
Windows Recall would
Recall would affect
would affect your
affect your computer
This video isn't
video isn't going
isn't going to
look at whether
at whether Windows
whether Windows Recall
Windows Recall will
Recall will be
a good or
good or bad
or bad thing
There are plenty
are plenty of
plenty of YouTube
of YouTube videos
YouTube videos on
videos on that
on that topic
that topic already
But rather we
rather we are
at what impact
what impact it
impact it will
on the computers
the computers running
computers running it
number of versions
of versions of
versions of Copilot
of Copilot, either
either out there
out there or
there or coming
or coming soon
the Copilot free
Copilot free version
And then there
there is Copilot
is Copilot Pro
Copilot Pro, which
is a subscription
subscription model adding
model adding additional
adding additional features
also a Copilot
a Copilot 365
Copilot 365, also
also a subscription
subscription model that
model that aims
that aims squarely
aims squarely at
squarely at the
at the Microsoft
the Microsoft 365
Microsoft 365 products
is a preview
a preview of
preview of Copilot
of Copilot Finance
And finally, the
the Copilot Security
Copilot Security, again
again another subscription
another subscription model
But today we
looking at Copilot+
I can tell
can tell, this
the only one
only one that
one that seems
that seems to
seems to mention
to mention the
mention the Windows
the Windows Recall
Windows Recall feature
Recall feature specifically
And Copilot+ is
Copilot+ is for
is for specific
for specific hardware
specific hardware only
look at some
at some details
some details for
details for Windows
for Windows Recall
are set to
set to trigger
to trigger every
trigger every 5
every 5 seconds
5 seconds, though
though this interval
this interval may
interval may be
may be configurable
Data is stored
is stored where
stored where the
where the screen
screen has changed
has changed from
changed from the
the last screenshot
of course the
course the question
the question over
question over multiple
over multiple screens
Many users have
users have two
have two or
or more monitors
This could well
could well need
well need a
need a great
deal of disk
of disk space
The documentation talks
documentation talks about
talks about 50GB
about 50GB of
50GB of free
of free space
Recall feature will
feature will pause
will pause itself
pause itself when
itself when the
when the free
the free disk
free disk space
disk space drops
space drops to
drops to only
to only 25GB
only 25GB free
The only Copilot+
only Copilot+ computers
Copilot+ computers I've
computers I've seen
I've seen so
so far have
far have about
have about a
about a dozen
a dozen laptops
these have the
have the Snapdragon
the Snapdragon X
Snapdragon X processor
X processor, which
which features a
features a neural
a neural processing
neural processing unit
processing unit, an
is obviously an
obviously an ARM
an ARM based
ARM based processor
based processor, so
using the ARM
the ARM version
ARM version of
version of Windows
has been documented
been documented as
documented as a
as a base
a base of
base of 16GB
of 16GB of
16GB of memory
of memory, which
which is rapidly
is rapidly becoming
rapidly becoming the
becoming the base
the base specification
base specification for
specification for Windows
for Windows, as
as many computers
many computers do
computers do now
do now have
now have more
more than 16GB
what are our
are our options?
our options? Content
options? Content Moderation
Windows Recall does
Recall does not
does not do
not do content
do content moderation
content moderation, so
so things like
things like account
like account numbers
account numbers, email
email addresses and
addresses and bank
and bank statements
bank statements may
statements may well
well be stored
In-private or incognito
or incognito web
incognito web browsing
web browsing sessions
browsing sessions are
sessions are to
be automatically excluded
Windows Recall won't
Recall won't store
won't store digital
store digital rights
digital rights management
rights management content
Screenshots are held
are held per
held per user
per user profile
you have four
have four members
four members of
of the family
the family using
family using the
using the one
the one computer
one computer, this
this will quadruple
will quadruple the
quadruple the amount
of space used
space used for
for the metadata
is also to
be a selective
a selective clearing
selective clearing of
clearing of snapshots
of snapshots as
snapshots as a
as a feature
a feature, so
so that you
into the history
history and remove
and remove snapshots
remove snapshots you
snapshots you do
Websites can be
can be specifically
be specifically excluded
specifically excluded from
excluded from the
from the capture
the capture process
So far, the
the documentation seems
documentation seems very
seems very web-based
very web-based and
web-based and hasn't
and hasn't mentioned
hasn't mentioned desktop
mentioned desktop applications
This will retrieve
will retrieve both
retrieve both text
both text and
text and visual
and visual matches
visual matches for
matches for your
for your search
your search, automatically
automatically sorted by
sorted by how
by how closely
how closely the
closely the results
the results match
results match your
match your search
your search, linking
to the exact
the exact location
exact location of
of the item
the item you
item you saw
Both BitLocker and
BitLocker and Data
and Data Encryption
Data Encryption are
Encryption are to
So what will
what will the
will the impact
the impact on
impact on your
your computer actually
computer actually be?
actually be? Taking
be? Taking one
Taking one snapshot
one snapshot every
snapshot every five
every five seconds
five seconds will
seconds will mean
will mean a
mean a maximum
maximum of With
of With a
With a high-definition
a high-definition screen
high-definition screen that's
screen that's 1920
that's 1920 x
1920 x 1080
x 1080 pixels
1080 pixels, this
this would produce
would produce 6.2
produce 6.2 MB
6.2 MB of
MB of uncompressed
of uncompressed 24-bit
uncompressed 24-bit data
24-bit data every
data every five
With a 2K
a 2K screen
2K screen, this
this would rise
would rise to
rise to 11
to 11 MB
11 MB and
MB and a
and a 4K
a 4K screen
4K screen, this
rise to 24
to 24 MB
Even if they
if they drop
they drop the
drop the colour
the colour depth
colour depth to
depth to 16
to 16 bit
16 bit, the
the data size
data size would
size would be
would be However
be However, as
as I'm currently
I'm currently capturing
currently capturing this
capturing this video
this video at
video at 60
at 60 frames
60 frames per
frames per second
per second, capturing
capturing a frame
a frame every
frame every five
seconds will not
will not overtax
not overtax the
overtax the computer
the image may
image may well
well be compressed
be compressed when
compressed when saved
For users with
users with multiple
with multiple screens
multiple screens, the
the data volumes
data volumes will
volumes will of
will of course
of course go
course go up
Processing and Generating
and Generating the
Generating the Metadata
We just don't
just don't know
know how Microsoft
how Microsoft will
Microsoft will be
will be processing
be processing these
processing these snapshots
The implication is
implication is that
that the neural
the neural processing
processing unit will
unit will be
will be involved
be involved in
involved in running
in running an
running an OCR
an OCR, that's
that's Optical Character
Optical Character Recognition
Character Recognition, type
type approach, to
to pull text
pull text out
text out of
the images to
images to build
build the metadata
to be run
be run as
as a low-priority
a low-priority batch
low-priority batch processing
batch processing task
processing task and
task and not
not in real
in real time
Once the snapshot
the snapshot has
snapshot has been
been processed, this
be saved as
saved as a
as a thumbnail
a thumbnail and
thumbnail and the
and the original
the original screenshot
original screenshot deleted
screenshot deleted, thereby
thereby saving disk
saving disk space
The suggested use
suggested use of
of the Recall
the Recall feature
Recall feature is
feature is to
is to trawl
to trawl your
trawl your history
your history of
history of activities
of activities, like
like a mini-Google
a mini-Google search
mini-Google search engine
search engine, and
and pull back
pull back matching
back matching results
matching results by
results by querying
by querying the
querying the metadata
the metadata days
metadata days, weeks
or months after
months after the
after the original
the original snapshot
original snapshot was
snapshot was taken
How long this
long this data
data is to
to be held
be held is
held is not
not yet clear
yet clear, but
the search to
search to be
to be useful
be useful, it's
it's likely to
be held for
held for months
With all this
all this valuable
this valuable metadata
valuable metadata sitting
metadata sitting on
sitting on your
your local computer
local computer, how
how will it
will it be
it be secured
be secured beyond
secured beyond the
beyond the BitLocker
the BitLocker and
BitLocker and encryption
and encryption already
encryption already mentioned?
already mentioned? It's
mentioned? It's expected
It's expected that
expected that like
that like any
like any other
any other product
other product, it
go through version
through version upgrades
version upgrades, so
so the structure
structure of the
of the Meta
the Meta storage
Meta storage may
storage may change
may change over
change over time
Windows Update will
Update will need
to have access
to perform such
perform such updates
AI is with
is with us
with us now
us now, and
have to look
to look carefully
look carefully at
carefully at all
at all aspects
all aspects of
aspects of how
of how it
how it can
it can affect
can affect both
affect both us
both us and
us and the
and the computers
the computers we
computers we use
we use to
use to connect
to connect to
connect to the
to the outside
the outside world
type of valuable
of valuable user
valuable user metadata
user metadata is
metadata is already
is already being
already being stored
being stored on
stored on many
on many remote
many remote servers
remote servers, but
first time, it's
it's all going
be in one
for thought, indeed
looking at Power
at Power Basic
Power Basic manuals
This manual here
manual here is
one I originally
I originally purchased
originally purchased for
purchased for the
Windows Compiler, back
in the days
the days when
days when it
when it was
it was known
was known as
known as the
as the PB
the PB DLL
PB DLL Compiler
This manual I've
manual I've had
I've had for
had for many
for many years
Power Basic does
Basic does ship
does ship with
ship with a
with a help
help file, both
the Windows and
Windows and the
the console compilers
And these help
these help files
help files are
files are very
useful when you're
when you're actually
you're actually coding
But occasionally you
occasionally you may
back to a
to a printed
a printed manual
is the Power
console compiler manual
is a larger
a larger formatted
larger formatted manual
formatted manual and
manual and is
and is over
is over 500
over 500 pages
one is specifically
is specifically on
specifically on the
And covers every
covers every command
every command that
command that the
compiler can actually
actually do in
do in detail
I find a
find a printed
printed manual particularly
manual particularly useful
particularly useful when
useful when I'm
when I'm looking
I'm looking to
see what topic
what topic I
topic I can
I can cover
can cover in
cover in the
the next YouTube
next YouTube video
And these manuals
these manuals have
manuals have not
not been gathering
been gathering dust
gathering dust in
dust in a
in a warehouse
a warehouse somewhere
These are printed
are printed on
printed on demand
on demand by
demand by a
by a company
a company called
company called Lulu
below to where
to where you
you can purchase
can purchase either
purchase either the
either the console
compiler manual or
manual or the
or the Windows
Windows Compiler Manual
these are a
a large type
large type format
type format, they
they are easy
are easy to
easy to read
Unlike many modern
many modern manuals
modern manuals which
manuals which have
which have very
have very tiny
very tiny fonts
of course, as
would expect, there
was an index
an index at
index at the
at the back
the back of
of the book
the book, listing
listing every command
every command and
command and the
and the page
the page on
page on which
on which it
is actually referenced
So for somebody
for somebody learning
somebody learning Power
learning Power Basic
Power Basic, this
is an ideal
an ideal companion
And the advantage
the advantage between
advantage between a
between a printed
a printed book
printed book and
book and a
and a help
file is that
that of course
of course, you
you can stick
can stick post-its
stick post-its in
post-its in particular
in particular pages
particular pages when
pages when you
want to reference
to reference something
reference something you're
something you're studying
you're studying at
studying at the
the Lulu company
Lulu company prints
company prints these
prints these on
these on demand
And this arrived
this arrived in
arrived in a
in a mere
a mere five
mere five days
brand new manual
So far, I've
I've only purchased
only purchased the
purchased the console
compiler manual, and
and I'll be
I'll be putting
be putting an
putting an order
an order in
order in for
Compiler Manual very
Manual very shortly
I'm sure you
sure you will
will find these
find these manuals
these manuals very
manuals very useful
very useful in
Power Basic coding
previous video I
video I covered
I covered the
covered the manual
the manual for
manual for the
Console Compiler which
Compiler which is
which is comprised
comprised of some
of some 550
some 550 pages
550 pages of
pages of useful
of useful information
useful information on
information on all
on all the
all the commands
the commands that
commands that the
I've now taken
now taken receipt
taken receipt of
receipt of an
of an even
an even larger
even larger manual
larger manual for
This is comprised
of some 690
some 690 pages
690 pages of
pages of information
Overall I am
I am very
am very impressed
very impressed with
impressed with the
with the content
of the manual
But not only
only the content
The quality of
quality of the
the manual itself
manual itself, the
the binding and
binding and the
the way it's
way it's presented
it's presented is
presented is excellent
is excellent and
excellent and ideal
and ideal as
ideal as a
as a reference
a reference work
And I can
I can highly
can highly recommend
highly recommend it
can actually purchase
actually purchase these
purchase these manuals
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
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
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
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
to store a
store a number
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
the x, the
the y and
Plus we'll also
store the star's
the star's mass
of ways of
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
This user-defined type
user-defined type we're
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
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
put it more
it more simply
more simply, single-precision
are very versatile
stored within one
within one of
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
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
type of variable
This includes decimal
includes decimal places
doing today, this
out just fine
have our user-defined
our user-defined type
user-defined type set
the application, within
within any of
functions or subroutines
or subroutines, we
we can declare
can declare a
local variable as
variable as that
as that user-defined
that user-defined type
we are declaring
are declaring a
variable called uStar
And we're declaring
we're declaring that
declaring that as
that as udt
as udt stars
So our local
local variable uStar
variable uStar, is
now a user-defined
user-defined type containing
type containing the
containing the four
four elements we
elements we declared
can now populate
now populate these
populate these quite
here to make
All the prefix
prefix command does
command does is
is it takes
takes the string
the string that's
string that's in
in the double
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
does the same
next three lines
is we're setting
of our x
our x coordinate
of the star
the star to
star to be
be a random
1 and 1000
and 1000, and
adding on another
on another random
That's a number
number between 0
populate our user-defined
user-defined type with
type with the
the values randomly
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
randomise command with
with a seed
a seed number
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
we've populated this
populated this local
local variable, we'll
we'll now want
want to push
push the information
to the log
the log so
log so we
see what values
what values have
values have come
have come out
out of it
using the format
format command to
to turn these
turn these numbers
these numbers into
numbers into strings
into strings so
strings so we
use our logging
our logging command
logging command to
to send information
send information out
of values for
values for the
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
can have arrays
have arrays of
arrays of user-defined
if we were
we were looking
were looking to
looking to store
to store information
store information on
information on a
on a multitude
multitude of stars
of stars, we
could use an
an array containing
array containing each
containing each element
each element being
element being this
being this user-defined
we can start
can start to
to use pointers
do the array
the array, let's
let's use pointers
use pointers with
pointers with what
what we've got
we've got –
got – the
– the single
the single variable
the moment, let's
let's comment out
out this 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
functions – one
one to store
on a star
a star and
star and one
one to output
output the information
So we start
we start off
start off as
off as we
variable as this
as this user-defined
this is exactly
is exactly the
same line of
of code as
as we used
used before to
before to declare
variable as the
as the user-defined
user-defined type for
type for stars
going to prepare
to prepare a
prepare a pointer
pointer to be
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
the word 'pointer'
word 'pointer' –
'pointer' – to
– to say
say that this
a pointer variable
that we've declared
we've declared this
declared this pointer
this pointer variable
pointer variable, we
now populate it
populating this pointer
pointer variable by
using the VARPRT
the VARPRT function
returns the 32-bit
the 32-bit address
address of a
of a variable
And in brackets
in brackets, we
of the variable
the variable we're
variable we're returning
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
is stored for
stored for 'U
for 'U star'
one to prepare
prepare the star
star to populate
the values within
values within the
within the user-defined
user-defined type, and
print the details
the details out
So we're calling
calling the first
first function 'prep
function 'prep star'
'prep star' and
star' and the
the printing function
printing function 'print
function 'print star'
see from both
from both of
of the calls
calls to these
these functions, we're
the pointer variable
pointer variable –
variable – the
the single star
single star variable
star variable –
variable – to
– to each
create the first
of those two
those two functions
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
this case, since
since we're passing
passing a pointer
a pointer, pointers
pointers have to
be passed by
passed by value
have the 'by
the 'by value'
'by value' word
value' word at
variable we're bringing
it's the pointer
the pointer for
pointer for 'star'
as a user-defined
which we declared
very end, we
This indicates this
indicates this variable
variable is in
fact a pointer
set up, how
do we populate
the values using
values using this
using this pointer
this pointer variable?
pointer variable? So
variable? So the
So the lines
the lines of
populate this value
this value look
value look remarkably
remarkably similar to
similar to what
only difference is
difference is the
is the prefix
the prefix line
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
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
know that it's
it's a pointer
a pointer that's
pointer that's being
that's being used
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
can see it?
see it? So
it? So we'll
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
We have 'byval'
have 'byval' before
'byval' before the
before the name
the variable, and
it's a user-defined
user-defined type of
type of stars
And again at
end we have
we're passing exactly
passing exactly the
the same variable
same variable in
variable in exactly
way to this
to this printing
this printing function
And to print
details of our
of our stars
our stars out
stars out to
to our log
our log, we're
using the 'format'
the 'format' command
'format' command to
to turn the
turn the value
value back into
back into a
a string so
use the fun
the fun log
fun log function
the variable name
variable name is
name is preceded
is preceded with
preceded with the
with the '@'
'@' sign to
sign to indicate
indicate to Power
Basic that it's
But the rest
the code looks
code looks exactly
looks exactly the
using the dot
the dot and
dot and the
of the element
the element within
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
have three coordinates
three coordinates for
coordinates for our
for our star
our star, and
have the star's
used a pointer
a pointer with
pointer with a
with a locally
a locally defined
locally defined user-defined
defined user-defined type
of using this
pointer variable? Say
variable? Say for
wanted to store
to store multiple
store multiple stars
multiple stars in
stars in an
let's dimension an
of 100 elements
array of our
of our user-defined
through this array
this array using
done before, we'll
need a local
variable to act
to act as
act as a
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
end to indicate
indicate that this
indeed a pointer
let's now do
for each star
each star, we're
populate the pointer
for the element
the array being
array being processed
populate the PStar
the PStar variable
PStar variable again
variable again using
again using var
using var pointer
var pointer, but
time pointing to
value into PStar
into PStar, we
quite happily call
happily call our
call our PrepStar
our PrepStar function
PrepStar function, exactly
of the PrepStar
the PrepStar function
PrepStar function, it's
it's receiving a
receiving a pointer
And it doesn't
doesn't really matter
really matter whether
matter whether you're
whether you're passing
you're passing the
a single declared
single declared variable
declared variable or
variable or an
or an element
an element of
element of an
It will handle
will handle both
handle both quite
both quite happily
have now populated
now populated the
populated the value
each star, let's
let's print some
print some of
of those values
Let's go for
the first three
first three stars
So again, we'll
next loop, and
call our printStar
our printStar function
going for lngR
for lngR equals
lngR equals 1
equals 1 to
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
calling the printStar
the printStar function
printStar function with
function with PStar
with PStar as
PStar as the
as the variable
the variable being
our function running
function running quite
running quite happily
have the information
the information coming
information coming out
array of stars
of stars just
stars just as
we had the
had the information
from the single
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
prove the information
information is coming
is coming out
coming out quite
out quite correctly
quite correctly, let's
let's print out
out the third
the third star
third star without
star without using
without using pointers
make sure the
sure the information
information is exactly
code to print
setting the element
element number to
to be number
be number 3
is the third
z coordinates of
coordinates of that
of that star
that star, and
also the mass
mass of the
run this now
this now, it
it should show
should show exactly
show exactly the
same values coming
the array as
array as it
is for this
this last piece
have the value
value coming out
the pointer functions
pointer functions and
functions and coming
and coming out
coming out directly
out directly without
directly without using
values are exactly
in summary, as
from this code
this code, this
a simple way
simple way to
way to use
to use pointer
use pointer, giving
you a lot
lot of flexibility
in how you
actually use information
use information which
information which you're
which you're manipulating
you're manipulating for
manipulating for users
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
do things in
things in a
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
as in a
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
create a queue
queue collection object
Like the other
the other collection
other collection objects
collection objects within
objects within PowerBasic
within PowerBasic, this
be created quite
created quite easily
declare our variable
our variable as
variable as an
as an iQueueCollection
an iQueueCollection, and
using the let
the let command
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
can show that
show that this
that this collection
currently empty by
empty by using
of the collection
the collection –
collection – the
– the Count
the Count property
store the number
number of items
of items within
items within our
within our collection
using the collection.count
have determined how
determined how many
how many items
many items are
items are in
in the collection
the collection, we'll
we'll push that
push that out
that out to
our log so
can get a
get a report
report of it
As this returns
a number, we're
the format dollar
format dollar command
turn the number
the number back
number back into
can send it
send it out
application now, so
that it's currently
it's currently reporting
currently reporting that
reporting that there
there are zero
are zero items
zero items in
items in the
in the queue
the queue, which
is quite expected
quite expected because
expected because we
because we haven't
haven't added anything
added anything to
anything to the
to the queue
the queue just
queue just yet
created our collection
our collection, how
we add something
to the queue?
the queue? Well
queue? Well, you
can add something
add something quite
something quite easily
the queue by
queue by using
using the enqueue()
the enqueue() method
takes a parameter
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
give this a
bit more flexibility
more flexibility, this
this particular method
particular method takes
method takes a
takes a variant
a variant as
variant as its
use a variant
a variant to
variant to illustrate
to illustrate what
illustrate what more
what more this
more this can
will declare a
declare a variant
a variant for
variant for our
for our input
creating a local
variable called item
called item input
item input as
input as a
as a variant
a variant variable
variant variable type
with the string
into the queue
enqueue() method with
method with that
that variable as
variable as its
added this item
this item to
item to the
the queue, the
the queue count
queue count should
count should now
should now return
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
will save a
Macros have a
very powerful addition
powerful addition to
addition to Power
What we've created
we've created here
created here is
is a macro
a macro called
macro called count
called count items
count items, which
takes in one
in one parameter
one parameter called
parameter called long
called long count
long count items
It then has
then has two
has two lines
One to obtain
to obtain the
obtain the collection
the collection count
collection count and
count and a
a second line
second line to
line to print
the log the
log the number
of items in
purpose of a
of a macro
a macro is
macro is that
is that at
that at compile
compile time any
time any reference
to this macro
this macro will
macro will be
be replaced in
replaced in the
in the source
code by the
by the lines
within the macro
we place a
place a call
to our macro
our macro count
macro count items
count items in
the code here
code here at
here at compilation
at compilation time
compilation time, the
Power Basic compiler
Basic compiler will
compiler will replace
will replace this
replace this single
code with the
the two lines
of code contained
code contained within
But it keeps
it keeps our
keeps our code
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
successfully added our
added our first
our first item
the queue collection
So of course
do a simple
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
1 to 5
be adding five
adding five new
five new items
new items to
to our collection
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
there are now
are now six
now six items
six items in
does indeed tell
indeed tell us
can add items
add items to
items to the
queue and we
we can count
can count how
items are actually
are actually within
within the queue
the queue itself
having put information
put information into
information into a
into a queue
a queue, there
wish to pull
back out again
are actually in
the queue, we
a straightforward for
straightforward for next
So we're declaring
we're declaring two
declaring two variables
The item variable
item variable as
to contain what
contain what we're
what we're pulling
pulling out of
of the queue
The long item
long item is
item is going
be our counter
our counter for
of items we're
items we're actually
actually pulling out
it's a first
first in first
in first out
first out, we're
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
will pull the
pull the first
first item out
item out of
queue and put
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
But it never
it never does
never does any
does any harm
any harm to
harm to actually
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
using the variant
the variant vt
variant vt command
value of vt
of vt empty
vt empty, then
then there's nothing
nothing in this
It's completely empty
And if this
if this variant
this variant type
variant type returns
type returns something
other than empty
than empty, then
then it contains
it contains information
can push out
push out to
to a log
a log the
log the string
string that's contained
that's contained within
within the variant
can turn this
turn this back
a string using
string using the
the variant dollar
variant dollar command
getting the six
the six items
six items coming
items coming out
The first test
first test and
test and the
and the test
the test one
test one, two
four and five
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
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
it gives you
Variants can hold
can hold a
hold a wide
range of information
Variant variables can
variables can be
can be considered
be a type
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
dynamic strings and
strings and many
and many other
many other types
The other one
other one of
of interest is
interest is we
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
many items there
items there are
the queue, Enqueue
Enqueue to add
queue and Dequeue
and Dequeue to
Dequeue to remove
to remove something
remove something from
flexibility for very
for very little
little code within
code within your
find these queue
these queue collections
queue collections useful
collections useful in
you for watching!
again at queue
at queue handling
your applications, by
queue collection to
collection to store
to store arrays
This was the
was the code
code we used
we used in
used in our
video on queue
on queue collections
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
in the order
the order they
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
that you could
you could store
could store other
store other types
of information within
information within your
within your queue
your queue, for
for example arrays
So let's clear
let's clear down
clear down this
to the basics
the basics and
basics and start
new code in
code we are
we are still
are still declaring
still declaring a
variable called collection
called collection as
collection as an
let command to
make that collection
that collection equal
collection equal to
to the class
the class queueCollection
our variable all
variable all set
handle our queue
queue collection now
variable to count
items in our
in our queue
make use to
to the macro
the macro at
macro at the
code called countItems
called countItems, to
our queue and
queue and to
on our log
is quite correctly
correctly showing that
showing that there
zero items currently
items currently sitting
add some data
into this queue
this queue, we'll
create a variant
variant variable to
hold our information
call that item
that item input
item input declared
input declared as
declared as a
create an array
array to add
to this queue
So we've declared
we've declared a
declared a local
local array, which
dimension array from
array from elements
from elements zero
elements zero to
zero to four
other words, it's
to hold five
hold five pieces
five pieces of
are then assigning
then assigning one
assigning one letter
one letter to
letter to each
to each element
our array, the
the letters A
letters A, B
D and E
then populate this
populate this variant
variant variable with
variable with our
with our array
simply by the
of the variant
the variant variable
variant variable equals
variable equals the
equals the name
and two brackets
populated this variant
this variant, we
now place it
it within our
within our queue
previous video by
video by using
using the collection
the collection dot
collection dot enqueue
having put one
put one array
one array into
the queue, can
we now put
second but different
but different array
different array into
the same queue?
same queue? So
queue? So we've
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
B1 and C1
populating our variant
our variant variable
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
two items in
let us now
us now see
now see if
order to extract
the queue, we're
we're creating an
creating an item
an item variant
data coming back
coming back from
a new output
new output array
output array to
array to put
put that data
data into and
into and a
and a counter
a counter for
counter for each
important when you
when you dimension
you dimension that
array to mark
the array, open
open bracket, zero
allows the array
to be overwritten
be overwritten by
overwritten by what's
by what's coming
what's coming back
coming back out
back out of
through each item
each item in
the collection and
collection and pull
pull the data
the data out
data out and
out and populate
and populate our
populate our output
a local item
local item variable
for the item
the item count
going from that
from that equals
that equals one
equals one to
which we determined
we determined follow
determined follow up
follow up in
using the macro
populating the VItem
the VItem variable
VItem variable using
the collection dequeue
collection dequeue method
test the variant
variant variable that's
variable that's been
that's been pulled
been pulled back
pulled back to
back to make
it's not empty
not empty using
empty using the
the inbuilt variant
inbuilt variant VT
now is we're
is we're not
going to assume
to assume that
assume that all
within the collection
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
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
may be arrays
use the variant
VT command to
kind of information
of information is
is stored within
stored within this
we can act
can act accordingly
use the select
the select command
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
the log to
log to report
report on what
on what kind
kind of variant
of variant type
variant type it
type it is
it stands at
stands at the
two items that
items that we
the queue are
queue are both
are both of
both of variant
variant type 8200
you'll see a
list of equates
of equates that
equates that tells
that tells you
tells you what
you what kind
information is actually
to come back
back in one
of these variants
And you'll also
you'll also see
also see that
the value 8200
value 8200 is
8200 is not
is because for
because for a
for a string
string array, it's
be a combination
combination of two
of two of
of these values
up an accord
an accord quite
accord quite neatly
in a case
for the string
the string and
string and array
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
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
in the variant
the variant which
variant which we've
which we've pulled
we've pulled back
pulled back from
from our collection
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
array from the
the lower bounding
lower bounding to
bounding to the
and push that
have our two
The first array
first array with
array with five
with five elements
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
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
information back from
the queue into
queue into another
into another array
another array and
array and displayed
it on our
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
look back to
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
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
the same named
same named array
So it should
should be using
the same area
same area of
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
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
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
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
with the information
information we put
we put into
it's not using
not using the
the original array
original array at
array at all
The information going
information going into
queue is handled
is handled quite
handled quite separately
quite separately, even
we are continually
are continually reusing
continually reusing the
reusing the same
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
sets of arrays
of arrays into
arrays into our
What happens now
happens now if
add a dynamic
a dynamic string
dynamic string item
string item to
the queue? As
queue? As we
previous video, we
populate our variant
our variant with
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
method to add
add that to
to the collection
have four items
four items in
the queue, three
three arrays and
arrays and a
and a dynamic
our code where
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
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
variant variable into
variable into a
can display it
display it to
in the log
And if there's
if there's any
there's any other
any other type
other type coming
type coming back
from the collection
the collection, we
display a simple
a simple message
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
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
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
can put different
of information as
information as variants
as variants into
variants into our
into our collection
our collection queue
information back one
back one item
one item at
item at a
time and display
display it or
it or use
or use it
use it within
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
you have contacted
have contacted the
contacted the computer
the computer, you
can put them
put them back
them back at
There are, however
some limitations to
limitations to putting
to putting arrays
putting arrays into
arrays into collection
into collection queues
help file that
file that ships
Basic does say
does say there's
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
a great many
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
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
think it's high
it's high enough
high enough up
enough up the
up the scale
the scale that
scale that you
you may never
may never encounter
never encounter it
you'll find queue
find queue collections
at the Remain
the Remain and
Remain and Extract
and Extract string
Extract string handling
string handling commands
The Basic language
Basic language has
language has always
has always had
always had some
had some very
very powerful string
powerful string handling
handling commands and
commands and PowerBasic
and PowerBasic is
PowerBasic is no
is no exception
at today are
today are two
are two string
two string handling
handling commands called
commands called Remain
called Remain and
These commands are
commands are probably
are probably overlooked
probably overlooked due
overlooked due to
due to the
the very good
very good functionality
good functionality that
functionality that the
that the parse
parse command has
command has in
has in PowerBasic
So let's start
let's start first
start first with
first with the
with the Remain
the Remain command
If we declare
we declare a
variable called Telephone
called Telephone and
Telephone and we
put into this
into this Telephone
this Telephone string
Telephone string the
string the words
the words Home
words Home Number
Home Number followed
Number followed by
by a Telephone
a Telephone Number
of actually stripping
actually stripping out
stripping out the
text from this
from this field
this field and
field and leaving
and leaving just
leaving just the
just the number
use the Remain$
the Remain$ command
Remain$ command here
here to do
do it in
it in a
order to understand
understand what the
what the Remain$
Remain$ command actually
actually does we're
does we're using
using it here
it here to
populate the Telephone
the Telephone variable
Remain$ takes a
is an optional
an optional first
optional first parameter
first parameter which
parameter which we'll
which we'll come
come back on
back on in
on in a
The first mandatory
first mandatory parameter
mandatory parameter is
the string you
string you wish
case we're interrogating
we're interrogating the
interrogating the Telephone
the Telephone string
parameter is what
is what you're
what you're actually
you're actually looking
looking for within
for within that
within that string
the Any keyword
Any keyword to
keyword to say
to say any
say any of
of the characters
the characters that
characters that follows
that follows is
follows is what
we're basically looking
basically looking for
for the instance
the instance of
instance of any
of any number
what is Remain$
is Remain$ going
Remain$ going to
do to the
to the Telephone
the Telephone variable?
Telephone variable? Let's
variable? Let's print
our log and
log and have
value 8 1
8 1 numbers
missing the first
the first 0
first 0 character
What Remain actually
Remain actually does
actually does is
is it looks
a match on
match on any
of these characters
these characters that
characters that we
we have put
having found one
found one of
these characters it
characters it will
return the remainder
it will look
for the 0
the 0 find
0 find a
find a 0
number and return
and return all
the string following
string following that
following that first
that first 0
Telephone string with
string with the
with the numbers
the numbers 1
numbers 1 2
1 2 3
2 3 4
3 4 followed
4 followed by
followed by Home
by Home number
Home number and
then the Telephone
the Telephone number
Telephone number we
Remain$ command to
command to skip
to skip over
skip over the
the first 4
first 4 characters
4 characters and
characters and start
and start at
at the fifth
the fifth character
fifth character of
the string performing
string performing exactly
performing exactly the
the same operation
same operation as
operation as we
did a moment
will see after
see after Remain$
after Remain$ we
Remain$ we are
are now showing
showing the first
the first optional
first optional parameter
optional parameter in
parameter in this
case the number
the number 5
to the command
the command that
command that we
to start on
start on the
on the fifth
we run it
run it now
it now we
we get exactly
get exactly the
the same result
same result coming
result coming back
It skipped over
skipped over the
It has then
has then looked
then looked for
looked for the
the first matching
first matching character
matching character in
character in its
in its string
its string in
string in this
case a 0
a 0 and
0 and has
and has returned
has returned the
returned the remainder
of the phone
the phone number
If we did
we did not
did not put
not put that
put that 5
that 5 in
5 in there
in there it
there it would
would have stopped
have stopped on
stopped on the
very first character
first character like
character like so
would have skipped
have skipped over
over the 1
the 1 and
1 and then
then you would
would have had
have had all
had all the
all the numbers
the numbers falling
numbers falling as
falling as in
as in 2
in 2 3
3 4 the
4 the Home
the Home number
Home number then
number then the
So the optional
the optional first
first parameter gives
parameter gives you
you a way
way of skipping
of skipping over
skipping over characters
over characters that
characters that you're
you're not interested
not interested in
well as using
the any parameter
any parameter we
can also look
also look for
a particular string
particular string of
string of more
of more than
Let's say we're
say we're taking
taking the telephone
telephone string and
string and we're
looking for match
for match to
match to return
return the characters
the characters after
characters after the
after the fifth
looking for 8
for 8 1
8 1 0
1 0 1
that now we
we get returned
get returned telephone
returned telephone number
command has skipped
has skipped over
the first match
first match of
match of 8
of 8 1
It finds that
finds that at
of the telephone
telephone number and
number and it
will return everything
return everything that
everything that remains
that remains in
remains in the
the string after
string after that
optional parameter allows
parameter allows you
you to start
to start somewhere
start somewhere further
somewhere further down
down the string
you put this
as a negative
a negative number
negative number it
it will work
will work from
work from the
have a telephone
telephone number as
number as we
we have shown
have shown here
shown here with
the extension number
extension number after
number after the
after the telephone
interested in returning
in returning just
returning just the
just the extension
the extension we
extension we can
the same command
Now we are
are starting 8
starting 8 characters
8 characters in
characters in from
Then we're looking
looking for ext
for ext as
ext as the
of the match
match we're looking
that now we'll
quite easily returns
easily returns the
returns the extension
extension number 1
number 1 2
While this kind
this kind of
kind of operation
of operation can
operation can be
done with other
with other string
other string handling
handling commands for
commands for example
for example parse
example parse and
parse and the
and the left
the left right
left right and
right and mid
and mid $
mid $ strings
can perform the
perform the operation
the operation in
operation in a
your applications where
applications where you
where you may
actually make use
of the Remain$
at the Extract$
the Extract$ command
Extract$ command which
is the complement
the complement to
complement to Remain$
Whereas Remain$ gives
Remain$ gives you
gives you what
you what remains
what remains in
remains in a
a string after
string after finding
after finding a
finding a match
a match the
match the extract
the extract will
extract will show
will show you
show you everything
you everything up
everything up until
up until but
until but not
but not including
not including what
including what you're
what you're looking
a string with
string with an
with an address
an address in
address in it
want to extract
to extract everything
extract everything up
not including the
including the first
the first comma
first comma we
comma we can
And here we're
here we're using
using the Extract$
Extract$ command as
command as the
as the parameter
to our fun
our fun log
As Extract$ returns
Extract$ returns a
a string this
string this can
this can quite
quite easily be
easily be done
to populate an
populate an intermediate
an intermediate variable
see the Extract$
Extract$ command is
command is taking
is taking two
two parameters here
to interrogate and
interrogate and the
second parameter being
being the delimiter
the delimiter that
delimiter that we're
do is look
at the address
the address variable
address variable from
from the left
left hand side
hand side till
side till it
till it finds
finds the first
first comma and
comma and it
return everything up
up until that
until that point
that point and
point and nothing
and nothing after
code now we
get the 12
the 12 Any
12 Any Street
Any Street which
Street which is
the string up
string up to
up to but
to but not
including the comma
extract everything which
everything which is
which is after
is after the
after the zip
the zip string
zip string we
string we merely
amend our delimiter
our delimiter to
delimiter to show
to show for
show for zip
we get everything
get everything up
including the string
the string zip
get the then
the then anywhere
then anywhere and
anywhere and the
the final comma
Just like the
like the Remain
Remain command the
command the Extract
the Extract command
Extract command has
command has an
has an optional
to extract up
extract up to
first comma but
comma but starting
but starting from
from the third
the third character
third character onwards
character onwards we
onwards we merely
put the first
first parameter in
parameter in in
case the three
the three followed
three followed by
the variable we
variable we wish
interrogate and then
and then our
then our delimiter
our delimiter in
case the comma
we get Any
get Any Street
Any Street but
Street but we're
missing the 12
the 12 from
12 from the
the beginning because
beginning because it's
because it's starting
it's starting on
starting on the
on the third
third character which
character which in
case is a
look at yet
at yet another
yet another scenario
another scenario let's
scenario let's look
look at two
at two differently
two differently formatted
differently formatted addresses
formatted addresses address
addresses address one
address one and
one and address
and address two
Address one has
one has been
has been delimited
been delimited by
a comma the
comma the street
the street number
street number followed
by the street
the street name
street name followed
name followed by
a comma delimiter
Address two has
two has been
has been similarly
been similarly formatted
similarly formatted but
formatted but its
but its delimiter
its delimiter rather
delimiter rather than
rather than being
than being a
a comma is
comma is a
we handle this
handle this with
this with one
with one line
line of code?
of code? If
use the extract
extract command again
command again with
with the optional
optional parameter of
parameter of three
of three to
three to say
say we wish
at the third
third character in
character in before
in before we
we look for
match we're followed
we're followed that
followed that by
variable name address
name address one
one and then
the word Any
This instructs extract
instructs extract to
extract to look
look for any
for any of
these as delimiters
as delimiters so
delimiters so it's
it's looking either
looking either for
either for the
for the colon
the colon or
colon or the
or the comma
the comma so
comma so will
so will we
will we get
get the street
street name coming
name coming out
coming out for
out for address
for address one
do indeed we
indeed we get
the words Any
words Any Street
So will this
will this work
this work or
work or address
or address number
address number two?
number two? If
two? If we
will see it's
see it's given
it's given the
given the same
the same output
same output for
output for address
for address number
address number two
So the use
of the Any
Any keyword allows
keyword allows you
to use any
use any delimiter
any delimiter and
delimiter and gives
and gives a
gives a fair
of flexibility on
flexibility on what
what the extract
extract command can
command can actually
actually do as
do as a
as a nice
a nice complement
nice complement to
complement to both
both the remain
remain and the
and the parse
the parse commands
find these commands
these commands you
commands you saw
saw in your
of the resource
the resource command
resource command in
command in PowerBasic
This command works
command works both
works both in
both in the
code for this
for this demonstration
this demonstration is
demonstration is mostly
is mostly going
mostly going to
console compiler, however
will be using
Windows compiler later
compiler later on
the first things
first things you
things you may
to use your
use your resource
your resource command
resource command for
command for is
for is to
is to embed
to embed an
embed an icon
containing our source
source code, we
is an icon
an icon at
of files called
files called add.ico
is the icon
icon we want
want to embed
to embed within
embed within the
a user looks
user looks at
looks at the
application within File
within File Manager
File Manager, they
they can see
can see an
see an associated
an associated icon
associated icon with
icon with it
using the resource
command takes two
the name or
name or number
or number of
name or the
we are simply
are simply saying
simply saying 'resource
saying 'resource icon'
'resource icon' which
icon' which is
to be referred
be referred to
referred to using
to using the
using the string
the string app
string app icon
app icon and
icon and the
icon we're loading
we're loading is
loading is going
to be add.ico
If we compile
we compile the
compile the application
will compile quite
compile quite cleanly
the folder, we'll
that the EXE
the EXE has
EXE has now
has now appeared
appeared and the
the icon that's
icon that's associated
that's associated with
associated with it
with it in
it in File
in File Manager
File Manager is
Manager is the
is the add
the add icon
add icon, the
the plus symbol
When adding icons
adding icons to
icons to your
your application, Windows
Windows will display
display the very
first icon added
icon added to
the resource file
resource file as
file as the
as the icon
of course add
course add multiple
add multiple icons
multiple icons or
icons or bitmaps
or bitmaps to
bitmaps to the
application using this
command to embed
to embed version
embed version information
version information on
on the executable
executable and look
look at properties
at properties and
properties and then
and then look
then look at
look at details
at details, at
is not much
not much information
much information held
within this page
is no file
no file description
file description, product
product name or
name or versions
All it's showing
it's showing is
showing is the
and the date
the date it
date it was
it was last
was last modified
number of resource
of resource commands
commands to embed
to embed this
embed this version
this version information
version information into
into the executable
We start by
start by using
the resource version
resource version info
version info, which
which indicates to
indicates to the
to the Power
Basic Compiler that
Compiler that we're
that we're about
about to give
give it version
it version information
give a file
a file version
file version and
version and a
and a product
a product version
product version value
this case I've
case I've set
I've set them
set them both
them both as
both as being
as being 1.2.3.4
They do not
do not necessarily
next thing in
thing in our
in our resource
our resource is
resource is the
is the resource
the resource string
resource string info
setting the language
the language ID
language ID and
and the character
going for US
for US English
US English and
English and the
character set to
to be Unicode
the resource statement
resource statement within
statement within the
within the help
help file, you'll
you'll see there
list of different
of different language
different language IDs
language IDs and
IDs and character
and character sets
you're in a
in a part
a part of
the world that
world that doesn't
that doesn't speak
doesn't speak English
speak English, you
can pick a
a different entry
different entry for
for the language
the string info
string info we're
info we're currently
currently using Unicode
using Unicode, but
of the others
the others you
others you merely
have to substitute
to substitute this
substitute this value
So having determined
having determined the
determined the language
ID and character
and character set
character set, we
now go on
on to set
set different version
different version information
here we're setting
setting a number
of different values
different values on
on the version
the version dollar
version dollar section
the company, the
the file description
file description, the
the file version
file version in
version in a
a string format
string format, the
the internal name
internal name, the
the original file
original file name
file name, any
any legal copyright
legal copyright you
copyright you wish
wish to declare
to declare, the
the product name
product name, the
the product version
product version and
version and any
and any comments
any comments you
comments you want
you want shown
want shown to
we compile that
compile that now
will again compile
again compile cleanly
compile cleanly, and
the file manager
file manager and
manager and right-click
and right-click and
right-click and look
at the Details
the Details tab
Details tab, this
this will now
will now tell
now tell us
information that we've
are now populated
populated the description
the description, the
file version, the
product name and
name and so
It's always very
always very useful
very useful setting
useful setting this
setting this resource
this resource information
resource information on
information on your
on your file
your file so
that if somebody
if somebody else
somebody else who
else who is
who is unfamiliar
is unfamiliar with
unfamiliar with your
your application clicks
application clicks on
clicks on it
on it, they
they can find
can find out
find out which
out which organisation
which organisation or
organisation or name
or name it
name it actually
it actually has
well as things
as things like
like the file
file and product
and product version
have that information
that information stored
information stored in
in the resource
the resource section
resource section of
our application, I'm
I'm now going
look at embedding
at embedding files
embedding files within
files within the
the folder two
folder two CSV
CSV files, a
a test demo
test demo 2
demo 2 and
2 and a
and a test
So perhaps these
perhaps these are
these are files
are files which
files which your
which your application
will depend upon
when you roll
you roll this
roll this application
this application out
application out to
to the users
the users, there
be three files
three files, the
executable and two
and two CSV
If these CSV
CSV files are
files are integral
are integral to
integral to the
to the way
way the application
the application works
application works, you
don't want anybody
want anybody deleting
anybody deleting or
deleting or amending
or amending them
be difficult if
difficult if the
if the folder
in which this
which this application
this application sits
application sits is
sits is given
is given full
given full rights
full rights to
rights to the
to make amendments
don't want them
want them deleting
them deleting your
deleting your key
your key files
to embed these
embed these two
these two files
two files within
is very easily
very easily done
easily done using
the resource RC
resource RC data
RC data command
call this command
this command twice
command twice, once
So the resource
resource command is
followed by RC
by RC data
RC data and
data and then
then two parameters
first parameter we're
parameter we're designating
designating as a
a number 4000
number 4000 and
4000 and 4001
and 4001, which
which is followed
wish to embed
to embed in
embed in the
of course could
course could be
be a path
a path to
path to another
to another folder
another folder or
folder or in
or in this
this case, just
just a reference
the file within
file within the
within the folder
where our source
source code lies
again compile quite
look in file
file manager, we'll
application has become
has become bigger
we have these
have these two
two files embedded
files embedded in
embedded in our
we get them
get them out?
them out? So
out? So when
application runs, these
two files will
files will be
will be extracted
from the resource
the resource and
resource and placed
and placed in
in the root
the root of
root of the
let's create test
create test folder
test folder on
folder on our
on our computer
our computer, which
actually put a
a new executable
new executable into
folder called test
called test area
something in a
in a code
a code so
when the executable
the executable runs
executable runs, it
attempt to extract
to extract both
extract both of
files and put
and put them
put them into
into the folder
folder which the
which the executable
the executable is
that function save
function save resource
two parameters, one
How this will
be called in
called in the
application is calling
is calling the
calling the name
create and the
the resource which
resource which has
this case, value
value 4000 for
4000 for the
first file and
file and 4001
and 4001 for
4001 for the
perform this extract
a file handle
file handle for
file we're about
is currently in
The string variable
string variable strData
variable strData can
strData can be
be populated quite
populated quite easily
the resource $
resource $ command
The first in
first in this
case is rcdata
tell the application
information out the
out the rcdata
the rcdata section
of the section
the section we
section we wish
is to value
to value 4000
going to open
open a file
a file which
file which we're
going to dump
dump the strData
the strData variable
strData variable into
will first pick
first pick up
the next free
next free file
free file handle
open for output
for output the
output the file
So that's open
that's open strFileName
open strFileName for
strFileName for output
for output as
output as the
as the file
the file handle
file handle we
handle we have
have just populated
matter of using
of using the
using the print
print statement to
statement to print
print that string
that string data
string data out
can then close
then close off
off the file
file and end
and end the
end the function
statement to ensure
ensure that a
that a carriage
is not output
not output automatically
that now, that
that again compiles
again compiles cleanly
copy our resource
our resource command
into the test
the test area
in this one
this one folder
one folder is
single file, the
the executable, the
the program runs
program runs and
runs and has
and has now
has now deposited
now deposited both
deposited both of
the files into
files into the
into the root
we've achieved is
achieved is we've
is we've extracted
we've extracted both
extracted both of
the files from
application and deposited
and deposited them
deposited them into
These can now
now be read
be read by
read by other
by other parts
And should either
should either of
these files be
files be deleted?
be deleted? When
deleted? When we
application again, they
they will be
will be recreated
can see, we
we can embed
can embed files
embed files within
application in the
resource section and
section and then
and then extract
then extract them
extract them quite
your application where
application where you
call a DLL
So this DLL
this DLL would
DLL would sit
would sit, possibly
possibly within the
folder as your
as your application
And again, we
would have the
same problem as
problem as we
as we do
do with files
that this file
this file could
file could get
could get deleted
get deleted at
deleted at some
into the Windows
compiler and create
very simple DLL
create a framework
a framework using
framework using a
using a libmain
a libmain, which
us the template
the template for
template for a
for a DLL
simple function within
function within here
within here that
will be exported
be exported as
exported as part
of the DLL
this function 'half
function 'half a
'half a value'
will take one
take one parameter
This parameter is
parameter is numeric
is numeric and
numeric and it
is of the
of the single
single variable type
If we receive
we receive this
receive this value
this value, it
will then divide
then divide the
divide the value
the value by
value by two
by two and
two and return
and return that
return that to
As well inside
well inside a
inside a DLL
a DLL, there
two additional things
additional things to
need the export
the export as
export as single
as single as
single as the
the function definition
The export is
export is telling
is telling PowerBasic
telling PowerBasic that
PowerBasic that this
be visible from
visible from outside
from outside the
outside the DLL
that it can
can be called
be called from
called from other
from other applications
the function, in
this case fun
case fun half
fun half a
half a value
a value, is
is internal to
internal to the
to the DLL
The alias is
alias is the
way the function
to be referenced
be referenced from
referenced from outside
this case, we
we left them
left them both
them both exactly
both exactly the
the same, but
but they did
they did not
did not necessarily
One key point
key point though
point though is
though is that
that the alias
alias is case
is case dependent
that when we're
this function from
function from outside
from outside, we'll
know the casing
the string which
string which forms
which forms the
forms the name
save this, we'll
call the file
the file simpleDLL.bas
file simpleDLL.bas and
simpleDLL.bas and we
do a quick
quick compile on
compile on it
it and it
and it compiles
it compiles quite
compiles quite cleanly
our code area
code area, we
is our simpleDLL.DLL
created a DLL
a DLL which
DLL which we're
we're now about
now about to
about to call
since this DLL
this DLL is
DLL is external
is external, there
are two ways
two ways of
ways of referencing
of referencing a
DLL and its
and its functions
its functions within
functions within your
within your code
first is early
is early binding
The early binding
early binding is
binding is where
where we declare
we declare this
as a function
a function at
application runs, the
it looks to
looks to make
sure that DLL
that DLL actually
DLL actually exists
let's put that
put that definition
that definition in
is our definition
We're declaring the
declaring the function
the function internally
function internally to
internally to the
application called funHalfAValue
We're indicating that
indicating that this
is an import
an import function
it's been imported
been imported from
imported from somewhere
from somewhere outside
somewhere outside and
outside and it's
and it's been
imported from this
from this simpleDLL.DLL
within the DLL
this is case
parameter being passed
function which in
it is returning
is returning a
returning a single
So how would
would we call
call this within
within our application?
our application? So
application? So first
will create two
One called value
called value and
value and one
one called new
called new value
set the original
the original value
original value as
value as being
being the value
we know when
this function, it's
value we give
give it and
it and it's
to return half
return half of
half of that
can call this
call this external
this external function
external function in
in the DLL
DLL by referencing
by referencing the
referencing the name
in the declaration
this case funHalfAValue
case funHalfAValue, passing
it the single
is the original
original value of
function is populating
is populating the
populating the new
new value variable
value variable which
variable which in
should be 5
take that new
that new value
value and we're
to push that
let's try compiling
into our test
our test area
test area, we
will copy first
copy first of
all the EXE
the EXE and
EXE and also
also the DLL
the DLL into
DLL into our
two files in
files in our
run the command
the command, it
that the new
new value is
value is indeed
is indeed 5
have successfully called
successfully called the
called the function
And our two
our two resource
two resource files
resource files have
have been pulled
been pulled out
pulled out and
out and deposited
and deposited in
deposited in the
however we delete
we delete the
delete the DLL
DLL and attempt
application again, it
it will complain
will complain that
complain that it
that it cannot
it cannot proceed
cannot proceed because
proceed because it
because it cannot
it cannot find
cannot find the
find the DLL
can we embed
we embed the
embed the DLL
the DLL inside
DLL inside the
inside the resource
of our application?
application? So let's
to use late
use late binding
late binding on
binding on the
on the DLL
store the DLL
the DLL within
DLL within the
the application just
application just as
did before with
before with the
put another resource
another resource rcdata
resource rcdata command
rcdata command at
the application, so
that the DLL
the DLL at
DLL at compile
time is embedded
is embedded inside
embedded inside the
If we note
we note the
note the size
of our EXE
our EXE at
EXE at the
the moment, which
which is 28K
is 28K, if
we compile now
compile now and
now and look
the executable, we
it's now gone
now gone up
gone up to
up to 34K
So it's added
it's added on
added on the
on the size
DLL into the
get the DLL
the DLL out
DLL out at
out at run
at run time
use another save
another save resource
save resource call
time we're using
we're using simple
using simple DLL.DLL
simple DLL.DLL as
DLL.DLL as a
a parameter and
parameter and 4002
and 4002 as
4002 as the
as the handle
pull the DLL
that's not enough
not enough for
enough for late
for late binding
early binding declaration
binding declaration means
declaration means as
means as soon
application runs before
runs before it's
before it's even
it's even run
even run a
run a single
line of your
your code, it
look for this
for this DLL
this DLL, and
and the DLL
DLL at that
in time will
time will not
not be there
So we'll comment
out this declaration
this declaration because
declaration because we're
using this one
a local function
function is in
is in effect
in effect a
effect a construct
a construct that
construct that will
that will point
will point towards
towards the function
The function get
function get value
get value will
value will not
not exist within
But it's taking
it's taking the
taking the parameter
the parameter we
parameter we wish
give it, which
variable type, and
variable type as
type as returned
as returned from
returned from the
from the function
So next, how
actually get hold
get hold of
hold of that
of that within
within the application?
the application? So
application? So we
out this call
this call we
call we did
for the early
The late binding
late binding does
binding does involve
does involve a
involve a little
bit more code
An each proc
each proc variable
proc variable, which
a handle, and
and an ASCII
an ASCII 100
ASCII 100 character
100 character function
the DLL we're
DLL we're about
do the late
late binding to
binding to the
the DLL itself
DLL itself by
itself by calling
by calling a
calling a Windows
Windows API, a
a load library
load library function
variable called hlib
the library, the
The load library
load library command
library command takes
path and or
and or name
or name to
value returned about
returned about this
about this call
call to load
to load library
load library returns
library returns a
which is greater
get the address
get the handle
that function by
function by using
using another API
call called get_proc_address
the library handle
library handle, and
function we wish
from that is
that is greater
got the address
the address call
address call of
call of the
now go ahead
ahead and attempt
attempt to execute
to execute the
execute the function
where we make
of the declaration
the declaration fun
declaration fun get_value
fun get_value we
get_value we put
And we perform
we perform this
perform this by
using the call
the call command
call command, DLL
the handle we've
handle we've just
we've just called
just called back
called back, and
the word using
word using, and
then our function
our function name
function name, the
one we declared
setting the output
output of that
that to this
to this SNG
this SNG new
SNG new value
got the code
the code completed
code completed, let's
let's try a
try a compile
go in now
in now and
and we'll copy
we'll copy the
copy the EXE
the EXE into
EXE into our
So the only
only thing sitting
thing sitting within
sitting within our
within our test
test area is
area is the
is no DLL
no DLL and
DLL and there
are no CSV
no CSV files
new value coming
coming out as
out as the
the value value
value value 10
value 10 divided
10 divided by
now see in
test area folder
area folder that
folder that not
that not only
only have we
we got both
got both of
CSV files, but
have the DLL
So the DLL
DLL is copied
is copied out
copied out to
the folder before
folder before we
we actually call
actually call the
call the library
This is late
is late binding
is we've embedded
we've embedded two
embedded two CSV
CSV files and
files and a
and a DLL
a DLL within
DLL within our
within our executable
we're using late
using late binding
the DLL to
DLL to ensure
DLL is extracted
is extracted before
extracted before we
we call it
of course no
course no reason
you couldn't embed
couldn't embed more
embed more files
more files within
files within your
when the resources
the resources are
resources are saved
are saved to
to the local
the local drive
local drive, they
they don't necessarily
don't necessarily have
in the local
the local folder
They could be
could be saved
to the Windows
the Windows temporary
Windows temporary folder
temporary folder for
folder for that
that particular user
only thing I
thing I wish
application is something
is something to
something to free
to free up
up the library
we have called
we have referenced
have referenced a
referenced a DLL
a DLL in
DLL in the
the library and
library and we've
given the load
library command to
command to Windows
to Windows, Windows
Windows will have
will have this
have this loaded
this loaded in
loaded in memory
with all DLLs
all DLLs, Windows
Windows will keep
will keep it
keep it in
in memory until
memory until the
until the number
of applications which
applications which have
have a handle
handle to it
to it descends
it descends to
descends to zero
it reaches zero
reaches zero, Windows
Windows will unload
will unload the
unload the DLL
So it's always
good practice at
practice at the
end of your
your application if
application if you've
you've done a
done a load
library command or
command or multiple
or multiple load
multiple load library
load library commands
library commands to
commands to load
to load DLLs
load DLLs into
DLLs into memory
into memory that
memory that use
that use the
use the Free
the Free Library
Free Library command
command to inform
to inform Windows
inform Windows that
Windows that you
that you no
you no longer
longer need a
This saves taking
saves taking up
taking up extra
up extra memory
extra memory in
memory in Windows
find these techniques
these techniques useful
techniques useful in
at the insertion
the insertion and
insertion and deletion
and deletion of
deletion of data
data to and
to and from
and from strings
of the advantages
advantages of the
of the many
the many dialects
many dialects of
dialects of Basic
of Basic, and
and PowerBasic in
PowerBasic in particular
in particular, is
ability to do
to do string
do string handling
looking at methods
at methods for
methods for inserting
for inserting and
inserting and deleting
and deleting text
deleting text from
from inside strings
local variable and
will populate it
with a string
have our local
local variable, data
containing a string
text is in
is in two
in two lines
two lines, and
and contains the
contains the word
the word 'Monday'
do is replace
is replace the
replace the word
word 'Monday' with
'Monday' with the
the word 'Tuesday'
look at three
at three different
three different mechanisms
different mechanisms by
mechanisms by which
we can achieve
can achieve this
first create a
variable called 'newData'
contain the content
content of our
of our amended
our amended string
variable called 'target'
is the target
the target string
target string we
string we are
looking for in
for in our
When performing this
performing this type
type of replacement
of replacement, one
of the common
the common ways
common ways of
ways of doing
doing it is
use the 'replace'
the 'replace' command
be creating three
creating three different
three different ways
ways of replacing
of replacing this
replacing this text
this text, we're
going to embed
embed these three
these three different
three different methods
different methods in
methods in three
in three functions
our first function
first function will
function will handle
will handle use
handle use of
of the 'replace'
call our first
first function 'replaceDay1'
data string that
string that we
And the replacement
the replacement piece
replacement piece of
want to slot
slot in to
in to replace
to replace the
But once we've
once we've actually
we've actually processed
actually processed and
processed and populated
and populated the
populated the new
new data variable
data variable, we
print the result
the result out
result out to
new function 'replaceDay1'
variable called 'amendedData'
called 'amendedData', which
data we've passed
'replace' command to
command to replace
replace the target
target string with
string with our
with our new
our new day
new day string
day string, within
within this 'amendedData'
this 'amendedData' variable
Using the 'replace'
the 'replace' function
'replace' function is
very straightforward way
straightforward way of
way of replacing
of replacing a
replacing a string
string within another
within another string
function we'll be
of the 'amendedData'
the 'amendedData' variable
data string we
word 'Monday' only
'Monday' only appears
only appears once
to be wary
be wary of
wary of when
of when using
when using the
'replace' command is
command is it
it will replace
will replace every
replace every instance
every instance of
instance of the
of the target
the target that
target that it
it finds within
finds within the
case the word
appears once, so
so it's good
good to use
word 'Monday' appeared
'Monday' appeared more
appeared more than
than once, using
'replace' command would
command would replace
would replace every
instance of 'Monday'
of 'Monday' with
So the fact
the fact of
fact of 'replace'
of 'replace' will
'replace' will replace
the target is
target is worth
is worth remembering
worth remembering in
remembering in your
your own code
determine which of
the three methods
three methods of
methods of replacing
replacing this string
this string are
are the most
the most efficient
most efficient, we're
using a timer
And because the
because the Windows
operating system could
system could be
could be busy
be busy doing
busy doing other
doing other things
other things when
things when our
when our function
our function actually
function actually runs
actually runs, we
run the function
the function multiple
we'll take an
take an average
an average of
average of the
of the length
length of time
of time it
time it takes
takes to run
A timer for
timer for our
for our CPU
our CPU cycles
CPU cycles, a
a loop number
loop number and
number and a
and a number
number of loops
of loops at
loops at 1000
at 1000, so
this function 1000
function 1000 times
we will wrap
will wrap the
wrap the call
to the 'replace
the 'replace day1'
'replace day1' function
day1' function inside
function inside of
inside of a
of a 'for
a 'for next
'for next loop'
we start the
start the loop
the loop, we're
calling the 'tix'
the 'tix' command
single parameter of
of the 'quad'
the 'quad' variable
'quad' variable, we're
We'll then run
run the loop
the loop 1000
loop 1000 times
1000 times, calling
calling our 'replace
our 'replace day1'
once the loop
loop has finished
has finished, we
we will end
end the 'tix'
'tix' command, again
again populating the
populating the timer
number of CPU
of CPU cycles
CPU cycles that
cycles that this
particular function has
function has taken
has taken to
taken to run
now create a
create a print_result
a print_result function
print_result function to
print the value
value out to
this new print_result
new print_result function
The data, the
of the timer
the timer, the
the loops and
loops and the
type we're actually
be the 'replace'
will print this
print this out
this out to
our log, so
we have information
have information on
information on how
long the function
the function took
function took on
took on average
on average to
average to run
format command, and
it the value
the timer divided
timer divided by
This division symbol
division symbol here
symbol here, as
the normal one
normal one, will
you a whole
the value output
value output, and
it has successfully
has successfully replaced
successfully replaced the
replaced the word
it has taken
has taken 1,336
taken 1,336 CPU
1,336 CPU cycles
CPU cycles to
cycles to run
to run on
run on average
is our baseline
our baseline, using
of new commands
new commands, str_delete
str_delete and str_insert
for_next loop, and
function called 'replace_day2'
called 'replace_day2' with
'replace_day2' with three
with three parameters
three parameters as
parameters as before
going to close
to close off
timer and print
and print out
out the results
this new replace_day
new replace_day function
parameters as they
they were before
We have again
have again created
again created a
variable called 'amended_data'
called 'amended_data' and
'amended_data' and populated
and populated it
populated it with
data that's come
that's come in
Rather than doing
than doing the
doing the code
the code on
code on a
a single replace
single replace command
replace command this
command this time
this time, we're
use two separate
two separate commands
out what position
what position the
position the word
word 'Monday' exists
'Monday' exists at
exists at, and
use the in-string
the in-string command
in-string command to
that quite successfully
return the character
character position where
position where the
where the word
word 'Monday' begins
As our data
our data only
data only has
has the word
word 'Monday' once
'Monday' once, it
it will find
will find the
find the first
the first instance
first instance of
'Monday' appeared twice
appeared twice, it
it would still
would still find
still find the
find the very
very first instance
function is ideal
is ideal where
ideal where the
word 'Monday' appears
'Monday' appears more
appears more than
than once, and
wish to find
instance of it
in our amended
our amended data
amended data variable
data variable, it
it contains the
contains the full
the full text
full text containing
text containing the
containing the word
use the str-delete
the str-delete command
str-delete command to
command to delete
delete the text
str-delete command takes
command takes three
variable that contains
text that we
is a numeric
numeric variable which
holds the position
the position where
position where this
where this text
this text starts
That's followed by
by the length
wish to replace
to replace, so
use the LEN
the LEN command
LEN command to
out how long
how long our
long our target
our target string
target string actually
string actually is
After this command
this command executes
command executes, the
the amended data
data variable would
variable would no
no longer have
longer have the
word 'Monday' in
'Monday' in it
would be removed
be removed completely
that we've removed
we've removed the
removed the word
word 'Monday', we
to insert our
new data, in
to insert it
insert it at
it at exactly
at exactly the
the same position
use the str-insert
the str-insert command
And the str-insert
str-insert command takes
takes three variables
wish to insert
numeric variable containing
containing the character
character position that
position that we
to insert to
insert the data
data at that
at that position
that position and
position and move
and move all
move all text
all text to
right of that
of that position
that position, further
further to the
do to finish
to finish this
finish this function
this function off
function off is
off is to
of the amended
having completed that
completed that, let's
see how long
have the run
run of our
of our replace
our replace day
replace day 2
day 2 function
2 function, handling
handling the delete
the delete and
delete and insert
and insert commands
the average number
average number of
CPU cycles is
cycles is slightly
is slightly lower
slightly lower than
lower than that
than that used
that used using
used using the
using the replace
the replace command
is running each
running each of
these functions 1000
functions 1000 times
at a third
a third way
third way of
of replacing our
replacing our text
use the string
the string append
string append approach
same way of
of doing our
doing our loops
now calling a
function called replace
called replace day
replace day 3
day 3, again
again passing the
passing the same
the same three
same three parameters
the print result
print result function
result function we've
function we've already
already created to
created to print
new function again
function again taking
again taking the
taking the same
We've again created
variable called amended
called amended data
But we're not
we're not initially
not initially populating
initially populating it
get the position
position where our
where our target
target string exists
string exists in
got that, we're
at populating the
populating the amended
use two other
two other string
other string functions
string functions, one
one called left
called left and
left and one
one called mid
The left dollar
left dollar command
dollar command will
command will give
us the string
string up until
until the start
of our Monday
our Monday word
will then add
the new day
new day, and
we will tack
will tack on
tack on to
of that everything
that everything to
everything to the
right of our
our Monday string
from here the
here the left
left dollar will
dollar will take
take our data
our data string
data string, start
start at a
at a position
a position minus
position minus 1
minus 1, and
that will give
give us everything
us everything up
everything up to
including the start
the word Monday
new value, Tuesday
will then use
use the mid
at our data
data variable from
from the starting
starting position plus
position plus the
plus the length
the target we
target we were
were looking for
looking for, which
And a return
a return from
function is again
is again the
again the amended
code now so
now so we
we can compare
can compare all
compare all three
all three functions
three functions together
are three functions
three functions now
functions now having
now having completed
replace command is
is taking 1,439
taking 1,439 CPU
1,439 CPU cycles
insert commands, is
is taking 1,248
taking 1,248 cycles
final function where
where we're using
using a string
a string append
append approach is
approach is taking
is taking 1,381
taking 1,381 CPU
1,381 CPU cycles
from this that
this that the
that the most
most efficient method
efficient method of
method of inserting
of inserting a
inserting a piece
text into a
a string is
string is the
is the delete
and insert approach
insert approach, followed
by the string
string append, and
by the replace
The reason the
reason the replace
command is probably
is probably taking
probably taking longer
taking longer to
longer to execute
to execute than
execute than the
than the other
other two, the
command is designed
designed to replace
to replace one
replace one or
or more instances
more instances of
instances of the
the target word
Therefore having replaced
having replaced the
replaced the first
first one, it
will look through
string to see
any more instances
the word to
word to replace
So in code
in code, it's
it's probably doing
probably doing a
doing a bit
bit more than
other two functions
Now admittedly, the
the average time
average time it
to run each
run each of
functions is very
There's not much
not much in
much in the
way of CPU
CPU cycles between
cycles between each
if you're performing
you're performing a
performing a particular
a particular function
particular function many
function many thousands
many thousands, tens
tens of thousands
of thousands or
thousands or even
or even millions
even millions of
millions of times
of times, this
this difference will
difference will add
will add up
have a need
a need to
do text replacement
text replacement in
replacement in a
in a really
a really efficient
really efficient way
efficient way because
way because of
of the amount
amount of replacing
of replacing you're
replacing you're doing
you're doing, it's
it's worth taking
worth taking this
taking this approach
this approach, measuring
measuring to see
see which one
which one is
one is likely
be the most
look at user-defined
at user-defined types
types and unions
since we covered
we covered user-defined
covered user-defined types
So today, we're
of a recap
a recap on
recap on how
how to set
and populate a
populate a user-defined
after that, we're
to cover the
cover the use
of the union
the union command
So first, let's
create a simple
a simple user-defined
simple user-defined type
to store some
store some information
some information on
information on an
on an account
create an account
an account to
account to store
to store two
store two things
two things, a
a balance and
balance and a
and a transaction
a transaction count
define the type
the type by
type by simply
by simply giving
simply giving the
giving the type
the type a
type a name
a name, in
this case, udt
two elements to
elements to this
to this account
this account, the
being the balance
the balance and
balance and the
being the transaction
the transaction count
of these are
these are defined
defined as being
as being long
being long variables
We can reference
can reference this
reference this new
this new user-defined
new user-defined type
user-defined type in
type in our
our code by
code by declaring
declaring a variable
a variable as
So here we've
here we've declared
variable called u
called u account
u account as
account as a
name suggests, this
But it's a
it's a local
local variable in
variable in which
in which you
have defined the
defined the structure
attempt to populate
data within this
within this structure
By simply entering
simply entering the
entering the u
the u account
u account, then
then a dot
a dot and
dot and then
then the name
the element, in
this case long
case long balance
long balance, we
can make that
make that equal
equal to 95.99
same with our
with our transaction
our transaction count
transaction count, giving
it a value
This also helps
also helps to
helps to make
make your code
your code quite
code quite readable
It's obvious that
obvious that we're
that we're setting
setting the balance
the balance on
balance on an
account to a
a specific value
prove that this
that this data
now sitting within
sitting within this
within this construct
this construct, we
can print the
Since our log
our log takes
log takes a
a string parameter
string parameter, we
the format $
format $ command
$ command to
command to convert
to convert our
convert our balance
our balance and
balance and our
and our transaction
transaction count into
count into a
we can append
can append it
the word balance
word balance and
balance and transactions
see the balance
the balance appears
balance appears as
appears as This
as This might
This might seem
might seem strange
value in as
as The reason
we're putting this
putting this value
a long balance
This variable type
variable type does
type does not
does not hold
not hold decimal
hold decimal places
decimal places, so
so it automatically
it automatically rounds
automatically rounds up
rounds up to
to the nearest
the nearest whole
nearest whole number
Since we're looking
looking at storing
at storing currency
storing currency, we
change this to
to a currency
a currency type
now we've defined
we've defined within
defined within our
within our user
defined type that
type that the
that the balance
the balance is
balance is now
now a currency
a currency, we
actually use that
use that in
our application again
application again, we'll
is now coming
out correctly as
correctly as 95.99
have stored two
stored two values
two values in
fine for a
for a couple
couple of pieces
of pieces of
but what happens
if we need
number of accounts?
of accounts? So
accounts? So since
have defined a
defined a user
defined type, we
can create an
which is of
is of that
of that type
we have declared
have declared a
declared a 10
a 10 element
10 element array
element array as
array as udt
as udt account
So each element
of this array
this array will
array will have
will have those
two values stored
values stored against
stored against the
against the element
So let's point
let's point this
point this towards
this towards the
towards the first
array and populate
variable called element
called element as
element as a
a long and
long and we're
a value 1
populate this element
this element, we
can use exactly
the same construct
we give the
give the name
the array followed
array followed by
by the element
element in brackets
in brackets and
brackets and then
then the element
within the user
this case, balance
balance and transaction
and transaction count
transaction count just
count just as
been stored within
can print that
are printing out
out the balance
and the transaction
transaction count to
count to our
the array, our
our balance is
balance is 95.99
is 95.99 and
95.99 and our
transaction count is
count is 1
stored two pieces
of information inside
information inside our
We can of
course add additional
add additional elements
additional elements to
elements to that
to that user
the things you
do with user
with user defined
defined types is
types is nest
is nest them
we've stored within
within this account
this account user
account user defined
some information about
information about a
about a user
be more than
more than just
than just one
just one thing
first name, the
the last name
last name and
name and possibly
and possibly an
possibly an email
an email address
So rather than
rather than add
than add these
add these elements
these elements to
elements to the
to the account
the account type
account type, we're
create another type
another type purely
type purely for
purely for the
created a user
defined type purely
the user information
user information containing
information containing the
containing the first
and an email
All strings within
strings within user
within user defined
defined types have
types have to
of fixed length
So we set
first name to
name to be
to be 100
be 100 characters
100 characters, the
the surname to
surname to be
characters and the
and the email
the email address
email address to
address to be
having defined the
defined the user
user as its
as its own
its own user
own user defined
can now fold
now fold that
fold that into
that into our
into our account
our account user
defined type by
by simply declaring
simply declaring another
declaring another variable
be a udt
a udt user
do we reference
we reference that
reference that in
in code? We
code? We can
We can simply
can simply extend
simply extend our
extend our data
data to have
array and in
brackets the element
the element we
element we are
we are wanting
are wanting to
wanting to populate
to populate, then
a dot for
dot for strUser
for strUser, then
then another dot
another dot and
the user user
user user defined
defined type, followed
case the first
you have many
have many of
these to populate
to populate, you
With the prefix
prefix command you
command you only
you only need
data in once
in once, as
the element and
element and the
variable we're looking
looking to populate
then the specific
the specific element
specific element being
being the first
last name can
name can then
then be specified
be specified in
specified in a
have a lot
lot of these
to populate, it
saves a good
a good deal
good deal of
these two sets
sets of code
of code lines
code lines are
lines are exactly
the same functionally
to prove we've
prove we've actually
we've actually populated
actually populated this
populated this data
this data, we
can again print
again print it
our log, just
As the information
within this user
type is a
a string, we
code now, we'll
getting the first
and the surname
the surname coming
surname coming out
wish to extend
extend this concept
this concept further
concept further and
further and we
to store an
store an account
an account number
account number for
A logical way
logical way of
doing this would
up a variable
a variable within
variable within the
type called account
called account number
account number, and
if we say
we say make
say make this
this a 8
a 8 character
8 character string
This would work
would work quite
work quite happily
So let's assume
assume for the
the moment that
moment that the
that the account
the account number
account number is
is actually comprised
actually comprised of
comprised of two
of two distinct
two distinct parts
Perhaps the first
two characters are
characters are a
are a department
a department code
department code and
and the remaining
the remaining six
remaining six characters
six characters are
characters are the
are the actual
the actual account
actual account number
account number details
number details itself
left the account
account number as
number as an
as an 8
an 8 character
character string within
string within this
defined type, throughout
throughout the rest
the application, should
determine the department
the department number
department number, the
two characters of
of the account
account number, you
to put additional
put additional code
in to work
to work this
this out all
all the time
This brings us
brings us nicely
us nicely to
nicely to the
to the union
used to actually
to actually split
actually split this
split this information
information into different
into different sections
So let's comment
moment and we're
create a union
a union type
But first we're
first we're going
create another user
be referenced within
referenced within the
within the union
called account split
It comprises of
comprises of a
of a two
a two character
two character department
character department and
and a six
a six character
six character account
gives us our
us our eight
our eight characters
in a union
a union statement?
union statement? Well
statement? Well we're
Well we're going
use a union
a union command
union command followed
command followed by
case we'll just
we'll just call
just call that
call that account
that account number
we're giving this
giving this special
this special union
special union user
union user defined
defined type two
type two elements
One called full
called full account
full account, which
is the full
the full eight
full eight characters
eight characters and
one is str
is str split
using the type
the type we
type we created
we created up
created up here
have two things
two things we
can store information
store information in
There's a full
a full eight
full eight character
eight character one
character one in
one in here
here and there
is also an
also an eight
an eight character
which is subdivided
is subdivided into
subdivided into two
into two characters
two characters and
characters and six
and six characters
all this could
this could have
could have been
have been done
been done in
a standard user
standard user defined
But the beauty
the beauty of
beauty of the
union command is
command is that
that is held
held within here
within here is
here is not
is not only
not only exactly
only exactly the
the same data
same data that
within here, it's
it's actually in
in the exactly
the exactly the
the same memory
same memory location
So any reference
the full account
full account will
account will give
give you eight
you eight characters
to the str
the str split
str split will
split will either
will either give
either give you
give you two
you two characters
two characters or
characters or six
or six characters
six characters, depending
depending on which
on which of
these you specify
But they'll be
they'll be coming
be coming out
coming out exactly
out exactly the
memory location as
location as the
as the data
held within full
within full account
So it gives
you the advantage
advantage of having
of having two
having two ways
ways of getting
of getting at
getting at the
at the information
the information, but
but no additional
no additional overhead
additional overhead for
overhead for storage
having set up
up the union
the union information
union information, we
replace this account
this account number
account number entry
number entry in
in the account
account type with
type with a
new entry, which
which will say
will say that
say that we
store the account
number as a
as a UDT
a UDT account
UDT account number
Referencing the union
have set this
this up, how
can we reference
we reference this
reference this in
code? So we
variable called account
will populate that
that with an
with an eight
eight character value
character value, the
two characters being
characters being the
being the department
six characters being
being the account
populate the element
array using this
using this syntax
this syntax, the
in brackets, then
then the account
account number and
and then SDR
then SDR full
SDR full account
holds the full
full account number
populating our account
our account number
account number into
number into that
into that construct
To prove that's
prove that's actually
that's actually arrived
actually arrived, we
attempt to print
print that value
that value out
is our value
have the eight
the eight character
eight character number
character number coming
number coming out
have not populated
not populated the
populated the part
type which defines
which defines the
defines the department
as the union
the union section
union section, which
which references the
references the department
department is pointing
is pointing at
pointing at the
at the full
account number, we
able to pull
pull that out
that out without
out without doing
doing any additional
any additional coding
By simply referencing
simply referencing the
referencing the STR
STR split as
split as opposed
the STR full
STR full and
full and giving
it the department
department number, which
is the information
the information we're
information we're after
that the department
department number comes
number comes out
comes out quite
quite happily as
happily as the
So to reference
to reference this
reference this one
this one element
one element takes
element takes a
takes a fair
do a shortcut
a shortcut in
shortcut in that
in that and
that and define
and define a
define a local
a local UDT
local UDT to
UDT to hold
hold the account
account number information
we've now defined
now defined a
a user account
user account, user
defined type as
type as our
as our account
account number, user
can populate this
populate this user
type by using
by using this
using this line
and the SDR
the SDR account
SDR account number
now print that
that out using
out using our
using our shortened
our shortened version
shortened version of
to use user
use user account
user account dot
account dot full
dot full account
full account and
account and user
and user account
account dot split
dot split dot
split dot department
code now, you'll
see the information
the information prints
information prints out
prints out just
out just as
just as before
now defined the
defined the department
department and we
information out quite
quite happily, we
can put tests
put tests on
tests on our
on our code
now to test
you have two
have two major
two major departments
major departments in
departments in your
in your organization
your organization and
organization and you
to interrogate that
interrogate that and
that and perform
perform some conditional
some conditional coding
use a solid
a solid case
solid case statement
testing the user
the user account
user account split
account split department
split department, which
which is we've
is we've seen
we've seen should
seen should be
should be a
be a two
two character number
If they give
they give you
give you value
you value 10
value 10, then
can do one
do one piece
gives us something
us something else
something else, we
can do some
do some other
some other piece
So we'll run
we'll run the
has correctly identified
correctly identified that
identified that we
we are in
are in department
in department number
department number 10
is we set
number of user
We then populated
then populated them
populated them with
them with some
with some information
information on account
on account details
account details and
details and user
and user details
We've gone further
gone further and
further and actually
and actually stored
actually stored additional
stored additional account
additional account information
account information in
a union, where
where the union
the union has
union has two
has two ways
of actually extracting
actually extracting the
extracting the data
You can pull
out the full
account number or
number or you
pull out just
out just the
just the department
And since these
since these two
these two elements
two elements are
elements are actually
actually stored in
the exactly same
exactly same area
of memory, updating
updating one will
one will automatically
automatically update the
update the other
you'll find that
find that code
that code useful
at the String
the String Verify
String Verify command
Amongst the many
the many string
many string handling
handling commands that
commands that PowerBasic
that PowerBasic possesses
PowerBasic possesses is
possesses is one
is one called
one called Verify
a String Verify
Verify command and
command and that's
of all, if
going to verify
to verify a
verify a String
a String, we'll
need a String
a String containing
String containing some
containing some data
having populated our
populated our data
variable with a
String of data
of data, we
see what's in
what's in this
this String, to
ensure that all
all the characters
the characters within
characters within this
within this String
this String exist
String exist within
within our mask
create two more
two more local
more local variables
local variables, a
a Result variable
Result variable, which
which will hold
hold a position
a position of
first character that
character that does
that does not
does not match
not match, and
and a Result
a Result String
Result String, which
hold the result
result of our
of our verification
our verification in
verification in text
use our verify
our verify String
verify String command
String command, we're
to embed it
embed it in
in a little
this function verifyDNABases
function verifyDNABases, and
– the data
data variable which
variable which contains
contains the entire
the entire String
entire String, and
a number, which
is a position
first character in
character in our
string that does
not match our
match our matching
our matching String
function returns the
value True, then
then it has
has indeed verified
indeed verified that
verified that our
that our String
our String is
String is correct
it returns False
returns False, then
it has failed
has failed to
failed to verify
the function does
function does not
does not verify
not verify, it
it will contain
contain the words
the words 'Fails
words 'Fails to
'Fails to verify
to verify at
verify at position'
at position', followed
by the 'Character
the 'Character position'
'Character position' for
position' for the
first character which
character which does
the output result
output result variable
we are to
are to verify
to verify the
verify the data
within our data
data variable, we'll
something to match
hold our matched
our matched String
our variable DNABases
variable DNABases, which
contains the letters
letters A, T
is our match
our match String
use the verify
the verify command
verify command to
ensure that every
that every character
every character within
character within our
variable is present
is present in
present in our
in our match
do that on
that on a
of code, using
using the verify
verify command, which
data variable containing
containing the whole
whole String, and
by the match
the match String
As the match
match String contains
String contains a
contains a number
of characters, verify
verify will check
see that every
data String exists
String exists within
exists within our
within our match
value to place
to place it
place it into
into our result
If the result
the result variable
result variable is
variable is 0
are no mismatches
it has found
has found a
found a character
a character in
data String which
String which does
in the match
test on that
that and return
and return either
return either true
will return to
have called our
called our new
new function, we
have to print
the results to
results to our
this by simply
by simply printing
simply printing out
out the result
is a result
The String verifies
can test our
test our function
our function by
function by putting
by putting something
putting something into
something into our
added the letter
the letter 'U'
letter 'U' to
'U' to the
run our program
our program again
again now, we'll
that it fails
it fails to
fails to verify
verify at position
at position 13
So verify can
verify can check
can check a
check a matched
a matched String
matched String against
String against your
against your data
your data String
data String and
String and ensure
and ensure that
every character properly
character properly appears
Verify is also
is also very
also very useful
very useful at
useful at checking
at checking numbers
And verify has
verify has an
an optional third
optional third parameter
third parameter which
to use here
going to specify
specify the starting
the starting character
starting character position
variable called start
start and we've
and we've populated
we've populated it
the value 9
to verify from
verify from the
from the 9th
the 9th character
9th character onwards
if we repopulate
we repopulate our
repopulate our data
So we've populated
we've populated our
the String value
String value equals
value equals, followed
followed by what
by what appears
be a monetary
a monetary value
the verify String
verify String with
this case our
case our first
is the optional
the optional one
the starting parameter
is not given
it assumes it's
assumes it's starting
it's starting at
starting at position
at position 1
And our matched
matched String contains
String contains the
contains the numbers
the numbers between
numbers between 0
0 and So
and So this
this will verify
will verify that
verify that everything
that everything from
everything from the
character onwards is
onwards is actually
since the result
result variable will
contain a 0
a 0 if
0 if the
the number verifies
number verifies, and
than 0 if
the number does
not verify, we
populate our result
it's 0 we
0 we print
print out number
out number verifies
If it's non-zero
it's non-zero we
non-zero we print
And the long
the long result
long result variable
contain the position
the position at
position at which
at which it
if we print
we print that
log and run
the value 123.99
value 123.99 verifies
we change that
that to add
an extra character
extra character to
character to the
the end, run
Because the letter
the letter A
letter A does
A does not
not appear in
in our matched
verify command works
command works on
works on case
on case dependent
case dependent searches
Therefore if your
if your character
your character appears
character appears as
appears as a
as a lowercase
a lowercase A
lowercase A and
A and your
and your match
your match String
String contains an
contains an uppercase
an uppercase A
uppercase A, then
then it will
will not verify
this is worth
worth remembering when
remembering when you're
we were to
were to do
do a case
case dependent verify
dependent verify, and
data string contains
word yes with
yes with the
first character uppercase
character uppercase, if
attempt to verify
to verify that
verify that against
against a match
a match string
match string containing
containing all uppercase
all uppercase letters
uppercase letters, this
this will not
So testing the
value of result
of result, if
0 we can
we can say
can say the
say the character's
the character's yes
character's yes uppercase
yes uppercase were
uppercase were found
we'll say they
say they are
are not found
we'll see yes
see yes was
yes was not
see from these
from these demonstration
these demonstration pieces
demonstration pieces of
that the verify
verify command does
command does have
does have a
a very specific
very specific use
specific use, and
and will save
will save you
of coding in
coding in specific
in specific situations
both the Power
at an API
an API to
API to return
to return weather
return weather data
weather data from
from a website
An Application Programming
Application Programming Interface
Programming Interface or
Interface or API
or API is
API is code
is code that
code that enables
that enables two
enables two software
two software programs
software programs to
programs to communicate
An API defines
API defines how
defines how a
how a developer
a developer should
developer should request
should request services
request services from
services from an
from an operating
an operating system
operating system or
system or other
or other application
use a specific
a specific websites
specific websites API
websites API to
to return data
return data on
on the weather
application we are
create today uses
today uses the
uses the API
the API libraries
API libraries from
libraries from José
These as you
will see can
see can be
can be downloaded
be downloaded from
downloaded from this
from this URL
The website we
website we are
be using today
using today for
today for the
for the weather
the weather data
weather data is
data is the
is the Open
the Open Meteo
Open Meteo website
at that website
This website allows
website allows you
allows you access
access to a
to a great
deal of weather
of weather forecasting
weather forecasting data
And the API
the API is
API is quite
is quite impressive
This documentation screen
documentation screen can
screen can be
used to build
build up the
the URL we
URL we are
using within our
location that we
So having selected
having selected your
selected your location
your location has
location has populated
has populated the
populated the latitude
the latitude and
latitude and longitude
and longitude boxes
We can next
can next set
next set the
set the forecast
the forecast length
forecast length time
The moment I'll
moment I'll set
I'll set it
it for one
for one day
set the hourly
the hourly weather
hourly weather variables
will return information
return information on
on the estimated
the estimated temperature
estimated temperature at
temperature at 2
at 2 meters
2 meters height
meters height on
height on each
on each hour
each hour of
hour of the
the current day
If we skip
we skip past
skip past all
past all the
the other settings
other settings, these
these settings allow
settings allow you
to set whether
set whether you
want the temperature
the temperature in
temperature in Celsius
in Celsius or
Celsius or in
or in Fahrenheit
in Fahrenheit, whether
want the wind
the wind speed
wind speed in
speed in kilometers
in kilometers per
kilometers per hour
per hour or
hour or in
or in meters
in meters per
meters per second
per second or
second or miles
or miles per
miles per hour
And precipitation once
precipitation once we
once we select
we select that
select that will
be done either
done either in
either in millimeters
in millimeters or
millimeters or in
or in inches
from the license
the license usage
license usage, you
use this for
this for non-commercial
for non-commercial use
non-commercial use as
use as long
as you make
you make less
make less than
less than So
than So if
scroll down further
down further we
further we will
find the API
the API response
information that the
that the API
API is going
we just hit
just hit the
hit the reload
the reload chart
reload chart, it
it will report
will report on
on the temperature
the temperature on
temperature on each
you can download
can download this
download this as
CSV file or
file or as
or as an
as an Excel
an Excel spreadsheet
Excel spreadsheet, what
we are principally
are principally interested
in is this
is this line
URL and the
the API details
to plug into
plug into our
into our program
our program to
program to return
to return this
return this inside
this inside the
will copy this
copy this URL
this URL and
URL and we'll
and we'll pop
we'll pop back
a URL we're
URL we're going
going to split
to split the
split the URL
the URL up
URL up into
up into two
into two parts
being the site
the site and
site and the
being the parameters
the parameters for
parameters for the
for the API
to get all
get all this
all this to
two additional libraries
additional libraries to
libraries to our
to our Power
Now that these
that these are
these are added
are added, there
are two constants
two constants I'm
constants I'm going
be using these
using these constants
these constants in
constants in today's
in today's application
is because this
because this particular
this particular web
particular web API
web API does
API does not
does not require
not require authentication
you are actually
are actually adapting
actually adapting this
adapting this program
this program to
program to use
to use other
use other web
other web APIs
web APIs, they
they may indeed
may indeed require
indeed require authentication
So you'll need
you'll need to
of these set
these set credential
set credential constants
that later in
the code when
access this web
this web API
set up four
up four local
first variable is
URL for the
for the website
second is for
string of characters
of characters which
characters which is
our call parameters
call parameters to
to the API
that some error
some error may
error may be
may be generated
Therefore we're creating
creating an error
error variable to
to hold any
hold any error
any error message
of the API
the API we're
API we're going
into a result
actually call this
call this API?
this API? Well
API? Well our
Well our first
up another variable
case this is
is our HTTP
our HTTP variable
setting that up
that up as
up as an
as an I
an I win
I win HTTP
win HTTP request
using a com
a com object
com object here
see from new
from new com
new com this
com this is
an object reference
object reference to
reference to an
an object variable
using this format
Object variable equals
variable equals new
equals new com
new com and
com and then
then a prog
a prog id
So the prog
the prog id
prog id we're
id we're using
we're using in
case is this
HTTP request 5.1
unable to instantiate
to instantiate this
instantiate this particular
particular object then
object then the
then the is
the is nothing
is nothing will
nothing will return
exit immediately because
immediately because we
So to give
us some feedback
some feedback we'll
feedback we'll put
a message out
message out to
our log to
log to say
say that we're
about to connect
set our URL
URL variable to
be the site
the site we're
site we're going
to be querying
set our API
our API variable
API variable to
be the parameters
for a forecast
telling it the
it the latitude
setting it for
it for early
for early temperature
early temperature for
temperature for one
for one forecast
one forecast day
forecast day ahead
have our parameter
our parameter set
parameter set up
set up how
up how do
do we make
to the website
the website API
called get API
get API output
to pass these
pass these variables
these variables over
variables over to
over to it
can see it's
see it's taking
it's taking five
taking five parameters
will have information
have information in
in the result
to output this
output this result
this result to
result to a
will either append
either append to
append to an
an existing file
existing file or
file or if
or if that
not exist it
exist it will
call our output
our output, output
output start dot
start dot text
And should our
should our function
our function fail
function fail then
fail then the
then the error
error variable will
will contain details
contain details of
of the error
will put that
put that out
our log as
log as well
within this error
this error variable
error variable is
is a wide
a wide or
wide or Unicode
or Unicode string
use the Acode$
the Acode$ command
Acode$ command to
to turn it
into a normal
a normal string
normal string which
string which we
can put out
put out to
the get API
API output function
be a generic
a generic function
used for many
for many different
many different websites
taking its five
its five parameters
The object for
object for the
for the HTTP
the HTTP call
HTTP call, the
the API string
API string, the
the error string
error string which
will be output
be output and
output and the
and the result
is also output
also output as
output as a
local variables within
attempt to attach
to the Web
the Web API
Web API and
API and pull
do this within
this within a
do an open
an open on
open on our
on our object
our object to
object to get
Although this particular
not require the
require the setting
the setting or
setting or use
or use of
use of credentials
code you would
would need to
to use should
use should there
there be credentials
Either credentials for
credentials for the
for the server
the server or
server or credentials
or credentials for
for the proxy
the proxy depending
proxy depending on
on the Web
the Web site
Web site API
site API you
API you are
you are connecting
are connecting to
case we don't
we don't require
don't require these
require these so
these so I've
so I've commented
I've commented them
commented them out
use the send
the send command
to send our
send our data
our data off
data off to
off to the
Having send the
the data off
Web site we
site we now
need to wait
wait for response
for response from
response from that
from that Web
that Web site
calling the wait
the wait for
for response for
response for the
get a response
a response we
response we need
to actually turn
actually turn this
turn this into
this into something
into something we
something we can
Here we're populating
populating the VStream
the VStream variable
VStream variable taking
variable taking the
taking the response
the response stream
response stream from
stream from our
from our object
is a variant
a variant we're
variant we're testing
testing the variant
the variant type
If it's equal
it's equal to
equal to VTE
to VTE unknown
VTE unknown then
unknown then we
that far we
pick up basically
up basically the
basically the buffer
from the Web
then using CB
using CB size
CB size to
size to return
characters in our
in our response
number is used
is used via
used via the
via the space
populate the STR
the STR buffer
STR buffer with
buffer with that
with that number
So our STR
our STR buffer
STR buffer will
buffer will now
now be big
big enough to
enough to hold
has come back
use the read
the read command
read command to
populate the buffer
the buffer with
with that data
that data or
data or that
or that length
pointer to point
to point at
point at the
location and memory
and memory in
memory in which
which our buffer
our buffer actually
buffer actually sits
We're then doing
then doing a
that our buffer
our buffer contains
buffer contains just
contains just the
just the information
we need with
need with no
with no blanks
no blanks on
blanks on the
Using the left
far we can
can then make
then make the
make the PI
the PI stream
PI stream equal
stream equal to
equal to nothing
This frees up
frees up the
up the memory
used by that
have data within
within the buffer
If the buffer
the buffer is
buffer is greater
have some information
some information returned
always possible we
possible we got
we got no
got no information
no information at
information at all
test the length
length of that
of that buffer
that buffer to
buffer to ensure
to ensure it's
ensure it's greater
If the length
of the buffer
than zero we
zero we can
populate the result
as we're doing
block we need
handle any errors
errors that come
that come up
case we're populating
we're populating error
The getOleErrorInfo Passing
getOleErrorInfo Passing it
it the object
the object result
is this new
be calling another
calling another API
OleGetErrorInfo to return
string which contains
which contains our
contains our data
our data for
for the error
can now compile
now compile the
the application quite
application quite successfully
to actually call
call this weather
this weather API
weather API and
API and return
and return some
return some data
some data and
data and create
create it within
it within a
within a text
Well it tells
data has returned
let's look in
in our folder
our folder to
folder to see
the output dot
output dot text
our output dot
is one exceedingly
one exceedingly long
exceedingly long line
However it's not
it's not very
not very readable
very readable from
readable from a
from a user
a user point
user point of
need to parse
to parse it
parse it to
it a little
more readable for
readable for human
for human eyes
call another new
function called parseJSON
This will parse
will parse this
parse this JSON
this JSON string
JSON string into
string into something
into something that
that is a
little more human
more human readable
will add that
that to our
So I've added
I've added this
added this parseJSON
this parseJSON function
parseJSON function to
function to the
I'll leave you
leave you at
you at your
at your leisure
your leisure to
leisure to look
look through how
through how this
how this function
this function actually
function actually performs
But it's basically
it's basically using
basically using the
the string builder
string builder class
builder class within
class within PowerBasic
within PowerBasic to
PowerBasic to build
up a string
a string from
string from individual
from individual characters
it's going through
going through all
characters within our
within our JSON
our JSON string
JSON string and
string and making
and making that
making that a
that a little
human readable by
readable by adding
by adding carriage
adding carriage return
- line feeds
line feeds at
feeds at the
end of significant
of significant points
It runs, gives
data and lets
and lets have
lets have a
a look now
have the original
the original string
original string in
one line and
line and our
our new parsed
new parsed string
parsed string is
string is much
is much easier
telling us first
us first of
all the input
the input we
input we gave
we gave it
and longitude, the
the time zone
time zone, the
the elevation, the
the early units
early units and
units and the
and the temperature
the temperature, which
we have interested
have interested in
return the temperature
is our Hourly
our Hourly data
data we're specifically
us two lines
of data, one
being the time
the time, the
the time of
time of day
of day in
day in 24
in 24 hour
24 hour clock
see that is
that is midnight
one is one
is one o'clock
one o'clock in
o'clock in the
in the morning
the morning and
morning and so
is our temperature
So the 10.9
the 10.9 is
10.9 is the
is the temperature
in Celsius at
Celsius at midnight
at midnight on
midnight on the
on the It
the It remained
It remained the
remained the same
the same at
same at one
at one in
morning and at
and at two
at two in
two in the
the morning it
morning it dropped
it dropped down
dropped down to
down to 10.7
have successfully returned
successfully returned data
returned data from
we've actually parsed
actually parsed that
parsed that information
that information into
into a more
a more human
human readable format
readable format, it's
it's also easier
also easier to
to read within
read within your
string we have
have is a
is a number
number of lines
of lines delimited
lines delimited by
by a carriage
can be stepped
be stepped through
stepped through in
through in your
in a simple
for the two
the two key
two key pieces
of information you're
information you're looking
So what if
what if we're
if we're after
we're after more
after more than
than just temperature?
just temperature? What
temperature? What if
we want rainfall
want rainfall as
rainfall as well?
as well? Well
well? Well, let's
the website and
website and see
do to get
we have currently
have currently ticked
currently ticked for
ticked for temperature
look for rain
then we scroll
scroll back down
back down again
It recognizes we've
recognizes we've changed
we've changed the
changed the parameters
the parameters and
parameters and need
and need to
need to reload
reload the chart
Now it's showing
it's showing you
showing you the
you the rain
the rain in
rain in the
in the chart
the chart so
chart so we
up the API
the API and
API and we
is our amended
our amended API
amended API string
picking up temperature
up temperature and
temperature and rainfall
have another row
another row of
row of data
We have rain
have rain and
rain and it's
us the amount
amount of rain
of rain in
rain in this
this case in
case in millimeters
in millimeters for
millimeters for each
for each hour
of the day
from this weather
weather API is
API is easily
is easily interpreted
And should you
amend the API
the API you
API you merely
to go onto
go onto the
onto the website
website and tick
tick the types
of information you
information you are
you are interested
can then amend
then amend your
amend your application
your application to
application to pick
up the key
the key pieces
information you're interested
you're interested in
is we've created
application that can
used to query
to query a
query a website
a website via
website via its
via its API
its API and
pull information back
This particular website
particular website is
website is very
in that it
that it generates
it generates the
generates the API
the API call
API call for
call for you
And therefore makes
therefore makes it
easy to select
select the types
information you're specifically
you're specifically interested
specifically interested in
look to actually
to actually chart
actually chart this
chart this information
this information within
again at an
application which used
which used an
used an API
API to connect
connect to a
a website to
website to obtain
to obtain weather
obtain weather forecast
weather forecast information
is the website
website we had
we had connected
had connected to
you to pick
a location and
location and also
also to select
select the type
type of weather
of weather that
weather that interests
that interests you
a forecast for
forecast for one
We had picked
had picked the
picked the temperature
the temperature and
temperature and the
and the rainfall
down the webpage
the webpage, this
display a chart
a chart of
chart of those
those two pieces
so happens today
happens today in
today in the
in the selection
the selection I've
selection I've picked
I've picked, there
is no rainfall
But additionally, this
this website gives
website gives you
you the API
the API as
API as a
can then paste
then paste this
paste this into
into our PowerBasic
our PowerBasic program
PowerBasic program and
program and pull
information off programmatically
So what our
what our existing
our existing application
existing application does
application does is
is it allows
it allows you
you to connect
connect to this
to this website
particular website has
website has no
has no authentication
no authentication, so
so it's quite
easy to connect
Having connected to
connected to the
with the API
API details, we
back the results
the results set
API Output that
Output that pulls
that pulls this
pulls this information
information back, stores
in a results
a results string
results string, and
an additional function
additional function that
function that parses
that parses this
parses this JSON
this JSON information
JSON information into
a more human-readable
more human-readable format
This format gives
format gives you
you a number
of data, and
the string is
is the time
the time, temperature
and rainfall information
The time is
time is in
is in one
in one hour
one hour time
hour time slots
time slots, and
you have the
have the temperature
the rainfall in
rainfall in each
of these time
these time slots
take this data
data and we're
to display it
display it on
it on a
on a small
a small window
small window, allowing
you to keep
keep this running
this running in
running in the
background and to
and to pull
information back periodically
back periodically from
periodically from the
from the website
of this website
this website has
website has a
has a couple
couple of limitations
be for non-commercial
non-commercial use only
use only, and
and you cannot
you cannot make
cannot make any
make any more
more than 10,000
than 10,000 API
10,000 API calls
API calls a
calls a day
you were querying
were querying the
querying the website
the website once
website once every
once every 60
every 60 seconds
60 seconds, you
you would only
would only make
only make about
make about 1,440
about 1,440 calls
1,440 calls to
calls to it
to it per
it per day
what I intend
intend to do
application up to
up to query
to query for
query for information
for information every
information every 15
every 15 minutes
15 minutes, and
and I'm specifically
I'm specifically looking
for the forecast
the forecast for
forecast for the
the next hour
Having received this
received this information
this information from
the website, we're
display a small
a small icon
small icon and
and a couple
couple of key
do that, there
couple more pieces
change the settings
the settings from
settings from Rain
from Rain to
Rain to Precipitation
to Precipitation, which
is the sum
the sum of
sum of rain
of rain, showers
showers and snow
We're also looking
also looking for
for the Cloud
the Cloud Cover
tell us whether
us whether it
it is overcast
is overcast or
overcast or sunny
want to capture
capture the Precipitation
the Precipitation Probability
us how likely
how likely it
is to actually
to actually rain
have a high
a high probability
high probability of
probability of rain
of rain, and
and a value
value for precipitation
for precipitation, and
and a high
a high cloud
high cloud cover
cloud cover, it's
it's more than
more than likely
than likely to
likely to rain
if we reload
we reload the
the chart, and
and we capture
we capture the
capture the URL
And we'll paste
we'll paste that
paste that into
And I'll comment
I'll comment out
out the two
the two previous
two previous APIs
we're now capturing
now capturing the
capturing the temperature
the temperature, the
precipitation probability, the
the precipitation, the
a forecast of
forecast of a
a single day
there's a few
a few changes
few changes we'll
we're running in
But this application
this application should
application should be
to run quite
run quite halfway
quite halfway in
halfway in the
in the Windows
don't want a
want a console
a console to
console to appear
to appear, we're
change the beginning
the program to
program to test
if we're in
And when it
when it compiles
it compiles, we
will set it
set it not
it not to
display a console
the very beginning
very beginning of
the code, by
by testing for
for the definition
of this constant
If this constant
this constant has
constant has been
has been defined
been defined, then
we are running
are running in
the Console Off
Console Off command
Off command to
do a Console
a Console Compilation
Console Compilation where
Compilation where there
where there will
be no console
up another constant
constant called Production
this constant is
constant is defined
is defined, then
know we are
running in Production
in Production Mode
want to minimise
to minimise all
minimise all information
all information going
information going out
going out to
out to keep
keep it just
it just in
just in a
single graphics window
test that before
that before we
run the Prep
the Prep Output
Prep Output and
Output and Fun
and Fun Log
Fun Log functions
So only if
only if it
is not production
not production will
production will we
will we actually
we actually use
use the Prep
Prep Output function
Output function or
function or the
or the Log
the Log function
we will repeat
will repeat that
repeat that through
that through the
no longer write
longer write to
write to our
to our OutputStar.txt
our OutputStar.txt file
OutputStar.txt file, as
information will be
will be inside
once the information
Result variable, we're
be one to
one to update
new function shortly
As we intend
we intend to
intend to run
this application continually
application continually, we
will only want
want to query
to query the
query the website
the website periodically
this video, I'm
I'm only going
going to query
have to run
to run in
run in a
back to function
to function this
function this loop
this loop shortly
graphics window and
window and a
and a loop
a loop counter
loop counter for
times we have
we have run
have run round
round the loop
we actually make
actually make the
make the API
API call, we
create a graphics
a graphics window
graphics window which
window which is
contain our output
the value which
new function now
As graphics windows
graphics windows can
windows can be
be created either
created either by
either by the
by the PowerBasic
console compiler or
compiler or the
or the PowerBasic
Windows compiler, this
an ideal construct
ideal construct to
construct to allow
you to compile
to compile your
compile your application
your application under
application under either
under either compiler
of all use
all use the
graphics window command
new graphics window
That's the top
to be 300
be 300 units
300 units wide
units wide and
wide and 200
and 200 units
200 units high
from this call
this call is
populate the 'win'
the 'win' variable
need this later
this later so
later so that
that when it
it comes time
comes time to
time to closing
to closing the
closing the window
the window down
window down, we
can actually detect
actually detect that
detect that it
has indeed closed
be a window
a window which
window which we
we want always
want always to
always to be
be on top
top of all
of all other
all other windows
other windows, we
way of marking
of marking it
it as such
API calls called
calls called 'setWindowPosition'
taking a number
of parameters, is
make it topmost
it topmost, using
using the hwind
the hwind topmost
hwind topmost constant
can now attach
now attach our
attach our graphics
And we've set
this one using
one using the
the redraw function
redraw function, which
which means messages
means messages sent
messages sent to
graphics window will
window will not
not be displayed
be displayed until
displayed until the
until the graphic
redraw command is
command is given
new font, so
can actually write
actually write in
write in large
in large characters
large characters to
characters to our
our new graphics
variable called 'dwFont'
create this as
a global at
global at the
set font specifies
font specifies the
specifies the font
the current graphics
current graphics window
are then clearing
clearing the graphics
window and setting
setting the background
a light grey
light grey colour
Then executing the
executing the graphics
redraw command, to
the function passes
function passes back
passes back the
the window it
window it has
it has just
has just created
application and create
create the font
the font variable
have declared it
declared it at
pb_main function, so
create a loop
loop to call
call our API
our API website
graphics window, this
to start our
start our loop
our loop counter
loop counter to
counter to a
many times we've
times we've been
we've been around
been around the
want to continue
to continue this
continue this loop
this loop until
loop until our
until our graphics
window is closed
We can detect
can detect its
detect its closure
its closure by
closure by using
using the 'isWindows'
the 'isWindows' API
'isWindows' API call
then the window
the window has
window has been
test our loop
If it gets
the value 20
value 20, then
we will again
will again reset
again reset it
reset it to
testing that loop
that loop counter
loop counter, and
is zero, we're
run the 'get
the 'get API
'get API output'
API output' function
So the 'get
output' function is
function is now
is now conditional
now conditional on
of our loop
after we've made
we've made that
made that call
that call, we
can then advance
then advance the
advance the loop
the loop counter
loop counter by
counter by using
using the 'increment'
the 'increment' command
'increment' command to
going to sleep
to sleep for
sleep for three
for three seconds
us to test
graphics window closing
window closing every
closing every three
every three seconds
we're going around
going around this
around this loop
this loop 20
loop 20 times
20 times, 20
20 times, three
three seconds gives
seconds gives us
us the full
the full 60
full 60 seconds
if the graphics
is closed, then
need the 'wait'
the 'wait' command
'wait' command at
the end, as
as our application
application will stay
will stay in
stay in the
in the loop
the loop until
user closes the
closes the graphics
create the 'updateGraphicsWindow'
the 'updateGraphicsWindow' function
that will actually
will actually take
actually take the
information and display
of our 'updateGraphicsWindow'
our 'updateGraphicsWindow' function
'updateGraphicsWindow' function, which
which takes its
takes its single
is the result
the result that
result that has
come back from
from the API
the API website
bit of work
of work to
work to get
this information onto
information onto our
graphics window, we've
we've had to
a few local
few local variables
the current time
are specifically interested
in the hour
use the 'time$'
the 'time$' command
'time$' command, which
Power Basic, to
return that time
up the date
use the 'date$'
the 'date$' command
'date$' command for
going to convert
to convert the
convert the date
the date into
date into year-month-day
into year-month-day format
variable called 'currentTimeSlot'
called 'currentTimeSlot', which
is basically going
be the reverse
the reverse date
reverse date, the
the letter 't'
letter 't', and
and the hour
need the date
the date time
time information in
information in this
in this format
this format, as
as that's the
that's the format
the format is
format is held
held in in
the result coming
in year, month
then the hour
the hour in
hour in 24-hour
in 24-hour clock
this result set
result set, I'm
this function 'readData'
first thing I
pull back is
back is the
is the entry
the entry it
entry it has
it has for
has for temperature
Is it in
it in Celsius
Celsius or is
it in Fahrenheit?
in Fahrenheit? So
Fahrenheit? So we're
that function 'readData'
will take as
take as its
parameter the result
the result set
result set variable
set variable containing
variable containing all
And we're specifically
for a double
a double quote
double quote, the
the word 'temperature'
word 'temperature' underline
'temperature' underline '2m'
underline '2m', and
and a closing
a closing double
closing double quote
give us all
us all of
of this line
using the 'middollar'
the 'middollar' command
'middollar' command to
back the fifth
fifth character for
character for two
for two characters
two characters, which
which will bring
will bring back
back the degrees
the degrees Celsius
degrees Celsius or
Celsius or degrees
or degrees Fahrenheit
degrees Fahrenheit symbol
create this common
this common function
common function, as
to make good
make good use
our new readData
new readData function
readData function taking
two parameters in
The resultData and
resultData and the
and the criteria
the criteria which
criteria which we're
which we're looking
here to look
through each part
each part of
know the data
data is one
is one long
long string delimited
string delimited by
by the carriage
next loop using
parse count to
count to work
of elements we're
elements we're looking
on the specific
the specific line
if this information
this information matches
information matches the
matches the criteria
the criteria we're
criteria we're looking
doing an if
an if on
if on left$
This is pulling
is pulling back
back the specific
the specific piece
specific piece of
information to see
matches our criteria
it finds a
finds a match
a match, then
then the function
will then exit
should be generic
be generic enough
generic enough to
enough to pull
pull back all
back all the
information we're interested
worked out whether
out whether we're
whether we're using
we're using Fahrenheit
using Fahrenheit or
Fahrenheit or Celcius
or Celcius, let's
let's now set
now set up
up the graphics
the graphics color
graphics color to
color to set
background colors for
colors for our
to clear any
clear any information
any information currently
information currently in
at is to
at the time
the time slots
time slots data
slots data is
data is this
be working out
out which time
which time slot
time slot we're
slot we're actually
have a common
function to read
data from our
from our results
our results set
results set, this
it very much
very much easier
So that whole
that whole data
whole data line
data line can
line can be
can be returned
be returned by
returned by a
call to read
to read data
read data looking
data looking specifically
for the time
the time line
With double quotes
double quotes on
quotes on either
on either side
either side, a
a semicolon and
semicolon and a
and a square
populating the value
current time slot
is a column
a column number
column number within
the string time
string time slots
We're obtaining that
obtaining that by
is another library
another library function
library function within
handling library, which
which takes three
string of all
and the common
the common time
common time slot
case is given
is given as
given as an
As the parse
parse command, which
within the parse
find function, uses
uses the empty
the empty length
length string as
string as special
as special handling
special handling for
handling for comma
for comma delimited
time is 11.15
is 11.15, we'll
for the slot
the slot that
slot that contains
that contains 11.00
going to advance
advance it to
As if we
in the 11th
the 11th hour
11th hour of
the day, we're
interested in what's
in what's happening
what's happening an
happening an hour
an hour from
hour from now
use the increment
increment command to
command to advance
to advance the
advance the time
the time slot
time slot by
slot by one
And we'll then
we'll then print
then print something
print something out
something out to
graphics window, which
send that text
that text out
let's test the
test the application
whether the 'in
the 'in the
'in the next
the next hour'
next hour' piece
hour' piece of
of text appears
text appears on
appears on our
close the graphics
graphics window, the
piece of data
of data I
data I want
screen is the
the read data
read data command
data command again
to pull information
from our result
our result set
result set, and
So the temperature
the temperature data
temperature data variable
is populated using
populated using read
using read data
with our slot
our slot number
slot number to
number to pull
the information specific
information specific to
to the time
slot we're interested
next hour, the
the temperature is
temperature is going
to be 6.0
be 6.0 degrees
6.0 degrees Celsius
So far, so
application and get
get the rest
data we're interested
So next I'm
back the probability
the probability of
probability of precipitation
of precipitation using
precipitation using exactly
the same method
running this and
this and printing
and printing this
printing this out
So the precipitation
precipitation probability is
probability is currently
is currently 3%
currently 3%, so
so it looks
it looks as
looks as though
as though any
though any kind
any kind of
kind of rain
of rain is
rain is unlikely
is unlikely at
unlikely at this
at this moment
this moment in
moment in time
determine the cloud
So again, the
have the precipitation
precipitation probability and
probability and the
and the cloud
cloud cover, we
can now decide
now decide on
decide on which
on which icon
which icon to
going to break
to break out
break out the
out the logic
logic that determines
that determines which
determines which icon
icon to show
show to a
separate function, which
we'll call Decide
call Decide icon
be passed two
passed two pieces
cloud cover and
cover and the
and the precipitation
use these two
these two pieces
information to determine
determine which icon
to show on
show on our
There are, of
of course, a
of actually determining
actually determining which
determining which icon
icon to use
If the percentage
the percentage cloud
percentage cloud cover
cloud cover is
cover is very
is very low
very low and
low and the
and the probability
of precipitation is
precipitation is very
very low, then
then it's likely
be a sunny
a sunny day
sunny day, so
display an icon
an icon that
icon that indicates
that indicates sunshine
if the opposite
the opposite is
opposite is true
is true, if
is very high
very high and
high and the
probability is very
very high, then
then it's very
it's very likely
to be heavy
be heavy rain
there is, of
a spectrum in
spectrum in between
going to approach
to approach this
approach this in
a fairly simplistic
fairly simplistic manner
simplistic manner by
manner by using
using a two-dimensional
value of cloud
of cloud cover
cloud cover as
cover as either
as either low
either low, medium
medium or high
with the precipitation
gives us an
way of determining
of determining which
determining which is
is the cloud
second element is
is the probability
if the cloud
cover is low
is low, then
at a sunny
sunny day if
day if the
if the rain
the rain probability
rain probability is
probability is also
is also low
So I've picked
I've picked out
picked out three
out three different
three different icons
different icons which
icons which we
to create shortly
create shortly, and
and I will
I will also
will also create
also create icons
create icons for
icons for the
the other probabilities
created this array
this array, we
couple of select
of select case
select case statements
case statements to
statements to work
out the likelihood
the likelihood of
likelihood of cloud
of cloud or
cloud or rain
And while this
while this approach
this approach is
approach is not
is not absolutely
not absolutely perfect
absolutely perfect, it
idea of how
of how you
you can approach
can approach these
approach these things
testing the cloud
cover is between
is between 0
0 and 49
and 49, then
we consider the
consider the cloud
cloud cover to
cover to be
to be low
be low, and
we're giving that
giving that a
that a value
values of 50
of 50 and
50 and 75
and 75, we're
we're considering that
considering that to
to be medium
be medium and
medium and giving
and giving that
value of 2
greater than 75
than 75, we're
we're seeing it's
seeing it's a
value of 3
will do the
do the exact
the exact same
exact same for
for the precipitation
And to return
contains the icon
the icon name
icon name, we
can then just
then just use
just use our
use our array
our array, using
the two elements
two elements for
elements for cloud
for cloud and
cloud and rain
and rain probability
create the icons
the icons themselves
I've used the
used the third-party
the third-party iconfx
third-party iconfx application
iconfx application to
application to create
to create icons
create icons before
icons before, and
here we're just
we're just creating
just creating a
creating a few
a few icons
few icons to
icons to be
to the video
the video where
video where I
where I actually
I actually covered
actually covered how
covered how to
to use iconfx
we've created some
created some icons
some icons in
icons in our
our folder, we
more code into
application to access
to access them
in the Update
the Update Graphics
Update Graphics window
window is where
So I'm setting
Y coordinates for
for our graphic
our graphic to
graphic to be
to be 5
be 5 and
5 and 90
setting the icon
the icon size
icon size as
size as 64
graphics render command
render command to
command to quite
quite easily position
easily position our
our graphic onto
setting the top
top left-hand corner
left-hand corner of
the icon, and
the icon as
icon as well
not actually pulling
actually pulling these
pulling these graphics
these graphics from
graphics from inside
from inside a
inside a resource
a resource in
resource in the
We're pulling them
pulling them from
from the folder
were to make
this a full
a full project
full project, I
I would more
would more than
than likely embed
likely embed the
embed the graphics
the graphics within
graphics within the
application itself in
itself in a
in a resource
a resource file
our display on
have some cloud
some cloud cover
cloud cover, but
have no rain
window will remain
will remain on
remain on top
on top, regardless
how many other
many other windows
other windows you
windows you actually
you actually open
actually open underneath
open underneath it
And this little
this little Graphics
little Graphics window
Graphics window can
window can quite
quite happily sit
happily sit in
sit in the
in the corner
the corner of
corner of one
of your monitors
it queries the
queries the API
API website once
But if you're
if you're wanting
you're wanting to
wanting to change
this to every
to every 15
15 minutes, it's
it's a minor
loop counter is
counter is set
is set at
set at 20
gives you every
you every 60
make this number
this number larger
did that, then
then we're now
have a query
a query every
query every 15
It will sit
will sit there
sit there quite
there quite happily
quite happily for
happily for 15
for 15 minutes
of the 15
the 15 minutes
15 minutes, it
it will re-query
will re-query the
re-query the website
website and update
update the information
has a very
a very rich
very rich API
pull back a
back a lot
lot of useful
of useful weather
useful weather information
weather information from
information from its
from its website
done today, we've
we've taken the
taken the existing
the existing application
existing application, which
which was querying
was querying a
querying a website
a website, to
to provide weather
provide weather information
weather information via
information via an
via an API
We've taken that
taken that and
that and we've
and we've compressed
we've compressed the
compressed the information
the information down
information down into
down into a
into a small
small graphics window
This can run
can run continually
run continually on
continually on your
your computer, periodically
periodically querying the
the website for
website for information
for information and
information and displaying
and displaying it
displaying it on
[Music] In today's
In today's channel
today's channel update
channel update, I'm
cover the two
the two places
two places you
places you can
you can get
can get both
get both information
both information on
information on and
on and view
view the videos
the videos uploaded
videos uploaded to
uploaded to the
to the channel
The videos are
videos are grouped
are grouped into
grouped into playlists
into playlists to
playlists to allow
to easily find
easily find videos
find videos that
videos that are
that are of
are of interest
of interest to
interest to you
you and were
and were uploaded
were uploaded before
uploaded before you
before you subscribed
you subscribed to
subscribed to the
The thumbnail for
thumbnail for these
for these videos
these videos gives
videos gives an
gives an indication
an indication on
indication on the
type of content
of content in
content in the
the video itself
Introduction videos cover
videos cover the
cover the basics
basics of programming
programming and concepts
and concepts in
concepts in PowerBasic
in PowerBasic and
PowerBasic and assume
and assume no
assume no knowledge
no knowledge of
knowledge of programming
These either have
either have no
no code or
code or just
or just limited
just limited amounts
limited amounts of
amounts of code
code to illustrate
illustrate the topic
General computer topics
computer topics videos
topics videos cover
videos cover computer
cover computer topics
computer topics beyond
topics beyond just
beyond just PowerBasic
For example, third-party
third-party products and
products and concepts
and concepts associated
concepts associated with
associated with general
with general programming
Library videos cover
cover the creation
the creation and
creation and use
and use of
use of libraries
of libraries within
libraries within PowerBasic
within PowerBasic itself
from these thumbnails
these thumbnails, they
they have either
have either both
either both the
Compiler and Console
and Console Compiler
Console Compiler Logos
Compiler Logos if
Logos if the
if the topic
the topic is
topic is relevant
is relevant to
relevant to both
to both or
both or just
or just the
just the type
type of compiler
of compiler that
compiler that the
that the video
the video covers
The snippet videos
snippet videos tend
videos tend to
tend to be
be 20 minutes
20 minutes or
minutes or less
or less in
less in duration
PowerBasic design videos
design videos cover
videos cover full
cover full projects
full projects in
projects in more
they can exceed
can exceed more
exceed more than
more than 20
than 20 minutes
20 minutes each
minutes each and
each and may
and may be
may be constructed
be constructed in
constructed in several
in several parts
Third-party add-ons videos
add-ons videos cover
cover the products
the products, some
some free and
free and some
and some licensed
some licensed, that
that can add
functionality of PowerBasic
of PowerBasic applications
PowerBasic applications and
applications and allow
allow you as
developer to create
to create better
create better applications
to the videos
the videos hosted
videos hosted on
hosted on YouTube
on YouTube, there
is a searchable
a searchable index
searchable index of
index of these
of these videos
these videos on
videos on the
on the GSF
When entering the
entering the website
the website, you're
you're presented with
list of recently
of recently added
recently added videos
column in this
in this list
this list holds
list holds a
holds a thumbnail
a thumbnail to
thumbnail to indicate
indicate the type
type of video
it has both
has both the
and Windows Compiler
Windows Compiler logos
Compiler logos, then
the code covered
code covered in
the video is
video is applicable
is applicable to
applicable to both
to both compilers
This index covers
index covers both
covers both of
both of our
of our YouTube
our YouTube channels
YouTube channels, the
the PowerBasic for
PowerBasic for Beginners
for Beginners and
Beginners and the
and the custom
the custom PC
custom PC hardware
PC hardware channels
When you enter
you enter the
enter the website
the website, you
you will first
will first be
first be taken
be taken to
taken to the
to the recently
the recently added
recently added page
you a view
a view of
view of all
all the videos
the videos that
videos that have
have been added
been added in
added in the
the last gives
last gives you
you an image
an image to
image to indicate
indicate the topic
topic of the
it a video
a video for
video for both
and Windows compilers?
Windows compilers? Just
compilers? Just for
Windows compiler or
compiler or is
is it one
it one for
for the hardware
the hardware videos?
hardware videos? This
videos? This is
by the subject
the subject and
subject and the
the date on
date on which
on which the
which the video
video was published
was published, a
a short description
short description and
description and a
and a series
series of keywords
We've not changed
not changed the
changed the format
the format of
format of the
the page you're
page you're looking
you're looking at
looking at at
at at the
is to extend
to extend the
extend the keywords
the keywords facility
on the keyword
the keyword, you
you will be
will be taken
that have that
have that keyword
This has all
all the usual
the usual links
usual links, like
like the link
to the YouTube
the YouTube video
YouTube video itself
video itself, the
link to GitHub
to GitHub, the
the video, a
a facility that
facility that allow
that allow you
you to download
to download a
download a zip
a zip file
zip file should
file should one
should one be
one be available
be available of
available of all
all the source
source code and
code and an
and an additional
icon that lets
that lets you
lets you view
you view the
view the primary
the primary source
primary source of
source of the
This opens in
opens in a
a separate tab
separate tab on
tab on your
on your browser
the page, we
number of tabbed
of tabbed headings
tabbed headings to
headings to allow
you to go
the specific videos
specific videos for
videos for that
for that subject
that subject, for
for example third-party
example third-party add-ons
The major change
major change we've
change we've made
we've made is
made is on
on the Buy
the Buy Keyword
Buy Keyword tab
This now gives
now gives you
you a list
all the keywords
the keywords themselves
keywords themselves which
themselves which you
you can search
can search out
search out from
from the page
page and clicking
and clicking on
clicking on any
of those links
those links will
links will take
will take you
take you to
you to a
to a page
a page that
page that lists
that lists all
lists all the
have that as
as a keyword
easier to find
to find videos
find videos which
videos which are
which are similar
are similar or
similar or on
or on the
the same topic
same topic as
topic as the
as the one
the one you
one you have
you have just
find these changes
these changes to
the website useful
website useful in
useful in finding
in finding videos
finding videos you
videos you may
may be interested
be interested in
interested in but
in but that's
Welcome to the
Basic for Beginners
for Beginners YouTube
Beginners YouTube channel
This channel was
channel was created
provide a series
series of informative
of informative tutorials
informative tutorials for
tutorials for both
allow those new
new to the
to the language
the language a
language a view
view of just
of just what
just what can
be done using
done using Power
using Power Basic
Today we're covering
we're covering a
covering a small
a small update
small update to
update to the
to the GSF
This website is
website is intended
is intended as
intended as an
as an easy
an easy to
to use index
use index for
index for the
the two YouTube
two YouTube channels
YouTube channels that
channels that we
that we run
URL for this
for this website
this website can
website can be
the description of
description of all
all the YouTube
the YouTube videos
well as displaying
as displaying on
displaying on this
on this initial
this initial page
initial page all
page all the
have been released
been released in
released in the
the last month
last month, there's
there's one addition
one addition we've
addition we've made
we've made to
made to it
to it today
Currently you can
you can look
the source view
source view for
view for any
of the applications
the applications covered
applications covered in
for that project
in our projects
our projects there
projects there are
are many library
many library videos
library videos which
which are utilised
These are included
are included at
included at the
And there's nothing
there's nothing currently
nothing currently on
currently on screen
screen that would
that would have
would have shown
have shown you
shown you what
you what that
what that code
that code actually
code actually is
a new menu
new menu option
menu option at
option at the
the screen called
screen called Library
called Library Files
This gives a
gives a list
all the libraries
libraries that are
that are currently
currently in use
at our result
our result before
result before, we
that this application
application is using
using a library
a library called
library called pb_file_handling_routines
We can view
can view that
view that library
that library now
library now by
now by going
by going to
the Library Files
Library Files page
Files page, scrolling
scrolling down and
down and finding
and finding the
finding the library
the library file
is our file
a source file
source file for
file for this
for this as
on that, we
are now viewing
now viewing the
viewing the source
this particular library
separate tab in
tab in your
in your browser
your browser from
browser from the
the original code
original code, so
you can jump
can jump back
jump back and
and forward between
forward between the
the two to
two to see
see what's within
what's within the
the library functions
library functions called
functions called from
called from the
As we add
we add new
add new libraries
new libraries to
our code base
code base, these
these will automatically
will automatically be
automatically be added
to this indexed
this indexed website
to find your
find your way
your way around
way around the
around the code
Welcome to an
to an update
an update for
update for the
We have recently
have recently gained
recently gained a
gained a few
few new subscribers
new subscribers to
subscribers to the
the channel and
channel and as
and as it's
as it's some
it's some time
time since our
since our last
our last update
last update then
update then this
then this short
short video should
video should provide
should provide some
provide some useful
some useful information
useful information to
information to assist
to assist you
you in getting
in getting the
getting the most
the most from
most from the
from the channel
we're now on
on the Power
There are currently
are currently 426
currently 426 videos
426 videos on
on this channel
this channel, covering
covering many topics
many topics on
topics on both
on both the
Basic Windows and
Windows and Console
and Console Compilers
on the More
the More section
More section here
section here, we
see that source
that source files
source files for
files for these
these projects are
projects are available
are available on
available on an
on an external
an external website
external website, this
one here, the
to that link
that link, it
us to this
to this page
This site is
site is in
in fact an
fact an index
an index to
index to the
the YouTube channel
YouTube channel, indexing
indexing all the
the videos which
on the channel
On the Recently
Added page we
all the recent
the recent videos
recent videos that
can see, each
each video is
video is listed
is listed separately
have a compiler
a compiler or
compiler or topic
or topic, which
to show what
show what type
what type of
of video it
video it is
it is, in
case a podcast
a podcast and
podcast and the
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
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
the Windows Compilers
Windows Compilers are
Compilers are shown
are shown again
shown again with
a different icon
from the obvious
the obvious details
obvious details of
of the subject
the subject of
subject of the
the video and
video and the
which it was
it was uploaded
was uploaded to
uploaded to YouTube
to YouTube, we
have a short
the website goes
website goes further
goes further, it
it not only
not only gives
only gives you
you a link
video itself, but
but it gives
gives you keywords
interested in videos
in videos on
videos on a
on a similar
a similar subject
similar subject, you
on a keyword
This brings up
up a separate
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
taken to 47
to 47 videos
47 videos, which
are all introduction
all introduction to
introduction to Power
Power Basic videos
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
be an icon
source view column
view column, and
on that, you
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
source code quite
quite easily from
easily from this
from this site
wish to download
to download all
download all the
the files for
files for this
particular project, there
is a zip
a zip files
zip files download
files download icon
Clicking on that
on that will
that will allow
to download the
download the zip
The GitHub link
GitHub link will
link will take
you to GitHub
to GitHub, where
you can view
can view and
view and download
and download the
download the files
files from here
This page only
page only covers
only covers those
covers those videos
those videos which
videos which have
been added recently
in videos purely
videos purely for
console compiler, if
the videos to
videos to do
with keywords and
keywords and the
and the ability
ability to download
to download or
download or view
or view the
code for each
are interested purely
interested purely in
purely in the
Windows compiler, you
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
console compilers, there
there is again
is again a
again a separate
Again for Power
Power Basic introductions
Basic introductions, Projects
Projects and Design
and Design, and
new entry of
entry of podcasts
now have prepared
have prepared a
prepared a number
number of audio
of audio podcasts
audio podcasts, which
which link to
link to videos
to videos which
which have already
already been uploaded
These videos give
videos give you
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
topic of a
a particular video
particular video which
video which has
which has already
last two options
two options in
in here allow
here allow you
allow you a
in a specific
a specific keyword
specific keyword, for
for example browser
example browser, you
the browser keyword
which have that
And the library
library files allow
files allow you
code of libraries
of libraries used
libraries used within
within the projects
the projects, by
on the source
source view icon
allows you, regardless
regardless of where
of where you
where you are
in the world
the world, the
ability to look
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
Welcome! This video
video will take
take the Power
console compiler code
compiler code we
code we prepared
prepared in our
last video and
video and add
and add some
add some advanced
some advanced string
advanced string handling
string handling and
handling and also
and also read
also read from
read from one
from one file
one file and
file and selectively
and selectively output
selectively output to
output to another
from our last
last video which
video which reads
which reads in
reads in text
in text from
text from a
file and outputs
and outputs it
outputs it to
Tonight we are
expand on this
this and we're
read from this
from this file
file and output
and output to
output to a
to a second
a second file
second file a
file a selected
a selected amount
selected amount of
Now to help
to help with
help with this
with this we
this we have
we have expanded
have expanded on
expanded on our
on our data
our data we
data we now
in a data
a data set
data set called
set called eye
colour and we've
couple more rows
to read each
read each of
of the lines
the lines within
lines within this
file and extract
and extract those
extract those lines
those lines that
lines that have
that have a
have a particular
a particular eye
particular eye colour
colour and output
and output the
output the whole
the whole row
whole row to
row to a
at a code
a code the
code the first
is to decide
to decide on
decide on the
on the name
will do we
do we will
the program which
program which contains
Now rather than
rather than change
than change our
change our existing
existing function we'll
function we'll keep
we'll keep it
keep it there
it there we're
there we're going
function and we're
new function read
and output as
output as well
file to input
to input we'll
input we'll want
actually add some
some extra parameters
to interrogate just
interrogate just as
a string then
that column we're
column we're interested
interested in and
finally the name
of the output
output file which
a constant up
constant up here
we're passing four
passing four parameters
four parameters into
parameters into this
this function now
function now so
so we better
we better as
better as well
as well create
well create the
here we'll want
put the beginning
function which contains
contains the parameters
the parameters so
parameters so we
define the parameters
the parameters at
are our four
our four values
four values coming
values coming in
coming in all
in all strings
all strings and
strings and we'll
we'll be returning
be returning a
returning a long
a long value
long value just
value just as
previous function which
is basically true
basically true or
Right so the
is to define
to define some
define some variables
some variables much
variables much as
did the other
the other night
other night which
night which is
be long file
long file for
file handle we're
handle we're going
do a count
a count and
count and we'll
store the headers
So first thing
do is just
is just exactly
just exactly what
exactly what we
the previous broadcast
bring in this
this code here
code here and
here and it's
actually exists first
return false if
the file using
file using our
using our file
our file handle
file handle defined
handle defined here
defined here and
here and if
if we don't
we don't manage
don't manage to
manage to open
want to generate
to generate an
generate an error
we do scan
do scan the
scan the file
the file successfully
file successfully we
successfully we will
output the number
of records which
records which we've
which we've read
we've read using
read using the
using the file
the file scan
file scan command
scan command and
command and we
read in the
first line which
line which we
which we know
we know contains
know contains the
contains the headers
the headers and
headers and there
and there it
there it is
Now one of
of the problems
the problems with
problems with reading
with reading in
reading in any
in any file
any file is
file is you
is you assume
you assume the
assume the file
the file format
file format will
format will not
case we have
have five columns
five columns within
columns within this
within this and
we're specifically interested
could do what
video and it
and it would
it would effectively
would effectively parse
effectively parse out
parse out based
out based on
based on column
column number five
would work fine
work fine until
changes the input
the input file
input file to
file to have
additional column somewhere
column somewhere before
somewhere before the
before the column
since the columns
columns are actually
actually named on
named on the
first line we
line we want
want to find
which column eye
column eye colour
eye colour actually
colour actually is
actually is in
is in before
before we interrogate
we interrogate the
interrogate the file
one is we
is we were
we were going
were going to
many columns we
The easy way
do that since
that since we
of the headers
the string headers
string headers variable
headers variable we
quite happily output
happily output to
console using a
new command we
command we haven't
we haven't seen
haven't seen yet
seen yet called
yet called parse
called parse count
Now parse count
parse count takes
count takes as
a parameter a
parameter a string
a string in
case the headers
It also wants
also wants to
wants to know
what the delimiter
the delimiter of
delimiter of that
it's a tab
delimited file because
file because we
because we set
we set it
it up that
up that way
that way and
way and since
and since parse
since parse count
parse count returns
count returns a
a number and
putting it to
the console we
console we want
want to convert
to convert that
convert that to
to a string
this now it
now it should
it should attempt
should attempt to
the file throw
file throw out
throw out the
of records read
records read the
headers and we
to put columns
put columns equals
columns equals and
equals and the
columns and finally
finally we want
want to close
handle and should
should we have
we have any
have any errors
any errors we
errors we will
return false and
false and probably
and probably a
idea to output
we do get
do get an
get an error
an error what
error what the
error actually is
is and assuming
and assuming we
assuming we get
the end here
end here the
here the function
the function can
can be equal
equal to true
to true because
true because we've
because we've successfully
we've successfully got
successfully got to
got to this
to this point
we try saving
try saving that
saving that and
will run our
our program we
program we have
have got an
got an error
we got an
got an error?
an error? Ah
error? Ah we
Ah we have
have not defined
not defined str
defined str header
str header the
header the compiler
the compiler has
compiler has quite
has quite correctly
quite correctly noticed
correctly noticed that
noticed that we
that we put
put in str
in str headers
str headers and
headers and we're
and we're referring
referring to str
to str header
str header singular
Now remember we
remember we had
had the demo
the demo at
demo at the
very beginning which
beginning which means
which means you
means you must
you must dimension
must dimension every
dimension every variable
every variable before
variable before you
before you use
you use it
Now if you
if you didn't
you didn't put
didn't put that
that in if
in if the
if the compiler
the compiler allowed
compiler allowed that
allowed that to
to happen string
happen string header
string header would
header would have
would have nothing
have nothing in
in it and
it and we
and we would
we would get
would get invalid
get invalid information
invalid information so
information so it's
good to actually
actually pick that
it again now
again now the
now the compiler
the compiler hopefully
compiler hopefully has
hopefully has found
has found all
found all the
all the errors
the errors there
errors there we
we go number
go number of
of records 11
records 11 there
11 there were
there were 11
were 11 records
11 records in
records in our
our file and
and there were
there were indeed
were indeed five
indeed five columns
five columns so
columns so the
so the computer
the computer has
computer has now
has now worked
many columns we've
columns we've actually
to our routine
our routine what
routine what we
now is we
want to interrogate
to interrogate each
interrogate each of
the lines one
lines one by
by one until
one until we
the previous routine
previous routine was
routine was we
was we put
put a while
a while command
while command in
command in because
in because we
loop and what
and what this
what this loop's
this loop's going
loop's going to
do is it's
is it's going
going to loop
to loop until
loop until it's
until it's not
file so once
so once it
once it gets
the file we'll
file we'll drop
we'll drop out
of this loop
this loop and
loop and then
then for each
for each line
each line we
data in and
in and we'll
we'll put it
a string called
string called str
called str data
str data which
data which we'll
which we'll remember
we'll remember to
remember to define
to define up
define up here
up here and
here and that
and that str
that str data
str data will
data will contain
contain the entire
we know after
know after specifically
after specifically the
specifically the eye
know at the
moment it's going
number five so
five so what
we'll do initially
do initially is
initially is we
value of column
of column number
five so we
parse command on
command on str
on str data
it's a tab-related
a tab-related file
tab-related file and
interested in column
in column number
Now if it
if it equals
it equals and
equals and we
and we were
we were wanting
were wanting to
wanting to go
go for whatever
for whatever we
whatever we get
we get in
get in for
the column value
column value so
value so there
we go we're
go we're actually
that string fifth
string fifth column
fifth column looking
column looking for
value we passed
in and if
if it actually
it actually does
actually does that
does that we
want to we'll
to we'll just
just put out
the console for
console for the
moment and what
will put out
out the entire
line to the
console so if
match is not
will put nothing
put nothing out
nothing out to
that now there
now there we
we go we
go we have
have pulled out
pulled out three
out three values
three values three
values three columns
three columns rather
columns rather each
rather each of
each of which
of which has
which has matched
has matched the
matched the brown
the brown eye
brown eye colour
eye colour we're
colour we're looking
looking for and
for and it's
and it's put
it's put them
put them out
them out so
out so it's
quite happily interrogated
happily interrogated to
interrogated to file
to file pulled
file pulled out
pulled out the
information we wanted
we wanted and
wanted and put
and put out
console so what
what we wanted
wanted to do
do in addition
to that was
that was be
was be a
little more clever
more clever about
clever about working
about working out
working out this
out this value
this value so
value so the
is how do
do we work
we work out
the value well
value well since
well since we
the headers contain
headers contain all
the values what
values what we
pick out that
out that value
that value so
value so in
find out what
out what that
what that value
value is so
is so what
to get another
get another genomic
another genomic function
genomic function and
what that column
that column value
column value is
value is going
be and we're
value in this
a number not
number not a
not a string
string and we'll
and we'll sort
we'll sort the
sort the number
the number there
number there so
there so that
a number now
number now up
now up here
up here when
here when we've
actually got the
got the headers
the headers this
headers this is
to be now
be now we
of actually working
actually working that
working that out
that out so
out so we're
new function very
function very useful
very useful can
useful can be
be used all
used all the
the time and
call that fun
that fun parse
fun parse find
parse find and
find and it's
to get some
get some values
some values it's
values it's going
to be turned
be turned on
turned on number
on number so
number so what
after is the
string we want
to interrogate which
interrogate which in
case will be
will be string
be string headers
string headers we
headers we want
it the delimiter
delimiter which we
we know is
know is a
is a tab
a tab and
it what we're
looking for now
now we knew
we knew what
knew what we
what we were
looking for because
for because we
because we passed
we passed it
passed it in
as a column
a column name
column name so
name so we'll
put the column
name so there's
there's our function
our function or
or the call
our function we'll
function we'll call
we'll call fun
call fun parse
parse find give
find give it
it the headers
the headers give
headers give it
the delimiter give
delimiter give it
it the thing
the thing we're
thing we're looking
for and it
number and that
and that number
that number can
number can then
then be used
as a replacement
a replacement for
replacement for the
the number five
number five now
five now we
new function so
function so let's
new function this
is a usual
a usual function
usual function to
function to have
to have because
have because you
because you can
it for lots
for lots of
lots of things
of things so
things so starting
so starting in
starting in function
in function now
function now we
know the header
the header is
header is going
the tab we
tab we will
will put again
put again as
a string we'll
string we'll just
just call it
call it delimiter
it delimiter i
delimiter i think
i think and
think and i'm
underline character to
character to fold
next line so
line so it's
so it's easier
it's easier to
read and we'll
we'll have column
have column name
column name again
name again as
a string now
string now how
now how are
pull off this
off this remarkable
this remarkable stunt
remarkable stunt well
stunt well the
well the first
actually find out
find out how
are now we
we knew we
knew we weren't
we weren't too
weren't too early
too early how
early how many
many columns we'll
columns we'll use
same logic so
logic so we'll
so we'll set
we'll set up
up a little
little counter and
counter and what
do we'll put
we'll put try
put try in
try in just
in just for
for the fun
the fun of
fun of it
of it and
it and what
loop which is
is basically telling
basically telling the
telling the computer
the computer to
computer to work
which column it
column it wants
it wants to
wants to look
look at so
at so it's
so it's starting
at column number
number one assuming
one assuming there
assuming there was
there was at
was at least
least one column
one column in
column in it
it and we're
to use parse
use parse count
parse count again
count again and
again and parse
and parse count
parse count is
the string we've
string we've passed
passed in which
in which in
headers and it's
take the delimiter
delimiter which in
know is going
be a tab
tab and a
and a for
next loop basically
loop basically will
basically will go
will go until
go until there
until there is
is nothing more
nothing more to
do so should
so should anything
should anything error
anything error within
error within here
within here we're
going to in
to in this
case we turn
we turn zero
turn zero as
zero as in
as in it
in it didn't
didn't find anything
find anything at
anything at all
at all so
all so as
so as long
long as this
as this actually
this actually gives
actually gives us
a value that
value that we'll
that we'll know
we'll know it's
it's a column
column number if
number if it
gives us zero
us zero then
zero then there's
there's no column
no column number
column number so
number so for
in here what
here what we
to check using
check using the
parse command of
command of our
of our str
our str headers
headers and the
the element we're
element we're looking
for is driven
driven by this
by this long
this long r
r which will
be in our
our case between
case between one
one and five
and five so
five so the
first time running
time running through
running through this
this loop it
loop it will
be one then
one then two
then two then
two then three
then three then
three then all
then all the
up to five
to five now
five now the
search criteria we're
criteria we're after
after is held
within this column
this column name
name so if
value on any
the columns matches
columns matches whatever
matches whatever our
whatever our column
our column name
column name is
name is then
is then we
know we found
we found the
looking for so
for so at
that point the
point the return
return value of
number and at
point we don't
to go any
any further we
further we can
the function straight
function straight away
straight away now
away now we
we know based
know based on
based on our
on our own
our own data
own data that
data that it
will get all
get all the
last column before
column before it
before it returns
it returns but
returns but should
but should somebody
should somebody shuffle
somebody shuffle the
shuffle the columns
the columns around
columns around in
around in the
in the input
input file so
file so the
so the eye
the eye colour's
eye colour's first
colour's first it
first it would
it would find
would find it
find it straight
straight away so
away so assuming
so assuming we've
assuming we've actually
we've actually keyed
actually keyed all
keyed all this
all this right
this right this
right this parse
parse find should
find should return
value of five
of five now
five now if
original code which
is fine we're
fine we're passing
we're passing eye
passing eye colour
colour and we're
we're passing brown
passing brown i
brown i have
have a sneaking
a sneaking suspicion
sneaking suspicion the
suspicion the eye
eye colour column
colour column has
column has actually
has actually got
actually got space
got space between
space between eye
between eye and
eye and colour
and colour yes
colour yes it
it does so
does so let's
so let's just
let's just change
just change that
that to eye
to eye space
eye space colour
space colour otherwise
colour otherwise it
otherwise it would
would not match
not match i
match i wouldn't
i wouldn't find
wouldn't find anything
find anything now
anything now what
use in here
is we are
use the debug
the debug functionality
debug functionality which
functionality which we'll
which we'll find
we'll find is
find is very
very useful within
useful within power
power basic now
basic now we're
now we're fairly
we're fairly sure
fairly sure of
sure of the
the code up
code up until
up until this
until this point
this point this
point this is
this is code
is code we've
code we've not
we've not actually
not actually tested
actually tested yet
tested yet so
yet so just
test this is
to work correctly
work correctly if
correctly if you
if you press
press the f9
the f9 on
f9 on any
on any line
any line it
line it makes
makes it go
it go bright
go bright red
bright red this
red this is
is a breakpoint
a breakpoint the
breakpoint the breakpoints
the breakpoints can
breakpoints can also
be set from
set from your
from your tool
your tool menu
tool menu up
menu up here
up here under
here under debug
under debug you'll
debug you'll find
you'll find there's
find there's a
there's a toggle
a toggle breakpoint
toggle breakpoint if
breakpoint if we
we press it
press it again
it again it
again it goes
it goes off
goes off if
off if we
it goes back
goes back on
back on again
on again now
again now it
now it means
it means if
means if you
put a breakpoint
a breakpoint in
breakpoint in here
here the program
program will actually
will actually stop
actually stop in
stop in debug
debug mode at
mode at that
that point go
point go back
main program and
program and we
and we press
press the bug
the bug icon
bug icon which
icon which lets
which lets us
lets us compile
us compile and
compile and debug
and debug the
debug the current
the current file
current file now
file now it's
now it's throwing
it's throwing a
throwing a wobble
a wobble ah
wobble ah yes
ah yes it's
yes it's quite
quite correctly syntactically
correctly syntactically saying
syntactically saying i
saying i didn't
i didn't put
didn't put the
the word as
word as in
as in debug
in debug again
debug again i
again i didn't
i didn't do
didn't do it
next one either
one either i'm
either i'm doing
i'm doing remarkably
doing remarkably well
remarkably well here
well here why
here why is
why is it
is it complaining
it complaining ah
complaining ah spell
ah spell a
spell a mistake
a mistake right
mistake right okay
right okay now
okay now we've
got the bugs
the bugs out
bugs out oh
out oh no
oh no it's
no it's still
it's still it's
still it's still
it's still morning
still morning it's
morning it's a
it's a caca
a caca because
caca because i
because i basically
i basically i
basically i can't
i can't spell
can't spell i'll
spell i'll call
i'll call it
call it the
it the limiter
the limiter is
limiter is it
it a limiter
a limiter all
limiter all right
all right hopefully
right hopefully we've
hopefully we've put
we've put on
put on that
that now yes
now yes should
yes should we
should we save
save it uh
it uh yes
uh yes and
yes and it's
and it's forgotten
it's forgotten my
forgotten my file
my file isn't
file isn't file
isn't file oh
file oh that
oh that one
that one all
one all right
all right okay
right okay debug
okay debug right
debug right okay
okay now we're
now we're running
we're running debug
running debug as
debug as you'll
see the line
the line it's
line it's sitting
it's sitting on
sitting on is
program which is
which is bright
is bright yellow
bright yellow now
yellow now since
now since we
in here somewhere
here somewhere put
somewhere put a
breakpoint on if
on if we
back and we
and we hit
f5 button it
it will step
through to get
to get to
to a breakpoint
a breakpoint so
breakpoint so what
so what it's
it's actually done
actually done here
done here is
here is it
is it stopped
it stopped here
stopped here so
here so we
can actually look
actually look at
at the value
the value if
value if you
if you right
you right click
on the variable
the variable click
variable click on
click on watch
on watch it
watch it shows
it shows you
shows you the
the value first
value first name
first name tab
name tab character
tab character surname
character surname tab
surname tab character
tab character address
character address bla
address bla bla
bla bla all
bla all the
name we're actually
actually after is
after is eye
is eye colour
eye colour which
colour which is
which is great
is great so
great so if
if you f8
you f8 into
f8 into that
into that it
will step into
the function if
we bring along
bring along r
along r up
r up we
up we watch
we watch that
watch that one
that one it
will then quite
then quite happily
quite happily tell
happily tell us
tell us it's
us it's zero
it's zero at
zero at the
the moment if
moment if we
we f8 that
f8 that it's
that it's now
it's now one
now one and
it matches no
matches no it
no it doesn't
it doesn't match
doesn't match so
match so it
so it keeps
it keeps going
keeps going two
going two three
two three four
three four five
four five and
five and it
has found it
found it it's
it it's found
it's found on
found on the
the fifth column
fifth column so
column so long
so long hour
long hour is
hour is going
be returned as
returned as five
as five there
five there we
we go so
go so we'll
at the column
column number now
number now watch
now watch that
that one there's
one there's a
there's a value
a value five
value five so
five so it's
quite correctly picked
correctly picked up
the value five
value five which
five which is
we're after so
after so if
want to just
to just continue
just continue to
continue to the
program now we
we could hit
could hit just
hit just the
just the f5
f5 button and
button and it
it will throw
will throw out
throw out to
the console are
console are the
the three we're
three we're interested
interested in so
in so even
so even if
even if the
eye colour was
colour was moved
was moved to
moved to a
a different column
different column it
column it will
will now correctly
now correctly find
correctly find it
find it regardless
it regardless of
of where it
it is as
is as long
long as we
get the name
the column correct
column correct then
correct then the
the column could
column could be
could be anywhere
be anywhere within
so that touches
that touches on
touches on debug
on debug very
debug very useful
very useful tool
useful tool we
tool we go
our main program
main program what
program what we
to output that
output that data
that data to
separate file now
file now in
where we display
we display on
where we would
we would want
do the output
the output now
output now rather
rather than individually
than individually hand
individually hand coding
hand coding a
coding a piece
to handle every
handle every single
every single one
single one another
one another generic
another generic function
generic function is
is a lightly
a lightly too
lightly too big
too big a
big a good
a good way
good way of
doing it so
it so what
with that when
that when we
a new generic
new generic function
generic function and
function and what
with this one
one is i've
is i've appeared
i've appeared one
appeared one we
earlier and i'm
to paste this
paste this one
this one in
in and explain
and explain to
explain to you
to you what
you what it
what it actually
actually does now
does now this
a function i'm
function i'm calling
i'm calling a
calling a pen
a pen to
pen to file
to file takes
file takes two
two parameters it
parameters it takes
add to and
to and it
takes the data
data to add
add to it
it the idea
this is you
multiple times and
times and if
file already exists
already exists it
exists it will
it will just
will just append
just append to
append to it
it and the
will create it
create it so
it so on
this one it's
one it's basically
it's basically again
basically again getting
again getting a
getting a file
file handle next
handle next file
next file handle
file handle from
handle from the
from the system
the system again
system again with
again with using
with using the
using the try
try catch just
catch just in
in case there's
case there's any
there's any errors
any errors it's
errors it's testing
it's testing to
already exists if
exists if the
already exists then
exists then it's
then it's doing
it's doing an
doing an open
an open name
open name of
file for append
for append remember
append remember the
remember the one
did before was
before was to
was to read
read a file
file we're now
we're now actually
now actually appending
actually appending to
appending to a
using a lock
a lock shared
lock shared approach
shared approach as
approach as in
as in we're
in we're putting
putting a lock
a lock but
lock but we're
but we're letting
we're letting other
letting other people
other people read
people read the
the file if
file if well
if well we're
well we're writing
we're writing to
writing to it
to it otherwise
it otherwise if
otherwise if the
the file doesn't
file doesn't exist
doesn't exist then
exist then we're
then we're opening
we're opening it
opening it for
it for output
for output and
output and then
and then all
then all we're
all we're basically
basically doing is
doing is a
a straightforward print
straightforward print to
data we passed
in and returning
and returning true
returning true should
true should some
should some error
some error occur
error occur then
occur then we're
we're returning false
returning false and
false and eventually
and eventually we're
eventually we're actually
we're actually closing
actually closing the
closing the file
file so if
we take this
line here steal
here steal it
steal it out
the program go
program go back
go back up
back up to
up to our
find the line
the line that's
line that's the
that's the line
the line we
line we were
were actually wanting
actually wanting to
wanting to output
to output so
output so what
to do there
do there is
there is we
want to append
to append to
append to the
the file now
file now we
now we haven't
we haven't told
haven't told it
told it what
it what file
what file to
file to go
go to right
to right but
right but we
but we did
we did pass
did pass in
output to so
to so that's
so that's quite
that's quite straightforward
quite straightforward to
straightforward to paste
to paste that
paste that one
one in that's
in that's we
that's we want
to output and
we've got is
got is in
in fact str
fact str data
str data str
data str data
data contains the
the entire record
entire record now
record now we
actually test that
test that because
that because this
because this call
call will return
or false so
false so what
if we've successfully
we've successfully managed
managed to write
write to the
file if we
we can we'll
can we'll put
put a field
a field to
field to output
output to file
to file and
do it will
will put record
put record written
record written now
written now assuming
now assuming we
assuming we coded
we coded all
coded all this
all this up
this up correctly
up correctly what
correctly what it
it should do
should do it
do it has
it has field
has field to
file we've done
we've done remarkably
done remarkably well
well here we
here we managed
we managed that
managed that we
that we never
we never specified
never specified the
specified the directory
the directory so
directory so what
do in that
in that one
that one is
we will specify
will specify xe
specify xe path
xe path at
path at the
at the front
the front of
front of that
of that now
that now that
now that hopefully
that hopefully should
hopefully should allow
to run no
run no it
no it still
it still doesn't
still doesn't allow
doesn't allow us
to run why
run why is
it not allows
not allows a
allows a run
a run what
run what do
do we call
file we called
called it output
it output file.txt
output file.txt well
file.txt well that's
well that's fine
that's fine why
fine why is
it not outputting
not outputting architectures
outputting architectures um
architectures um, i
need to debug
to debug in
debug in this
this one to
be honest this
honest this one
put a debug
a debug in
debug in there
in there because
there because obviously
because obviously it
obviously it is
is returning false
false and we
will find out
what that error
that error actually
error actually says
So F5 on
F5 on it
on it permission
it permission denied
permission denied okay
denied okay it's
okay it's giving
it's giving us
us a permission
a permission denied
permission denied for
denied for some
So a question
a question is
question is where
is where is
where is it
is it trying
it trying to
trying to write
to write to?
write to? It's
to? It's trying
It's trying to
write to myfile.txt
to myfile.txt which
myfile.txt which is
is our input
to the input
look at we're
at we're giving
giving it output
it output file
Oh I think
I think we've
think we've picked
we've picked a
picked a wrong
a wrong file
wrong file here
to our read
our read to
read to file
Yes we are
be the output
a wrong variable
The programmer is
programmer is quite
is quite correct
the fact we
fact we made
made a mistake
now we're pointing
we're pointing towards
pointing towards the
towards the right
the right file
has indeed written
indeed written three
written three records
three records to
records to the
are three records
three records it's
records it's actually
it's actually found
Now to be
to be tidy
be tidy we
tidy we probably
we probably want
put the header
the header in
header in there
in there as
there as well
Just so you
read the thing
the thing inside
thing inside Excel
inside Excel or
Excel or any
or any other
any other program
go back F2
back F2, go
our function again
function again and
again and I
and I think
I think what
think what we
do is up
is up here
up here once
here once we've
the headers we
headers we will
will then steal
then steal our
steal our little
our little function
Paste it in
it in there
there and what
what we're putting
we're putting rather
putting rather than
line we're putting
It should write
should write it
write it quite
it quite happily
Now the only
only thing we
thing we didn't
we didn't think
didn't think of
think of is
of is that
is that we're
that we're not
we're not clearing
not clearing out
the file before
file before we
Since the file
the file still
file still exists
still exists it
it will continue
will continue to
continue to append
So this gets
gets us to
to another bit
another bit of
bit of file
of file handling
file handling magic
here is since
is since we're
since we're running
running this read
this read file
read file and
do before we
we start is
start is to
that the output
output file doesn't
to try another
try another try
use the kill
kill command and
going to kill
to kill, attempt
attempt to kill
to kill the
kill the output
output file to
sure it doesn't
it doesn't exist
Now the reason
the reason I'm
reason I'm putting
try catch one
catch one is
one is that
first time you
you run this
run this program
this program on
program on machine
on machine it
machine it doesn't
it doesn't have
output file then
file then it
then it would
it would in
would in theory
in theory error
theory error if
error if you
if you try
you try and
try and wipe
and wipe it
wipe it by
it by killing
by killing it
So this case
case will not
will not bothered
not bothered if
bothered if it
it actually errors
actually errors because
errors because it's
because it's only
it's only error
only error could
error could be
could be that
be that it
that it can't
it can't actually
can't actually wipe
actually wipe the
wipe the file
It says it's
says it's written
it's written three
output file there
file there we
It's put the
put the three
the three data
three data lines
data lines in
lines in and
in and it
and it stopped
it stopped at
stopped at that
point and if
run it again
again it would
it would do
would do exactly
same thing and
thing and it's
and it's no
it's no longer
no longer it
longer it kills
it kills the
kills the file
the file first
file first before
first before it
before it writes
it writes to
writes to it
done in this
this video then
video then is
then is we've
is we've read
we've read from
one file we
we have programmatically
have programmatically pooled
programmatically pooled information
pooled information based
information based on
on a parameter
a parameter in
this case eye
case eye colour
and we've written
we've written the
written the data
So I think
I think that
think that completes
completes the work
work for this
this particular session
at the searching
the searching of
searching of arrays
Following the recent
recent videos on
videos on machine
on machine learning
machine learning, there
there are probably
are probably some
probably some questions
some questions on
questions on array
on array searching
Holding data in
data in arrays
in arrays is
arrays is a
useful and efficient
and efficient way
efficient way of
of actually holding
actually holding data
holding data within
data within memory
within memory so
memory so it
can be searched
be searched easily
searched easily and
easily and quickly
whether the data
the data you're
data you're looking
for is within
is within an
an array, you
of different search
different search methods
of all today
all today, we're
to prepare an
prepare an array
an array with
array with some
some data so
data so we
we can search
can search it
have done here
have dimensioned an
dimensioned an array
array of string
of string values
string values, holding
holding 20 elements
20 elements from
elements from element
from element 1
element 1 to
1 to element
to element 20
this array with
array with a
with a function
called populate array
the reference of
reference of our
our array itself
Arrays of course
course can take
can take data
take data from
data from many
from many sources
going to directly
to directly populate
directly populate the
parameters list of
list of this
have a reference
We are performing
are performing this
performing this population
this population using
population using the
Assign command has
has two parts
first part is
to populate followed
populate followed by
by the equals
And I've folded
I've folded each
folded each of
of data down
data down to
a separate line
separate line so
basically a long
list of parameters
these parameters we
parameters we are
we are supplying
are supplying has
supplying has three
has three words
one is 'we
is 'we won't
'we won't look'
you use the
Assign command, it
takes the first
first parameter, in
this case 'we
case 'we won't
won't look' and
look' and populates
and populates it
populates it into
into the first
array you have
you have designated
It then continues
then continues to
continues to populate
of the remaining
the remaining elements
remaining elements with
elements with the
the values you
values you have
you have assigned
have populated this
populated this strData
this strData array
strData array with
array with 20
with 20 values
20 values, each
of them a
them a string
next is we're
search out the
information from this
from this array
the best method
best method of
method of searching
of searching, we're
do some metrics
some metrics on
metrics on this
up the search
the words 'we
words 'we will'
'we will' in
will' in this
in this array
to return how
return how many
how many matches
many matches we've
matches we've actually
from the array
the array data
array data that
data that we
just populated, there
number of matches
of matches which
matches which will
which will obviously
will obviously come
obviously come up
For example, 'we
'we will see'
will see', 'we
'we will return'
When you're searching
you're searching string
searching string arrays
string arrays, you
either do a
independent search or
search or a
or a case
case dependent search
for a case
dependent search, then
then this element
this element of
the data would
data would not
not be returned
be returned, because
because the first
the first letter
first letter is
letter is uppercase
is uppercase W
at two methods
two methods of
methods of searching
of searching data
searching data out
going to insert
to insert that
insert that code
that code into
code into a
function called 'search
called 'search for
'search for data'
for data', passing
first being our
being our search
search criteria, what
looking for, and
second being a
being a reference
many matches we
matches we have
we have, we're
to return from
this function a
function a value
we'll declare this
declare this local
a long above
long above the
above the call
call to 'search
to 'search for
Before we write
we write the
in this search
this search for
search for data
for data, we'll
takes to actually
actually run this
run this function
PowerBasic has an
has an inbuilt
an inbuilt command
inbuilt command called
command called Tix
Tix is a
very useful command
useful command in
command in that
that it measures
it measures clock
measures clock cycles
clock cycles of
cycles of the
of the CPU
get a very
a very granular
very granular value
granular value back
value back for
back for how
how long your
long your code
your code took
code took to
took to run
variable called 'cycles'
called 'cycles' as
'cycles' as a
as a quad
A quad is
quad is one
the variable types
variable types which
types which can
which can contain
can contain very
contain very large
very large numbers
large numbers indeed
command to start
to start counting
start counting is
counting is Tix
is Tix, followed
after the function
the function has
function has completed
use the tix
the tix end
tix end command
end command, followed
into which we've
which we've been
we've been putting
been putting our
putting our cycle
our cycle count
As the Windows
operating system is
system is a
is a multitasking
a multitasking system
multitasking system, it's
that the number
number of cycles
of cycles will
cycles will vary
will vary between
vary between runs
run a loop
This loop will
loop will call
call our search
our search for
for data function
data function many
function many times
take the average
of cycles to
cycles to work
the function takes
function takes to
us a much
much better average
better average of
the time it
run our function
create two variables
variables to enable
One for a
for a loop
loop and one
a loop count
set our loop
our loop count
loop count at
count at a
at a value
value of 50,000
data function completed
function completed and
completed and we
we have closed
have closed off
closed off the
off the Tix
the Tix command
Tix command, we
then display on
screen the number
of matches found
matches found and
found and the
number of search
of search cycles
search cycles we've
cycles we've actually
we've actually used
actually used up
used up as
as an average
using our fun
fun log command
log command, which
which will just
will just push
just push the
of all displaying
all displaying the
displaying the number
of cycles divided
cycles divided by
by the loop
the loop count
us the average
the average value
And we'll follow
we'll follow that
of matches of
matches of data
of data we've
data we've actually
actually found within
found within our
let's go now
go now and
now and create
create this search
data function as
function as a
as a for
new function search
function search for
for data with
data with its
being the search
array which we
wish to search
need a row
a row counter
row counter and
counter and we'll
we'll have variable
have variable for
of matches we've
is going from
from the 1
the 1 to
be the last
will be element
be element number
element number 20
the parameters, the
search criteria matches
criteria matches the
will first look
first look for
for a direct
a direct match
simple if condition
If the element
the element long
element long roll
long roll in
roll in our
our array matches
array matches the
matches the search
search criteria, then
we'll increment the
increment the matches
the matches variable
end of reading
of reading through
reading through each
calling function as
function as long
as long matches
So our search
search criteria at
criteria at the
moment are the
are the words
matches found is
found is zero
is zero, none
none at all
the search cycles
search cycles are
cycles are 1727
So stepping through
the array took
array took around
took around 1700
around 1700 CPU
1700 CPU cycles
let's now search
search for something
for something we
something we know
know that will
that will exist
will exist in
then we change
change our search
search criteria to
criteria to match
to match that
match that and
We're taking 1950
taking 1950 search
1950 search cycles
search cycles now
cycles now and
now and it
it has returned
has returned one
returned one match
take this as
this as our
as our baseline
our baseline for
baseline for this
for this for
So that's if
that's if it's
it's a direct
direct match we're
for a partial
a partial match
partial match, we'll
now we're using
in string value
This looks inside
looks inside the
inside the element
array and looks
and looks to
see if part
if part of
that array matches
array matches what
matches what we've
what we've passed
in on that
on that criteria
will and we
see we found
we found much
found much the
same value, dependent
make it case
it case independent
case independent, we
need a different
a different if
different if statement
This statement is
statement is using
using the upper
the upper case
upper case command
case command, ucase
Applying this to
this to both
to both sides
both sides of
sides of the
of the if
if statement means
statement means it's
means it's going
be a case
So we're interested
in the length
of the search
will and we're
looking for this
this to exist
to exist at
exist at the
will return 13
return 13 values
13 values and
values and runs
and runs in
runs in around
in around baseline
around baseline for
baseline for for
for for next
a second function
second function which
array scan function
scan function within
function within PowerBasic
use this in
Tix command to
command to measure
to measure the
measure the clock
the clock cycles
a loop for
function called scanForData
called scanForData, again
again passing two
search criteria and
criteria and the
the data array
data array itself
is completed the
completed the loop
to use Tix
use Tix End
Tix End to
End to close
off our measurement
our measurement of
measurement of the
of the clock
will then print
of cycles and
cycles and the
of matches we
this new scanForData
new scanForData function
As before with
before with two
with two parameters
and the reference
scan command which
first parameter on
parameter on array
on array scan
array scan is
scan is the
array which you
wish to scan
to scan, in
this case strData
next part we're
part we're going
to use is
use is the
is the from
the from statement
This tells the
tells the scan
the scan that
scan that we're
interested in from
in from characters
from characters one
characters one to
In much the
way we use
dollar command in
We follow this
follow this with
with a collate
a collate command
collate command which
which is saying
is saying collate
saying collate uppercase
case independent match
looking for it
for it to
equal to our
to our search
parameter is toLongMatch
returns the element
the array in
array in which
which we found
we found our
found our match
a match, the
long match will
match will be
will be greater
increment the long
the long matches
long matches variable
matches variable to
variable to record
to record that
record that we
indeed found a
scan command will
command will only
will only find
only find the
very first match
first match on
match on our
on our search
will not search
not search through
search through the
But let's run
sure it will
have our scan
our scan cycles
scan cycles are
cycles are showing
showing as 1,125
as 1,125 to
1,125 to find
scan the rest
any more matches
we know using
know using our
using our for
next loop that
loop that it
that it did
it did indeed
did indeed find
indeed find 13
find 13 matches
scan command to
command to scan
of the array?
the array? Since
array? Since the
Since the long
long match returns
match returns the
element in which
which we actually
actually found a
then advance to
advance to move
to move on
the next match
variable called next
called next match
next match to
match to do
run this in
loop until we
find no more
scan command almost
command almost exactly
difference being that
being that after
that after the
after the name
the array where
array where we
where we had
we had two
had two brackets
two brackets open
brackets open and
open and close
and close brackets
close brackets, we
a variable in
variable in there
This is telling
is telling array
telling array scan
array scan to
scan to start
to start its
start its scan
its scan at
scan at the
at the next
the next element
next element along
Because we've taken
taken the match
match variable and
variable and added
and added one
added one to
the command is
command is exactly
the same and
same and it
return the match
the match it
match it finds
it finds in
long match variable
value returned in
returned in match
in match is
match is greater
then we did
we did indeed
indeed find a
next slot to
slot to start
start searching again
value of next
of next match
match to tell
tell the array
array scan where
scan where to
where to start
to start looking
start looking from
So we're taking
we're taking next
taking next match
next match and
match and adding
adding on long
on long match
long match to
match to it
that the array
scan command starts
command starts its
starts its scan
its scan from
scan from the
from the element
array we told
we told it
told it to
it to start
If we told
start at element
at element five
element five and
and it found
it found a
a match at
match at the
at the seventh
the seventh element
seventh element, the
the value populated
value populated into
populated into long
into long match
long match would
match would be
the value two
value two because
two because it's
because it's two
it's two elements
two elements beyond
elements beyond where
beyond where it
where it started
need to calculate
to calculate the
calculate the next
next match based
match based on
that criteria by
criteria by adding
match to the
value in next
in next match
run this code
it should run
should run round
loop and scan
and scan the
scan the array
array for every
for every match
every match it
getting the same
the same results
same results back
results back from
back from both
from both functions
loop is taking
is taking just
taking just over
just over 12,000
over 12,000 CPU
12,000 CPU cycles
cycles to return
to return 13
return 13 matches
our array scan
scan is taking
is taking 15,000
taking 15,000 cycles
15,000 cycles and
cycles and giving
and giving us
giving us again
us again 13
again 13 matches
So at first
at first glance
first glance here
glance here, it
would appear that
appear that the
that the for
next loop appears
loop appears to
to be slightly
be slightly more
slightly more efficient
more efficient than
efficient than the
than the array
And remember, we're
actually running each
these functions assumption
functions assumption that
array is fairly
is fairly random
And both functions
both functions will
functions will need
look through every
through every element
every element within
array to discover
to discover to
discover to see
indeed a match
what the data
the array was
array was unique
was unique for
unique for each
to find this
find this element
this element here
element here prepared
here prepared to
prepared to see
is very close
code now looking
now looking for
will see something
see something quite
something quite interesting
search cycles for
cycles for the
for the for
loop is around
is around 14,000
of cycles for
for the scanning
the scanning method
scanning method using
method using array
using array scan
scan is only
is only 2,700
run that again
that again to
again to make
sure that just
that just wasn't
just wasn't a
wasn't a fluke
And we're getting
we're getting very
getting very similar
very similar data
similar data coming
So what makes
what makes the
makes the array
array scan suddenly
scan suddenly much
suddenly much more
much more efficient
than the for
next loop despite
loop despite us
despite us having
us having not
having not changed
not changed any
changed any code?
any code? Let's
code? Let's try
Let's try one
try one further
one further code
further code change
change to see
if it makes
it makes a
makes a difference
know we're only
to get one
get one value
one value back
value back from
from this particular
this particular search
particular search, let's
let's change the
change the for
next loop so
loop so that
when it does
it does actually
actually find a
match in the
in the for
using the exit
the exit for
for command so
command so that
once we find
we exit immediately
exit immediately and
immediately and return
this now, we'll
we have significantly
have significantly reduced
significantly reduced the
reduced the number
number of clock
of clock cycles
clock cycles for
It's now down
now down to
down to 5,000
scan command still
command still beats
still beats it
beats it at
it at only
at only 2,700
only 2,700 cycles
So when it
comes to which
to which type
which type of
type of search
of search is
search is the
is the most
most efficient for
efficient for your
for your data
your data, it
it does really
does really depend
really depend on
depend on what
on what you're
for and what's
and what's in
But this method
this method of
of actually using
actually using the
using the Tix
how many clock
many clock cycles
clock cycles parts
cycles parts of
parts of your
your application are
application are using
are using when
using when you're
you're developing it
developing it is
it is very
very useful because
useful because if
because if you
you are calling
a function many
many thousands of
thousands of times
of times, the
the faster the
faster the function
the function runs
function runs, the
the better for
better for your
And once you
you have optimized
have optimized your
optimized your code
your code, you
then just comment
just comment out
out the Tix
the Tix commands
Hopefully this approach
this approach to
approach to array
to array searching
array searching has
searching has given
concept of associative
of associative arrays
associative arrays within
arrays within your
what are associative
are associative arrays
associative arrays and
arrays and what
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
than once in
once in the
Let's assume we're
assume we're going
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
this way, for
for example bank
example bank accounts
bank accounts where
accounts where the
where the account
account number links
number links to
links to the
the data value
data value or
value or values
or values associated
values associated with
As the key
the key is
key is unique
is unique you
unique you should
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
would need a
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
this functionality is
functionality is inbuilt
Basic and it's
and it's called
it's called Power
called Power Collections
at some code
to illustrate this
For those of
those of you
of you who
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
going to revisit
to revisit them
we can concentrate
can concentrate in
concentrate in a
detail on how
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
you look closely
look closely at
closely at the
the data, you
there were in
were in fact
in fact two
fact two John
two John Smiths
since we need
store a unique
of these users
these users, we're
pick the account
would expect, in
in banking systems
banking systems, the
number is a
is a unique
for the customer
have the account
to pull any
pull any of
of the information
the customer out
customer out of
of the banking
the banking system
This data at
moment is held
in a plain
a plain CSV
plain CSV file
task in the
pull this information
application and store
in a format
a format which
format which we
can put into
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
string of 8
of 8 characters
store the first
and surname as
surname as strings
as strings of
strings of fixed
fixed length 50
length 50 characters
The address as
address as 100
as 100 characters
and the telephone
string of 14
of 14 characters
advantage of using
of using a
type is that
is that you
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
identifier is going
be the account
account number, we're
put a prefix
a prefix on
prefix on the
use an account
number for two
for two different
two different purposes
More will become
will become clearer
become clearer when
clearer when we
up a constant
a constant or
constant or the
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
the text user
using a Power
a Power Collection
Power Collection, we
to define that
define that collection
variable called Customers
called Customers as
Customers as an
as an iPowerCollection
then making Customers
making Customers equal
Customers equal to
the class PowerCollection
completes the setting
up of the
of the PowerCollection
the PowerCollection and
PowerCollection and we
look at putting
at putting some
putting some data
now declare a
declare a user
as our type
we're creating udtCustomers
creating udtCustomers as
udtCustomers as uCustomers
you'll remember, is
type we set
we intend holding
intend holding two
holding two different
two different types
of information for
for our customers
our customers, we're
us to tell
tell the difference
difference between them
call that RecordType
start to set
set up some
up some variables
some variables which
variables which are
used to get
to get data
get data into
into our PowerCollection
our PowerCollection and
PowerCollection and to
get data out
with the key
The key we
key we are
are setting up
setting up as
as a local
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
allows the first
first part to
part to contain
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
within the Windows
the Windows subsystems
Next we're creating
variable called longR
this to read
read through our
Next we're declaring
we're declaring a
declaring a VData
a VData variable
is the variant
the variant that's
variant that's going
in a PowerCollection
finally we're storing
we're storing an
storing an item
an item number
is the record
record number in
the collection itself
having set these
set these up
these up, how
in our CSV
into the PowerCollection?
the PowerCollection? Well
PowerCollection? Well we're
be to load
load this raw
this raw CSV
raw CSV file
into the collection
call that loadRawFile
If this new
new function returns
then our CSV
CSV file has
been loaded into
false then we'll
then we'll report
we'll report that
report that we
that we could
could not load
not load the
load the CSV
taking a single
see the MyUserData
the MyUserData exists
MyUserData exists in
have the beginning
in its single
single parameter, to
load the collection
the collection from
collection from a
from a CSV
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
This is read
This useful function
useful function takes
the file you're
file you're reading
you're reading and
reading and the
use of such
of such library
such library functions
library functions saves
functions saves you
saves you quite
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
row in that
that array we're
read through it
through it one
it one row
one row at
row at a
next we're using
to define each
adding to each
these elements a
elements a piece
case we're taking
taking the user
text user, and
that the fifth
fifth column from
from our CSV
other elements of
the surname, the
populated our user
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
the power collection
power collection to
collection to add
add our data
being the key
the key, 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
been successful and
successful and we
have stored that
that returns a
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
this would prevent
would prevent putting
prevent putting a
putting a duplicate
a duplicate key
duplicate key into
key into the
we get that
get that far
that far, we're
we're returning true
returning true to
then the data
data will have
will have been
have been loaded
the case, can
can we also
we also pull
also pull the
collection and put
put it out
out to another
to another file
another file just
file just to
to prove we
prove we have
have been successful
been successful in
successful in storing
in storing the
storing the data
new function, save
to create with
create with the
data that's currently
that's currently within
file to actually
us to pull
And we're opening
we're opening our
opening our file
our file to
file to which
to which we're
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
And we're converting
we're converting the
converting the data
data within V
within V data
V data to
storing that within
within the record
the record type
record type variable
the first four
first four characters
four characters that
characters that determine
that determine whether
a user user
defined type or
type or it's
or it's the
it's the account
the account one
account one we
cover the current
the current one
current one in
one in more
more detail later
within a collection
a collection is
collection is all
is all user
all user data
user data, this
one that's going
going to execute
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
taking the information
information that's coming
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
wish to output
be handling account
handling account data
account data separately
data separately later
separately later on
later on, we're
to declare another
declare another user
type before we
as the customers
the customers user
customers user defined
defined type, we're
up another user
type to hold
to hold account
hold account information
case an account
account number with
number with balance
with balance and
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
will appear before
appear before the
before the key
the key in
how far we
far we get
getting the information
information coming up
coming up to
up to say
say we have
of entries stored
entries stored in
in our power
And additionally, we're
we're getting a
getting a message
message to say
have successfully saved
successfully saved the
saved the collection
the collection to
collection to disk
at what's come
what's come out
know how a
how a customers
a customers dot
customers dot text
that it stores
it stores information
stores information from
from the power
power collection in
collection in a
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
the other data
easily see we
see we pulled
we pulled the
pulled the information
information in from
and we've output
we've output it
output it to
we've actually saved
actually saved information
saved information into
into this customers
this customers dot
text file, that's
that's the content
of our power
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
in the customers
the customers dot
text file, we
then load it
load it directly
it directly from
directly from there
to use yet
use yet another
yet another new
called load collection
populate the power
power collection directly
collection directly from
directly from the
from the customers
single parameter, specifying
be loading the
loading the collection
collection from disk
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
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
is our unique
unique identifier in
identifier in the
we're opening up
opening up a
We're running a
running a while
loop to handle
handle every record
every record within
record within that
within that file
set command to
populate the user
type for each
did before, we
quite easily define
easily define our
define our key
our key, which
using the customers
the customers add
customers add method
add method again
method again to
create the account
the account data
account data, we'll
be doing exactly
result is S
is S OK
S OK, then
have successfully stored
successfully stored the
stored the information
us a message
say it's already
been stored or
stored or there
or there has
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
many records are
are actually sitting
actually sitting within
sitting within the
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
will print out
out our log
our log, the
of records we
records we find
customers power collection
successfully stored nine
stored nine records
nine records from
records from the
from the data
and we're reporting
we're reporting nine
reporting nine records
nine records found
records found in
So we've loaded
we've loaded up
text file, put
collection and reported
and reported on
reported on a
have a power
power collection running
collection running, how
a new record
new record to
to the collection?
the collection? One
collection? One that
One that did
that did not
in the original
the original CSV
original CSV file
use our prefix
our prefix command
prefix command again
easy to add
add to each
the elements in
in the user
a new account
new account number
account number of
number of thirteen
of thirteen hundred
the data, there
not currently an
currently an entry
entry for thirteen
for thirteen hundred
have no problems
no problems storing
problems storing this
storing this information
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
we're putting their
putting their telephone
their telephone number
telephone number in
number in as
populating the key
the key with
with the account
we're using customers
customers dot add
dot add to
add to add
add this piece
use of user
types is quite
quite useful as
as it gives
a little packet
little packet of
packet of data
of data you
data you can
can add quite
add quite easily
easily to power
to power collections
added this extra
of information, can
can we display
we display how
many records we've
records we've gotten
we've gotten, which
should now show
now show ten
show ten rather
ten rather than
rather than nine
than nine as
nine as we've
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
see it's gone
it's gone from
gone from nine
from nine records
records found up
found up to
up to ten
So we've successfully
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
all the accounts
the accounts that
accounts that we
we have for
have for our
for our users
store some different
some different type
different type of
type of information
the same power
same power collection
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
new user Fred
user Fred Smith
Fred Smith is
two records within
power collection, a
a customer's record
customer's record and
record and an
an account record
use the customer's
the customer's add
customer's add command
add command and
and this data
to be sure
be sure that
sure that this
this particular record
particular record has
record has been
been added successfully
added successfully, we
object result to
result to see
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
the word stored
word stored and
stored and also
also a count
records we have
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
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
need the accounts
the accounts one
accounts one because
one because we're
because we're going
be using it
it to put
to put account
put account data
account data in
data in for
in for our
our new 1300
new 1300 account
the account 1300
account 1300 has
1300 has been
successfully stored and
stored and we're
we're now up
up to 11
to 11 records
11 records within
records within our
within our power
as adding data
adding data to
power collection, there
wish to remove
to remove data
remove data from
to remove a
remove a customer's
the moment an
moment an account
account number So
remove that record
that record from
record from the
easily by specifying
by specifying the
specifying the key
the key, which
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
can again test
again test to
we're putting two
putting two messages
the log, one
one to see
what we've removed
we've removed and
removed and another
and another to
another to count
are now left
code now, we're
we're now down
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
entry for account
for account number
account number 600
make an update
an update to
update to that
that one to
one to change
to change its
change its value
we'll test to
sure the record
the record exists
record exists in
specify the key
the customer's contains
customer's contains command
contains command to
back the item
that returns zero
returns zero, then
then no record
no record has
has been found
than zero, you
use that item
that item number
back the actual
actual data using
data using the
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
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
that to pull
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
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
update the data
for this customer
command and update
So we're changing
we're changing this
changing this case
this case, both
both the phone
phone number and
and the address
address of this
of this customer
So having updated
having updated the
updated the user
now replace the
replace the data
in the customer's
power collection with
collection with our
the customer's replace
customer's replace command
with the add
the add command
add command, it
takes the same
takes the key
to push into
push into the
the collection, replacing
replacing what was
what was already
was already there
our object result
result to ensure
ensure the account's
the account's been
account's been updated
us the result
the result we
result we expect
is a message
say the data
the data was
data was found
was found at
found at record
at record number
record number three
the user 600
user 600 account
600 account has
account has been
what other commands
other commands can
commands can we
can we actually
actually use on
use on our
on our power
our power collection?
power collection? Over
collection? Over time
Over time, the
data being added
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
can perform this
perform this with
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
the data items
data items are
items are sorted
are sorted in
sorted in ascending
in ascending sequence
If you change
you change this
this to one
to one, the
the items will
items will be
be sorted in
sorted in a
in a descending
a descending sequence
to move through
move through each
in our collection
our collection and
collection and display
it on screen?
on screen? Again
screen? Again, we
the customer's collection
The V data
data is, of
of course, the
data that comes
comes out of
out of each
of each record
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
handle our user
our user records
set command, pull
from our variant
variable into our
into our user
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
We're using type
using type set
type set to
set to pull
into the account's
the account's user
account's user defined
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
need to display
display on our
then in next
in next command
the next record
before we finish
we finish off
finish off, we're
save the collection
the collection back
collection back to
to disk, overriding
overriding the customers
this now contains
now contains all
all the updated
the updated data
updated data and
and will allow
have updated the
updated the customers
And you will
that the keys
the keys are
keys are now
are now sorted
now sorted in
in ascending order
we have saved
to disk, you'll
see that account
account number the
number the power
will be unable
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
Record 1300 is
1300 is already
is already stored
already stored, so
we can no
no longer add
longer add it
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
doesn't exist within
exist within the
created a power
collection to do
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
we're using variants
using variants to
variants to pull
from this power
this power collection
determine what we
to do based
do based on
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
can handle that
handle that data
that data independently
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
business of developing
of developing applications
developing applications, you
well have a
which are very
are very similar
when you're starting
you're starting off
starting off developing
off developing a
developing a new
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
good to build
to build your
build your application
your application from
application from a
from a template
Templates can be
can be accessed
accessed from the
from the drop-down
the drop-down menu
drop-down menu in
menu in the
in the toolbar
list of templates
of templates currently
templates currently available
of the templates
the templates ship
templates ship with
with PowerBasic itself
PowerBasic itself, both
compiler and in
can add your
add your own
your own templates
created a video
a video some
video some time
some time ago
time ago on
ago on template
on template creation
you can find
find that on
that on YouTube
advantage of course
of course in
course in using
in using templates
using templates is
templates is that
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
with a basic
a basic requirement
This requirement may
requirement may well
may well give
well give you
give you most
you most of
the information you
information you need
need to start
to start coding
you start your
start your coding
your coding, it
harm to map
to map out
map out what
to do, even
even just in
just in comments
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
can probably do
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
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
to check any
check any preconditions
any preconditions for
preconditions for the
application to be
to be allowed
allowed to run
wish to check
application is already
is already running
Or there may
be some preconditions
some preconditions by
preconditions by which
wish the application
the application only
application only to
only to run
a particular day
day of the
of the week
We'll take this
this as an
as an example
set this application
this application up
application up, only
the week, we
check the current
simple function to
determine which day
which day we're
day we're actually
looking to check
if the day
the day is
day is Saturday
not a Saturday
a Saturday, then
then we'll send
we'll send a
message to our
log and we
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
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
an I PowerTime
I PowerTime variable
can set IPDate
set IPDate to
IPDate to be
the class PowerTime
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
matches the string
for the day
the day name
using the ipdate.dayOfWeek
the ipdate.dayOfWeek string
ipdate.dayOfWeek string, which
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
with the comparison
the comparison of
comparison of the
of the strings
day name matches
name matches, we
return true, otherwise
running that application
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
Another thing to
thing to take
take into consideration
into consideration with
consideration with your
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
out to where
where it came
it came from
for example, we
information in an
an array within
array within our
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
whole application, in
which case it
case it is
it is functionally
is functionally accessible
functionally accessible within
accessible within any
within any part
we could create
could create an
which is local
is local only
local only to
only to the
the current function
current function or
function or subroutine
There are advantages
are advantages and
disadvantages of doing
doing it either
it either way
moment that we're
go down the
down the route
the route of
route of having
having a global
have declared this
declared this array
this array at
our code, and
calling the array
a single letter
single letter, the
While this will
will work within
work within your
your application, it's
idea to name
to name your
name your arrays
your arrays to
arrays to give
of what they
are and what
and what they're
what they're for
So I would
would suggest that
suggest that you
that you establish
you establish a
establish a naming
a naming convention
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
variable with GA
That's G for
for global and
global and A
A for array
The STR further
STR further indicates
further indicates that
indicates that it's
it's a string
Staff data is
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
that it's an
it's an array
an array, it
indeed a string
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
code is partially
is partially self-documenting
defined that we're
to have this
have this global
have to dimension
to dimension it
dimension it to
many elements it
elements it actually
how many dimensions
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
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
useful to re-dimension
to re-dimension it
re-dimension it using
it using a
For example, %MAX_STAFF
can define this
define this constant
this constant at
And anytime in
anytime in the
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
some point in
the future your
future your application
your application requires
application requires to
requires to change
of 1000 to
1000 to some
to some other
some other value
other value, there
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
an external configuration
external configuration file
configuration file, or
or even in
even in a
in a database
course would give
would give you
advantage of being
of being able
able to change
change the functionality
the application without
application without changing
changing the application
the re-dimensioning of
re-dimensioning of your
of your array
your array can
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
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
function of course
course could get
could get that
that from a
database or from
or from anywhere
the system that
system that had
that had that
had that information
up the global
be storing the
the data, we
get the staff
the staff data
staff data from
data from somewhere
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
up the functionality
the application into
application into smaller
into smaller code
smaller code, functions
And since a
since a function
a function can
function can return
can return a
a value, you
this return value
return value to
value to determine
whether the function
if we're returning
say the function
successful and false
false to say
is not successful
not successful, we
we can report
can report to
report to our
our log that
log that the
that the attempt
the attempt to
load the staff
staff data has
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
When you're fleshing
you're fleshing out
fleshing out this
this function you
function you would
you would of
would of course
of course populate
course populate the
of this prototype
this prototype, where
where we're just
we're just looking
just looking to
to do, this
this stub function
stub function will
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
adjust the staff
the staff of
staff of A
will perform whatever
perform whatever manipulation
whatever manipulation you
manipulation you wish
do on the
then this manipulation
this manipulation has
manipulation has not
not been successful
successful and you
you can exit
returns true, you
can then continue
continue on to
And your final
your final section
final section of
code will be
be to do
do something to
something to save
the data you
data you have
have just finished
just finished amending
again we're taking
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
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
looked at today
is a mechanism
can actually submit
actually submit your
submit your application
your application into
application into different
different sections, each
each section performing
section performing a
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
part of your
your code can
code can actually
can actually determine
actually determine whether
whether it's worth
it's worth continuing
worth continuing or
continuing or not
This combined with
combined with a
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
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
not be so
be so clear
so clear in
clear in six
in six months
six months time
months time when
have to come
come back and
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
the future have
future have to
to pick it
up to do
to do support
find this helpful
this helpful in
helpful in your
in your developments
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
application to run
looking at libraries
they and why
and why you
why you should
be using them?
using them? First
them? First of
console compiler is
compiler is often
is often used
often used to
used to write
to write applications
write applications which
which have little
have little or
little or no
or no user
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
is the processing
the console application
console application we
the moment, you'll
see that I've
that I've highlighted
I've highlighted a
highlighted a line
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
in another code
another code library
code library to
application at compile
This include file
include file can
file can contain
can contain a
contain a great
It can even
can even nest
even nest into
nest into additional
into additional libraries
we have highlighted
have highlighted here
highlighted here is
is the Win32
the Win32 API
Win32 API include
API include file
ships with PowerBasic
with PowerBasic and
PowerBasic and gives
gives you access
the full Windows32
full Windows32 application
Windows32 application programming
When PowerBasic compiles
PowerBasic compiles your
compiles your application
your application, it
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
are then this
then this code
be compiled and
compiled and linked
and linked into
linked into your
your application executable
there are functions
are functions and
functions and subroutines
and subroutines within
subroutines within these
within these included
these included files
included files that
files that are
are not referenced
not referenced within
referenced within your
own code, then
then that code
that code will
code will not
included in your
in your eventual
your eventual compiled
eventual compiled application
This means the
means the size
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
this application we're
be doing lots
doing lots of
lots of file
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
and subroutines will
subroutines will be
will be common
be common to
common to many
to many applications
many applications and
applications and to
save you having
to rewrite them
rewrite them or
them or paste
or paste them
paste them in
them in every
in every time
time you wish
wish to write
write a new
If you include
you include this
include this code
in an include
an include file
include file, you
you can reference
can reference it
reference it in
code and bring
and bring all
bring all this
all this useful
this useful functionality
useful functionality into
functionality into your
added the pb
handling routines include
routines include file
file to our
our application with
application with one
see what that
what that particular
that particular library
particular library has
library has in
in it, we
we can drag
can drag that
drag that into
into our compiler
is the include
include file for
file for pb
for pb file
It contains a
of functions, which
which I've documented
I've documented at
documented at the
So by adding
adding this include
our application, we
can now reference
now reference all
reference all the
functions within this
This means a
means a lot
lot of common
of common functionality
common functionality can
can be included
be included on
included on all
on all of
all of your
of your applications
your applications by
applications by setting
of these library
these library files
working in a
in a team
a team, it
it means code
means code that
have written can
written can be
be used by
used by other
by other members
of course saves
course saves time
saves time because
time because they
because they are
are not reinventing
not reinventing the
reinventing the wheel
the wheel every
wheel every time
every time they
time they want
do something that
something that you
that you or
you or another
or another programmer
another programmer has
programmer has already
has already coded
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
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
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
include file is
file is stated
is stated after
stated after that
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
attempt to compile
this application now
to see just
see just what's
just what's being
what's being included
being included in
included in an
an application, we
can change one
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
and then do
then do another
do another compilation
another compilation, we
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
these are coming
are coming from
Windows API we
API we included
we included at
the beginning, plus
plus our own
our own library
own library files
library files at
see the code
has been extracted
the functions which
functions which have
pulled out of
out of these
library files and
files and included
and included in
of these, as
I said, are
So what's the
what's the advantage
advantage of keeping
of keeping your
keeping your include
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
folder containing your
containing your own
your own executable
own executable, there's
always a danger
a danger that
danger that you
that you will
you will make
make some change
some change to
to a library
a library file
library file and
and not copy
not copy it
copy it back
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
able to access
to access the
access the most
most recent version
So keeping them
keeping them in
them in a
a common location
common location that
location that everyone
that everyone can
everyone can have
can have access
access to, and
and is where
is where you
where you compile
you compile from
compile from, is
is always an
always an advantage
This way your
way your application
application can be
can be built
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
brand new application
new application, one
thing you will
the beginning is
beginning is to
to decide what
decide what libraries
what libraries are
libraries are going
to be needed
be needed within
needed within this
start your development
your development, you
you will probably
will probably have
probably have to
of new functions
new functions which
functions which do
which do not
do not exist
exist within these
within these libraries
If you find
you find these
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
new library, thereby
thereby saving yourself
saving yourself time
yourself time in
time in the
the future and
future and the
time of your
of your fellow
your fellow developers
These libraries of
libraries of course
course can be
can be passed
passed to anyone
to anyone who
anyone who codes
who codes in
codes in Power
that we've looked
console compiler, let's
far as libraries
as libraries are
libraries are concerned
are concerned, you
same thing with
thing with the
console compiler, you
can have your
have your libraries
your libraries in
libraries in the
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
folder above, or
in a hard-coded
a hard-coded network
hard-coded network location
is something else
something else with
else with libraries
with libraries we're
libraries we're going
have four libraries
four libraries here
libraries here, the
handling routines, the
the macro library
macro library, a
a button plus
plus library, and
and a library
a library to
load JPEGs as
JPEGs as bitmaps
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
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
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
we handle this?
handle this? Well
this? Well, we
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
in the button
button plus include
plus include file
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
be loaded within
loaded within your
your application, we
way of taking
of taking this
taking this common
this common code
common code out
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
strip out and
put into its
its own library
The two types
two types and
and the startup
the startup and
startup and the
and the shutdown
we select all
select all these
all these and
these and put
put them in
save this into
into a file
a file called
file called pbgdi
called pbgdi plus
pbgdi plus common
plus common dot
common dot include
want to remove
to remove these
remove these or
these or for
or for the
just comment them
comment them out
them out in
out in here
we'll also load
also load up
the other file
other file which
file which it
it was complaining
was complaining about
within the button
include file we
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
that now it
However you may
may not want
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
have is to
is to include
to include this
include this in
plus library and
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
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
not been included
been included already
application will compile
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
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
And would only
would only include
only include each
include each library
each library once
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
libraries and then
and then test
for that at
that at compilation
Now adding the
adding the simple
the simple once
simple once word
once word after
word after include
after include means
include means you
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
everything in development
in development a
development a lot
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
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
for use and
use and what
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
speed up your
your development significantly
And ideally when
ideally when one
these libraries needs
libraries needs to
be amended either
amended either to
to have new
have new functions
new functions in
functions in it
it or perhaps
or perhaps changing
perhaps changing the
changing the parameters
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
covered this in
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
constant and the
I have declared
declared this local
single letter name
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
will run just
run just fine
creating variables with
variables with names
with names that
do not reflect
not reflect what
reflect what is
what is contained
is contained within
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
string and populating
and populating the
populating the t
can then output
then output the
output the value
that variable to
variable to our
getting a value
value of 33,600
text on screen
on screen, we
we can assume
can assume that
assume that this
that this value
value in t
in t is
t is the
to follow by
follow by putting
by putting each
putting each of
these values into
a variable of
variable of its
But again, as
they are single
are single character
single character variable
character variable names
variable names, it's
particularly obvious what
obvious what they
what they actually
they actually represent
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
variables to explain
to explain what
explain what it
what it means
staff is the
of staff per
staff per department
number of departments
of departments is
departments is set
is set and
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
our log by
log by simply
by simply multiplying
simply multiplying each
multiplying each of
these variables together
variables together and
together and populating
populating our string
give us exactly
us exactly the
But the code
code is now
is now more
now more readable
readable and therefore
and therefore maintainable
So where do
where do constants
do constants come
constants come in?
come in? Let's
in? Let's assume
departments is not
going to vary
point of putting
putting a value
a value into
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
It's set at
set at compile
let's set the
of departments as
departments as a
declared a constant
constant called 'total
called 'total departments'
'total departments' and
departments' and made
and made it
made it equal
it equal to
percentage sign at
sign at the
the name indicates
name indicates to
indicates to PowerBasic
to PowerBasic that
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
the department variable
department variable has
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
your application, when
when your application
application is compiled
is compiled, it
will replace any
replace any reference
reference to total
to total departments
total departments with
departments with the
value held at
the application, in
this case 20
ensures that it
again now, we
we're getting exactly
getting exactly the
used the format
put a comma
a comma in
comma in after
in after thousands
you who are
who are coming
are coming to
coming to PowerBasic
to PowerBasic from
PowerBasic from other
other applications, you
may be used
used to using
to using a
a constant keyword
PowerBasic does not
we can emulate
can emulate it
emulate it by
it by using
by using macros
on screen, we've
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'
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
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
replace the 'total
the 'total departments'
departments' constant string
constant string with
with the 'total
'total departments' VB
departments' VB style
VB style macro
can see, you
use the 'macro'
the 'macro' keyword
'macro' keyword to
keyword to effectively
to effectively extend
effectively extend the
extend the language
we have replaced
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
value of 40
would be quite
be quite easy
easy to replace
replace with a
with a constant
a constant, setting
setting its value
its value to
value to 40
what if the
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
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
to the rescue
If we follow
we follow the
follow the macro
the macro with
macro with the
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
tend to keep
keep this naming
this naming convention
naming convention so
convention so that
so that regardless
that regardless of
how large your
large your application
application is, it's
easy to see
see what everything
what everything actually
everything actually is
see this one
code as being
being a constant
a constant, and
what it contains
it contains is
contains is going
a single, something
something with a
with a decimal
a decimal place
we're making it
making it equal
equal to 375
to 375 divided
375 divided by
divided by 10
application compiles, will
will slot in
in the 'value'
the 'value' here
'value' here into
here into your
into your code
your code, so
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
should get a
get a reduced
a reduced number
reduced number of
hours per week
per week, which
So this handles
this handles numeric
handles numeric constants
numeric constants, either
either using the
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
macro to calculate
to calculate values
calculate values which
which are not
are not whole
not whole numbers
create another constant
another constant, in
this case, TotalRecords
performing a for
next loop, from
to 5, we
we can replace
can replace the
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
to change, you
change one line
have to hunt
to hunt through
hunt through the
whole application to
application to find
find out everywhere
out everywhere the
everywhere the number
number 5 is
5 is used
can output the
output the word
the word 'record'
word 'record' followed
'record' followed by
version of our
of our record
our record number
now run the
application to get
to get 'record'
get 'record' and
'record' and the
well as numeric
as numeric constants
numeric constants, we
also have string
have string constants
wanted to replace
replace this hard-coded
this hard-coded word
hard-coded word 'record'
word 'record' with
'record' with a
a string constant
call it 'record
it 'record label'
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
you need Wide
need Wide or
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
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
your entire application
entire application and
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
Ideally at the
top of your
your code for
code for readability
followed by 'space'
by 'space' followed
'space' followed by
by the record
record number appears
number appears on
have successfully replaced
successfully replaced a
replaced a hard-coded
a hard-coded string
hard-coded string with
string with a
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
value that appears
that appears many
appears many times
many times throughout
times throughout your
throughout your application
application and is
and is not
be changing during
changing during the
the application, a
constant is ideal
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
graphics controls and
controls and images
The dialogue you
dialogue you see
screen here at
moment is to
select a background
a background image
Having selected this
selected this background
this background image
background image, it
then select a
date from the
from the Date
be the target
the target date
target date to
date to which
going to count
to count down
count down to
Next the user
select a text
a text colour
the colour the
colour the text
the text appears
then finally we're
finally we're giving
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
user is happy
is happy with
happy with what
with what they've
what they've selected
they've selected, they
the Save Image
Save Image button
Image button at
This will extract
will extract the
extract the image
image from the
from the graphics
control and save
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
to allow flexibility
allow flexibility, the
application will scan
will scan the
scan the folder
folder and check
how many JPEGs
many JPEGs it
JPEGs it can
it can find
can find in
find in the
display the names
names of these
of these JPEGs
these JPEGs in
JPEGs in the
you wish, more
more images on
on the drop-down
drop-down list, you
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
event handler, we're
that will load
load our image
our image list
passing this new
function to parameters
to parameters, the
new function, loadImageList
be to reset
reset the combo
Resetting the combo
box is always
good idea when
idea when you're
when you're creating
you're creating a
allows the function
the code, ensuring
ensuring that none
that none of
none of the
the previous data
previous data will
data will be
will be still
be still sitting
still sitting in
using the dir$
the dir$ command
dir$ command to
command to sweep
through our current
our current folder
current folder and
folder and look
and look for
look for files
the extension jpeg
by using dir$
be the name
currently in and
in and the
and the extension
the extension we're
extension we're looking
this case jpeg
While the value
by this is
not blank, we
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
should have four
have four entries
four entries on
the files is
files is now
now appearing with
appearing with its
with its file
its file name
file name on
name on our
on our combo
of these entries
these entries on
will then load
then load up
load up that
up that file
that file and
callback function that
handles the events
events on our
combo box, which
the background image
background image list
this is clicked
text that is
box is single
is single select
single select only
select only, you
select one item
one item on
get text quite
text quite easily
using the handle
the current control
current control, which
the CBO background
CBO background image
we're sending that
sending that to
variable called strImage
This identifies the
identifies the name
functions in a
library we've previously
we've previously created
function called loadImageFile
this takes four
the image we
image we wish
return the width
height of that
And finally, it
return a handle
the bitmap, which
which it's loaded
it's loaded the
the image into
used a few
new variables here
variables here, we'll
created these new
these new variables
new variables, let's
code where we're
calling our include
our include files
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
dedicated to loading
to loading a
loading a JPEG
a JPEG in
JPEG in as
as a bitmap
our final library
final library is
library is to
do the reverse
the reverse to
reverse to take
take a JPEG
a JPEG from
JPEG from a
from a graphics
So I'll go
I'll go back
that the load
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
specify the graphics
control on which
on which all
which all the
all the subsequent
the subsequent operations
subsequent operations are
set this to
this to use
redraw option, as
to update things
update things much
things much quicker
And then at
then at the
the end, we'll
redraw to allow
see the completed
the completed image
graphics copy to
copy to copy
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
up the resources
we will redraw
will redraw the
to our dropdown
our dropdown and
dropdown and select
and select one
graphics control populated
control populated with
with the image
image on our
control is only
is only part
only part of
the full image
because the image
image is larger
than the graphics
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
another graphics command
And this graphics
this graphics command
graphics command is
the graphics stretch
graphics stretch page
stretch page command
us to resize
resize the bitmap
the bitmap to
bitmap to fit
fit the graphics
itself and two
and two additional
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
way of detail
if that's made
that's made a
made a difference
And we select
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
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
taken a jpeg
a jpeg file
jpeg file from
folder and displayed
displayed it in
graphics control, adjusting
adjusting the size
of the bitmap
So that's stage
that's stage one
out our dates
date control will
control will allow
to select dates
select dates quite
dates quite happily
but the next
capture the dates
the dates from
dates from the
callback function we're
one we're declaring
we're declaring is
declaring is static
be the end
end date that
date that the
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
date control, we
determine what they've
what they've actually
they've actually done
at the notify
to populate, first
of all, one
of the pointers
you to put
to put multiple
put multiple date
multiple date controls
date controls on
screen and be
and be able
able to determine
which one the
one the user
we've determined which
determined which date
which date control
date control the
has selected, we
in a date
a date time
date time change
populate our end
our end date
end date by
date by picking
from our pointer
our pointer for
the month and
month and the
and the year
using the UK
UK format of
format of dates
of dates throughout
dates throughout this
throughout this application
use the American
the American format
American format, feel
free to actually
actually move these
move these around
allow the code
actually changed the
changed the date
application loads initially
loads initially, we
set the date
the date as
date as being
So we'll pop
to our initialization
our initialization dialog
put two lines
populate the str_end_date
the str_end_date variable
application which returns
returns the UK
the UK date
UK date in
date in day
in day, month
If you're using
using the American
free to change
to change and
change and replace
and replace this
replace this function
second function is
date in a
Strictly speaking, we
need this one
in here because
here because when
because when the
control will have
have the current
in it anyway
it's a useful
a useful function
useful function to
to have as
have as it
as it allows
date control at
control at any
any point during
point during the
during the application
that far with
far with the
the code, our
text colour drop-down
select the colour
colour that they
that they want
they want the
text to impose
to impose on
impose on top
initialization dialog section
dialog section, we
add some text
some text colour
text colour options
There's two pieces
of information needed
information needed here
text name for
example red, white
and green, and
Combo boxes allow
boxes allow you
you to store
text which appears
which appears to
also a value
value which can
be a long
long variable stored
variable stored in
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
populate these arrays
As they're quite
they're quite small
quite small arrays
small arrays, it's
assign command, giving
giving the four
the four values
four values that
we want placed
want placed in
placed in those
in those arrays
up some more
more variables at
the items selected
items selected from
combo box, we
of the selected
selected text colour
text colour, and
two arrays for
arrays for the
text colour and
set these arrays
these arrays up
arrays up, we
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
combo box, the
string value you
value you wish
put in to
and which item
which item on
the list this
list this is
when you're adding
you're adding the
adding the first
it would return
would return number
return number one
If the combo
sorted alphabetically, then
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 list, as
as item one
item one will
will be moved
be moved down
moved down to
down to item
to item two
item two because
because it's now
it's now sorted
trapping the item
item that it
that it gets
it gets added
gets added as
added as, because
because we'll need
we'll need that
need that for
is the combo
combo box set
box set user
set user command
save the value
combo box of
box of our
of our colour
our colour, red
application now, our
box for the
for the colours
the colours should
colours should be
should be populated
be populated, which
is to apply
to apply text
apply text to
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
we'll do as
do as we
did before, we'll
we'll capture from
capture from the
box the name
name that the
has selected, and
populate the graphics
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
into a common
have that completed
that completed, we
to get what
get what the
user selected for
use the combo
combo box get
box get select
return the item
is zero, it
means the user
user has yet
has yet to
yet to select
So in that
that case, we'll
we'll default it
default it to
it to item
to item number
item number one
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
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
long text colour
text colour variable
want to apply
to apply a
apply a piece
of text to
that function apply
function apply countdown
apply countdown text
countdown text, taking
graphics control handle
end date the
date the user
the long value
long value of
our new apply
new apply countdown
countdown text column
number of days
of days between
days between the
between the current
current date and
the date the
selected on the
on the date
will then take
then take that
take that information
that information, form
form up a
text and put
put it onto
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
date and one
the forward date
forward date that
store the text
out where on
control we're actually
to be positioning
be positioning this
positioning this piece
take the end
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
passed in to
in to this
populate the current
the date that
using the today
the today and
today and the
new date methods
date methods in
methods in our
in our class
So today picks
today picks up
New date picks
date picks up
use the time
the time diff
time diff method
diff method for
method for working
days between these
these two dates
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
that by first
by first using
first using a
graphics operations will
operations will be
the text fairly
text fairly large
fairly large so
large so it
seen by using
a graphics set
set a font
a font up
using the font
I've specified courier
specified courier new
courier new as
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
dialogue is closed
closed down we
can then do
do a font
a font end
font end command
end command which
which will free
will free up
space used by
So we're also
graphics color command
Using the passed
the passed in
passed in value
in value for
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
background as it
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
of days can
days can either
either be 1
be 1, 2
2 or possibly
or possibly even
possibly even 3
even 3 characters
3 characters length
characters length, the
length of our
text is going
to vary depending
vary depending on
the date selected
date selected by
just how wide
how wide this
wide this piece
is in order
order to centre
to centre it
centre it in
the graphics commands
the graphics command
graphics command with
command with text
with text size
text size X
size X and
string containing the
control will return
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
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
us exactly where
exactly where we
to start printing
then set that
that value using
value using the
graphics set POS
set POS command
POS command and
command and then
and then print
then print our
then redraw this
redraw this to
see what displays
can set our
set our background
our background image
background image, we
pick a date
a date, we
set our text
our text colour
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
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
the graphics colour
graphics colour command
colour command we're
we're using minus
using minus one
we change this
to a minus
a minus two
minus two and
two and run
once more, select
select our image
our image, pick
pick our date
our date, select
select the text
colour and apply
and apply to
Now the background
text is completely
is completely transparent
completely transparent, making
making it much
see the text
a date, calculate
calculate the number
date and that
and that date
that date, display
display that information
that information on
allow the save
image button to
save the updated
the updated graphics
updated graphics control
graphics control back
control back to
to disk as
our code I've
code I've set
constant to name
to name our
name our output
We could of
could of course
course put something
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
call it test.jpg
event that is
that is triggered
on the create
the create image
create image button
clicks on our
on our create
our create image
image button we
button we want
save the graphics
control to disk
got a new
new function that
function that will
that will perform
perform that in
that in one
is called save
called save graphics
save graphics control
pick our background
pick our text
And we apply
we apply that
apply that to
image button let's
button let's have
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
created a graphics
graphics control, populated
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
any other content
other content within
content within a
within a graphics
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
a long way
name suggests the
suggests the data
the data command
data command is
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
data is embedded
is embedded within
embedded within the
application should that
should that data
that data require
data require to
be changed then
changed then you
then you will
to amend your
application and recompile
This isn't necessarily
isn't necessarily a
necessarily a problem
problem if you
using the data
data commands to
commands to store
to store data
store data that
that is changed
is changed very
changed very infrequently
Most modern applications
modern applications store
applications store the
data in databases
in databases outside
databases outside your
outside your binary
your binary executable
store information within
to be build
be build data
The data statement
data statement is
statement is used
used for keeping
for keeping track
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
list of strings
of strings in
strings in this
case eye colours
amber and grey
So these six
these six pieces
six pieces of
pieces of data
data are stored
are stored within
can we access
we access them?
access them? Well
them? Well first
of entries in
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
going to cycle
through each one
of these pieces
data to pull
be doing that
doing that by
data items using
items using the
through a for
loop for lngR
loop we are
read from our
data statement and
statement and add
add the information
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
element that you
we are reading
are reading each
reading each of
the entries from
entries from 1
from 1 up
1 up until
until the total
of entries which
entries which is
which is 6
these strings a
strings a comma
be a trailing
a trailing comma
trailing comma in
comma in the
we are returning
are returning I
returning I am
I am using
am using the
using the rtrim
the rtrim command
rtrim command to
trim the rightmost
the rightmost comma
rightmost comma from
comma from the
from the string
can return that
return that data
So having returned
having returned the
returned the data
calling function we
put this out
log to see
it will push
will push out
the data statements
that the quotes
the quotes we
quotes we had
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
of the eye
color and each
of the names
the names is
names is separated
is separated by
we do if
do if we
add more data
the build data
build data function
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
command will read
will read all
read all the
data statements within
statements within the
within the subroutine
the subroutine or
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
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
limitations to the
data statement which
statement which you'll
which you'll have
you'll have to
to watch out
watch out for
In other parts
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
of each subsequent
each subsequent line
subsequent line until
line until you
until you get
you get to
the end prefix
end prefix command
in many cases
many cases can
cases can save
can save you
However the data
data command does
command does not
does not support
not support prefix
support prefix if
prefix if we
we tried to
tried to compile
It would generate
would generate an
Saying data may
data may not
not be used
used with the
Also if you
if you attempt
attempt to use
use the underline
fold down the
down the data
following line this
line this will
this will also
will also not
also not be
not be accepted
more data merely
data merely add
merely add more
more data statements
you'll see for
see for this
data we've put
here the words
the words more
words more test
more test and
word data in
data in double
application now you
now you will
will see you
see you are
are actually getting
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
subroutine or a
or a function
called from anywhere
from anywhere in
anywhere in your
your application pulling
application pulling back
the data as
data as a
as a return
return from a
from a function
However as I
as I have
I have said
have said if
said if you
to change any
change any of
data in these
in these data
these data statements
data statements you
statements you will
have to edit
to edit your
edit your source
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
into a dynamic
a dynamic link
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
applications making use
you have within
have within it
up the Power
compiler and compile
and compile a
compile a DLL
a DLL just
DLL just to
just to perform
perform this purpose
the create new
create new file
new file and
file and we'll
create a DLL
a DLL framework
DLL framework using
using a lib
a lib main
We'll save this
folder as of
as of application
of application and
the file libdata.bas
will return some
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
exported as string
will allow this
allow this function
called from outside
to put much
put much the
same code in
in here as
here as we
data line with
line with the
six eye colours
I've additionally put
additionally put an
an extra piece
of text at
the beginning saying
beginning saying DLL
saying DLL just
data is coming
from a DLL
is purely so
purely so we
see the difference
the difference on
difference on screen
data line and
we're using data
using data count
data count to
many entries we
entries we have
have in data
in data within
compile that, that
give us our
us our DLL
we compile on
compile on the
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
the library name
library name in
name in this
this case libdata.dll
case libdata.dll and
libdata.dll and the
and the alias
the alias the
alias the name
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
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
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
is the i-colors
the i-colors followed
i-colors followed by
followed by some
by some numbers
from the DLL
the DLL, as
can tell because
tell because we
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
we've embedded some
embedded some data
some data within
data within some
within some data
some data statements
statements within a
the main application
We then used
then used the
used the read
to read that
read that data
out and return
calling function so
our console log
We've also taken
also taken the
taken the same
same data statements
data statements and
statements and created
and created a
keep the DLL
and its data
its data quite
data quite separate
quite separate from
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
on the log
Data statements can
statements can be
be a useful
a useful way
useful way of
way of embedding
of embedding data
embedding data within
data within applications
But as with
with all approaches
all approaches to
approaches to data
to data processing
data processing, you
see how often
how often this
often this data
be a regular
a regular update
regular update, then
then possibly a
possibly a data
a data command
command is not
not the place
the place to
place to store
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
look at graphics
at graphics windows
be looking again
at the graphics
want this application
be run either
run either in
the console or
console or the
windows compiler, we're
here to turn
to turn off
off the console
the console if
console if we're
if we're running
we're running under
running under the
under the console
are running under
console compiler the
compiler the console
console will not
will not appear
and display a
display a graphics
All graphics windows
graphics windows require
windows require a
require a handle
a handle by
handle by which
can control them
control them, so
variable for that
for that handle
create our graphics
to reuse a
reuse a piece
used in a
a previous program
previous program to
program to set
set the windows
the windows position
windows position to
to be topmost
will ensure our
ensure our graphics
window is visible
user and it
it will appear
appear on top
we've now displayed
now displayed the
displayed the graphics
graphics window we
window we want
instructs the application
application to direct
to direct all
direct all graphics
graphics commands to
commands to this
to this specific
this specific window
option to buffer
to buffer any
buffer any commands
any commands going
commands going to
graphics window not
window not to
this would display
would display a
graphics window on
window on our
on our monitor
So having displayed
having displayed this
displayed this graphics
this graphics window
window to the
user we'll want
display some text
some text upon
text upon it
see we're going
make the text
the text a
text a little
a little bigger
little bigger by
bigger by setting
up a font
handle for our
for our font
specify that the
that the font
font we want
use is Courier
is Courier new
Courier new 18
new 18 point
We're next going
going to clear
graphics window, set
to be light
be light grey
light grey, then
colour command to
command to say
say any text
any text going
text going to
going to that
to that graphics
that graphics window
be a foreground
a foreground colour
foreground colour of
colour of black
of black and
black and a
and a background
a background colour
background colour of
colour of light
of light grey
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
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
were no further
no further commands
further commands in
commands in the
function to execute
to execute so
execute so the
application would end
put a loop
a loop in
loop in at
end to wait
be closed by
closed by the
function called isWindow
This takes as
single parameter the
parameter the Windows
Windows handle we
handle we had
had created when
created when we
we're running round
running round this
this loop every
loop every second,testing
every second,testing to
second,testing to see
whether the window
window has indeed
indeed been closed
see a graphics
graphics window successfully
window successfully appears
successfully appears on
displayed the two
it's now waiting
now waiting for
waiting for the
to click X
click X on
X on the
window to close
close the window
in the taskbar
the taskbar there
taskbar there is
an icon showing
icon showing for
showing for our
graphics window it
window it will
from the taskbar
the taskbar so
taskbar so the
has now terminated
will have seen
have seen the
seen the icon
the icon used
icon used for
application and on
graphics window itself
window itself is
itself is a
a default graphic
with a graphic
a graphic of
graphic of our
our own choice?
own choice? Well
choice? Well in
Well in the
the folder I've
folder I've created
an icon called
icon called grid
called grid icon
use this icon
this icon both
icon both for
application and for
display the graphics
to this extract
this extract icon
extract icon API
The extract icon
icon API call
API call takes
call takes three
parameter is for
for the module
the module handle
we use get
use get module
get module handle
module handle and
handle and as
and as its
its parameter an
parameter an empty
length string it
string it will
get the module
module handle of
application we're currently
we're currently running
Next we give
it the name
Finally we give
the parameters zero
will return an
return an icon
an icon handle
icon handle and
the same message
same message command
message command to
set that icon
that icon as
icon as small
as small on
small on the
using another handle
another handle only
handle only to
only to declare
declare this one
one up at
see our graphics
graphics window now
window now has
now has an
has an icon
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
a second graphics
second graphics window?
graphics window? How
window? How do
do we go
ahead and do
and do that?
do that? As
that? As we've
before we use
graphics window with
window with the
the text second
text second graphics
second graphics window
window and we're
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
using the set
the set windows
set windows position
windows position API
position API call
call to make
make the window
the window topmost
this new window
new window using
window using the
using the win
the win to
win to handle
same font as
font as the
the first window
the graphics background
graphics background and
background and we're
words more data
our second graphics
draw the graphics
the graphics to
graphics to our
our second window
second window if
window if we
now see there
are now two
now two graphics
two graphics windows
graphics windows on
windows on the
With the second
the second graphics
graphics window having
window having the
having the text
the text more
text more data
then move the
move the graphics
the graphics windows
graphics windows around
windows around the
the screen quite
screen quite happily
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
for the closure
the closure of
closure of the
first graphics window
having displayed two
displayed two graphics
graphics windows what
windows what if
put more text
more text onto
onto the first
We can reattach
can reattach the
reattach the first
first window by
window by simply
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
ensure the user
to see this
see this we
this we can
see our both
our both graphics
both graphics windows
graphics windows have
windows have appeared
have appeared and
first window has
indeed got yet
got yet more
yet more data
more data on
data on it
graphics window any
window any attempt
any attempt to
attempt to close
close the first
window will of
of course will
course will close
close the other
the other graphics
other graphics window
window and terminate
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
the graphics splash
graphics splash progress
splash progress library
progress library which
which we covered
one is designed
designed to display
progress bar on
the screen for
be a third
a third graphics
third graphics window
window we will
will need yet
need yet another
yet another handle
variable for this
for this third
this third graphics
within the new
new library we've
library we've just
we've just added
This will open
open up a
up a graphics
window with some
with some text
some text on
it and a
and a progress
position the graphics
graphics window at
window at the
the coordinates relative
coordinates relative to
the other windows
other windows we
windows we can
call to ensure
it is displayed
user and top
and top of
be a progress
progress bar we
bar we want
call a little
display some progress
some progress on
progress on the
function called report
called report progress
report progress and
progress and this
parameters as it
will be writing
be writing to
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
the screen saying
screen saying still
saying still processing
still processing and
processing and when
when it gets
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
calling another function
library to update
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
now successfully displayed
successfully displayed three
displayed three graphics
three graphics windows
windows on a
on a user's
a user's screen
But can we
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
load an image
an image onto
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
load a jpeg
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
handle for a
for a bitmap
have that handle
that handle we
quite happily load
happily load the
load the memory
the memory bitmap
memory bitmap onto
bitmap onto the
need some variables
some variables for
variables for this
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
the handle itself
called loadImageFile which
loadImageFile which is
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 bitmap itself
So should this
should this function
this function return
function return true
return true, in
case it has
has successfully loaded
loaded the jpeg
the jpeg and
jpeg and turned
and turned it
turned it into
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
the correct window
will copy our
copy command has
command has several
has several options
case all we're
doing is taking
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
100 by 100
by 100 inside
100 inside the
inside the graphics
display our graphic
graphic to the
Having completed the
completed the copy
the copy we
copy we can
the graphic bitmap
graphic bitmap end
end command to
command to free
used by working
by working on
working on the
on the bitmap
Then we could
could use the
redraw command again
again to display
display the bitmap
bar appears as
appears as before
as before and
before and once
and once it
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
have used graphics
used graphics commands
create three separate
three separate graphics
separate graphics windows
the user's monitor
Two of them
them have text
third is set
set as a
as a progress
bar and we
have additionally positioned
additionally positioned the
positioned the jpeg
the jpeg as
jpeg as a
So using these
using these commands
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
of searching large
searching large arrays
a time in
time in your
your development of
development of applications
of applications when
applications when you
need to deal
to deal with
deal with a
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
you get the
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
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
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
yet to develop
to develop, and
have a folder
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
these files stores
files stores raw
stores raw data
For example, 'Cities'
The cities has
cities has a
has a selection
selection of fictional
of fictional cities
is the seed
the seed data
seed data we're
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
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
of records of
data that this
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'
from this application
file called 'myLargeFile.Text'
Everything is done
is done within
within the 'Generate
the 'Generate File'
'Generate File' function
of arrays to
arrays to store
held within those
within those files
those files we
files we just
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 header, this
you require a
require a comma
comma delimited file
delimited file, just
substitute a comma
a comma string
comma string for
string for the
the tab constant
next part in
part in the
to load each
load each of
of these static
these static files
static files, these
these seed files
seed files, into
its own array
have populated those
populated those arrays
those arrays, we're
loop for one
for one to
Generating the information
information and pushing
and pushing it
pushing it out
delete the 'myLargeFile.Text'
the 'myLargeFile.Text' that
'myLargeFile.Text' that currently
currently sits in
sits in the
and we double-click
the executable, it
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
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
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
actually got a
got a text
in here, let's
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
load into one
into one large
one large array
large array inside
array inside our
inside our Power
to try three
try three different
different methods of
methods of actually
of actually searching
actually searching out
searching out data
to consider the
consider the unique
reference to our
to our record
our record to
record to be
be the email
email address, which
an array into
our libraries, the
Routines Library, to
load this file
this file into
into our selected
our selected array
The 'read the
an array' function
array' function, which
the file, and
the second, the
the array sort
array sort command
sort command to
command to sort
our array in
array in ascending
ascending order, starting
starting from row
from row number
Row number zero
number zero are
zero are the
we'll leave them
leave them at
the array, we're
to try and
try and search
and search some
search some data
I will create
another constant at
our application called
application called 'search
called 'search string'
is the email
for within our
As the array
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
down the file
us a good
function to search
to search using
search using a
that function 'search'
function 'search' or
'search' or 'next'
or 'next', taking
array we want
to search, and
being the constant
constant we're passing
we're passing into
passing into that
into that function
that function for
function for what
for what we're
case the email
email address of
know how long
actually search this
search this, we
have some kind
kind of metric
of metric in
metric in here
get a good
a good metric
good metric, I'm
command that measures
that measures the
measures the clock
cycles of our
of our CPU
easily by defining
by defining a
defining a variable
can start our
start our count
our count by
count by using
tix command, followed
then once our
once our function
our function has
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
a log to
long that took
So now let's
now let's create
create the for
next loop function
A by-reference array
by-reference array as
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
know how big
big the array
the array actually
array actually is
actually is, the
u-bound command is
return the upper
records within it
have to compare
to compare the
compare the information
array with our
with our search
long r element
r element of
array will give
the full data
full data for
that record, including
including the email
email address, the
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
of the email
email address, so
using the len
long the search
the search string
search string is
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
doing this kind
kind of comparison
of comparison, it's
we know what
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
we know our
know our entry
our entry has
entry has been
been found, and
can display some
what we found
we found and
found and what
that point, we
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
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
a string we
can display in
display in 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
find that entry
baseline for using
for using a
loop to search
to search data
search data out
data out from
the large array
at a second
a second way
second way for
way for searching
for searching our
our data from
data from an
from an array
perform this, and
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
and the search
search string we're
string we're actually
And after that's
after that's run
that's run, we
we will report
report on a
CPU cycles used
new function, passing
two parameters and
parameters and reporting
and reporting in
reporting in the
see we're searching
we're searching array
searching array scan
scan command, which
to tell array
tell array scan
this case, strData
don't know all
know all the
the record, we
to look, in
this case, at
first column, from
first character on
character on that
on that record
that record for
record for the
scan command does
option for scanning
for scanning particular
scanning particular character
particular character positions
character positions, and
That's the from
can go from
As our search
string is an
is an email
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
following line so
line so you
see it all
it all on
all on one
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
the parameter that's
parameter that's been
for our function
our function, the
search string variable
a value, we're
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
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
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
first glance, it
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
and final method
final method of
method of scanning
of scanning this
scanning this array
With an index
index search, the
is to index
to index the
index the array
be a slight
a slight bit
slight bit of
bit of overhead
of overhead on
overhead on the
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
clock cycles we're
cycles we're going
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
first field in
setting the delimiter
the delimiter as
delimiter as being
being a tab
to use delimiters
use delimiters other
delimiters other than
other than tabs
create an index
an index array
idea behind an
behind an index
index array is
array is that
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
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
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
more than that
than that and
that and go
and go up
last one of
one of B
a start and
start and an
an end index
end index for
index for each
for each letter
each letter A
letter A 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
then you should
able to search
to search only
search only 1
only 1 address
1 address you're
address you're looking
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
is taking a
want to index
to index, the
being the index
the index itself
index itself, and
are the unique
the unique field
unique field number
field number and
and the delimiter
delimiter in our
in our records
after that, we
will end our
end our clock
our clock counting
clock counting and
counting and display
CPU cycles it's
cycles it's taken
it's taken to
taken to generate
to generate this
generate this index
create the index
the index array
index array function
with its parameters
This function assumes
function assumes that
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
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
unique ID variable
The unique ID
unique ID is
ID is pulling
first column, based
In this scenario
this scenario, this
email address, but
but it could
it could quite
easily be the
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
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
using the ASCII
the ASCII command
ASCII command to
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
the first slot
first slot in
whether the value
of the index
index has actually
actually changed from
the previous one
can save the
save the details
details to our
to our indexed
our indexed array
using two constants
two constants here
constants here for
and end, just
just for documentation
And by the
time we get
very last value
last value in
up that and
that and mark
and mark its
mark its index
its index end
index end as
end as being
these two constants
two constants at
Index start and
start and indexed
and indexed end
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
of the original
the original searches
original searches combined
have to index
to index this
index this array
this array once
and make use
of this index
function called search_indexed
The two we've
two we've had
we've had for
had for the
the previous functions
previous functions, and
the additional parameter
additional parameter is
parameter is our
is our index
our index, the
have just generated
once that function
function is complete
is complete, we
will then throw
then throw out
cycles to our
create this final
taking in these
in these three
data array, the
search string and
string and our
and our indexed
the previous fornix
previous fornix loop
fornix loop, we're
create a fornix
fornix loop in
loop in here
when we indexed
we indexed the
indexed the array
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
to come into
And having determined
determined that slot
that slot number
slot number, we
from the indexed
the indexed array
indexed array the
array the start
and end row
end row numbers
row numbers, which
it's a straightforward
a straightforward matter
straightforward matter of
But rather than
rather than scanning
than scanning the
scanning the whole
whole array, we're
we're only scanning
only scanning for
scanning for the
and end rows
end rows that
rows that we
know that this
this particular email
particular email address
email address should
address should be
should be sitting
be sitting in
an entry, we
can then throw
then throw a
throw a message
which row number
row number we
we found it
found it on
have our scans
our scans in
scans in place
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
generate the index
So to answer
to answer the
answer the question
the question which
question which of
three methods is
methods is the
most efficient way
way of scanning
of scanning large
scanning large data
large data, it
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
looking for only
for only one
only one record
record in a
a large array
large array, then
then either the
either the for
next loop or
loop or the
or the array
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
is the easiest
the easiest and
easiest and fastest
and fastest way
of actually getting
actually getting it
getting it to
it to run
to run quickly
easily see that
see that by
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
looking for two
So we paste
we paste in
paste in a
a second call
second call to
to the search
the search for
search for next
for next and
next and the
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
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
give you food
for thought in
thought in developing
in developing your
developing your applications
applications where large
where large data
large data is
data is involved
to use Link
use Link List
Link List Collections
List Collections within
Collections within your
again at collections
at collections under
collections under PowerBasic
under PowerBasic supported
PowerBasic supported, both
compiler and Windows
prepare a list
a list collection
can start this
start this by
this by declaring
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
done with previous
with previous videos
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
into and take
and take data
take data out
of this collection
variant to contain
contain our data
data is simply
is simply going
simply going to
a text string
text string called
string called test
number of methods
of methods and
methods and properties
and properties with
properties with this
this particular class
But first of
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
created the collection
the collection the
collection the collection
the collection will
collection will be
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
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
Since our collection
our collection is
collection is entirely
entirely empty this
empty this should
this should return
should return zero
does indeed return
indeed return the
value zero for
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
variant which contains
to write our
write our log
our log again
log again to
the collection which
collection which should
now return the
So our data
our data has
data has now
add another piece
another piece of
will then attempt
attempt to pull
a new string
new string to
string to our
collection and we're
So we declared
we declared a
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
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
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
see it's very
easy to pull
to pull all
pull all the
the collection using
collection using a
the collection how
collection how do
we go about
go about inserting
about inserting a
inserting a new
a new item
new item between
item between items
between items one
items one and
one and two
use the insert
the insert method
insert method with
method with an
an index number
variable called index
that to two
to two and
two and we'll
and we'll use
insert method to
method to insert
new data at
at the second
the second item
second item position
will take what
take what is
what is currently
currently in item
in item two
item two and
two and move
move it down
it down to
to item three
So our collection
our collection will
collection will now
will now have
have three items
three items in
items in it
new data will
will be item
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
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
videos to make
readable and a
What this macro
macro will do
will take all
take all the
the macro and
macro and put
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
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
our collection on
collection on the
the macro temp
macro temp construct
It's followed by
by a declaration
a declaration of
declaration of that
calling this macro
this macro multiple
macro multiple times
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
as you're attempting
you're attempting to
attempting to declare
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
a programmer having
programmer having to
having to worry
to worry about
worry about this
about this issue
So following that
following that we
a for each
for each next
each next loop
is pulling information
our list collect
list collect collection
collect collection putting
collection putting it
into the item
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
it in after
in after our
after our last
our last commands
last commands and
commands and this
this should send
should send the
send the information
information that's now
that's now in
in a collection
a collection out
collection out to
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
Test2 data has
has been moved
been moved down
the third item
third item and
item and our
and our macro
our macro is
macro is working
nicely to display
to display what's
display what's in
So having built
up a collection
collection of three
of three items
three items can
items can we
we now delete
now delete an
delete an item
an item by
item by index
by index position
perform a deletion
a deletion by
deletion by specifying
specifying the index
the index we
index we wish
remove the first
first item in
item in our
calling the remove
remove method and
method and we're
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
first item which
item which was
which was the
was the test
the test string
test string has
string has now
has now disappeared
now disappeared from
disappeared from our
collection and we
now have only
have only two
only two items
two items left
items left in
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
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
in to that
that particular index
particular index place
code now you
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
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
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
zero in the
current index and
index and we
items in a
a collection by
collection by using
by using count
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
position for new
for new data
be inserted into
the collection is
collection is 2
is 2 so
2 so the
next free slot
free slot would
slot would be
would be slot
be slot number
slot number 3
let's add some
data to collection
to collection to
collection to make
created a for
variant with the
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
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
on the collection
the collection now
the last position
last position in
position in our
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
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
the beginning using
beginning using next
using next or
next or from
or from the
last entry using
entry using last
using last and
last and previous
let's start from
start from the
from the other
the other end
other end of
collection and set
very first item
Easily done by
by using listcollect.first
then pull out
the first by
first by using
using the next
next command and
next one on
the list coming
list coming out
coming out using
out using next
using next once
next once more
first item comes
item comes out
comes out as
out as newer
as newer data
newer data and
the next as
next as test2data
has successfully moved
successfully moved the
moved the index
the index back
index back to
However what if
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
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
our collection as
collection as we've
we'll now prepare
now prepare an
array and add
and add this
we are dimensioning
are dimensioning an
dimensioning an array
array with three
with three elements
three elements going
elements going from
0 to 2
to 2 as
2 as a
as a dynamic
dynamic string array
can then assign
then assign values
assign values to
values to those
to those three
those three elements
three elements using
So we're assigning
we're assigning a1
assigning a1 b1
a1 b1 and
and c1 to
c1 to those
three elements within
elements within that
then populating our
our variant by
variant by let
by let item
let item input
item input equals
input equals and
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
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
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
support this we're
to be coming
from the variant
our macro temp
macro temp list
temp list two
list two additional
two additional values
be using and
using and one
for a for
next loop count
will dimension those
dimension those underneath
It's important that
important that we
that we dimension
a zero element
zero element array
before we're still
still using for
for each to
each to go
go through each
element within our
variant which is
same construct we've
construct we've used
previous videos for
videos for collections
statement to test
If the variant
variant type is
type is both
is both dynamic
both dynamic string
dynamic string and
and array we
array we know
string of a
of a coming
a coming out
If it's just
just a dynamic
dynamic string then
handle that as
that as we've
done before by
before by sending
by sending the
sending the message
the message out
the log using
log using variant
using variant dollar
variant dollar to
dollar to convert
convert the variant
the string array
string array we're
array we're using
with the variant
the variant data
next loop going
lower bounding of
array we've just
we've just received
just received to
received to the
This allows it
allows it to
array we're pushing
we're pushing the
pushing the information
created this macro
this macro we
macro we can
now call this
call this after
this after our
after our collection
our collection has
collection has been
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
successfully added both
added both dynamic
both dynamic strings
strings and an
array to our
created a linked
a linked list
linked list collection
We've shown we
shown we can
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
next commands to
commands to step
the collection one
collection one item
quite easily step
easily step through
the entire collection
entire collection by
loop and we've
and we've demonstrated
we've demonstrated the
demonstrated the use
use of macros
of macros to
macros to save
save you time
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
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
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
to this version
this version of
version of Linux
of Linux Mint
Linux Mint is
Mint is Wine
Wine is an
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
of the Linux
the Linux system
Linux system to
system to perform
to perform the
perform the actions
the actions you
actions you wish
wish in the
we have plugged
have plugged in
plugged in a
in a USB
a USB drive
couple of PowerBasic
PowerBasic applications on
applications on them
These applications have
applications have not
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
up a folder
a folder on
on our USB
our USB drive
is the AutoForm
the AutoForm project
AutoForm project we've
project we've run
we've run in
application has two
has two executables
two executables, a
a FormRunner application
FormRunner application which
application which gives
the forms you
forms you can
run the FormRunner
the FormRunner, it
will run and
run and display
dialog is showing
is showing the
showing the two
the two configuration
two configuration files
the first configuration
first configuration file
file and click
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
the configuration is
configuration is stored
stored in an
see the dialog
dialog has successfully
has successfully appeared
successfully appeared on
Each object on
dialog is configured
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
icon on which
can click to
click to give
forms currently keyed
from this, this
this PowerBasic Windows
Windows application appears
application appears to
Let's just go
just go to
currently unpopulated, and
And finally we'll
finally we'll change
we'll change the
change the date
OK button, this
this should save
And it should
now be displayed
Linus user, So
So the running
running of our
of our PowerBasic
our PowerBasic Windows
to be successful
So let's come
let's come out
application and let's
and let's try
try running a
running a console
into the associated
the associated arrays
associated arrays, we
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
we got when
got when we
when we ran
we ran it
ran it on
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
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
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
all in a
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
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
our recent videos
recent videos we
videos we have
used macros, but
but this will
the first video
first video in
video in which
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
macro is a
a powerful text
powerful text substitution
text substitution construct
substitution construct that
construct that, as
have said, can
used in three
in three ways
single line macro
line macro, a
a multiline macro
multiline macro, or
or a macro
a macro function
video is going
cover the single
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
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
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
and especially where
especially where someone
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
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
Basic that the
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
should be more
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
the code? What
code? What we
screen now is
message to send
pi to our
So you'll see
you'll see in
have referenced mPI
When you go
you go to
go to compile
your application, the
the text mPI
text mPI is
mPI is replaced
is replaced with
with the actual
actual value of
For example, this
This keeps your
keeps your code
code quite clean
quite clean and
clean and succinct
using the str$
the str$ command
str$ command to
turn this numerical
this numerical value
numerical value into
have used the
used the optional
optional parameter, comma
comma 18, to
want this to
this to 18
to 18 significant
prints out 18
out 18 significant
significant digits with
digits with a
a macro in
macro in this
this way allows
way allows you
you to effectively
can be easily
be easily demonstrated
easily demonstrated by
demonstrated by another
by another use
another use of
What we've put
put on screen
screen is macro
is macro, n
n release package
release package equals
package equals macro
may take you
take you a
you a moment
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
compile your code
your code, any
any evidence of
evidence of the
of the mReleasePackage
the mReleasePackage will
mReleasePackage will be
actually use this?
use this? Say
this? Say for
store two pieces
store the build
build version and
version and the
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
is effectively extending
effectively extending your
extending your language
your language to
language to have
to have anything
have anything you
into a macro
would we reference
the code? If
wanted to send
send this to
our log, we
of text out
text out saying
out saying 'release
saying 'release build
'release build version
build version equals'
version equals' and
equals' and then
use the word
to be already
be already set
the value alpha
value alpha build
And the ver
the ver number
ver number is
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
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
the language type
language type you
type you can
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
code we wanted
local variable, in
variable called 'strData'
a default value
list of five
of five numbers
well be something
be something you'll
something you'll do
you'll do in
And you may
you may prepare
may prepare several
prepare several variables
several variables with
the same default
same default values
values to be
be changed later
changed later on
is there an
there an easier
an easier way
easier way of
way of using
set these default
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
up this construct
this construct for
construct for you
is the construct
the construct we're
construct we're going
call our macro
our macro 'mPrepFormat'
code here, it
a parameter, 'strVariable'
But unlike functions
unlike functions and
and subroutines, you'll
see the type
type of this
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
pass in as
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
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
declaration of the
to make whatever
make whatever that
whatever that variable
that variable is
variable is equal
to our comma
our comma delimited
of five values
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
in our single
single line 'macro
line 'macro mPrepFormat'
Containing the name
wish to first
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
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
This becomes particularly
becomes particularly useful
particularly useful if
useful if you're
of different variables
different variables, all
to be prepared
be prepared in
prepared in the
For example, we're
to prepare three
prepare three additional
three additional variables
additional variables, data2
data3 and data4
to set data4
set data4 with
data4 with a
different format, so
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
to be putting
be putting into
putting into that
we're using local
using local and
local and whatever
whatever the variable
populating that variable
that variable with
we add these
add these additional
these additional variables
additional variables to
variables to our
our output log
output log and
log and then
the values come
values come out
come out quite
variables to declare
to declare and
declare and populate
and populate with
populate with a
default value, this
easy and fast
and fast way
fast way of
doing it in
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
let's declare a
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
within a user
defined type in
type in your
want to prepare
to prepare it
prepare it with
For example, empty
length strings or
strings or in
case a date
a date in
in the date
the date field
a new macro
new macro and
this one prep
one prep udt
give it two
type we wish
to actually declare
actually declare and
data we want
put into one
into one of
the string fields
print out both
out both the
both the date
value from that
our macro with
being a user
being a string
As before these
before these are
these are straight
are straight substitutions
Whatever comes in
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
passed on the
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
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
save a wee
a wee bit
wee bit of
However you can't
you can't use
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
not on a
will generate an
If you also
you also use
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
are fairly small
fairly small limitations
small limitations to
to what you
do with macros
we've actually prepared
actually prepared our
prepared our macro
our macro let's
macro let's try
elements are coming
are coming out
coming out to
our log quite
log quite happily
being the Date$
the Date$ value
Date$ value and
we passed on
if you're preparing
you're preparing a
preparing a number
on this premise
this premise you
premise you can
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
date into this
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
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
the code or
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
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
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
will again look
again look at
your applications, this
this time tackling
time tackling macro
tackling macro functions
video on macros
on macros we
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
a quick recap
Mecros are basically
are basically text
basically text substitutions
text substitutions performed
substitutions performed before
performed before your
They are effectively
are effectively pre-processed
have here a
here a macro
macro called m-release
called m-release package
will do when
do when your
application compiles is
compiles is that
the word m-release
word m-release package
m-release package with
package with the
the word macro
to create things
create things on
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
the string release
string release build
means when your
when your program
your program actually
program actually compiles
actually compiles, the
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
make your coding
your coding less
coding less tedious
less tedious, much
as we use
we use libraries
use libraries of
libraries of functions
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
included in this
reference this encode
this encode file
encode file at
file at the
move this single
line macro into
macro into our
have referenced this
referenced this library
this library in
library in our
and compile and
compile and run
And our application
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
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
your executable, as
these are text
are text substitutions
performed before the
before the actual
the actual compilation
at now are
now are macro
are macro functions
macro functions themselves
need a problem
a problem which
problem which our
which our macro
macro is going
be the solution
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
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
C and D
The data2 string
data2 string contains
contains four numbers
four numbers, 1
create a macro
macro function whose
take the first
first character from
character from the
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
So our macro
be called fold
called fold string
fold string and
string and will
and will take
two parameters, data1
data1 and data2
macro will populate
populate our output1
our library and
library and we
new macro function
previous video we're
be passing the
two parameters inside
parameters inside the
inside the brackets
But as this
a macro we
macro we don't
declare the type
this is merely
merely a text
a text substitution
text substitution process
were to perform
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
in the data1
the data1 variable
data1 variable, one
pull out one
out one character
one character from
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
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
could be used
be used several
used several times
several times within
times within the
same function or
or subroutine in
subroutine in your
have a collision
a collision with
collision with the
with the declaration
of the local
use the macro
macro temp command
temp command to
around that problem
The micro tem
micro tem command
tem command makes
command makes sure
makes sure that
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
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
replaced as longr0001
as longr0001 for
longr0001 for the
first time it
If we call
this macro later
macro later on
same function it
function it will
appear as longr
as longr 0002
And everything else
everything else within
else within this
this macro function
macro function will
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
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
code the output
output variable is
is the return
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
now run and
run and the
output variable contains
variable contains A1
contains A1, B2
successfully taken two
taken two variables
variables and interleaved
and interleaved the
interleaved the string
the string constants
string constants into
constants into a
new output variable
And we've outputted
we've outputted that
outputted that to
macro function is
and simple function
it does illustrate
does illustrate what
illustrate what we
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
call it once
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
code now it
cleanly and will
and will give
us the output
the output reversed
now have 1A
have 1A, 2B
3C and So
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
to use within
use within your
application is the
of the randomise
randomise command is
used to seed
to seed the
seed the random
This seed value
seed value can
value can be
used to give
you a predictable
a predictable list
predictable list of
list of pseudo
of pseudo random
pseudo random numbers
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
small macro as
macro as a
return a randomised
a randomised seed
this macro random
macro random seed
library and we'll
So this macro
this macro is
return a D
D word, a
a numerical value
numerical value which
use to seed
to seed our
seed our random
our random number
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
to use macro
use macro temp
macro temp to
temp to ensure
to ensure there
ensure there are
are no collisions
no collisions with
collisions with the
with the variables
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
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
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
is to copy
to copy the
within that register
that register to
register to the
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
that register into
register into the
into the declared
the declared variable
of the strengths
the strengths of
strengths of inline
inline assembly within
assembly within Power
You can pass
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
by these lines
should get back
back a nice
a nice large
nice large D
large D word
D word value
our value on
value on screen
while we're sending
we're sending this
sending this value
screen we would
we would normally
would normally use
normally use it
of the randomize
the randomize command
randomize command as
command as you
Calling randomize and
randomize and forward
and forward by
forward by our
by our macro
to compile that
compile that and
us a random
variable called value
called value we
value we set
that variable using
random command to
command to give
1 and 20
push that value
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
command once more
more and get
get a different
So first time
first time we're
time we're getting
we're getting So
getting So this
very easy way
way of getting
of getting a
getting a pseudo
couple of macro
of macro functions
These macro functions
macro functions are
functions are set
an include library
include library with
library with the
the previous macro
previous macro functions
macro functions we
called from any
from any of
any of your
applications and will
will only add
only add to
the code of
the executable should
executable should the
should the macros
the macros be
macros be referenced
very useful way
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
look at software
at software add-ons
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
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
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
get into that
into that we'll
that we'll have
create a service
a service to
service to monitor
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
to take down
take down any
down any of
the normal Windows
normal Windows services
Windows services, so
use an application
an application we
application we wrote
we wrote some
wrote some time
time ago which
ago which will
create a PowerBasic
PowerBasic Windows service
our application here
code of course
course will be
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
a service called
service called 'AAAmonitor
called 'AAAmonitor folder
'AAAmonitor folder service'
us to install
to install this
install this service
this service and
service and then
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
is a folder
a folder that
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
This application can
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
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
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
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
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
It will either
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
then press the
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
to the taskbar
the taskbar, right
right clicking and
clicking and selecting
and selecting Task
selecting Task Manager
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
right click we
click we can
can quite simply
quite simply start
simply start the
So our service
our service is
service is now
is now running
the system scheduler
system scheduler and
scheduler and set
up a monitoring
a monitoring process
System scheduler can
scheduler can be
be found down
found down in
the system tray
of different event
different event types
event types we
types we can
We're interested here
interested here in
here in setting
in setting up
up a service
a service watcher
it a title
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
The next choice
next choice you
choice you have
you have is
have is your
is your criteria
We're specifically wanting
specifically wanting to
wanting to know
know when the
when the service
the service is
service is not
is not running
want the service
the service running
service running all
running all the
do is what
way of an
of an action
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
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
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
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
event which is
going to notify
to notify us
notify us that
us that something
something has indeed
has indeed occurred
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
on the root
root of our
our path called
path called status.txt
It will append
will append to
append to that
that file each
file each time
it is triggered
will then wait
then wait for
wait for two
compile that, and
that's the event
up in System
in System Scheduler
if we pop
we pop back
pop back in
in there, right
right click, pick
pick edit, and
up our new
be an application
click new event
new event and
event and we
now enter the
enter the details
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
a box to
to put parameters
put parameters in
parameters in, should
should they be
they be acquired
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
it as normal
as normal for
normal for the
the moment as
moment as we
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
by the service
the service watcher
The advanced tab
advanced tab will
tab will come
let's save this
to our service
our service watcher
We can edit
can edit that
edit that and
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
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
this value, say
to every 10
every 10 minutes
And it gives
gives you other
you other options
start at some
the future, at
at a particular
a particular time
particular time and
time and a
and a particular
leave this at
this at one
at one minute
one minute intervals
minute intervals for
intervals for the
that now, and
if we enable
enable the event
the event, we
at the log
the log of
log of the
the event when
event when something
when something actually
something actually triggers
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
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
click and view
view the event
the event log
event log file
tells us that
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
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
of our monitor
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
log file, we
see it's telling
us the service
not running, and
now running the
running the appropriate
the appropriate action
the folder, we
now a status.txt
a status.txt, and
is telling us
that the service
the service has
service has indeed
has indeed stopped
indeed stopped and
stopped and the
time it stopped
successfully used Splinterware
used Splinterware system
system scheduler to
scheduler to monitor
a service of
service of our
of our choice
This monitor can
monitor can be
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
the criteria, which
you have selected
have selected, you
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
So let's delve
let's delve a
delve a little
a little deeper
little deeper into
deeper into the
into the other
options for this
We haven't yet
haven't yet looked
yet looked at
at the advanced
advanced tab has
tab has a
the run as
run as tab
sets the user
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
you want no
want no feedback
no feedback to
this to run
run quite silently
save that, if
the log file
log file, we'll
moment the service
service is running
is running as
running as a
as a specific
a specific user
that we've changed
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
will not display
not display any
display any console
any console or
console or other
or other windows
other windows to
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
else can system
can system schedule
system schedule do
schedule do in
in this advanced
this advanced tab?
advanced tab? We
tab? We have
have a notifications
a notifications tab
up to send
to send an
an email notification
For which you
define an SMTP
an SMTP server
defined that, you
put in an
in an email
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
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
the event processing
event processing, if
if an event
an event is
event is missed
is missed, for
example when the
when the computer
the computer or
computer or server
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
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
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
look down in
the bottom window
bottom window, it
us that this
that this service
this service does
service does no
no longer exist
click and look
the bottom, we'll
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
trigger an additional
an additional process
additional process of
process of our
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
can create some
create some of
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
very quick and
you'll find all
find all this
to day applications
day applications, but
Welcome in this
Windows compilers today
compilers today we
the parameters passed
parameters passed between
passed between functions
between functions and
did a video
to revisit the
revisit the subject
the subject for
subject for those
who are just
are just using
just using Power
compiler can be
have two include
two include files
include files at
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
code to be
be used either
used either in
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
function you can
you can include
can include code
include code and
code and call
and call other
call other functions
other functions and
start this demonstration
this demonstration by
demonstration by calling
called process count
process count by
count by reference
this function called
function called count
have declared the
declared the count
the count as
count as a
loop to count
to count between
count between one
be called five
called five times
function process count
count by ref
the brackets we
brackets we have
parameter list, in
this case just
case just a
single parameter called
parameter called count
called count, which
This is preceded
is preceded by
preceded by the
the word byref
word byref to
byref to indicate
that this parameter
this parameter has
been passed by
passed by reference
reference to where
Power basic by
basic by default
by default passes
default passes parameters
passes parameters by
parameters by reference
we had no
had no mention
no mention of
mention of the
the word by
word by ref
by ref it
ref it would
would still be
still be passed
function we're declaring
called value also
value also as
populating that local
that local variable
local variable with
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
printing the value
the values put
values put out
a log are
log are two
are two, three
five and six
is because every
because every time
time we call
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
thing to note
to note when
note when you're
when you're calling
you're calling functions
calling functions is
functions is that
the value you're
value you're passing
you're passing in
passing in here
is called count
called count which
variable we could
could have this
have this called
this called something
called something entirely
something entirely different
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
application would work
would work just
work just as
just as well
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
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
we place an
place an increment
an increment command
increment command in
command in as
as the bottom
the bottom line
bottom line of
line of this
function which would
which would increment
would increment the
the long new
long new count
As this value
this value being
value being passed
passed in is
in is being
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
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
being passed back
something to be
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
or function will
will be reflected
be reflected in
reflected in the
in the calling
you wish not
wish not to
not to pass
pass them by
them by reference
by reference you
reference you can
pass it byval
it byval that's
byval that's by
that's by value
way the actual
variable is passed
is passed and
passed and not
and not the
not the pointer
pointer to where
where it sits
it sits in
sits in memory
change our code
code to call
the values return
values return to
return to as
to as they
As any change
made to this
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
basic will allow
you to pass
to pass up
pass up to
to 32 parameters
32 parameters between
parameters between functions
say we wanted
pass a parameter
parameter to a
a subroutine as
subroutine as opposed
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
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
the word sub
word sub followed
sub followed by
by the subroutine
the subroutine name
subroutine name and
The main difference
main difference between
difference between a
between a function
a function and
and a subroutine
a subroutine is
subroutine is that
is that a
that a function
a function will
As we see
we see here
see here the
function has declared
has declared that
declared that it's
return a long
Functions are very
useful as you
you can embed
can embed them
embed them in
them in your
Subroutines on the
on the other
the other hand
other hand do
hand do not
do not return
not return values
see our subroutine
our subroutine is
subroutine is returning
is returning this
returning this value
value here 6
here 6 which
6 which was
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
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
your code we're
code we're going
determine whether a
whether a value
a value is
value is odd
is odd or
odd or even
a variable which
test and we're
true or is
is it false?
it false? Power
false? Power basic
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
we're passing our
passing our parameter
our parameter value
parameter value to
determine what to
on the return
It's always an
an advantage to
advantage to name
name your functions
your functions for
for the purpose
the purpose they
purpose they perform
this case 'is
case 'is value
'is value even'
value is even
value is false
your code much
read and understand
function is value
is value even
value even passing
even passing the
passing the single
parameter of value
of value defined
value defined as
And our return
function is also
is also defined
also defined as
the modulus command
modulus command to
the value, divide
by 2 and
2 and if
if the remainder
the remainder from
remainder from that
from that division
that division is
division is 0
0 then the
value is divisible
is divisible by
divisible by 2
Therefore the value
the function calling
function calling this
Otherwise there is
is some remainder
some remainder and
remainder and we
and we return
we return the
now it would
it would tell
would tell us
the number 9
number 9 is
9 is odd
to an even
an even number
for example 12
example 12 and
12 and run
code again it
So we've passed
we've passed a
passed a variable
function and returned
and returned a
returned a value
which is either
is either true
Another thing you
do with parameters
with parameters is
parameters is make
is make one
make one or
or more of
more of the
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
we've populated that
populated that variable
the value function
value function passing
function passing it
as you do
you do this
do this if
this if we
we make no
make no change
no change to
value even then
even then the
then the program
program will no
no longer compile
attempting to call
a function with
function with two
parameters and the
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
to accept either
accept either one
either one or
or two parameters
two parameters is
parameters is to
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
every parameter after
the first declaration
first declaration of
declaration of optional
of optional will
optional will be
will be optional
optional parameters need
parameters need to
to be at
be at the
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
test for it
command called is
called is missing
is missing returns
missing returns true
true then there
is no optional
If if missing
if missing returns
missing returns false
then the optional
parameter has indeed
indeed been passed
You can place
can place this
place this at
your function to
the optional or
optional or optional
or optional parameters
optional parameters have
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
not been passed
this construct allows
construct allows you
to set your
set your code
your code to
to handle missing
handle missing parameters
the parameter is
parameter is missing
is missing then
missing then you
have no reference
no reference to
to the named
the named parameter
For example special
example special value
parameter is not
is not missing
not missing then
can reference the
reference the value
for the on
the on in
code you can
populate a locally
a locally declared
locally declared variable
declared variable with
print out that
that the optional
optional parameter equals
parameter equals 13
it so there
optional parameter the
parameter the code
will still compile
still compile and
and run and
run and it
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
to pass more
pass more information
more information than
information than just
than just numbers?
just numbers? Let's
numbers? Let's declare
We've now declared
now declared a
declared a user
called udt car
udt car and
car and it
it has four
has four elements
four elements make
elements make model
make model type
model type and
type and color
these is set
as a 20
a 20 character
20 character string
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
be fixed length
fixed length so
length so it's
up to be
to be large
be large enough
large enough for
enough for the
data you're going
can now declare
as that user
is called ucar
called ucar and
ucar and it's
it's been declared
been declared as
a udt car
udt car which
car which is
is the type
declared a moment
populate that by
by the construct
construct of ucar
of ucar dot
ucar dot and
the element name
of typing and
prefix command takes
command takes the
string which appears
which appears immediately
appears immediately after
immediately after it
after it and
it and adds
and adds it
adds it to
that follows until
follows until we
get to end
to end prefix
saves you in
you in some
some cases a
cases a great
typing and makes
and makes the
code look nice
look nice and
populated this user
defined type how
type how do
do we pass
we pass that
to a function?
a function? Actually
function? Actually quite
Actually quite simply
quite simply as
simply as we
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
the list within
list within the
within the brackets
this new show
new show car
show car details
car details function
parameters list we've
list we've declared
variable in this
this case ucar
case ucar as
ucar as the
as the udt
the udt car
udt car type
car type in
way as you
as you declare
you declare any
declare any other
other variable passed
variable passed on
So all we're
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
case the string
the string make
string make followed
make followed by
that each element
type is printed
is printed out
printed out on
out on a
on a separate
get the Ford
the Ford Capri
Ford Capri electric
Capri electric silver
electric silver printed
silver printed out
we've successfully passed
passed a user
defined type from
type from one
However we can
go further with
further with this
we had multiple
had multiple car
multiple car details
car details to
details to pass
pass to our
we're dimensioning an
as udt car
car and the
of elements we
elements we have
have specified as
specified as two
step through a
through a little
populate this information
we're doing between
doing between one
and two and
two and we're
the prefix which
prefix which is
element number and
then the details
The make the
make the model
the model the
model the type
the word just
word just so
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
put the two
two brackets at
brackets at the
in a ucars
a ucars open
ucars open then
open then close
then close brackets
that we're passing
passing an array
array by reference
on our function
function to actually
to actually display
actually display these
display these to
user we're calling
the function showAllCarDetails
array is defined
is defined as
as a u
a u cars
u cars open
cars open and
and close bracket
it's an incoming
an incoming array
incoming array which
by reference and
reference and we're
we're specifying that
specifying that the
that the type
defined type car
putting a for
next loop in
in here again
display each element
determine the number
of elements within
elements within the
using the ubound
this case two
printing the details
details out to
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 as in
as in make
in make, model
get the details
the details for
details for number
and the details
for number two
can pass a
pass a great
of data using
array as one
as one of
But it's important
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
function and another
and another function
another function or
or subroutine by
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
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
determine where the
the data actually
data actually sits
made to data
to data within
array will of
of course be
course be reflected
calling routine as
routine as they're
they're both pointing
both pointing at
the same place
if the name
the name you're
name you're using
you're using in
list is different
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
run a process
A simple arithmetic
simple arithmetic process
arithmetic process that's
process that's going
be called many
called many times
up some local
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
set the values
for the counter
the counter to
counter to 10
to 10 and
10 and the
the total to
total to be
1 to 1000
function process 1000
process 1000 times
determine how long
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
tix command takes
case a quad
a quad value
up the cycle
the cycle count
cycle count of
after the processing
the processing I'm
processing I'm calling
I'm calling tix
calling tix end
Which picks up
the value again
value again and
again and subtracts
and subtracts the
subtracts the first
first value from
cycles used between
used between the
between the tix
the tix and
tix and the
and the tix
useful to determine
just how efficient
how efficient one
efficient one routine
one routine is
is to another
out the total
total to the
the log with
log with the
create this fun
this fun process
fun process function
very straightforward process
straightforward process which
process which takes
two parameters coming
coming in the
in the total
the total and
total and the
and the counter
And it adds
it adds to
adds to the
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
function the value
the total variable
see it gives
a value 10,000
value 10,000 and
10,000 and it
has taken 20,787
taken 20,787 CPU
20,787 CPU cycles
cycles to perform
to perform these
perform these 1000
these 1000 iterations
function that performs
that performs something
performs something purely
something purely arithmetic
purely arithmetic can
arithmetic can we
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
has a different
a different type
type of function
of function called
function called fast
called fast proc
created a fast
a fast proc
fast proc function
taking in exactly
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
to use by
use by value
The arithmetic calculation
arithmetic calculation within
calculation within the
within the routine
the routine is
routine is exactly
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
returning that total
that total to
function and call
and call this
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
different value coming
get the same
same value for
the total 10
total 10 000
But the number
cycles is considerably
is considerably less
It's only 7371
So running this
running this as
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
So just in
case the position
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
here and we'll
it in before
in before the
before the other
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
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
can't use local
use local variables
variables within the
have something that
that is computationally
is computationally intensive
computationally intensive and
intensive and you're
and you're calling
you're calling it
calling it a
great many times
many times it
times it can
it can speed
up your processing
your processing as
processing as you
this completes our
completes our short
our short look
short look at
look at parameters
at parameters being
being passed between
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
how they can
This will lead
will lead on
lead on nicely
on nicely from
nicely from our
previous video on
video on user-defined
on user-defined types
today is take
is take the
take the application
application we created
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
application is we
up a user-defined
user-defined type called
type called udt_account
of elements, a
a balance, a
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
array of 10
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
fairly standard operation
standard operation for
operation for a
for a user-defined
user-defined type held
type held within
held within an
of the user-defined
user-defined type is
type is to
allow you, the
the programmer, to
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
have actually printed
actually printed the
printed the details
the details from
details from inside
inside the array
the array out
our log, using
and the property
the property you're
property you're actually
case the balance
again we're populating
populating the user
user information, which
the user element
user element of
user-defined type, allowing
save the first
last name of
further down still
down still we're
still we're storing
storing the account
building up in
our array a
array a set
a set of
of data for
data for a
a particular user
array is 10
is 10 elements
in size, we
we could store
could store 10
store 10 users'
10 users' data
And slightly further
the code we're
code we're showing
we're showing a
showing a shortened
a shortened version
We're defining a
defining a user-defined
user-defined type as
type as the
user-defined type defined
type defined at
then we're populating
populating that user-defined
us to extract
extract the information
that specific element
specific element of
using a shortened
a shortened form
using this shortened
this shortened version
shortened version to
version to print
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
user-defined types, we
use a pointer
a pointer on
pointer on the
we specified above
declare a pointer
here we're declaring
variable called P1
we're declaring this
declaring this as
the udt account
the final part
final part of
of this piece
code is ptr
is ptr, which
which is pointer
So P1 is
P1 is a
A pointer is
pointer is a
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
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
populating the P1
the P1 variable
P1 variable using
using the var
the var pointer
var pointer command
variable we want
want to point
declared the user
user account further
account further up
our code, here
here on this
So we're pointing
we're pointing at
pointing at where
at where that
where that information
that information is
is actually stored
having defined where
defined where that
actually stored, we
can actually reference
actually reference it
reference it using
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
what this generates
is the account
account number, appearing
the 10123456, and
the pointer, we
we can obtain
can obtain exactly
obtain exactly the
So our P1
our P1 variable
P1 variable is
variable is pointing
user-defined type we
type we specified
we specified earlier
specified earlier in
code is pointing
is pointing only
pointing only at
only at the
would we handle
we handle it
handle it if
wanted to point
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
dimensioning the array
is the line
we used to
used to dimension
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
element in that
that our pointer
our pointer 2
pointer 2 is
2 is pointing
at the array
actually reference every
reference every element
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
pointer variable and
variable and in
and in square
in square brackets
square brackets is
brackets is the
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
as the pointer
the pointer is
pointer is concerned
is concerned, is
Following that, we
in the structure
structure that you
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
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
complete the code
out the account
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
it to populate
If we wished
we wished to
wished to populate
populate the very
the very next
very next element
next element of
yet populated, we
by using at
using at P2
at P2 and
P2 and in
square brackets the
element we wish
to populate, and
then the parts
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
this could indeed
could indeed be
indeed be a
be a variable
populate the variable
the variable longElement
variable longElement to
longElement to be
be 1, we
can slot that
slot that in
that in quite
happily to our
it will still
today is that
taken an existing
an existing array
existing array which
which is all
all user defined
populated that array
that array with
array with data
with data, and
pointer to both
to both extract
both extract data
extract data from
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
software add-ons for
add-ons for the
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
look of your
have previously looked
previously looked at
looked at a
at a version
a version of
version of WinLift
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
to use it
it within PowerBasic
within PowerBasic, and
going to apply
to apply WinLift
apply WinLift to
WinLift to one
of our projects
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
the first screen
first screen today
This small application
small application is
a fairly bland
fairly bland form
bland form, and
to use WinLift
use WinLift to
WinLift to enhance
the form while
form while maintaining
while maintaining its
maintaining its current
its current functionality
let's delve into
see what WinLift
what WinLift can
WinLift can do
can do for
do for us
a folder containing
folder containing the
containing the code
add two DLLs
two DLLs to
DLLs to this
to this folder
are the DLLs
the DLLs we're
DLLs we're going
using for WinLift
is the WinLift32.DLL
the WinLift32.DLL and
WinLift32.DLL and the
and the ZTrace32.DLL
add an include
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
purpose of WinLift
of WinLift is
WinLift is to
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
These are held
held in two
in two folders
this particular skin
particular skin is
skin is Sony
is Sony, and
a resource folder
resource folder which
folder which can
can contain some
contain some images
need one more
one more definition
more definition file
is the SKS
the SKS file
is a flat
file that specifies
that specifies the
specifies the definition
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
These describe how
describe how each
how each part
of your window
your window is
window is going
are all inside
all inside this
inside this Sony
this Sony folder
do to change
look of our
I'm additionally going
additionally going to
an icon for
application itself as
itself as it
it currently does
currently does not
not have one
define the ZTraceDLL
the ZTraceDLL and
ZTraceDLL and also
and also include
also include the
include the WinLift32.encode
the WinLift32.encode file
at the definition
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
the user, we
to define which
define which skin
which skin of
skin of WinLift
of WinLift we're
WinLift we're going
up a few
variables in order
WinLift uses Unicode
So all of
these strings we're
strings we're going
to be setting
be setting up
up as WStringZ
comes the point
we actually define
actually define and
define and initialize
and initialize the
initialize the skin
the skin engine
we define the
define the resource
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
be the basics
basics of skinning
of skinning our
skinning our window
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
The form look
form look has
look has changed
has changed completely
have the existing
existing buttons for
buttons for exit
for exit and
exit and run
and run form
run form and
have the list
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
change this application
this application any
application any further
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
have a clock
a clock running
clock running at
running at the
screen in real
number of buttons
are all custom
all custom buttons
custom buttons to
buttons to WinLift
to WinLift itself
And the screen
screen is resizable
the buttons has
buttons has a
has a font
a font embedded
font embedded on
embedded on it
our original form?
original form? As
form? As the
the form stands
form stands, it
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
add the WinLift
the WinLift clock
setting a variable
for the resource
the resource folder
a folder we
folder we looked
looked at which
at which contains
contains our resources
the clock image
specifying the png
the .png file
within the WinLift
the WinLift library
WinLift library called
library called clock_control
define this clock
this clock constant
clock constant at
the code, which
do in a
setting the anchor
the anchor of
anchor of the
the clock to
clock to the
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
form is resized
So let's define
let's define this
can see with
see with that
that one line
added a clock
a clock to
add any timers
add any special
code to redraw
redraw the clock
The clock is
clock is just
is just there
can we enhance
we enhance these
enhance these buttons
these buttons on
on the form?
the form? Let's
form? Let's look
at that next
two buttons defined
buttons defined on
and a run
a run form
to comment those
comment those two
those two out
two out in
of the custom
the custom buttons
custom buttons that
buttons that WinLift
that WinLift supports
This uses another
uses another function
WinLift library, the
the push button
push button image
for our run
our run form
form button, this
will not only
not only add
only add the
add the button
the button to
the form, it
it will place
will place an
place an image
use the constants
the constants to
constants to decide
to decide whether
decide whether you
want the buttons
the buttons centred
buttons centred or
centred or left
or left or
or right justified
two new buttons
As I kept
I kept the
kept the same
the same constant
same constant for
the buttons are
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
if we turn
we turn our
turn our eyes
our eyes to
eyes to the
list box, what
what I'd like
list box slightly
box slightly larger
And perhaps change
perhaps change the
the colour on
colour on the
Now these commands
these commands do
commands do not
do not appear
to have actually
have actually changed
changed the form
the form colours
is because they
they are being
are being controlled
being controlled from
controlled from the
from the skin
skin engine itself
engine itself using
using the definition
the definition file
to try now
try now is
the way that
way that works
that works by
works by creating
a new skin
new skin definition
skin definition file
We will clone
will clone the
clone the existing
the existing one
existing one and
we'll make some
make some minor
some minor changes
I have copied
have copied the
copied the Sony
the Sony SKS
Sony SKS file
SKS file and
file and created
created a Sony
a Sony EX
Sony EX file
of these SKS
these SKS files
SKS files is
files is to
to define both
define both the
both the images
the images and
images and certain
and certain items
certain items of
items of each
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
make some very
some very slight
very slight changes
slight changes to
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
change our form
our form so
form so it's
so it's using
the new SKS
new SKS file
that the look
has changed again
background image is
image is actually
is actually now
actually now sitting
within the form
So we still
make this text
this text a
managed to change
change the colours
colours of the
dialogue title and
and the plain
the plain text
plain text on
So our video
our video form
video form is
form is looking
is looking much
looking much better
font command after
command after the
after the form
has been skinned
is now larger
on it, it
it gets small
gets small again
So we're heading
we're heading in
heading in the
the right direction
to try is
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
will just amend
just amend the
to take out
take out reference
out reference to
the font globally
will define our
define our font
our font in
font in the
in the PB_Maine
the PB_Maine function
Now we've done
list box from
box from within
initialised dialogue function
extended style of
style of our
function to get
form list to
list to populate
populate an array
add this array
this array to
the font of
font of the
getting a list
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
think we have
have successfully transformed
successfully transformed our
transformed our project
project to use
is still within
the form, which
have not changed
not changed yet
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
have done this
done this with
this with only
with only very
only very minor
very minor modifications
minor modifications to
modifications to our
original code, while
while retaining the
retaining the existing
new control to
the clock control
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
the buttons themselves
Plus we now
have a background
a background to
background to the
next video, we'll
on to cover
cover the rest
Can WinLift handle
WinLift handle dynamic
handle dynamic forms?
dynamic forms? I'll
forms? I'll put
actually apply and
apply and donate
and donate to
donate to get
to get WinLift
again at Graphics
video on Graphics
on Graphics Windows
Graphics Windows we
Windows we had
application which could
which could be
could be compiled
be compiled either
compiled either using
using the console
see it launches
it launches three
launches three graphics
graphics windows, the
is a sample
a sample graphics
sample graphics progress
graphics progress bar
Once that completes
that completes, it
will load a
a JPEG graphic
JPEG graphic up
graphic up from
from the directory
the directory and
directory and deposit
and deposit it
deposit it in
will put text
on that window
that window and
window and text
and text on
on a second
we make any
any changes to
this code, I'm
change the JPEG
the JPEG slightly
JPEG slightly to
slightly to trim
trim off the
off the excess
the excess round
excess round the
round the side
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
that's what our
what our graphic
our graphic is
graphic is going
look like now
can make some
make some more
some more changes
more changes to
it stands, we're
using three libraries
three libraries, the
API library which
library which comes
which comes with
comes with PowerBasic
PowerBasic and two
Progress library, which
display the progress
progress bar in
bar in a
in a graphics
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
windows require bitmaps
require bitmaps to
bitmaps to load
load into them
into them, this
this library allows
library allows you
you to take
JPEG file, convert
a bitmap and
bitmap and allow
load that directly
that directly into
directly into your
into your control
your control or
control or graphics
or graphics window
this part of
code is this
where we clear
we clear the
graphics window, and
background to a
to a light
We're then changing
then changing the
changing the graphics
graphics colour so
colour so that
so that any
that any text
any text that
text that appears
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
with the background
the background is
background is make
is make it
it a gradient
gradient fill, so
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
window we wish
wish to paint
new function PaintBackground
function PaintBackground, taking
up our local
our local variables
variables in here
of a user-defined
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
variable is another
is another handle
another handle for
the final variables
final variables are
variables are the
as the graphics
window can vary
can vary, the
make sure I'm
sure I'm pointing
I'm pointing towards
towards the correct
use the hwin
the hwin variable
hwin variable, which
parameters list, to
to point it
point it towards
it towards that
towards that window
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
obtain the device
device context of
context of our
of our current
our current graphics
populate the hdc
the hdc variable
hdc variable with
populate the TriVertex
the TriVertex array
putting two sets
sets of information
information in here
in here –
here – first
– first of
all the width
and height in
height in pixels
pixels of the
the window itself
Secondly we're putting
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
making it 230
it 230 for
230 for red
for red and
red and 150
and 150 for
150 for red
for red on
the other side
to the gradient_full_windows
the gradient_full_windows API
gradient_full_windows API function
This will perform
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
graphics window so
window so the
see what's on
what's on it
And there you
there you will
see the background
of the sample
the sample graphics
sample graphics window
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
hand side to
side to a
to a darker
a darker red
darker red on
amend the colour
colour of this
of this gradient
this gradient fill
gradient fill quite
fill quite easily
easily by amending
by amending the
amending the values
in the paint_background
the paint_background function
put some values
some values in
values in for
for the green
the green element
green element of
our colour and
colour and run
will get quite
quite a different
that is being
is being printed
being printed on
printed on this
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
our text command
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
where the text
is actually written
the text being
text being written
being written to
put a graphics_colour
a graphics_colour command
graphics_colour command in
in to override
override the standard
the standard colours
Before we'd use
we'd use the
graphics colour with
colour with its
two parameters -
parameters - the
- the black
the black for
black for the
and the light
the light grey
light grey for
grey for the
If we remove
we remove the
remove the light
light grey and
grey and we
put in -2
in -2, this
to be transparent
be transparent and
transparent and allow
allow the background
our gradient fill
gradient fill to
fill to show
to show through
is now successfully
successfully displayed and
displayed and the
background colour is
colour is showing
is showing through
populated our graphics
graphics window, can
can we copy
we copy data
copy data from
data from it
from it and
it and on
graphics window? Let's
window? Let's go
after the JPEG
the JPEG is
JPEG is rendered
graphics window, we
want to copy
use a graphics_attach
a graphics_attach command
graphics_attach command to
command to reference
reference the second
graphics window we're
window we're going
write to is
use the graphic_copy
the graphic_copy command
graphic_copy command, referencing
referencing the first
first window and
area of that
of that window
that window we
copy and where
on the second
the second window
second window we're
So the graphics_copy
the graphics_copy command
graphics_copy command will
we're actually copying
actually copying from
since we're copying
we're copying from
copying from a
next parameter needs
parameter needs to
Next are the
of the area
the area we
area we wish
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
tell it where
it where we're
where we're copying
we're copying to
copying to on
we're moving to
moving to 100
to 100 by
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
Basic to redraw
window and make
make it visible
it visible to
get our progress
Once it completes
it completes, the
the JPEG will
JPEG will be
and a section
of that graphics
graphics window has
window has now
now been copied
been copied to
copied to the
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
window to somewhere
to somewhere else
somewhere else on
else on the
first graphics window?
graphics window? We
window? We can
can take exactly
approach as we
use the graphics_attach
the graphics_attach command
Basic that what
that what we're
to be writing
writing to is
use the graphics_copy
graphics_copy command to
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
get the progress
bar as before
JPEG will then
then be copied
be copied to
to the primary
the primary window
have the secondary
the secondary window
secondary window populated
window populated as
populated as before
before and we
have an image
an image copied
image copied to
copied to a
a separate area
separate area of
added a gradient
fill to our
to our primary
our primary graphics
primary graphics window
the text so
text so that
text is written
is written to
written to that
graphics window, it
it allows the
allows the background
the background screen
background screen to
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
window to a
a separate location
separate location on
location on that
on that first
that first graphics
We can probably
probably do more
do more to
more to the
to the paint
the paint background
paint background function
background function to
function to make
it more generic
more generic so
generic so that
specify the colours
the colours in
creation of clickable
of clickable buttons
clickable buttons on
buttons on a
number of videos
of videos which
which cover the
creation of dialogues
of dialogues in
dialogues in the
These dialogues allow
dialogues allow you
to create objects
create objects on
screen that users
that users can
users can click
And additionally the
additionally the Windows
Windows Compiler provides
Compiler provides you
you with an
with an Event
Event Handler, a
series of callback
of callback functions
callback functions, in
you can handle
can handle the
events that have
have occurred when
occurred when users
interact with this
with this dialog
functionality is not
is not available
not available within
Mainly because the
because the console
compiler is designed
designed to operate
to operate with
operate with console
with console applications
console applications, which
do not require
not require dialogues
happens if all
if all you
all you have
have is the
is the console
compiler and you
and you need
provide some kind
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
user a button
button to click
click on from
on from within
we do this?
do this? Well
this? Well today
Well today we're
application can run
can run either
run either within
either within the
window and on
on that graphics
going to provide
provide a clickable
a clickable button
the code behind
code behind is
behind is going
going to detect
detect that the
task within the
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
a variable, in
case a D-word
This being the
the active graphics
active graphics window
graphics are only
are only redrawn
only redrawn to
redrawn to the
screen at a
at a point
a point in
where we wish
use the handle
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
want to send
to send some
send some text
some text to
screen so we're
a font to
font to do
command and we'll
and we'll pick
we'll pick Courier
pick Courier New
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
it's quite visible
quite visible on
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
want to instruct
instruct PowerBasic to
PowerBasic to set
set that font
that font as
as the current
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
it a background
a background of
background of light
So to complete
this section we
section we will
words 'Click button
'Click button when
button when ready'
when ready' to
ready' to the
execute the redraw
to redraw that
redraw that to
have two windows
two windows on
A standard console
standard console window
console window which
window which we're
display information and
information and a
and a graphics
window which has
which has the
when ready' at
ready' at the
So to terminate
to terminate the
application we will
we will close
window and then
exit the console
window is prepared
is prepared how
prepared how can
we display a
display a button
a button on
the screen? One
screen? One of
do within a
window is you
you can render
can render graphics
render graphics to
graphics to it
create a bitmap
a bitmap which
bitmap which is
be the image
image of our
of our button
our button and
button and we're
going to render
to render that
render that on
a bitmap graphic
bitmap graphic called
graphic called 'Click
called 'Click me
'Click me dot
me dot bmp'
at that it's
a simple rectangle
simple rectangle with
rectangle with the
words 'Click me
'Click me on
me on it'
image we will
we will render
will render onto
render onto our
window which will
which will become
will become our
become our button
do we render
we render that
render that onto
that onto the
onto the screen?
the screen? Well
screen? Well we'll
to define in
define in a
in a variable
a variable a
variable a path
path to and
to and the
variable called 'bmp_name'
called 'bmp_name' and
'bmp_name' and we're
with the 'Click
the 'Click me
dot bmp' which
bmp' which exists
which exists within
As the bitmap
the bitmap you're
bitmap you're going
to be rendering
be rendering may
rendering may be
be of different
different sizes you
sizes you want
the bitmap at
bitmap at runtime
we can open
can open the
open the bitmap
the bitmap for
bitmap for binary
for binary handling
binary handling and
handling and we
and height out
height out of
bitmap file itself
used this technique
this technique in
technique in previous
we're assigning the
assigning the long
the long file
long file variable
file variable to
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
then close down
will declare those
declare those variables
those variables we've
variables we've now
The width, the
for the bitmap
determined the size
bitmap we now
have to decide
to decide where
decide where we
called X graphic
X graphic and
graphic and one
one called Y
called Y graphic
position the button
the button 100
button 100 pixels
100 pixels in
pixels in from
side and 100
and 100 pixels
100 pixels down
pixels down from
will define both
define both of
those variables at
can actually load
actually load our
load our graphic
our graphic up
graphic up and
bitmap and where
and where we
place it on
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
bitmap file on
file on disk
set of parameters
of parameters are
parameters are in
are in brackets
coordinates we want
start the bitmap
bitmap at and
at and the
want to end
end the bitmap
This is why
is why we
why we picked
have the button
can detect mouse
detect mouse clicks
that the mouse
the mouse has
mouse has been
been clicked in
clicked in order
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
dialog tools are
tools are doing
are doing for
doing for you
for you in
you in the
create the basics
basically a loop
loop to capture
to capture mouse
capture mouse clicks
to run render's
run render's loop
render's loop and
loop and try
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
need to detect
to detect whether
detect whether the
whether the graphics
is actually still
actually still open
still open or
open or has
or has it
has it been
it been closed
been closed by
use a straightforward
a straightforward is
straightforward is window
is window command
we determined earlier
determined earlier when
earlier when we
window is still
still active or
it is no
no longer active
longer active then
active then we
can exit this
from the isWindow
the isWindow function
isWindow function is
function is false
then the graphics
been closed and
closed and we
is still open
still open we
open we need
whether the mouse
been clicked or
clicked or not
a graphic window
graphic window click
window click command
click command we
it the hWindow
the hWindow handle
hWindow handle and
handle and we're
it three additional
A click variable
click variable and
variable and an
If the click
the click variable
click variable returns
variable returns zero
then there has
been no mouse
no mouse click
it returns one
returns one then
one then the
then the left
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
graphics screen are
screen are returned
are returned in
returned in the
the long x
long x and
the long y
long y variables
to declare these
declare these new
of our click
value of long
of long click
long click is
click is greater
then the mouse
mouse has indeed
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
the mouse somewhere
mouse somewhere inside
somewhere inside the
window and click
and click we
see the coordinates
coordinates are now
coordinates that have
have been clicked
clicked on it
on it should
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
After all we
all we know
know the location
the button, we
we know its
know its width
width and we
know its height
So it's a
matter of arithmetic
of arithmetic to
arithmetic to work
whether the x
coordinates are within
are within that
within that boundary
we're testing if
testing if long
if long x
long x is
x is greater
is greater or
greater or equal
the original position
original position of
bitmap and less
x coordinate plus
And also with
also with its
with its within
its within the
within the boundings
the boundings of
boundings of the
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
and the coordinates
coordinates are returned
we click somewhere
click somewhere on
the button it
button it is
is indeed picking
indeed picking up
it's a button
although we are
are now picking
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
would normally get
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
the illusion to
illusion to the
user that they've
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
graphic line width
it slightly thicker
slightly thicker so
thicker so we
put a simulated
a simulated shadow
simulated shadow in
shadow in place
place to indicate
indicate the fact
the fact the
fact the button
button has actually
actually been depressed
this new line
new line width
line width variable
set its value
value to 2
to 2 pixels
to draw two
draw two lines
two lines, one
one along the
along the top
the top edge
top edge of
and one down
one down the
down the left
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
being the top
the ending point
ending point is
point is the
the color to
color to be
to be dim
be dim grey
second line is
line is a
is a vertical
end we will
do a graphic
graphic redraw to
So having drawn
having drawn this
drawn this vertical
this vertical and
vertical and this
and this horizontal
this horizontal line
horizontal line, we
re-render the bitmap
bitmap to appear
to appear as
appear as if
if it's slightly
it's slightly to
slightly to the
right and slightly
and slightly down
As if the
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
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
the same margin
will see when
button it appears
to be depressed
it's not returning
not returning back
returning back up
up again like
again like a
like a button
a button would
button would normally
would normally do
have to simulate
to simulate that
simulate that again
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
do it instantaneously
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
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
redraw command once
more to redraw
redraw that graphic
that graphic to
the user so
user so they
so they may
they may see
may see it
get our graphics
which is still
is still detecting
still detecting the
detecting the clicking
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
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
mouse click is
click is over
is over the
it is over
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
its original position
redrawing the graphic
user will give
will give the
illusion that the
button is in
in fact interactive
this technique you
technique you can
can display buttons
display buttons on
then once the
it once you've
once you've done
you've done the
done the redrawing
then call any
call any function
any function within
be quite possible
quite possible although
possible although a
although a bit
work to create
window with interactive
with interactive controls
However if you're
lot of dialogue
of dialogue work
dialogue work I
work I would
would recommend doing
recommend doing as
doing as much
much as you
can in the
if you really
you really need
need to you
to you can
do some within
some within the
creation of arrays
your applications, arrays
arrays can be
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
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
use of some
of some random
random data generation
data generation in
generation in this
this application, we're
use the Randomize
Randomize command using
command using its
using its single
parameter of timer
number generator with
generator with the
So firstly, we're
create a one-dimensional
a one-dimensional string
one-dimensional string array
string array with
And having created
having created this
some data using
Assign command takes
takes the name
first parameter, followed
by an equals
an equals sign
equals sign and
sign and then
then a comma
values you wish
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
they have arrived
next loop, stepping
will see, although
have five lines
of data appearing
the screen, only
only four of
four of them
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
when we dimensioned
we dimensioned the
dimensioned the array
gave it the
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
has created an
created an array
array with six
with six elements
six elements, starting
the element zero
element zero, then
then one, two
four and finally
and finally five
when we use
Assign command, we
the value apple
value apple into
apple into the
is the zero
And because our
because our for
going from one
to five, it
it will only
will only display
only display those
display those five
those five elements
not display the
display the zero
zero element, which
which is why
is why one
why one of
of them was
them was missing
require the zero
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
equivalent to dimensioning
to dimensioning it
dimensioning it from
it from elements
zero to five
you only want
only want elements
want elements one
elements one to
to five, you
in brackets put
brackets put one
this array, there
be no zero
no zero element
see all five
all five elements
five elements are
elements are now
Whether you have
have a zero
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
column header name
other thing that
thing that it's
useful to do
do when accessing
when accessing your
accessing your array
your array is
is not to
not to assume
to assume the
assume the element
the element size
At some points
some points in
points in your
may well redimension
well redimension an
redimension an array
array to change
change its size
a nice dynamic
nice dynamic way
what the lower
lower bounding and
bounding and the
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
replace the for
the for lngR
lngR equals one
to five with
five with a
code will work
out the lower
lower bounding value
bounding value and
upper bounding value
bounding value of
the array dynamically
way your code
your code does
code does not
does not need
the event of
event of the
array being redimensioned
code again, it
time the for
loop is dynamically
is dynamically working
dynamically working out
The dimensional aspects
dimensional aspects of
aspects of your
array can sometimes
can sometimes depend
sometimes depend on
data that you
wanted to hold
hold information based
at storing information
storing information for
the last 10
last 10 years
Perhaps the number
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
can dimension an
an array from
from elements one
one to 10
10 and put
values in, having
having something even
something even more
even more dynamic
more dynamic is
dynamic is quite
create a one
dimensional array with
array with an
with an element
an element for
for each year
each year and
year and store
store the numbers
the numbers of
numbers of staff
of staff working
staff working for
working for each
here is create
is create two
One to specify
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
to dimension an
array using these
two variables from
variables from the
start year to
year to the
array will not
not be 0
or 1, it
will be 2013
will be 2023
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
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
to a log?
a log? How
log? How would
would we access
we access it
access it from
from the array?
the array? So
array? So using
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
case for that
that particular array
particular array, the
the staff count
staff count array
count array, will
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
we're also getting
also getting out
getting out the
of staff for
staff for each
as we populated
populated the years
the years 2022
years 2022 and
2022 and values
and values coming
out for those
So this shows
this shows that
shows that when
you dimension array
dimension array, you
you have quite
have quite a
of flexibility of
flexibility of the
of the lower
upper bounding elements
go further than
further than just
than just positive
just positive numbers?
positive numbers? Let's
numbers? Let's say
wanted to create
create another one-dimensional
another one-dimensional array
one-dimensional array, but
time with an
an element number
element number for
for each temperature
each temperature, holding
holding the number
of days at
days at that
at that temperature
would we go
go about doing
about doing that?
doing that? Let's
that? Let's say
Let's say, for
in the temperatures
the temperatures of
temperatures of -10
of -10 to
-10 to plus
to plus 5
array from -10
from -10 to
-10 to 5
will create one
create one element
then assign to
assign to that
to that array
that array some
array some values
to populate some
populate some values
some values into
the first seven
first seven elements
seven elements of
elements of this
populated that, let's
let's use the
same construct, the
next loop, using
using the lower
upper bounding, to
our log the
log the temperature
see what comes
what comes out
are our temperatures
our temperatures from
temperatures from -10
first seven have
seven have appearing
have appearing on
on screen, from
populated the values
the other temperature
other temperature values
temperature values, they're
they're all coming
all coming out
out as 0
the numbers we
numbers we use
we use for
and ending elements
ending elements of
elements of an
an array when
array when you
you dimension them
dimension them do
them do not
to be positive
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
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
create a two-dimensional
two-dimensional array, holding
holding a day
a day number
day number in
first element and
rainfall in the
this new array
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
populate that using
that using a
first column the
column the day
the day number
0 and 6
second column, we're
to be generating
be generating a
generating a random
0 and 200
number of millimeters
of millimeters of
millimeters of rainfall
can report on
report on each
of the seven
the seven days
seven days how
days how much
how much rainfall
much rainfall occurred
log the data
data that's sitting
that's sitting in
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
for the L-bound
the L-bound of
L-bound of the
case is 1
is 1, and
case is 7
U-bound commands have
commands have an
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
basically the number
second dimension is
dimension is the
in the upper
of rows, hence
hence the comma
the comma 1
determined that, we
printing out using
out using the
the inbuilt dayname
inbuilt dayname command
have stored a
stored a value
value between 0
and 6 in
6 in the
first row, first
first element, we
actually print out
print out what
out what dayname
what dayname that
dayname that is
The dayname$ function
dayname$ function will
the actual name
actual name of
the day, starting
starting with Sunday
with Sunday for
Sunday for the
our second column
second column is
is the rainfall
the rainfall itself
see we are
we are getting
are getting the
getting the 7
the 7 days
7 days printing
days printing out
printing out on
the log, and
and a random
random number generated
number generated for
generated for the
for the amount
amount of rainfall
more readable, and
It's not immediately
not immediately obvious
immediately obvious that
column is actually
is actually the
actually the day
day number, or
or that the
in fact rainfall
can set these
these up in
up in constants
in constants at
up a simple
a simple enumeration
this particular enumeration
particular enumeration, we
setting up constants
using the singular
the singular command
singular command, so
so it means
it means that
means that the
that the following
following line, in
this case dayname
case dayname, is
with the %
the % sign
% sign in
sign in your
are setting its
the next constant
next constant, in
this case rainfall
case rainfall, we
have not given
not given a
given a value
code will automatically
will automatically populate
automatically populate that
This saves having
having to put
to put them
put them all
them all in
all in specifically
would we put
we comment out
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
that we're storing
storing the dayname
storing the rainfall
we use these
these constants through
constants through the
we don't really
don't really need
which column number
number that data
that data is
It's all handled
all handled by
handled by the
by the constant
So we'll make
we'll make the
same change for
change for displaying
for displaying the
displaying the data
a new piece
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
get the 7
7 days worth
days worth of
worth of rainfall
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
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
want to pack
to pack and
pack and compress
and compress your
compress your executable?
your executable? One
executable? One of
of the reasons
reasons for this
is that if
that if you're
if you're running
you're running in
in a networked
a networked environment
networked environment, you
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
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
is a shared
a shared folder
shared folder, every
every time a
time a user
a user wishes
user wishes to
wishes to execute
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
of other executable
other executable packers
executable packers out
packers out there
these are free
are free, and
these are commercial
are commercial applications
to be concentrating
be concentrating and
concentrating and looking
looking at UPX
below to this
on the Download
the Download latest
Download latest release
latest release, it
it takes you
takes you to
to a section
section of GitHub
of GitHub, where
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
zip file, and
and once unzipped
once unzipped, these
the files that
files that we
that we get
have a HTML
a HTML file
HTML file, which
which has details
has details of
the commands you
And you get
get the executable
the executable command-line
executable command-line utility
command-line utility itself
is the AutoForms
the AutoForms Runner
AutoForms Runner application
It is comprised
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
once it runs
it runs, it
it will bring
will bring up
up a single
single dialog, allowing
to pick which
pick which form
which form to
form to load
the next executable
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
keyed in so
in so far
We covered this
this in detail
in detail in
detail in about
in about 10
about 10 videos
forms folder, we
see the AutoForms
the AutoForms EXE
AutoForms EXE is
EXE is around
is around 448K
around 448K in
448K in size
means a large
a large executable
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
number of embedded
of embedded icons
Each icon or
icon or bitmap
or bitmap you
bitmap you add
you add to
add to your
your application increases
application increases the
increases the size
to use UPX
use UPX to
UPX to compress
to compress both
compress both of
of these executables
these executables, to
if this affects
this affects the
affects the way
at the documentation
the documentation for
documentation for UPX
for UPX, its
its purpose is
is to compress
to compress the
compress the executable
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
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
you have in
have in fact
in fact compressed
fact compressed your
compressed your executable
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
I will enter
will enter the
enter the path
path to UPX
the way UPX
way UPX works
to be just
be just using
just using the
the default means
default means we're
means we're only
put in one
of the binary
the binary executable
binary executable that
executable that we
wish to compress
try is autoform.exe
a little timeout
little timeout at
timeout at the
of the batch
the batch file
batch file so
console window will
window will stay
will stay on
stay on screen
screen for around
for around six
around six seconds
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
take a copy
a copy of
copy of that
can compare it
compare it to
it to what
to what it
it is going
look like after
like after compression
is our copy
on our batch
our batch file
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
a folder and
folder and run
the formrunner application
formrunner application again
pick our form
our form, hit
and our autoforms
our autoforms executable
autoforms executable runs
executable runs quite
It lets us
lets us display
us display all
display all the
the detail that's
detail that's been
And lets us
lets us step
us step through
have an executable
an executable that
executable that is
that is half
half the size
with the initial
the initial file
initial file as
file as well
have now amended
now amended the
amended the batch
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
and we'll run
we'll run that
run that there
And double click
And it tells
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
executable runs just
runs just fine
our second executable
second executable still
executable still functional
achieved is the
compression of two
of two separate
two separate executables
separate executables in
executables in one
in one batch
one batch file
can we compress
we compress a
compress a dynamic
dynamic link library?
link library? We
library? We have
We have down
have down at
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
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
first two because
two because they
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
even if your
if your executable
your executable is
executable is quite
quite small you
you can still
can still get
still get a
a good ratio
good ratio of
ratio of compression
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
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
Reducing your time
your time taken
taken to download
download it from
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
calling again the'hasDependentControl'
you for watching
of rows basedon
rows basedon the
basedon the array
we've been passed.Next
been passed.Next we're
passed.Next we're going
do a nestedfor
a nestedfor next
nestedfor next loop
looking through eachcolumn
through eachcolumn and
eachcolumn and each
and each row.This
each row.This function
row.This function makes
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
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
us more room.So
more room.So that
room.So that the
column does notrun
does notrun into
notrun into the
the next column.So
next column.So now
column.So now that
this final functionfinished
final functionfinished let's
functionfinished let's try
compile to makesure
to makesure we
makesure we haven't
haven't missed anything.So
missed anything.So our
anything.So our application
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
Let'sjust drag in
in some datafrom
some datafrom one
datafrom one of
the HTML pages.And
HTML pages.And there
pages.And there we
our table atthe
table atthe bottom
atthe bottom of
of the page.We
the page.We have
page.We have the
have the titlecolumns
the titlecolumns column
titlecolumns column one
and we havethe
we havethe data
havethe data underneath
data underneath it.Let's
underneath it.Let's try
it.Let's try it
it with anotherpage
with anotherpage with
anotherpage with some
some more data.Now
more data.Now we
data.Now we have
which has oneheader
has oneheader and
oneheader and two
two data lines.And
data lines.And again
lines.And again we
a caption isactually
caption isactually positioned
isactually positioned inthe
positioned inthe middle
inthe middle of
of the table.And
the table.And we
table.And we have
two a largerdata
a largerdata column
largerdata column and
smaller data column.So
data column.So in
column.So in summary
we've achieved todayis
achieved todayis we
todayis we have
for table tags.Within
table tags.Within the
tags.Within the table
we're supporting thecaption
supporting thecaption tag
thecaption tag which
to put acaption
put acaption above
acaption above the
above the table.We
the table.We have
table.We have support
tag to allowus
to allowus to
allowus to put
put column headersin
column headersin which
headersin which are
shown in bold.The
in bold.The width
bold.The width of
driven by thedata
by thedata within
thedata within that
within that table.If
that table.If the
table.If the column
wider then thatis
then thatis the
thatis the width
of that column.If
that column.If the
column.If the data
actually wider thenthat
wider thenthat will
thenthat will be
be the width.So
the width.So this
width.So this is
basics of thebeginnings
of thebeginnings of
thebeginnings of table
of table support.There's
table support.There's a
support.There's a great
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
Power Basic Compilers
new project, to
use of blockchains
of blockchains within
blockchains within Power
what is blockchain
is blockchain, and
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
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
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
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
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
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
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
of these entities
these entities carries
entities carries out
carries out transactions
out transactions with
transactions with the
And each site
each site keeps
site keeps track
of the transactions
the transactions it
transactions it has
moment no central
no central authority
central authority with
authority with the
of all transactions
And each entity
each entity is
entity is unaware
is unaware of
unaware of transactions
of transactions that
transactions that did
did not affect
not affect them
add a central
a central entity
central entity, which
want to hold
hold a list
all transactions made
transactions made in
made in the
order they occurred
want some unique
some unique transaction
unique transaction number
transaction number on
number on each
on each transaction
each transaction, to
to be identified
be identified in
identified in the
the order that
order that they
that they occurred
This works fine
works fine for
for the central
the central entity
central entity, as
as they have
have a record
a record of
record of every
of every transaction
every transaction, and
and any reporting
any reporting can
reporting can be
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
as such it's
such it's a
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
all the entities
the entities had
entities had a
had a copy
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
a while, and
and the others
the others continued
others continued working
continued working, then
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
to check with
check with the
with the others
the others to
others to ensure
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
up any missing
any missing data
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
used within a
within a company
a company or
company or organisation
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
by a group
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
to this question
It depends entirely
depends entirely on
entirely on what
what you need
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
 What we
this series is
series is to
at creating a
creating a blockchain
a blockchain solution
blockchain solution in
solution in Power
a project from
project from initial
using both the
 Today we
will start the
start the Cluster
the Cluster Processing
Cluster Processing Project
 It can
to complete processing
complete processing tasks
processing tasks dealing
tasks dealing with
dealing with very
very large datasets
order to reduce
to reduce this
reduce this processing
this processing time
processing time we
time we have
looked at using
at using parallel
using parallel processing
processing and multi
and multi threading
multi threading on
threading on a
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
of those computers
those computers deals
computers deals with
deals with a
with a section
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
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
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
allow the Cluster
the Cluster to
Cluster to be
to be scalable
be scalable depending
scalable depending on
 processing task
 Any computer
Any computer or
or server can
server can be
to the cluster
the cluster as
cluster as long
long as it
it is on
the same network
 As each
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
be large datasets
large datasets, there
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
to this common
this common data
common data store
 Now we
have got to
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
call that computer
that computer the
computer the 'Task
the 'Task Leader'
the computers which
computers which are
which are doing
are doing the
doing the processing
the processing, we
call the 'Task
the 'Task Workers'
 The 'Task
'Task Leader' needs
Leader' needs 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
have been known
been known to
known to the
the Task Leader
Task Leader at
Leader at some
the past, they
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
of those cores
those cores should
cores should be
able to support
support a separate
a separate task
This will considerably
will considerably increase
considerably increase the
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
What the Task
Task Leader needs
Leader needs to
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
-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
been completed, it
needs to save
save the results
results to a
to a common
a common storage
common storage area
 So this
a short summary
short summary of
of the requirement
the requirement for
requirement for this
for this cluster
this cluster processor
What we'll cover
we'll cover in
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
look at classes
at classes and
classes and objects
they and how
use them within
them within Power
within Power Basic?
 So what
what is an
an object in
object in programming
in programming terms?
programming terms? How
terms? How can
can I use
I use it
use it and
and what is
is it for?
it for? There
for? There have
been many different
many different coding
different coding languages
coding languages created
languages created over
created over the
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
 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
wish to carry
to carry out
carry out within
out within your
 The idea
behind this encapsulation
this encapsulation is
encapsulation is that
object is reusable
is reusable in
reusable in future
future applications that
applications that would
that would need
would need that
need that functionality
 This should
should save you
you time developing
time developing new
developing new applications
new applications as
applications as they
as they will
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
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
by other developers
developers who only
who only need
know the interface
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
class is used
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
 When in
When in your
your code you
code you create
a new instance
new instance of
instance of an
an object, the
the definitions in
definitions in the
in the class
the class are
class are used
the new instance
instance of that
 As such
such you can
can create multiple
create multiple separate
multiple separate instances
separate instances of
the same object
same object and
object and each
and each will
each will have
will have its
its own distinct
own distinct copy
distinct copy of
the variables defined
variables defined within
defined within the
within the class
 In Power
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
code or slow
or slow down
down the processing
 While this
While this may
may be true
be true of
true of other
of other languages
other languages, Power
Basic has gone
has gone a
gone a long
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
an object, you
you instantiate it
 This creates
This creates the
creates the object
object which encapsulates
which encapsulates both
encapsulates both the
both the code
the variables within
variables within it
 These variables
These variables are
variables are referred
are referred to
to as instance
as instance variables
data is hidden
is hidden within
hidden within the
within the object
object and cannot
and cannot be
be accessed directly
accessed directly as
directly as these
as these variables
variables are invisible
the code outside
code outside the
outside the object
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
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
to use objects?
use objects? -
objects? - Class
- Class is
is a definition
a definition of
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
set of methods
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
similar to a
a function or
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
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
object is created
 - Constructor
- Constructor, this
an optional class
optional class method
class method run
method run when
run when the
 - Destructor
- Destructor, this
 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
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 should interface
should interface with
interface with applications
with applications making
 You may
may have a
have a review
a review stage
review stage after
stage after an
after an application
an application has
been completed and
completed and as
and as part
of that review
that review you
review you may
you may look
may look at
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
that you created
you created using
created using traditional
using traditional functions
traditional functions and
and subroutines is
subroutines is very
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
option of redeveloping
of redeveloping this
redeveloping this useful
this useful code
useful code in
form of an
an object that
object that can
be easily be
easily be used
used in future
future applications needing
applications needing that
needing that functionality
 Power Basic
Basic does give
the flexibility of
flexibility of having
of having your
having your entire
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
below to a
to a simple
a simple example
simple example of
example of a
of a Power
Power Basic class
for watching! 






















































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































