QBasic and QB64 Discussion Board

# Flood Fill Flow Chart

I'm having a really hard time visualizing how a flood-fill algorithm works.

I can find the algorithm online pretty easily, and I can even get it to work by script-kiddy-ing.

But I don't understand it.

Is there a flowchart? I've Googled for it at length, and I can't find anything.

Posted on Jan 17, 2011, 10:15 AM

# Flood fill, my favourite

Moderator

The key to understanding flood fill is to understand what a "continuous region" actually is. (I will just use the word "region" from now on.)

You can think of a region as an area of pixels that are all the same colour and all "connected", basically you could colour all of them "without lifting the pen from the page".

Do you know what I mean? If so, good. But we need to be more precise about it.

So here is a more precise defintion:

Suppose a pixel belongs to some region, call it region X. Then all the neighbours of that pixel which are the same colour as it is, also belong to region X.

That's all! Notice that by applying this repeatedly you eventually discover all pixels belonging to the same region.

Note that in a floodfill, we get one initial pixel and we want to find all pixels belonging to the same region as that pixel. So here is pseudo-code for a floodfill algorithm:

1. place initial pixel in work-list
2. if work-list is empty, end
3. retrieve (and remove) a pixel from work-list
4. add all neighbours of the pixel that have the same colour to work-list
5. change colour of the pixel
6. GOTO 2.

The work-list consists of pixels that you know are in the same region as the initial pixel, but whose neighbours may not have been considered yet. Over time, the entire region will be explored.

Step 5 is important: if you leave it out, you will keep revisiting pixels you've already checked.

Algorithms vary considerably in step 3. Recursive or stack-based solutions retrieve the most recently added pixel from the work list. Queue-based solutions retrieve the least recently added pixel. (Queue-based solutions usually use less memory, but I encourage you to try both and compare.)

If you want any further explanation, or some tweaks you can make to make it run faster, let me know. I implemented a super-fast VGA floodfill a while ago.

Posted on Jan 18, 2011, 3:21 AM

# Speed

I don't understand the queuing here...

But i think that much speed is lost when some pixels are checked twice. The flooding is a border problem, border says line, line says adjacent pixel. If you put all pixels coordinates (from the line) in a array and do all next-to-pixel checks, many pixels will be checked twice. OTOH recalling all the checks would also cost some time.. and mem. So how to optimise this ?

thanks, L

Posted on Jan 22, 2011, 1:19 AM

# Some tricks...

Moderator

The first trick applies only to certain VGA modes. VGA has a "colour compare" feature which lets you check which pixels in a horizontal group of 8, match a certain colour. VGA also lets you change the colour of the 8 pixels in one go.

Try this:

That method has another optimisation that complements the VGA advantage - it fills a horizontal line as far to the left and right as possible, and then checks the line above and the line below for any continuous horizontal stretches with the matching colour. It only adds ONE pixel per stretch to the queue.

Operating with horizontal lines like this means pixels are rarely checked twice in the horizontal direction (although they are still checked twice fairly often in the vertical direction). It also means far less usage is made of the queue, making it more efficient.

You may be able to improve performance by storing extra information on the queue. For example, if reading pixels is expensive (such as when using POINT on a bitplane screen) you can store which direction the pixel was in when it was added. This lets you avoid re-checking a pixel. You can also change the colour of a pixel *before* adding it to the queue, which means it will never be added to the queue twice. If you're using the horizontal ranges technique, you can store information about the "parent" range in the queue so it is not re-checked.

Posted on Jan 22, 2011, 1:41 PM

# Re: Some tricks...

Thanks, I'm going to try to flow-chart this for myself. This is much better than the only other explanation of flood-fill I found on the internet (http://www.bobpowell.net/floodfill.aspx), which I'm sure is accurate... though inscrutable (to me).

Posted on Jan 22, 2011, 3:30 PM

# AB AC AD BC BD CD

Hi,

I am v new to QB. I have been writing a little program to help me with my writing.
What i am stuck with is i want a way for QB to quiz me on 4 ideas for the and then tell me which i prefer. kind of like a psychometric test does.

something like:

input "what is your first idea?", idea1\$
input "what is your second idea?", idea2\$
input "what is your third idea?", idea3\$
input "what is your fourth idea?", idea4\$
CLS
print "do you prefer "; "1."; idea1\$; "or "; "2."; idea2\$; "?"
input "enter 1 or 2 ", XXXX
print "do you prefer "; "1."; idea3\$; "or "; "2."; idea4\$; "?"
input "enter 1 or 2 ", XXXX
print "do you prefer "; "1."; idea1\$; "or "; "2."; idea3\$; "?"
input "enter 1 or 2 ", XXXX
print "do you prefer "; "1."; idea2\$; "or "; "2."; idea4\$; "?"
input "enter 1 or 2 ", XXXX
print "do you prefer "; "1."; idea1\$; "or "; "2."; idea4\$; "?"
input "enter 1 or 2 ", XXXX
print "do you prefer "; "1."; idea2\$; "or "; "2."; idea3\$; "?"
input "enter 1 or 2 ", XXXX

obviously the XXXX would be replaced by some piece of code i need. maybe an IF...THEN.

what i want is that it comes up with something like:
your order of preference (from favorite to least preferred) is:
Idea4\$ (1 vote)

Cheers,
Dan

Posted on Jan 13, 2011, 5:02 PM

# Try an array

CLS
DIM choice(4)

input "what is your first idea? ", idea1\$
input "what is your second idea? ", idea2\$
input "what is your third idea? ", idea3\$
input "what is your fourth idea? ", idea4\$

CLS
print "do you prefer "; "1. "; idea1\$; " or "; "2. "; idea2\$; "?"
input "enter 1 or 2 ", num
choice(num) = choice(num) + 1

print "do you prefer "; "1. "; idea3\$; " or "; "2. "; idea4\$; "?"
input "enter 1 or 2 ", num
choice(num + 2) = choice(num + 2) + 1

PRINT Idea1\$, choice(1)
PRINT Idea2\$, choice(2)
PRINT Idea3\$, choice(3)
PRINT Idea4\$, choice(4)

END

--------------------------------

Get the concept?

Pete

 This message has been edited by The-Universe on Jan 13, 2011 9:21 PM

Posted on Jan 13, 2011, 9:20 PM

# Why don't you use TWO Arrays?

R

CLS
DIM idea\$(4), choice(4)

input "what is your first idea? ", idea\$(1)
input "what is your second idea? ", idea\$(2)
input "what is your third idea? ", idea\$(3)
input "what is your fourth idea? ", idea\$(4)

CLS
print "do you prefer "; "1. "; idea\$(1); " or "; "2. "; idea\$(2); "?"
input "enter 1 or 2 ", num
choice(num) = choice(num) + 1

print "do you prefer "; "1. "; idea\$(3); " or "; "2. "; idea\$(4); "?"
input "enter 1 or 2 ", num
choice(num + 2) = choice(num + 2) + 1

PRINT Idea\$(1), choice(1)
PRINT Idea\$(2), choice(2)
PRINT Idea\$(3), choice(3)
PRINT Idea\$(4), choice(4)

END

When you start numbering variable names, it's time to use an array!

Posted on Jan 13, 2011, 10:37 PM

# I think what you are asking is "How do I sort?"

Moderator

The easiest way to sort is to swap things that are in the wrong order. QB has the SWAP statement to help you do this.

With 4 items it's feasible to make a series of IFs and SWAPs that will produce the desired ordering, but with more items it becomes very tedious. Using an array allows you to write a short loop instead, so I will show how it's done.

One of the most obvious sorting techniques is "bubble sort" and the idea behind it is to look through the list, and if you see a pair of items next to each other that are in the wrong order you swap them. Then you repeat the procedure until you no longer find anything out of order.

DIM Idea\$(1 to 6)

Idea\$(1) = "May"
Idea\$(2) = "the"
Idea\$(3) = "Force"
Idea\$(4) = "be"
Idea\$(5) = "with"
Idea\$(6) = "you"

DO

swappedSomething = 0
FOR I = 1 to 5 'Scan through list
SWAP Idea\$(I), Idea\$(I+1)
swappedSomething = 1 'and remember that it was done
END IF
NEXT

LOOP WHILE swappedSomething = 1

Another technique is selection sort, where you go through the list and locate the largest item and put it first, then go through the remaining items and find the largest and put it second, then go through the remaining items and find the largest and put it third, and so on. It looks like this:

FOR I = 1 to 5 'Item we're looking for
FOR J = I+1 to 6 'Go through the rest of the list
IF votes(J) > votes(I) THEN 'This one is larger than what we have currently
SWAP Idea\$(I), Idea\$(J)
END IF
NEXT
NEXT

You should figure out how at least one of these methods works. You probably haven't seen certain things before so if you have any questions please ask.

Posted on Jan 14, 2011, 7:01 PM

# * I don't think that is the sort of thing he was looking for. :)

Posted on Jan 14, 2011, 10:38 PM

# *He did say "from favorite to least preferred"

Moderator

Posted on Jan 15, 2011, 1:10 AM

# Ah, but you have to walk before you can run....

Unless of course you are a junior senator of ethnic background with a lot of dumb ideas, a way to make gullible people believe you can make them happen, and an uninspiring opponent to compete against, but I digress...

Let's just see if the OP comes back. Between the three of us, we pretty much did the work for him. I'm OK with that, because he posted code, instead of an assignment.

You know for some of the homework slackers we used to get, back in the day, a really smart slacker would have posted a part fo an assignment at one forum, took the code, and perpetually kept posting at other forums until his assignment was completed. I guess the fly in the ointment is always that smart slacker remains to this day an oxymoron., while the slacker will at best aspire to the level of: PRINT MID\$("oxymoron", 4)

Nice description of sorting, by the way,

Pete

Posted on Jan 15, 2011, 7:19 AM

# * You can't sort one till ya know what it is...

R

Posted on Jan 15, 2011, 8:46 PM

# Now wonderingif if Dan's last name is Phool?

Because if he doesn't come back, he's a Dan Phool!

Pete

 This message has been edited by The-Universe on Jan 16, 2011 7:02 AM

Posted on Jan 15, 2011, 9:29 PM

# * It's nothing personal Dan....:-P

R

Posted on Jan 15, 2011, 11:21 PM

# My bit and Clippy's comment is from an American commercial...URL*

 This message has been edited by The-Universe on Jan 16, 2011 7:08 AM

Posted on Jan 16, 2011, 7:06 AM

# *Very funny -- now my mnemonic device for you is re-Pete.

R

*

Posted on Jan 16, 2011, 2:09 PM

# * Well that's just way too Bobvious.

Posted on Jan 16, 2011, 6:33 PM

# *You were the one suggesting TWO of them :P

Moderator

Posted on Jan 15, 2011, 9:59 PM

# heavy-duty non-recursive quicksort

umm... for REALLY big sorting tasks:
'* declare and fill a test array
REDIM array(0 TO 33555432)
FOR i& = LBOUND(array) TO UBOUND(array)
array(i&) = (RND * (UBOUND(array) + 1)) AND 16777215
NEXT
'* Call iterative quicksort
sort% = 1
QuickSort array(), LBOUND(array), UBOUND(array), sort%

'* Sequence Check -- accounts for equal array values

SequenceCheck array(), LBOUND(array), UBOUND(array), sort%
ERASE array
END
SUB SequenceCheck (array(), start&, finish&, order%)
hold& = start&
FOR j& = start& TO finish&
SELECT CASE order%
CASE 1
IF array(j&) > array(hold&) THEN
STOP
ELSE
IF array(j&) < array(hold&) THEN
hold& = j&
END IF
END IF

CASE ELSE
IF array(j&) < array(hold&) THEN
STOP
ELSE
IF array(j&) > array(hold&) THEN
hold& = j&
END IF
END IF
END SELECT
NEXT
END SUB

SUB QuickSort (array(), start&, finish&, order%)
DIM LStack&(LOG(finish& - start&) \ LOG(2) + 1, 0 TO 1)
StackPtr& = LBOUND(Lstack&)
LStack&(StackPtr&, 0) = start&
LStack&(StackPtr&, 1) = finish&
StackPtr& = 1

DO
StackPtr& = StackPtr& - 1
Low& = LStack&(StackPtr&, 0)
Hi& = LStack&(StackPtr&, 1)

DO
i& = Low&
j& = Hi&
compare = array(Low& + INT(RND * (Hi& - Low&)))
DO
SELECT CASE order%
CASE 1
DO WHILE array(i&) > compare
i& = i& + 1
LOOP

DO WHILE array(j&) < compare
j& = j& - 1
LOOP

CASE ELSE
DO WHILE array(i&) < compare
i& = i& + 1
LOOP

DO WHILE array(j&) > compare
j& = j& - 1
LOOP

END SELECT
IF i& > j& THEN
EXIT DO
ELSE
SWAP array(i&), array(j&)
i& = i& + 1
j& = j& - 1
END IF
LOOP

IF j& - Low& < Hi& - i& THEN
IF i& < Hi& THEN
LStack&(StackPtr&, 0) = i&
LStack&(StackPtr&, 1) = Hi&
StackPtr& = StackPtr& + 1
END IF
Hi& = j&
ELSE
IF Low& < j& THEN
LStack&(StackPtr&, 0) = Low&
LStack&(StackPtr&, 1) = j&
StackPtr& = StackPtr& + 1
END IF
Low& = i&
END IF
LOOP WHILE Low& < Hi&
LOOP WHILE StackPtr&
END SUB

Posted on Jan 18, 2011, 5:33 PM

# *What a curious sense of humour you have :P

Moderator

Posted on Jan 19, 2011, 12:55 AM

# * What is so funny Art?

R

Posted on Jan 19, 2011, 7:57 AM

# * yeah, this is SORT of funny, i mean the heavy-duty part

Posted on Jan 19, 2011, 9:36 AM

R

http://www.qb64.net/forum/index.php?topic=2559.msg21302#new

If you have any problems post them in the Bugs Forum.

Have fun!

Ted

 This message has been edited by burger2227 on Jan 11, 2011 11:22 PM

Posted on Jan 11, 2011, 11:20 PM

Hi, I have two problems.

One:
I made a thread before about playing videos and Dav helped me by referring me to http://www.qb64.net/forum/index.php?topic=76.0 the code works great for what I am trying to do, but how do you actually make a FLI video. I have some videos I want to be able to play, but the are MPEG4 right now. I can convert them to any common format using Fotmat Factory (recommended), but I can figure out how to convert to an FLI video. Im pretty sure it just takrs a bunch of pictures and plays them in sequence, but how could I get all the frames from say an AVI video? Also are there any good programs for putting the pictures back together into an FLI?

Two:
I decided that I dont like the default font, so I looked into loading new fonts and it is kind of confusing to me. Could someone please explain this. What I was trying to do is just make it use a different font through the entire program regardless, I dont want any special italics or anything, and also I wanted it to load it from the folder that the program is running from.

Thanks for any help.
-Zack

Posted on Jan 10, 2011, 7:57 PM

# print a qbasic program

1. when i try to print my program it comes back saying printer error yet any other printing is ok

2. using qb's copy facility i want to copy part of a program and then paste it into a do

Posted on Jan 8, 2011, 1:59 PM

# What do you want to do, print or copy and paste?

R

What do you want to do, print or copy and paste?
They are two different things.

To copy and paste from one part of a program to
another in QBasic, drag your mouse to mark the
required area, then press CTRL INSERT. To copy,
go to the new area and press SHIFT INSERT. If
you remain in the QBasic editor, you may also
open another .BAS file and paste into the new
program.

Regards, Don Smith

Posted on Jan 8, 2011, 2:49 PM

# Use Notepad to print out the code.

S

QB's print function is not available outside of pure DOS.

Close your program. Locate the program file on the Windows desktop. Double-click the file to open it. It may ask which program to use to open that type of file (.bas). Select Notepad. Now every time you double-click a .bas file, it will open it with Notepad. Print out the code from there. You can also copy and paste to your heart's content.

Posted on Jan 8, 2011, 7:35 PM

# Seperate COMMAND\$ into args

Hello, this is a noob question:
I need to split COMMAND\$ any number of arguments, based on spaces for example if COMMAND\$ contained "hello how are you" the program would get four seperate arguments: hello, how, are, you.
I have had a go at doing it on several occasions using MID\$ in a FOR loop, but my attempts failed.

Thanks!

Posted on Jan 6, 2011, 6:58 PM

# I'll trade ya. Show me how you create the string command

R

How do you create your command parameters before they are read? I need an example using a command line from Qbasic to another program.

DIM param\$(10)
CLS
text\$ = "Hello world my name is Clippy"

L = LEN(text\$)

FOR n = 1 TO L
txt\$ = MID\$(text\$, n, 1)
IF txt\$ = " " OR txt\$ = CHR\$(9) THEN 'space or TAB
index = index + 1
param\$(index) = tmp\$
tmp\$ = ""
ELSEIF n = L THEN param\$(index + 1) = tmp\$ + txt\$
ELSE tmp\$ = tmp\$ + txt\$
END IF
NEXT

Q\$ = CHR\$(34)
FOR i = 1 TO 10
PRINT Q\$ + param\$(i) + Q\$
NEXT

 This message has been edited by burger2227 on Jan 7, 2011 4:06 PMThis message has been edited by burger2227 on Jan 7, 2011 9:49 AMThis message has been edited by burger2227 on Jan 7, 2011 9:48 AM

Posted on Jan 6, 2011, 7:49 PM

# Try this

Like you said, for loops and mid\$.

text\$ = "This should do the job for you mate"

DIM commandarray(LEN(text\$)) AS STRING
FOR i% = 1 TO LEN(text\$)
IF MID\$(text\$, i%, 1) = " " THEN
commandarray(comcnt%) = txt\$
txt\$ = ""
comcnt% = comcnt% + 1
ELSEIF i% = LEN(text\$) THEN
txt\$ = txt\$ + MID\$(text\$, i%, 1)
commandarray(comcnt%) = txt\$
ELSE
txt\$ = txt\$ + MID\$(text\$, i%, 1)
END IF
NEXT

FOR i% = 0 TO comcnt%
PRINT commandarray(i%)
NEXT

Posted on Jan 6, 2011, 8:12 PM

# Here's QB45's CMD_EX.BAS

R

Here is the QuickBASIC 4.5 program, CMD_EX.BAS, which is located
in the \QuickBASIC\BAS\ADV_EX\ subdirectory. ComLine.Bas is a
COMMAND\$ function programming example.

Regards, Don Smith
========================================================================

' +----------------------------------------------------------------+
' |                                                                |
' |                    C o m L i n e . B a s                       |
' |                                                                |
' +----------------------------------------------------------------+
' | ComLine.Bas is based on the QuickBASIC 4.5 program, CMD_EX.BAS |
' | which is located in the \QuickBASIC\BAS\ADV_EX\ subdirectory.  |
' | ComLine.Bas is a COMMAND\$ function programming example.        |
' +----------------------------------------------------------------+

DEFINT A-Z

DECLARE SUB Comline (N, A\$(), Max)

COLOR 15, 1: CLS
REDIM A\$(1 TO 15)
' Get what was typed on the command line.
CALL Comline(N, A\$(), 10)
' Print out each part of the command line.
PRINT
PRINT SPACE\$(9); "Number of arguments = "; N
PRINT
PRINT SPACE\$(9); "Arguments are: "
FOR I = 1 TO N: PRINT SPACE\$(24); A\$(I): NEXT I

SUB Comline (NumArgs, Args\$(), MaxArgs) STATIC

' +----------------------------------------------------------------+
' |                                                                |
' |                         SUB ComLine                            |
' |                         --- -------                            |
' +----------------------------------------------------------------+
' | SUB ComLine is based on the QuickBASIC 4.5 program, CMD_EX.BAS,|
' | which is located in the \QuickBASIC\BAS\ADV_EX\ subdirectory.  |
' | ComLine.Bas is a COMMAND\$ function programming example.        |
' +----------------------------------------------------------------+
' |                                                                |
' | Subroutine to get command line and split into arguments.       |
' | Parameters:  NumArgs : Number of command line args found.      |
' |            Args\$() : Array in which to return arguments.       |
' |            MaxArgs : Maximum number of arguments array         |
' |                      can return.                               |
' +----------------------------------------------------------------+

CONST TRUE = -1, FALSE = 0

NumArgs = 0: In = FALSE
' Get the command line using the COMMAND\$ function.
Cl\$ = COMMAND\$
L = LEN(Cl\$)
' Go through the command line a character at a time.
FOR I = 1 TO L
C\$ = MID\$(Cl\$, I, 1)
'Test for character being a blank or a tab.
IF (C\$ <> " " AND C\$ <> CHR\$(9)) THEN
'Neither blank nor tab.
'Test to see if you're already
'inside an argument.
IF NOT In THEN
'You've found the start of a new argument.
'Test for too many arguments.
IF NumArgs = MaxArgs THEN EXIT FOR
NumArgs = NumArgs + 1
In = TRUE
END IF
'Add the character to the current argument.
Args\$(NumArgs) = Args\$(NumArgs) + C\$
IF LEFT\$(Args\$(NumArgs), 1) = "/" THEN
Args\$(NumArgs) = MID\$(Args\$(NumArgs), I + 1, LEN(Args\$(NumArgs)))
END IF
ELSE
'Found a blank or a tab.
'Set "Not in an argument" flag to FALSE.
In = FALSE
END IF
NEXT I

END SUB

Posted on Jan 7, 2011, 12:19 PM

# * I forgot TAB. Thanks for reminding me, but what if they use TWO spaces?

R

Posted on Jan 7, 2011, 4:08 PM

# Not a problem

R

Hey there Clippy.

As command line parameters, I tried "help me out here"
with "help" following by one space, "me" followed by two
spaces and "out" following by three spaces. And the
result was:

help
me
out
here

So, the program seems to work even with varying the
number of spaces.

Best regards, Don Smith

 This message has been edited by MarineDon on Jan 8, 2011 9:27 AM

Posted on Jan 8, 2011, 9:19 AM

# * Yeah, but MINE doesn't LOL :-P

R

Posted on Jan 8, 2011, 9:32 AM

# Arrr why doesnt this work?

I am confused. I am trying to get my program to do something if you press this key but do something else if you press a different key, and I dont want to use DO/LOOP for that particular function. I tried:

---
DO
PRINT "Hi"
IF INKEY\$ = "CHR\$(24)" THEN
PRINT "up arrow"
SLEEP
END IF
IF INKEY\$ = "CHR\$(25)" THEN
PRINT "down arrow"
SLEEP
END IF
LOOP
---

I also tried it without the "" but it still didn't work. It works fine if I say IF INKEY\$ = "a" THEN , but not when I use CHR\$. Also I also tried to set CHR\$(24) as A but that didnt work either. Is there an alternative to INKEY\$ that I could use, or just some trick to CHR\$ that I missed?
-Zack

Posted on Jan 4, 2011, 8:13 PM

# INKEY\$ has to be assigned to a variable to work properly...

R

INKEY\$ represents a key press that's stored in the keyboard buffer. Once it has been accessed for any reason, it is erased and as such is very unreliable for testing key presses. If you assign it to a variable, however, that variable will hold its value for as long as you need it. For example:

DO

DO
k\$ = INKEY\$
LOOP WHILE k\$ = "" 'This nested loop waits for a key press

PRINT k\$ 'this prints the key press
LOOP UNTIL k\$ = CHR\$(27) 'pressing Esc will end the program

Once k\$ holds a value, it can be used, tested, etc., until another key is pressed. Incidentally, you don't put CHR\$()'s in quotations, only characters ("a").

If you want to know the ASCII code for any character, go to Help/Contents/ASCII Character Codes. They're all listed, and these are the numbers you place in any code involving CHR\$() to represent characters. Be sure to press Page Down to see the extended character set.

-Bob

 This message has been edited by qb432l on Jan 4, 2011 10:20 PM

Posted on Jan 4, 2011, 10:10 PM

# Ya don't put CHR\$(25) inside of QUOTES! IT IS A KEYWORD!

R

CHR\$(25) is actually the Control key with the "Y" key pressed. IF you print the variable value then it would return a DOWN arrow.

Quotation marks denote the start and end of a STRING value!

When you put CHR\$ inside of quotes, you are designating it as a string and you can NEVER press all of the keys to create that string as INKEY\$ can only read ONE KEY at a time!

DO
K\$ = INKEY\$ 'you only need to read INKEY\$ once per loop
IF K\$ = CHR\$(24) THEN
PRINT K\$
SLEEP
END IF
IF K\$ = CHR\$(25) THEN
PRINT K\$
SLEEP
END IF
LOOP UNTIL K\$ = CHR\$(27) 'escape key press exits loop

SLEEP presents another thing. SLEEP CAN be interrupted by a keypress, BUT the keypress STAYS in the keyboard buffer and can still be read by INKEY\$!

http://qb64.net/wiki/index.php?title=ASCII

Ted

 This message has been edited by burger2227 on Jan 5, 2011 8:38 AMThis message has been edited by burger2227 on Jan 5, 2011 8:36 AMThis message has been edited by burger2227 on Jan 5, 2011 6:44 AM

Posted on Jan 5, 2011, 6:43 AM

# Err, i might be wrong

But up arrow is CHR\$(0) + CHR\$(75) and down is CHR\$(0) + CHR\$(80) ???

Posted on Jan 5, 2011, 10:01 AM

# * Err DO THOSE ARROWS PRINT? ASCII characters genius :-P

R

Posted on Jan 5, 2011, 1:06 PM

# *He's not trying to print them!!!

His code

DO
PRINT "Hi"
IF INKEY\$ = "CHR\$(24)" THEN
PRINT "up arrow"
SLEEP
END IF
IF INKEY\$ = "CHR\$(25)" THEN
PRINT "down arrow"
SLEEP
END IF
LOOP

what i reckon he is after...

DO
PRINT "Hi"

_LIMIT 30 'qb64 only
kb\$ = INKEY\$
SELECT CASE kb\$
CASE CHR\$(0) + CHR\$(72)
PRINT "up arrow"
SLEEP
CASE CHR\$(0) + CHR\$(80)
PRINT "down arrow"
SLEEP
END SELECT
LOOP

so where is he printing arrows?

Posted on Jan 5, 2011, 2:56 PM

# Urine IDIOT!

R

I don't give a RATS ASS what he is trying to do! HE CAN'T USE CHR\$ INSIDE OF QUOTES!

DO
PRINT "Hi"
IF INKEY\$ = "CHR\$(24)" THEN
PRINT "up arrow"
SLEEP
END IF
IF INKEY\$ = "CHR\$(25)" THEN
PRINT "down arrow"
SLEEP
END IF
LOOP

REMOVE THE QUOTES! THEN IT WILL WORK WITH CTRL + X and Y by reading INKEY\$ ONCE in the loop and transferring that to a string variable I named K\$.

THEN PRINT THE CHARACTERS!

It JUST SO HAPPENS that BOTH of those ASCII characters PRINT an ARROW UP AND DOWN! So I decided to PRINT THEM instead of the words!

GOOFBALL!

Well NOW he knows how to read the arrow pad keys too thanks to you! LOL

 This message has been edited by burger2227 on Jan 5, 2011 6:59 PMThis message has been edited by burger2227 on Jan 5, 2011 6:11 PMThis message has been edited by burger2227 on Jan 5, 2011 5:17 PM

Posted on Jan 5, 2011, 5:06 PM

Sorry clippy, i got the wrong end of the stick, mine had poop on it too!!!

But as you say, he got something extra, and i learnt something as well.

Posted on Jan 5, 2011, 5:28 PM

# Silly Clippy, it's "You're an idiot!" not "Your an IDIOT!"

Or what did they call the chemistry student who flunked his urology lab three times?

Urine idiot!

--------------

Pete

Posted on Jan 5, 2011, 6:53 PM

# what did i miss

Moderator

that provides justification for that level of hostility and rudeness?

it appears to me that unseen machine was trying to be helpful, and pointed out something that needed pointing out, and that hadn't been yet covered. neither you nor thebob had shown him how to detect the arrow keys, something he clearly intended to do.

>I don't give a RATS ASS what he is trying to do!

you should.

regards,
michael

Posted on Jan 10, 2011, 8:33 PM

# * LOL, welcome to our forum. Are you NEW here?

R

Posted on Jan 10, 2011, 9:15 PM

# Re: Err, i might be wrong

Moderator

i think the up arrow is chr\$(0) + chr\$(72), or, as i like to represent it, mki\$(&h4800). i think you are right about the down arrow.

if there is no keystroke waiting in the buffer, inkey\$ returns an empty string (0 bytes). if there is a keystroke waiting, inkey\$ returns either a 1 byte or 2 byte string. if it returns a 1 byte string, it is an ascii code. thebob's post tells you how to find a list of their values in the help. if inkey\$ returns a 2 bytes string, the first byte is null (chr\$(0)), and the second byte is a scan code. you can find a list of scan codes in the qbasic help. the link to it is just below the link to the ascii list in the qbasic help.

regards,
michael

Posted on Jan 10, 2011, 8:28 PM

# WAV files

Anyone here know how to player WAV files in QB?? I've looked at some QB wav files and they don't work or don't play the whole file and have noise.

What sound card is needed and what type of WAV file is required to play them in QB & DOS.

Posted on Dec 31, 2010, 4:21 PM

# Try QB64

Moderator

If you are happy using Windows or GNU/Linux then get QB64, it can play all kinds of sound files.

If you really are using nothing but DOS, then playing WAV files is more difficult. I'm afraid I have little experience in that area, although if you're managing to get SOME sound from the WAV players you found then you're probably on the right track and there are timing problems or something like that.

Posted on Dec 31, 2010, 4:34 PM

# Yes, timing problems

Adding SLEEP 1 to the main loop seems to play more of the wav file but it is not how it should sound. And lots of noise.

I was hoping someone might know what WAV files (sampling rate/ bitrate/etc) would work with what sound cards (sound blaster 8/16?).

Anyways, I have to ask, why does almost every question here is now answered with "use QB64/use a library"? It goes against the nature of QBASIC and DOS programming. Should just use java then. It has any function you might ever need built in.

Posted on Dec 31, 2010, 5:02 PM

# Was the goal of learning QB to do things the hard way?

I love QB too, but I have better things to do in life than to pick the hardest possible way to accomplish something. If I wanted to fly from California to Arizona, sure I could get there by flying west for a few days, but flying east makes the trip a whole lot faster and easier.

I see things this way...

QB64 supports all modern operating systems, QB doesn't.

QB64 allows for some functions that QB probably would have had, if it didn't go out of development.

And sure, you could learn JAVA, but why? You already know most of the statements for QB64, which makes programming all the other supporting parts of a program far easier than learning Java or some other language.

Pete

Posted on Dec 31, 2010, 5:51 PM

# flying west will make you to be a better man

Posted on Jan 1, 2011, 1:17 AM

# learn java

It would be an investment of time which would pay off later. I have read in the past about your so called very large business programs. Java is designed with this in mind. Quick modifications & adaptations to very large programs and best productivity in the writing of this type of code is something java is designed for. Perhaps for small applications java can be a bit impractical and it is slow. But if you're using QB64 or even QBasic, you should not never complain about the speed of java.

Posted on Jan 1, 2011, 2:34 AM

# Speaking of SPEED, did you get your driver's license yet? :-P

R

Posted on Jan 1, 2011, 4:34 AM

# In a sense, I agree

Moderator

> SLEEP 1

Use a timer loop:

Et! = TIMER + 0.02 'delay for 0.02 seconds
DO:LOOP WHILE TIMER < Et!

0.02 is as small as you can get with TIMER. If you want a shorter delay try

WAIT &H3DA, 8, 8
WAIT &H3DA, 8

What's supposed to happen is the software should wait for a status change or interrupt from the sound card and at that point refill the DMA buffer. If the software isn't doing this then it should be.

> I was hoping someone might know what WAV files (sampling rate/ bitrate/etc) would work with what sound cards (sound blaster 8/16?).

I would guess that a sound card which can play WAV files can be configured to whatever sample rate you want. I assume that SB16 can play 16 bit samples while older SB can only play 8 bit samples. But it's dead easy to convert a 16-bit sample to an 8 bit sample - just take all the odd bytes.

> Anyways, I have to ask, why does almost every question here is now answered with "use QB64/use a library"?

In a sense, I agree. I've never liked writing a program perched on top of a mountain of code that I didn't write - worse still a mountain of software that I don't have the source code for. This is surely why I'm currently working in OS research.

I've written an article, in fact:

http://imortisoft.no-ip.org/b2b/?Issue_%234:Editorial%3A_Should_BASIC_be_basic%3F

But to be fair, computer technology is advancing but QB isn't. We have amazingly high-resolution screens and sound hardware and cheap cameras and printers and networking. QB was never designed to support them, and more importantly most of them won't work under DOS.

QB64 is our chance to open up this world without losing the "nature" of QB and DOS hacking. And GNU/Linux is a great platform for it: an operating system for which all the source code is available.

Don't reject the future, but help shape it! Think about getting involved with QB64 - we can have a say.

 This message has been edited by Mikrondel on Dec 31, 2010 6:16 PM

Posted on Dec 31, 2010, 6:16 PM

# No, you don't get a say...

Because you only have 1-star. I have 5-stars, and they are special ones!

Pete

- I'll ride a skateboard down the side of a building for a trinket, provided it's shiny!

Posted on Dec 31, 2010, 9:19 PM

# * Oh look! A SHINY paperclip! :-O

R

 This message has been edited by burger2227 on Jan 1, 2011 4:40 AM

Posted on Jan 1, 2011, 4:35 AM

# Re Oh look! A SHINY paperclip! :-O

What point am I missing?

Raydar

Posted on Jan 1, 2011, 6:41 AM

# Is it ta ta true a shiny paper clip can't be ta ta rusted?

I've started to stutter ever since the skateboard accident, which occurred shortly after your post!

Pete

Posted on Jan 1, 2011, 9:37 AM

# * Happy New Year to all my friends at QBasic Form

Posted on Dec 31, 2010, 4:09 PM

# *Same to you, Moneo -- and to all the others (of course, I'll celebrate 2011 before Pete)!

R

*

Posted on Dec 31, 2010, 4:33 PM

# Happy New Year.!

And two years closer to getting rid of Barack Obama, priceless!

Pete

Posted on Dec 31, 2010, 6:06 PM

# getting QB64 to work

I am a great ENTHUSIAST for QB64 and LONGING to get it working fully.

I have told all my friends and ALL of them have various "difficulties".

You guys are so CLEVER - but have LONG FORGOTTEN how to GET STARTED

Could we please have - as a glorious NEW YEAR PRESENT - a SIMPLE way to get QB64 loaded so we can ENJOY finding out about it.

For those of us "blessed" by Bill Gates there are varied obstacles placed in our way, depending on whenther forced to use
XP or Vista, or Win 7 etc and which of his bodge-fixes are in use.

Also due to Windows, we are forced to "plug" many "defects" with things like Prevx (and thousands more) each of which RESTRICTS what we may download and/or plasters our screens in red warnings after/if we get QB64!

As I have said, we newbies can hardly understand every 5th word in your discussions. But I understand that
1. The original download (I succeeded with that as I am on XP) includes a HUGE examples and training section
but NEVERTHELESS
2. Someone has written a download that runs just ONE Prog (was it called "balls") and RUNS and CAN BE SENT anywhere worldwide and runs and is just a few MB size

Something based on a slimmed-down version that INTRODUCES QB64 via one or two example progs.
The current full version took 6 hours to download to Windows 7 and could NOT be unzipped (as it may have got corrupted) and Bill Gates would NOT allow us to download 7-zip and any such files.

Many thanks
GREAT WORK
John

Posted on Dec 31, 2010, 2:44 AM

# Gates got his own Karma back on him...

He spent years screwing people, trying to keep Micro\$oft ahead of the competition. Now he screwed himself. M\$ stock is a tenth of what is was worth at one point, and Apple is ten times what is was worth when it was being clobbered by Gates.

Kudos to Steve Jobs for keeping the big picture in perspective more. He is no saint, but he certainlly delivered a better product line, instead of forcing crap down our throats and telling us we better like it. I will be glasd when QB64 is fully Apple compatible.

As for modifying the QB64 download, I hope that happens, and soon.

As for instructions on how to get it working, hmm, it hasn't given too many people problems; so, I'm having a hard time figuring out what your problem is, other than I suspect the download was too big and failed.

Pete

 This message has been edited by The-Universe on Dec 31, 2010 3:11 AM

Posted on Dec 31, 2010, 3:10 AM

# Re: Gates got his own Karma back on him...

Posted on Dec 31, 2010, 11:07 AM

# 7 HOURS?

R

Please explain your problems more clearly. If your computer is "protected" then you must expect that protection to attempt to block certain things. Please elaborate on the problems you have had.

Naturally the lack of "Administrator Rights" may prevent a download or program installation. This is often considered a GOOD THING by the owner of that PC. You MUST have their approval to do those things.

Once downloaded and unzipped QB64 has an auto-update option that will keep your versions up to date WITHOUT further action by the user. If your PC has problems try unzipping the download to a short named file path. QB64 will unzip into it's own "QB64" folder.

The author, Galleon, will be working on QB64 in January on his "summer break" so any reported problems will be addressed soon. Please feel free to explain your situation and problems that you encounter here or at the QB64 Forum.

http://www.qb64.net/forum/index.php

Ted

Posted on Dec 31, 2010, 8:31 AM

# Re: 7 HOURS?

Hello Ted

As you know, helping a FRIEND is oft HARDER than helping yourself!

My friend in this case "Delmer Hinrichs" [Email Removed] is far more expert with QBASIC than I. We have exchanged GREAT QB progs for 25 YEARS!
It is just he got swindled into buying Windows 7 Vista.

Now he (apart from thus being denied your GREAT QB64) has to run ALL my progs at 1/100th of my XP speed on a load-of-junk called Dos Key etc, torturing himself with its limitations.

Thus to let HIM SEE my simulations of the orbital stability around the Trojan Lagrange "stable" positions in star, planet, Trojan systems I have to increase the time tics HUGELY and stability disappears due to calculation errors solving the Dif Equns.

He is getting SO DISAPPOINTED and fed up!
Has spent MONTHS trying to bootup into DOS - even bought a floppy drive for it!

He is FAR MORE experienced than I - so his problems are completely REAL!!!!

Thank you so very much
John

 This message has been edited by Mikrondel on Dec 31, 2010 2:24 PM

Posted on Dec 31, 2010, 11:25 AM

# QB64 doesn't use DOS. Windows 7 should run it fine!

R

I see that you quickly ADOPTED my style of highlighting...

But your reply tells us nothing! We need SPECIFIC problems that he is having! WHY can't he simply download it? Why is he trying to use DOS in Windows 7? It won't work well! Is his PC 64 bit.

Give him the QB64 link and have him post his SPECIFIC problems there. I'm NOT gonna chase HIM down! It is HIS problem not ours...

Posted on Dec 31, 2010, 12:17 PM

Moderator

Spammers and scammers run software that crawls the web and records email addresses. Posting email addresses in the clear is an invitation for spam and scams. Therefore I removed the email address to protect its owner.

Posted on Dec 31, 2010, 2:32 PM

# Not to worry...

All the spammers are at QB64.

Hey, if you need some new puma shoes, I thing I know someone who knows someone, who knows a bot that can get you a deal!

Pete

Posted on Dec 31, 2010, 5:54 PM

# Funny one I got recently

Moderator

It went along these lines:

"Earn up to \$150 a week working from home!"

I think these people missed out on marketing 101...

Posted on Dec 31, 2010, 7:04 PM

# Stop whingeing and be clear about the problem

Moderator

Funnily enough you're not very good at giving feedback.

If you have a problem, tell us what you're trying to do, the tell us relevant details and the exact procedure(s) you have tried, and what happens - in particular any error messages or informational messages. Include relevant details like the operating system and web browser used. Check whether the operating system is 32-bit or 64-bit.

If you have a suggestion for QB64 then make it clear also. Galleon provides ONE download of QB64 precisely because he wants to keep things simple for beginners.

> As I have said, we newbies can hardly understand every 5th word in your discussions.

BE MORE SPECIFIC! If you don't understand something, please ask us to explain it.

> Apparently "Uncle Bill" does not think that I should download any real programs, that have a BAS or EXE extension.

Which is probably good judgement on his part. Otherwise less discerning users would soon render their computers unusable by accumulating malware, spyware, trojans, media players, games, toolbars, and all manner of "protective" software.

Yes, "protective" software does slow down your computer! Running more than one set of protective software severely impacts performance for little benefit. I use nothing more than a basic firewall with Windows and have not had a virus problem for many years, because I know how to browse the web safely. Using GNU/Linux reduces your chance of virus problems to almost nil, and as an added benefit the system doesn't decide what you can and can't do. The GNU philosophy is centered around the freedom to use software in any way you like and to understand, modify, and copy it at will.

But back to Wındows - in most cases restrictions such as those preventing you downloading BAS and EXE files are not hard to bypass. The exact procedure depends on the program you are using. You may need to change some options or disable your "protective" software. Stop whingeing about how "Bill" has degraded your life and TAKE ACTION to overcome your problems.

One last thing - clean out your mailbox. I tried to send you an email but it was rejected due to your mailbox being full.

Artelius

Posted on Dec 31, 2010, 4:25 PM

# All he got out of that was...

BE MORE SPECIFIC! If (5th word) don't understand something, please (5th word) us to explain it.

I don't know about you weird Australians, but I sure don't want some dude pleasing me.

Kidding aside, I chalk this one up to a very unusual problem and being such, I don't see any serious need for additional work on Rob's part to modify QB64, other than the fact that I still believe it is a better idea to package QB64 separate from all those example programs. Those examples should be packaged as a separate download. Of course that's just my opinion, but like the saying goes, "Everyone is entitled to my opinion."

Pete

Posted on Dec 31, 2010, 6:03 PM

# In need of help

Hi, I know I have asked this question before, but how do you make a program scroll. Thanks for before but I think you misunderstood me. You had the program display something longer than the screen and make it look like its scrolling. What I was looking for was a user controlled scroll like with the bar on the right of the screen, it has 3 lines on it. Would you have to import the picte of that or does it come hardwired with it.

Also, is there a way to make a Menu bar displayed apart from the main
Program at all times, like a "Menu | Edit | Save | Exit" kinda thing, where depending on what you click it will GOTO a different section of code.

Lastly, is there a way to make it wait for ESC the entire program, like if you ever press ESC no matter where you are it will bring you to the main screen. Is there a way to do this without putting LOOP WHILE INKEY\$ = "" or whatever all over the place. If there isnt then can someone explain to me how to get it do it with loop and while. Like, what is the code for the key ESC?

Any help will be appreciated, and thanks in advance.

Posted on Dec 30, 2010, 7:44 PM

# You can use ON KEY to GOSUB to an exit procedure.

R

See Chapter 12 of my Q-basics demonstrator for an explanation of how to use ON KEY event trapping. Unzip into your QB.EXE folder.

http://dl.dropbox.com/u/8440706/Q-Basics.zip

http://dl.dropbox.com/u/8440706/QB45.zip

 This message has been edited by burger2227 on Dec 31, 2010 8:42 AM

Posted on Dec 30, 2010, 8:55 PM

# I think you misunderstood me

I am fammiliar with the ON KEY command, but what I was wondering was if there is a way to do it the entire program. Like if you told it at the beginning that if you ever press Esc for the entire time the program is open then goto to the start. I wont need Esc for anything else. Is this possible?

Posted on Jan 2, 2011, 6:40 PM

# Re: In need of help

There is a way to do all of these things in BASIC, but it requires leaning how to program. If it was a statement, I'd list it, but what you are looking for could take several lines of code.

http://www.network54.com/Forum/190883/message/1172174995/

Pete

 This message has been edited by The-Universe on Dec 30, 2010 9:36 PM

Posted on Dec 30, 2010, 9:32 PM

# *i barely remember writing that. i should have made it so you could drag it with the mouse

Moderator

Posted on Jan 10, 2011, 8:36 PM

Moderator

> What I was looking for was a user controlled scroll like with the bar on the right of the screen, it has 3 lines on it. Would you have to import the picte of that or does it come hardwired with it.

If you're talking about those lines and arrows and lines that you see around the edges of QB, they're just special characters, formed with CHR\$. Try this:

FOR I = 32 TO 255
COLOR 7: PRINT USING "### "; I;
COLOR 2: PRINT CHR\$(I); SPACE\$(3);
NEXT

> Also, is there a way to make a Menu bar displayed apart from the main
Program at all times, like a "Menu | Edit | Save | Exit" kinda thing, where depending on what you click it will GOTO a different section of code.

Well, at any point your program isn't busy doing anything, it can check for user input and process it accordingly. When you PRINT you have to be careful not to print over those menus. Doing this nicely is not easy.

> Lastly, is there a way to make it wait for ESC the entire program, like if you ever press ESC no matter where you are it will bring you to the main screen. Is there a way to do this without putting LOOP WHILE INKEY\$ = "" or whatever all over the place.

In theory yes. The processor has interrupt lines, this means hardware (like a mouse or keyboard) can cause the processor to stop what it is doing to deal with an event. For example, when you press a key, the keyboard sends an interrupt to the processor. The processor runs some code which was put there by the OS to record the key press, and then resumes your program.

So in theory you could add some code there that detects ESC and operates on your program. It turns out that this is very difficult.

In practice, your program just has to check if the key has been pressed, often enough so that the user doesn't notice the delay. PRINTing takes very little time so you don't need to check for the key after every PRINT statement. But whenever you're waiting for the user to type something (or just delaying) you need to also check for escape.

I don't recommend the usage of ON KEY because it's too easy to introduce bugs that way. But ON KEY works by adding a check (invisibly) after every line in your program. So it's a similar principle, really.

If you write your program in an event-based style, which means your program follows this structure:

DO
'Wait for an Event (keypress, mouse motion, click, time lapse, etc.)
'Take action based on event
LOOP

then it's easier to implement something like that.

> Like, what is the code for the key ESC?

CHR\$(27), but you can find out for yourself by using ASC (the opposite of CHR\$), like this:

DO
K\$ = INKEY\$
LOOP WHILE K\$ = ""
PRINT "ASCII code is"; ASC(K\$)

Posted on Dec 31, 2010, 9:57 PM

# Ok... But

The second two are very helpful, Thanks. But with the first one I meant the action of the program rather than the picture. Like on the mouse, in between the left and right clickers, there is that little scroll thing. When you move it back or forth, it moves the text on the screen up or down. And the bar on the right of the screen tells you at what point on the page you are at relative to the entire length of the page. So if you are halfway through the text, the bar would be in the middle. But I think Pete already helped me with that, I havent been able to try the code he recommended yet.

Posted on Jan 1, 2011, 6:34 PM

# Scrollbar theory

Moderator

The ratio of the viewport (i.e. screen) to the image height should be the same as the ratio of the scrollbar height to the height of the scrollbar container.

Similarly the position of the viewport (as a proportion of the image size) should be the same as the position of the scrollbar (as a proportion of the size of its container).

Maybe you want to figure the rest out for yourself, so I'll leave it here. Let me know if you want more help.

 This message has been edited by Mikrondel on Jan 1, 2011 7:05 PM

Posted on Jan 1, 2011, 7:05 PM

# Ok...

I understand what you are saying, but havent had much experience in QB64 and I have no idea how to make that work.

Posted on Jan 2, 2011, 6:37 PM

# What exactly is the problem?

Moderator

Do you need help with drawing the scrollbars, or doing the mathematics to work out where the scrollbar should be, or what?

Also, do you want to use text mode or graphics mode?

Posted on Jan 2, 2011, 7:58 PM

# Uh

All I really want is when you move the middle mouse button forward, the text moves up, and when you move it back, the text moves down. The picture was just to clarify what I was talking about.

Posted on Jan 2, 2011, 9:00 PM

# You could use a string text array

R

Load each line of text from a file into an array. Make sure the lines are less than 80 characters.

Use the _MOUSEWHEEL values to select a span of say 20 lines in the array. The values increase as you scoll down. The value will be limited to number of LINE INPUT # reads for each file minus 20 because you can't read past the end of the array.

DIM Array\$(100)
OPEN "Q-Basics.BAS" FOR INPUT AS #1 '====use any text file with 100 lines
DO UNTIL EOF(1)
inputcount = inputcount + 1
LINE INPUT #1, Array\$(inputcount)
IF inputcount = 100 THEN EXIT DO
LOOP
CLOSE #1
DO

DO WHILE _MOUSEINPUT
row = row + _MOUSEWHEEL
IF prevrow <> row THEN
IF row > 0 AND row <= inputcount - 20 THEN
CLS: LOCATE 2, 1
FOR n = row TO row + 20
PRINT Array\$(n)
NEXT
END IF
END IF
prevrow = row
LOOP
LOOP UNTIL INKEY\$ > ""

Ted

 This message has been edited by burger2227 on Jan 2, 2011 9:59 PMThis message has been edited by burger2227 on Jan 2, 2011 9:53 PM

Posted on Jan 2, 2011, 9:51 PM

# Thanks

Thank you so much. This works and it was exactly what I was looking for. :D

Posted on Jan 3, 2011, 7:46 AM

# Uh, one more question

This is exactly what I was looking for, but with the code you gave me before, how would you set the value of the mousewheel. I am making it so depending on what CASE you entered, it will display a different array. However if you look at an array with many lines and go all the way to the bottom, then try to look at another array with less lines, you have to scroll up a lot before it will display anything. Is there a way to set the mousewheel to 0 upon opening the array? Also could you like use that value, like if you pressed "a" it would add 10 to this variable. Thanls in advance.

Posted on Jan 3, 2011, 10:55 AM

# _MOUSEWHEEL resets to 0 after you read it

Moderator

It's actually the row variable in Clippy's example that needs to be reset when you change to a different array.

And read carefully through Clippy's example code. Make sure you understand how it works and if not, ask for an explanation.

Posted on Jan 3, 2011, 2:20 PM

# Opening videos

Is there a way for a program to open and play a video and then wait for it to finish playing for it to move to the next command?

Posted on Dec 29, 2010, 4:48 PM

# Nope

There is no native support for video files. AS qb64 can use external libraries you might be able to get one that you can link too. If you find one, let me know!

Posted on Dec 29, 2010, 5:51 PM

# I've only been able by using .FLI & Audio files.

.FLI is a 320x200, 256 color Video only format (SCREEN 13). Here' code for that:
http://www.qb64.net/forum/index.php?topic=76.0

You can easily add QB64's built-in Audio playing commands to the FLI player to play a WAV/MP3 while the FLI is playing.

I'm trinkering with the library stuff to play other formats, but have had no success yet (except in failing -- 100% success there!).

- Dav

Posted on Dec 29, 2010, 6:04 PM

# Thanks

Thanks, this will work :)

Posted on Dec 29, 2010, 7:24 PM

# *Merry Christmas to everyone! o<}} :o) }}}}} (Santa CLASCII).

R

*

 This message has been edited by qb432l on Dec 25, 2010 3:42 AM

Posted on Dec 25, 2010, 3:42 AM

# Re: *Merry Christmas to everyone! o<}} :o) }}}}} (Santa CLASCII).

screen _newimage(640,480,32),,1,0

for i=-30 to 30

line (320,100)-step(i,400),_rgb(40,40,0)

next

for j=0 to 8 step .5

for i=.5 to 3.14159-.5 step .001

line (320,320-j*40)-step((200-j*j*3)*cos(i),(100-j*j*1)*sin(i)), _rgb(0,i*50,0)

next

next

screen ,,0,0

do

_limit 30

pcopy 1,0

for i=0 to 500

pset (rnd*640,rnd*480),_rgb(255,255,255)

next

_display

loop until inp(&h60)=1

sleep

system

Posted on Dec 25, 2010, 1:48 PM

# *Gorgeous!

R

*

Posted on Dec 25, 2010, 9:14 PM

# * Thanks Bob, my secret is jojoba oil... oops, wrong response.

 This message has been edited by The-Universe on Dec 26, 2010 11:49 AM

Posted on Dec 26, 2010, 11:49 AM

# My secret to staying young and beautiful is to stay out of the sun...

R

...or any other location where I might actually be seen.
-Bob

Posted on Dec 27, 2010, 3:15 AM

# LOL - But then Canada has a proctive barrier against UV radiation from the sun...

It's called 10 feet of snow!

Pete

Posted on Dec 27, 2010, 8:13 AM

# Actually, no.

S

All that snow reflects back the sun's rays so you get exposed to radiation from below as well as from above.

Posted on Dec 27, 2010, 8:45 AM

# *Ah, but not when you're are under it! Unless you are 10'+ tall, then, excuse the reply.

Posted on Dec 27, 2010, 12:05 PM

# Actually, I've never been particularly frightened of the sun...

R

...or any of that stuff about the ozone. Isn't that just what's left over when you've finished eating a donut?

-Bob

Posted on Dec 27, 2010, 12:57 PM

# That theory is unsound...

If you're eatung a jelly donut, or a cream filled!

Pete

Posted on Dec 27, 2010, 6:58 PM

# * Merry Christmas back at ya Bob, and everyone or two others here.

Posted on Dec 25, 2010, 8:15 PM

# Network 54's strange idiosyncracies

R

Dear Friends:

Introducing ADJUST54.BAS, a program which modifies and
adjusts a QBasic program so as to work with Newwork 54's
strange idiosyncracies. It does four things:

(1) At the top, it places a HTML tag:
"<span style="color:#000000;font-size:10pt;font-family:'Courier New'>"

(2) It places a CHR\$(160) for each space in the program.
This is actually a Spanish accented "a".

(3) It places a HTML 60 wherever a "<" is found. The 60
is proceeded by an ampersand, number sign, and two zeros,
and ends with a semicolon.

(4) It places a HTML 62 wherever a ">" is found. The 62
is proceeded by an ampersand, number sign, and two zeros,
and ends with a semicolon.

The program asks for the name of the .BAS file and then works
its magic and presents the newly formatted program as the
click on "Edit", "Select All" and then "Edit", "Copy" (or
CTRL-C works as well). The program is then "pasted" into
Network54's "Message Text Box", using "Edit", "Paste" or
CTRL-V. Once Notepad is exited the file "temptemp.txt" is
deleted, so if the file is to be saved, please click "file" and
"save as" with another filename.

The SUB ExistFile (x\$, flag) was written by Pete and it's pretty
neat (rhimes). I have my own "exist" SUB but I prefer Pete's.

The ADJUST54.BAS file is below and it has been formatted with the

Christmas Greetings to all, and Happy New Year, Ho, Ho, Ho,
Don Smith

'====================================================================
'====================================================================
'ADJUST54.BAS - Public domain program by Don Smith
'This program adjusts QBasic code for Network 54's strange idiosyncracies
'
DECLARE SUB EditText (Text\$, Row%, Col%, RCol%, FG%, BG%, TextType\$, LenStr%, ExitCode%)
DECLARE SUB ExistFile (x\$, flag)
DECLARE SUB OneLine (LineRow%, LineCol%, LineFG%, LineBG%, Style%, LenStr%)
DECLARE SUB TinyBox (ULRow, ULCol, LRRow, LRCol, BoxFGColr, BoxBGColr, SingOrDoub)
begin:
COLOR 15, 1: CLS
CALL TinyBox(4, 14, 16, 65, 15, 1, 2)
CALL TinyBox(10, 24, 12, 56, 15, 1, 1)
CALL OneLine(6, 14, 15, 1, 4, 51)
CALL OneLine(14, 14, 15, 1, 4, 51)
LOCATE 5, 33: COLOR 14, 1: PRINT "ADJUST54.BAS": COLOR 15, 1
LOCATE 7, 17: PRINT "Enter BASIC filename to convert it to Network's";
LOCATE 8, 17: PRINT "strange idiosyncracies.";
LOCATE 15, 23: PRINT "Press <Esc> to exit with no input";
COLOR 11, 1: LOCATE 15, 29: PRINT "<"; : LOCATE 15, 33: PRINT ">";
LOCATE 11, 26: PRINT "Enter file name: ";
CALL EditText(InLine\$, 11, 43, 55, 15, 1, "", 12, ExitCode%)
IF ExitCode% = 27 THEN COLOR 7, 0: CLS : SYSTEM
CALL ExistFile(InLine\$, flag)
IF flag = 0 THEN
CALL TinyBox(18, 16, 21, 63, 15, 1, 1)
LOCATE 19, 19: PRINT "File " + CHR\$(34) + InLine\$ + CHR\$(34) + " Not Found.";
LOCATE 19, 25: COLOR 14, 1: PRINT InLine\$; : COLOR 15, 1
LOCATE 20, 19: PRINT "Press <Esc> to exit or <Enter> to try again.";
COLOR 11, 1
LOCATE 20, 25, 0: PRINT "<"; : LOCATE 20, 29: PRINT ">";
LOCATE 20, 42, 0: PRINT "<"; : LOCATE 20, 48: PRINT ">";
DO
DO
Pound\$ = INKEY\$
LOOP UNTIL LEN(Pound\$) > 0
Pound% = CVI(Pound\$ + CHR\$(0))
IF Pound% = 27 THEN
COLOR 7, 0: CLS : SYSTEM
ELSEIF Pound% = 13 THEN
InLine\$ = ""
GOTO begin
END IF
LOOP
SYSTEM
END IF
OPEN InLine\$ FOR INPUT AS #1
OPEN "temptemp.txt" FOR OUTPUT AS #2
PRINT #2, "<span style='color:000000;font-size:10.0pt;font-family:Courier New'>"
COLOR 15, 1: CLS
DO
FOR LineIn% = 1 TO LEN(Adj\$) + 1
IF LineIn% = LEN(Adj\$) + 1 THEN
LineIn% = 0
LineLook\$ = ""
EXIT FOR
END IF
IF LineLook\$ = CHR\$(32) THEN         'empty space is Spanish accented "a" character
LineLook\$ = CHR\$(160)
ELSEIF LineLook\$ = "<" THEN          '<   < LESS-THAN SIGN
IF MID\$(Adj\$, LineIn% + 1, 4) <> "span" THEN
LineLook\$ = "<"
END IF
ELSEIF LineLook\$ = ">" THEN          '>   < GREATER THAN SIGN
IF MID\$(Adj\$, LineIn% - 2, 2) <> "w'" THEN
LineLook\$ = ">"
END IF
END IF
NEXT
LOOP UNTIL EOF(1)
PRINT #2, "</span>"
CLOSE #1: CLOSE #2
SHELL "notepad.exe" + " " + "temptemp.txt"
KILL "temptemp.txt"
SYSTEM

DEFINT A-Z
SUB EditText (Text\$, Row%, Col%, RCol%, FG%, BG%, TextType\$, LenStr%, ExitCode%)
' +---------------------------------------------------------------------+
' |                    -  S U B   E d i t T e x t  -                    |
' +-----------+---------------------------------------------------------+
' | Row%      |  The screen row.                                        |
' +-----------+---------------------------------------------------------+
' | Col%      |  The screen column.                                     |
' +-----------+---------------------------------------------------------+
' | RCol%     |  The right far column.                                  |
' +-----------+---------------------------------------------------------+
' | Text\$     |  The text that is sent and returned from the edit line. |
' +-----------+---------------------------------------------------------+
' | TextType\$ |  For all ASCII characers 32 to 255, TypeOfText = ""     |
' |           |  For numbers only, TypeOfText\$ = "1234567890"           |
' |           |  For numbers with commas and decimals points,           |
' |           |  TypeOfText\$ = ".,1234567890"                           |
' |           |  For Yes or No answers, TypeOfText\$ = "YNyn"            |
' |           |  Whatever is included within the parethesis             |
' |           |  is what will be accepted by the SUB EditText.          |
' +-----------+---------------------------------------------------------+
' | LenStr%   |  The length of the Text\$ to be edit.                    |
' +-----------+---------------------------------------------------------+
' | ExitCode% |  Returned positive number of the key that was used      |
' |           |  to exit the edit call.                                 |
' +-----------+---------------------------------------------------------+
LOCATE Row%, Col%: COLOR FG%, BG%: PRINT SPACE\$(LenStr%);
TText\$ = LEFT\$(Text\$ + STRING\$(LenStr%, 32), LenStr%)
CPosition% = LEN(Text\$) + 1
LenStr% = LenStr% + 1
TRUE = 1
Insert = 0
DO
IF Insert THEN
Insert = -1
LOCATE , , 1, 4, 7
ELSEIF NOT Insert THEN
Insert = 0
LOCATE , , 1, 6, 7
END IF
LLen% = RCol% - Col%
NRow% = CINT(LenStr% / LLen% + .5)
NRow% = Row%
Creek% = CPosition% \ LLen% + 1
IF Creek% > 1 THEN
Cp = (CPosition% MOD (Creek% - 1) * LLen%)
IF Cp = 0 THEN
Creek% = Creek% - 1
Cp = LLen%
END IF
ELSE
Cp = CPosition%
END IF
R = Row%
FOR x = 1 TO NRow%
LOCATE R, Col%: PRINT MID\$(TText\$, x * LLen% - LLen% + 1, LLen%);
R = R + 1
IF CPosition% >= LenStr% THEN
CPosition% = 1
END IF
NEXT
LOCATE Row% + Creek% - 1, Col% + Cp - 1
DO
KeyCode\$ = INKEY\$
LOOP UNTIL LEN(KeyCode\$)
KeyCode% = CVI(KeyCode\$ + CHR\$(0))
IF KeyCode% > 31 AND KeyCode% < 255 THEN   'ASCII characters 32 to 254
IF CPosition% <= LenStr% AND Insert THEN
LOCATE , , 1, 4, 7
TText\$ = LEFT\$(TText\$, CPosition% - 1) + KeyCode\$ + MID\$(TText\$, CPosition%, LenStr% - CPosition%)
CPosition% = CPosition% + 1
END IF
IF CPosition% <= LenStr% AND NOT Insert THEN
MID\$(TText\$, CPosition%, 1) = KeyCode\$
CPosition% = CPosition% + 1
END IF
ELSEIF KeyCode% = 8 THEN                           '<BackSpace>
IF CPosition% > 1 THEN
CPosition% = CPosition% - 1
TText\$ = LEFT\$(TText\$, CPosition% - 1) + MID\$(TText\$, CPosition% + 1, LenStr% - CPosition%) + " "
END IF
ELSEIF KeyCode% = 21248 THEN                       '<Delete>
TText\$ = LEFT\$(TText\$, CPosition% - 1) + MID\$(TText\$, CPosition% + 1, LenStr% - CPosition%) + " "
ELSEIF KeyCode% = 20224 THEN                       '<End>
FOR xx = LenStr% TO 1 STEP -1
IF MID\$(TText\$, xx, 1) > CHR\$(32) THEN
CPosition% = xx + 1
EXIT FOR
END IF
NEXT
ELSEIF KeyCode% = 27 THEN                          '<Esc>
ExitCode% = KeyCode%
GOTO ExitRoutine
ELSEIF KeyCode% = 13 THEN                          '<Enter>
Creek% = (CPosition% / LLen% + .5)
CPosition% = Creek% * LLen% + 1
ExitCode% = KeyCode%
GOTO ExitRoutine
ELSEIF KeyCode% = 18176 THEN                       '<Home>
CPosition% = 1
ELSEIF KeyCode% = 20992 THEN                       '<Insert>
Insert = NOT Insert
ELSEIF KeyCode% = 19200 THEN                       '<LeftArrow>
IF CPosition% > 1 THEN
CPosition% = CPosition% - 1
END IF
ELSEIF KeyCode% = 19712 THEN                       '<RightArrow>
IF CPosition% < LenStr% THEN
CPosition% = CPosition% + 1
END IF
END IF
LOOP WHILE TRUE
ExitRoutine:
ExitCode% = KeyCode%
Text\$ = RTRIM\$(TText\$)
END SUB

DEFSNG A-Z
SUB ExistFile (x\$, flag)
' ============================================
' | SUB ExistFile code written by            |
' | Pete (Admin) at the QBasic Forum.        |
' ============================================
' |  x\$ is the file name or file type:       |
' |  File name example: MM.BAS               |
' |  File type example: *.BAS                |
' ============================================
' |  CASE -1: PRINT "File exists"            |
' |  CASE -2: PRINT "File type exists"       |
' |  CASE 0: PRINT "File not found."         |
' ============================================
flag = 0
SHELL "dir /b " + x\$ + ">tmp.tmp"
ff1% = FREEFILE
OPEN "tmp.tmp" FOR INPUT AS #ff1%
DO UNTIL EOF(ff1%)
LINE INPUT #ff1%, filename\$
IF UCASE\$(filename\$) = UCASE\$(x\$) THEN
flag = -1
EXIT DO
ELSEIF INSTR(x\$, "*") < 0 OR INSTR(x\$, "*") <> 0 THEN
flag = -2
EXIT DO
ELSE
flag = 0
END IF
LOOP
CLOSE #ff1%
KILL "tmp.tmp"
END SUB

SUB OneLine (LineRow%, LineCol%, LineFG%, LineBG%, Style%, LenStr%)
' +-------------------------------------------------------------------+
' |                           SUB OneLine                             |
' +-------------------------------------------------------------------+
' |  Not counting REM (') lines, SUB OneLine has 12 lines.            |
' +-------------------------------------------------------------------+
' |  SUB OneLine will place one line on screen.  There are 4 types    |
' |  of lines to choose from.  See Style% below.                      |
' +---------------+---------------------------------------------------+
' |  LineRow%     |   Row to place line.                              |
' +---------------+---------------------------------------------------+
' |  LineCol%     |   Column to place line.                           |
' +---------------+---------------------------------------------------+
' |  LineFG%      |   Foreground color of line.                       |
' +---------------+---------------------------------------------------+
' |  LineBG%      |   Background color of line.                       |
' +---------------+---------------------------------------------------+
' |  Style%       |  Style% = 1   ÃÄÄÄ´                               |
' |               +---------------------------------------------------+
' |               |  Style% = 2   ÆÍÍÍµ                               |
' |               +---------------------------------------------------+
' |               |  Style% = 3   ÌÍÍÍ¹                               |
' |               +---------------------------------------------------+
' |               |  Style% = 4   ÇÄÄÄ¶                               |
' +---------------+---------------------------------------------------+
' |  LenStr%      |  Length of string (line).                         |
' +-------------------------------------------------------------------+
IF Style% = 1 THEN         'ÃÄÄÄ´
SingLine\$ = CHR\$(195) + STRING\$(LenStr%, CHR\$(196)) + CHR\$(180)
ELSEIF Style% = 2 THEN     'ÆÍÍÍµ
SingLine\$ = CHR\$(198) + STRING\$(LenStr%, CHR\$(205)) + CHR\$(181)
ELSEIF Style% = 3 THEN     'ÌÍÍÍ¹
SingLine\$ = CHR\$(204) + STRING\$(LenStr%, CHR\$(205)) + CHR\$(185)
ELSEIF Style% = 4 THEN     'ÇÄÄÄ¶
SingLine\$ = CHR\$(199) + STRING\$(LenStr%, CHR\$(196)) + CHR\$(182)
END IF
LOCATE LineRow%, LineCol%
COLOR LineFG%, LineBG%
PRINT SingLine\$;
END SUB

SUB TinyBox (ULRow, ULCol, LRRow, LRCol, BoxFGColr, BoxBGColr, SingOrDoub)
' +----------------------------------------------------------------------+
' |                          SUB TinyBox                                 |
' +----------------------------------------------------------------------+
' |  ULRow = Upper Left Row.  ULCol = Upper Left Column.                 |
' |  LRRow = Lower Right Row. LRCol = Lower Right Column.                |
' |  BoxFGColr = The Foreground Color The Box.                           |
' |  BoxBGColr = The Back Ground Color Of The Box.                       |
' |  SingOrDoub = 1 (Single Line Box). SingOrDoub = 2 (Double Line Box). |
' +----------------------------------------------------------------------+
COLOR BoxFGColr, BoxBGColr
IF SingOrDoub = 1 THEN
LOCATE ULRow, ULCol
PRINT CHR\$(218) + STRING\$(LRCol - ULCol, CHR\$(196)) + CHR\$(191);
FOR BoxY = ULRow + 1 TO LRRow - 1
LOCATE BoxY, ULCol
PRINT CHR\$(179) + STRING\$(LRCol - ULCol, " ") + CHR\$(179);
NEXT
LOCATE LRRow, ULCol
PRINT CHR\$(192) + STRING\$(LRCol - ULCol, CHR\$(196)) + CHR\$(217);
ELSEIF SingOrDoub = 2 THEN
LOCATE ULRow, ULCol
PRINT CHR\$(201) + STRING\$(LRCol - ULCol, CHR\$(205)) + CHR\$(187);
FOR BoxY = ULRow + 1 TO LRRow - 1
LOCATE BoxY, ULCol
PRINT CHR\$(186) + STRING\$(LRCol - ULCol, " ") + CHR\$(186);
NEXT
LOCATE LRRow, ULCol
PRINT CHR\$(200) + STRING\$(LRCol - ULCol, CHR\$(205)) + CHR\$(188);
END IF
END SUB

 This message has been edited by MarineDon on Dec 25, 2010 9:56 AMThis message has been edited by MarineDon on Dec 25, 2010 9:50 AMThis message has been edited by MarineDon on Dec 25, 2010 9:46 AMThis message has been edited by MarineDon on Dec 25, 2010 9:19 AMThis message has been edited by MarineDon on Dec 25, 2010 9:12 AMThis message has been edited by MarineDon on Dec 25, 2010 9:11 AMThis message has been edited by MarineDon on Dec 25, 2010 9:09 AM

Posted on Dec 24, 2010, 1:45 PM

# Re: Network 54's strange idiosyncracies

R

This is to practice with ADJUST54.BAS to see if it really works.
Below is the QB45 file IdealMen.Bas. Don Smith

DEFINT A-Z
Choice = 1 'Choice is placed before "begin:"
begin:
COLOR 15, 1: CLS
LOCATE 2, 30: PRINT "Ideal Menu Demo";
LOCATE 20, 30: PRINT "Press <Esc> To Exit";
REDIM M\$(7)
M\$(1) = "1. One"
M\$(2) = "2. Two"
M\$(3) = "3. Three"
M\$(4) = "4. Four"
M\$(5) = "5. Five"
M\$(6) = "6. Six"
M\$(7) = "7. Seven"
Row = 5  '.....Row to place menu
Col = 34 '.....Column to place menu
FG = 15  '.....Foreground color
BG = 1   '.....Background color
SD = 2   '.....SD=1 (single space) SD=2 (double space)
ExitCode = 0
CALL IdealMenu(M\$(), Choice, Row, Col, FG, BG, SD, ExitCode)
IF ExitCode = 27 THEN
CLS : SYSTEM
ELSE
COLOR 15, 1: CLS : PRINT M\$(Choice)
END IF
DO: LOOP WHILE INKEY\$ = ""
GOTO begin

FOR XYZ = 1 TO MaxNum
LOCATE Row + (XYZ * SD) - SD, Col, 0
NEXT
IF SD = 0 THEN SD = 1
DO
DisPlayFG = 15: DisPlayBG = 4 'HiLite color
GOSUB Display
DO
Hit\$ = INKEY\$
LOOP UNTIL LEN(Hit\$) > 0
Hit% = CVI(Hit\$ + CHR\$(0)) 'CVI code numbers!
DisPlayFG = FG: DisPlayBG = BG 'regular color
GOSUB Display
IF Hit% = 13 THEN                        '<Enter>
EXIT SUB
ELSEIF Hit% = 27 THEN                    '<Esc>
ExitCode = 27
EXIT SUB
ELSEIF Hit% > 48 AND Hit% < 48 + MaxNum + 1 THEN '<press a number>
Choice = Hit% - 48 '0 = 48 and 9 = 57
EXIT SUB
ELSEIF Hit% = 18432 THEN                 '<UpArrow>
Choice = Choice - 1
IF Choice < 1 THEN Choice = MaxNum
ELSEIF Hit% = 20480 THEN                 '<DnArrow>
Choice = Choice + 1
IF Choice > MaxNum THEN Choice = 1
END IF
LOOP
Display:
COLOR DisPlayFG, DisPlayBG
LOCATE Row + (Choice * SD) - SD, Col - 1, 0
PRINT " " + IMenu\$(Choice) + " ";
RETURN
END SUB

Posted on Dec 24, 2010, 1:52 PM

# *Thanks, Don (and Pete) -- seems to work great. Merry Christmas to you, too.

R

*

Posted on Dec 25, 2010, 1:13 AM

Hello

Trying to do some basic indirect addressing

Do I need to declair something to make it work.

Looking to do something like this

100 X=X+1
110 A(X)= 0
120 IF X < 100 THEN GOTO 100

THE QBASIC GIVE ME A FAULT AT 110 BECAUSE OF THE BRACKETS ?

SEEMS TO TAKE THE INDRECT ADDRESSING WITH NO FAULT FOR THE BELOW

IF I USE FOR TESTING

Z1= 100
X=1
A=Z(X)

BUT DOES NOT STORE THE VALUE OF Z1 INTO A

THANKS FOR ANY INPUT

Posted on Dec 20, 2010, 4:59 PM

# What are you using brackets for?

R

If you say an array, then you are on to something. DIM the array at the start of the program. The number specifies how many values it can hold.

DIM A(100)

100 X = X + 1 'I bet there is a GOTO 100 somewhere or you'll never be back :-)
110 A(X) = 0 'sets index number X to zero
120 IF X < 100 THEN GOTO 100 'will GOTO 100, 100 times

First, you don't need line numbers in QB unless you are using GOTO to move around. Do yourself a favor and try to do things with loops instead.
GOTO will cripple your programming abilities!

Z1 = 100
X = 1
A = Z(X)

In your second example, Z1 has NOTHING to do with the Z array as far as Qbasic is concerned. You MUST reference an index inside of the brackets.

Z(1) = 100
X = 1
A = Z(X)

PRINT A 'displays 100

Ted

Posted on Dec 20, 2010, 7:21 PM

# Re: Indirect addressing not working

Moderator

qbasic requires that arrays with an upper bound above 10 be declared. as clippy showed you, use the DIM keyword to declare an array. if you do not declare an array, qbasic assumes an upper bound of 10. that is why your first example generated an "subscript out of range" error. notice that x is 11 when the error occurs. even though qbasic does not require that all arrays be declared, you should do so anyway.

dim arrayname (lowerbound to upperbound) as type

dim a(0 to 100) as integer
'this is a single dimension array of 101 integers. the lower bound is 0. the upper bound is 100.

dim c(0 to 7) as string
'this is a single dimension array of 8 variable length strings.

dim chessboard(0 to 7, 0 to 7) as integer
'this is a 2 dimension array of 64 integers. access the first element like this:
chessboard(0,0)=1

type employeetype
empname as string * 32
jobdesc as string * 32
wage as integer 'pennies per hour
end type
dim employee(0 to 9) as employeetype
'this array uses a user defined data type.

employee(0).empname = "sally"
employee(0).jobdesc = "clerk"
employee(0).wage = 725

here is a program that stores all 26 capital letters in an array:

defint a-z
dim letters(0 to 25) as string * 1
for i = 0 to 25
letters(i)=chr\$(65 + i)
next i
for i = 0 to 25
print letters(i);
next i
print
system

Posted on Jan 10, 2011, 9:09 PM