QBasic and QB64 Discussion Board

[QB Forum Archives (1999-2009)/ ] [QB FAQ] [QB Links and Downloads] [Subforums and Chat Room] [Search]

QB64.Net Homepage   QB/QB64 Keywords   QB Graphics Forum   Homework Policy



Koch fractal ?

by (no login)

I made a few searches, but sorry no joy :

On internet, Pete's page while it seemed easy but he forgot to share the code, then on this forum, my only post, in the whole internet, no much left.

And, my recursion based algo is broken.

L

Posted on May 7, 2013, 2:13 PM

Respond to this message   

Return to Index


recursive

by Ben (no login)

'#lang "fblite"
DEFSNG A-Z


DECLARE SUB tri (x, y, s, a)
DECLARE SUB koch (s, i, x, y)

CONST scrW = 640
CONST scrH = 480
'const pi = 4*atn(1)
DIM SHARED pi
pi = 4 * ATN(1)

'dim shared cc = 2*sqr(3)/9
DIM SHARED cc
cc = 2 * SQR(3) / 9



'screenres scrW, scrH, 32
SCREEN 12

s = 400
tri scrW / 2, scrH / 2, s, 0
tri scrW / 2, scrH / 2, s, pi

koch 400, 4, scrW / 2, scrH / 2

SLEEP
SYSTEM

SUB koch (s, i, x, y)
IF i = 0 THEN EXIT SUB
FOR a = pi / 6 TO 2 * pi + pi / 6 STEP pi / 3
xx = s * cc * COS(a) + x
yy = s * cc * SIN(a) + y

tri xx, yy, s / 3, a + pi / 6

koch s / 3, i - 1, xx, yy
NEXT
END SUB

SUB tri (x, y, s, a)
c = SQR(12) / 6

'line (x,y)-(x+s*c*cos(pi/6 + a),y+s*c*sin(pi/6 + a))
'line (x,y)-(x+s*c*cos(5*pi/6 + a),y+s*c*sin(5*pi/6 + a))
'line (x,y)-(x-s*c*cos(pi/2 + a),y-s*c*sin(pi/2 + a))

LINE (x + s * c * COS(pi / 6 + a), y + s * c * SIN(pi / 6 + a))-(x + s * c * COS(5 * pi / 6 + a), y + s * c * SIN(5 * pi / 6 + a))
LINE -(x - s * c * COS(pi / 2 + a), y - s * c * SIN(pi / 2 + a))
LINE -(x + s * c * COS(pi / 6 + a), y + s * c * SIN(pi / 6 + a))

'line(x,y-s*c)-(x+s*c*cos(pi/6),y+s*c*sin(pi/6))
'line -step(-s,0)
'line -(x,y-s*c)
END SUB

Posted on May 7, 2013, 7:20 PM

Respond to this message   

Return to Index


Re: recursive

by Ben (no login)

[linked image]

I edited to enable the image. - Pete



    
This message has been edited by The-Universe on May 8, 2013 12:35 AM

Posted on May 7, 2013, 7:20 PM

Respond to this message   

Return to Index


Yes...

by (no login)

http://www.petesqbsite.com/sections/zines/qbcm/issues/3-2/default.html

Download and tweak to your taste Apollo12.bas, and play with this easy Screen 12 fractal code. It can plot:

the flock of Von Koch
the triangle of Sierpinsky
the Apollonia fractal
the Apollonia gasket

Posted on May 8, 2013, 12:17 AM

Respond to this message   

Return to Index


'#lang "fblite"? It woks in Qbasic and QB64

by (Login burger2227)
R

Didn't know FB had a lite?

Posted on May 8, 2013, 8:25 AM

Respond to this message   

Return to Index


it was converted

by Ben (no login)

notice the commented out statements

fblite is the sort of QB-like language option in freebasic that forgives use of undeclared variables and other such bug inducing bad habits.

Posted on May 8, 2013, 1:45 PM

Respond to this message   

Return to Index


if you uncomment the first set of 3 lines...

by Ben (no login)

& comment the rest, you get this.., I didn't even realize it was there, haha

http://qbasic.orgfree.com/flake.png

Posted on May 8, 2013, 1:39 PM

Respond to this message   

Return to Index


...

by (no login)

- How do you understand that the perimeter of the Koch curve tends toward infinite when n goes to infinite, while the area still remains under 8/5 ?

Adding something because the perimeters grows in n ^ 4, and never goes convex, but this something is almost nothing.

Anyway i don't understand your algo.

L

Posted on May 9, 2013, 1:57 AM

Respond to this message   

Return to Index


infinite perimeter

by Jim (no login)

It is kind of unintuitive. You'd think if it has infinite perimeter and you were to wrap it around with a wire, you'd need an infinitely long wire, but it's not the case. You would end up with lengths so small that you would need to stretch or cut up the wire to fit. Disregarding atoms and such, you can take any wire and stretch it to infinite length, but it would end up being infinitely thin, but could retain constant mass? or infinitely small mass?

Posted on May 9, 2013, 11:59 AM

Respond to this message   

Return to Index


Parsing csv strings

by (no login)

Hi,

Very simple parsing program, but :

- Is it Dosbox or LTRIM$, anyway a single space, " " was not trimmed by LTRIM$. If i set :

cline$ = " "

This is not trimmed, maybe rtfm.

thx, L


====================================================

outfile$ = "csv.txt"
n = 2

DIM CSV(n) AS STRING

'CLS OUTPUT FILE :
KILL outfile$
OPEN outfile$ FOR APPEND AS #1
CLOSE #1

OPEN outfile$ FOR OUTPUT AS #2

CSV(1) = _
"CALL TRIAN((Sx - Lx) * 1 / 3 + Lx, (Sy - Ly) * 1 / 3 + Ly, (Sx - Lx) * 2 / 3 + Lx, (Sy - Ly) * 2 / 3 + Ly, (Sx - Lx) * 1 / 2 + Lx, (Sy - Ly) * 1 / 2 + Ly, ((Sx - Lx) * 1 / 2 + Lx) - SQR(ABS(D ^ 2 / (1 + (-(Sx - Lx) / (Sy - Ly)) ^ 2))), ((Sy - Ly) * 1 / 2 + Ly) - (SQR(ABS(D ^ 2 / (1 + (-(Sx - Lx) / (Sy - Ly)) ^ 2)))) * (-(Sx - Lx) / (Sy - Ly)), D / 3, C, n - 1)" _


CSV(2) = _
"CALL TRIAN((Rx - Sx) * 1 / 3 + Sx, (Ry - Sy) * 1 / 3 + Sy, (Rx - Sx) * 2 / 3 + Sx, (Ry - Sy) * 2 / 3 + Sy, (Rx - Sx) * 1 / 2 + Sx, (Ry - Sy) * 1 / 2 + Sy, ((Rx - Sx) * 1 / 2 + Sx) + SQR(ABS(D ^ 2 / (1 + (-(Rx - Sx) / (Ry - Sy)) ^ 2))), ((Ry - Sy) * 1 / 2 + Sy) + (SQR(ABS(D ^ 2 / (1 + (-(Rx - Sx) / (Ry - Sy)) ^ 2)))) * (-(Rx - Sx) / (Ry - Sy)), D / 3, C, n - 1)" _


FOR i = 1 TO n

cline$ = CSV(n)

'Trim to first and last parenthesis :

c = INSTR(cline$, "(")
cline$ = RIGHT$(cline$, LEN(cline$) - c)
cline$ = LEFT$(cline$, LEN(cline$) - 1)

'CSV LOOP :

ON ERROR GOTO ERRORHANDLE

DO WHILE LEN(cline$) > 0
cline$ = LTRIM$(cline$)

'getting infos :

c = INSTR(cline$, ",")

'proceeding :

IF c > 0 THEN

stub$ = MID$(cline$, 1, c - 1)
PRINT #2, stub$

'uptdating :

cline$ = RIGHT$(cline$, LEN(cline$) - c)

ELSE

PRINT #2, cline$
cline$ = ""

END IF

LOOP

'separate
PRINT #2,

NEXT i

CLOSE #2

GOTO skip
ERRORHANDLE:
PRINT c
END
skip:

END






Posted on May 7, 2013, 6:13 AM

Respond to this message   

Return to Index


sorry, my bug...

by (no login)

hate that ! will exterminate all bugs !

Posted on May 7, 2013, 6:17 AM

Respond to this message   

Return to Index


help with a program

by JoeLewis (no login)

it's simple I'm sure to some but I'm just starting. what would a program look like that can do this..

ask the user the weight of their fish
if a negative number is entered, end.
If the fish is 0-2 pounds, reply "small sized"
2-5 pounds "medium sized"
5+ pounds "large fish"
and continue asking for fish weights until a negative number is entered

Posted on May 6, 2013, 2:07 PM

Respond to this message   

Return to Index


Negativ weight can be useful for solving center of mass problems.

by (no login)

You should search for Input, IF statement or Case...

L

Posted on May 6, 2013, 2:16 PM

Respond to this message   

Return to Index


what would

by JoeLewis (no login)

what would the code be with an IF statement

Posted on May 6, 2013, 3:34 PM

Respond to this message   

Return to Index


Joe,

by (Login Kewbie)
R

Below is a link to the forum's Homework Policy. You can also access it near the top of the page where you opened this post.

http://www.network54.com/Realm/QBasicFAQ/QBasicHomework.html

What Lisztfr was suggesting is that you look up some QBASIC keywords using the Help system. In order to do what you need to, you will need to write code that uses the following QBASIC statements:

DO
INPUT 'ask the user the weight of their fish
IF, END 'if a negative number is entered, end.
IF, PRINT 'If the fish is 0-2 pounds, reply "small sized"
IF, PRINT '2-5 pounds "medium sized"
IF, PRINT '5+ pounds "large fish"
LOOP 'and continue asking for fish weights until a negative number is entered

Once you have a program written, if you are having problems with it, post the code here to show what you have done, and ask questions about any behavior that you don't understand.

For instance, you might ask how you can tell if a negative number has been entered. We will be happy to help you with that. What we will NOT do is write the program for you.

Kew

Posted on May 6, 2013, 6:34 PM

Respond to this message   

Return to Index


Thank you

by JoeLewis (no login)

I was having a hard time understanding the basics but I've kinda figured it out. Wasn't really looking for someone to write it for me

Posted on May 8, 2013, 9:44 AM

Respond to this message   

Return to Index


If you get more complex assignments...

by Pete (Login The-Universe)
Admin

If you happen to come back and see this message, you are certainly welcome to use this forum for help in the future. The best way is to write what code you can, post it, and state what it is you don't understand, what could make the program work better, why it doesn't work, etc. I think that kind of support actually has helped a lot of students in school learn how to code better, and enjoy coding more. It can get frustration if you try something over and over and don't make progress, otherwise.

Pete

Posted on May 8, 2013, 10:22 AM

Respond to this message   

Return to Index


Some hints on how to proceed

by Solitaire (no login)

Here is an outline on how you would go about preparing your program. This is how you should always plan before you start writing any code:

1. Put the entire program into a DO loop to continue until the value of the weight is negative.
2. Inside the loop:
a. Tell the user to enter weight of a fish, or a negative number to stop.
b. Get user's input of the weight and save it to a variable.
c. Use either an IF-THEN-ELSE block or a SELECT CASE block for evaluating the weight. Inside the IF or SELECT block, output the string with the size, matching the value of the weight variable.

Sorry, but no one here will write the code for you. Since this is a homework assignment, you need to post the code you have so far and ask for help if you're having trouble with a specific part of the code.



    
This message has been edited by Solitaire1 on May 7, 2013 1:05 PM

Posted on May 6, 2013, 6:26 PM

Respond to this message   

Return to Index


* If we do your homework, your teacher will know.

by (Login burger2227)
R

Posted on May 6, 2013, 8:34 PM

Respond to this message   

Return to Index


Come on Joe, you don't have to weigh fish...

by Pete (Login The-Universe)
Admin

Because they come with their own scales.

Pete happy.gif

Posted on May 8, 2013, 12:38 AM

Respond to this message   

Return to Index


Attention all Personnel

by Radar O'Reilly (Login The-Universe)
Admin

A new sub-forum has just been added to the Index. Welcome the Android QB64 App Developers Message Board, moderated by MystikShadows... I know!

Apparently I missed the Second Coming, because my ol' pal MystikShadows was recently raised from the dead and is back in our coding community once again. He may need some time off to see a doctor, if his resurrection lasts for more than 4-hours, but kidding aside, I'm glad to see him back and looking forward to Android discussions that will be added here and at QB64.

Mobile devices are the future, and I'm really glad Galleon has recognized that, and is heading in this direction. The ability to use our QB programs on mobile devices is going to be huge.

That is all,

Radar

Posted on May 5, 2013, 12:48 PM

Respond to this message   

Return to Index


Sorry, it was my fault mentioning him...

by (Login burger2227)
R

wink.gif

Posted on May 5, 2013, 2:18 PM

Respond to this message   

Return to Index


* Next time put an asterisk in your post, ferret-face.

by Hawkeye (Login The-Universe)
Admin

Posted on May 5, 2013, 3:36 PM

Respond to this message   

Return to Index


*It wasn't empty. Didn't you see the blinking eye face?

by Solitaire (Login Solitaire1)
S

Posted on May 5, 2013, 5:36 PM

Respond to this message   

Return to Index


* Those don't count, major.

by Trapper John (Login The-Universe)
Admin

Posted on May 5, 2013, 5:42 PM

Respond to this message   

Return to Index


Major who?

by (Login burger2227)
R

Hot Lips?

Posted on May 5, 2013, 10:43 PM

Respond to this message   

Return to Index


Not who, who-lihan!

by Col Potter (Login The-Universe)
Admin

Get it together, Burns!

S.P.

Posted on May 6, 2013, 5:05 AM

Respond to this message   

Return to Index


EXIT SUB is nice.

by (no login)

So you can prevent executing malicious code left below, simplifying the tests of variables... test just once, do it and exit ; no care about the rest of code ; no Goto.

It's more and more difficult for me to program, maybe Alzheimer ; takes me ages to figure out a plan. A good thing to help newbies would be to focus on something like templates, useful for a general functions.

Cheers, L

Posted on May 5, 2013, 12:16 PM

Respond to this message   

Return to Index


Page flipping in QB64

by Edvard (no login)

why isn't page flipping working in QB64? What is wrong with my program? It is supposed to switch between two screens graphics, fist containing vertical lines and the other horizontal

SCREEN _NEWIMAGE(640, 480, 32), , 1, 1
FOR x = 0 TO 640 STEP 6
LINE (x, 0)-STEP(2, 480), _RGB(255, 255, 255), BF
NEXT
SCREEN , , 0, 0
FOR y = 0 TO 480 STEP 6
LINE (0, y)-STEP(640, 2), _RGB(255, 255, 255), BF
NEXT


DO
SCREEN , , 1, 1
_DELAY 1
SCREEN , , 0, 0
LOOP UNTIL INKEY$ = CHR$(27)
SYSTEM

Posted on May 5, 2013, 1:49 AM

Respond to this message   

Return to Index


Re: Page flipping in QB64

by (Login MCalkins)
Moderator

It is flipping, but then it is flipping back immediately.

change:

SCREEN , , 1, 1
_DELAY 1
SCREEN , , 0, 0

to:

SCREEN , , 1, 1
_DELAY 1
SCREEN , , 0, 0
_DELAY 1


I would suggest, that especially if you're going to use _NEWIMAGE modes, that you just use multiple images instead of "pages".


DIM handle(0 TO 1) AS LONG
DIM x AS LONG, y AS LONG

handle(0) = _NEWIMAGE(640, 480, 32)
handle(1) = _NEWIMAGE(640, 480, 32)
SCREEN handle(1)
FOR x = 0 TO 640 STEP 6
LINE (x, 0)-STEP(2, 480), _RGB(255, 255, 255), BF
NEXT
SCREEN handle(0)
FOR y = 0 TO 480 STEP 6
LINE (0, y)-STEP(640, 2), _RGB(255, 255, 255), BF
NEXT


DO
SCREEN handle(1)
_DELAY 1
SCREEN handle(0)
_DELAY 1
LOOP UNTIL INKEY$ = CHR$(27)
SYSTEM
'_FREEIMAGE handle(1)
'_FREEIMAGE handle(0)



You would also have access to things like _SOURCE and _DEST.

Regards,
Michael

Posted on May 5, 2013, 2:27 AM

Respond to this message   

Return to Index


Thanks

by Edvard (no login)

I can't believe I overlooked that little error. I think I meant to add _LIMIT like so.

SCREEN , , 1, 1
_DELAY .1
SCREEN , , 0, 0
_LIMIT 5

I wonder if it's possible to keep the delays in real time, such that the time it takes to actually flip the page isn't causing a delay beyond what's set.

Posted on May 5, 2013, 5:00 AM

Respond to this message   

Return to Index


you're welcome.

by (Login MCalkins)
Moderator

If it's any consolation, it took me a while to notice it also.

I'm not the best person to answer your other question. In theory, _LIMIT, or something like it, should be pretty good for maintaining a rough average, I think. Windows is not a real time operating system, so you are never guaranteed exact timing. Perhaps someone else can answer better.

Regards,
Michael

Posted on May 5, 2013, 5:44 AM

Respond to this message   

Return to Index


No biggie, but just learned something about integer division...

by (Login qb432l)
R

In a little text mode (that's right, Pete) money management program I wrote, I use integer division (\) in a sub program that prints results in $ format (PRINT USING is a tad unpredictable in QB64). In any case, I discovered an anomaly. I had an amount, 999.79 that was interpreted as an amount >= 1000. In other words, QB/QB64 round up when doing integer division. If the amount had been 999.49 it would have worked, but 999.5 and greater, rounds to 1000.

Like I say, no biggie, but something to be aware of.

-Bob

Posted on May 3, 2013, 9:59 AM

Respond to this message   

Return to Index


Yep, QB does that to coordinate and color values too

by (no login)

Because they require whole number values. You probably just forgot...

COLOR 11.5: PRINT "not color 11!"

PRINT USING rounds decimal point values by the number of decimal places too.



Posted on May 3, 2013, 2:11 PM

Respond to this message   

Return to Index


I didn't forget...

by (Login qb432l)
R

I just never knew it. To me, the "integer" in the operator's name just meant "the-number-of-times-this-number-can-be-found-whole-in-that-one", not that it was working exclusively in integers. As it is, the operator is semi-useless, since so many operations it's used in involve decimal fractions - and it's true of MOD, too.

'For example, this is what I thought Integer divison/MOD did ---

Amount = 9999.99
TestValue = 1000

Balance = Amount

CLS
PRINT
PRINT
PRINT "Amount being tested:"; Amount
PRINT

DO
IF Balance (less-than) TestValue THEN EXIT DO
Balance = Balance - TestValue
TestNum = TestNum + 1
LOOP

PRINT "Integer divison value:"; TestNum
PRINT "MOD value:"; Balance

END

'-Bob



    
This message has been edited by qb432l on May 3, 2013 3:40 PM
This message has been edited by qb432l on May 3, 2013 3:39 PM
This message has been edited by qb432l on May 3, 2013 3:10 PM

Posted on May 3, 2013, 2:49 PM

Respond to this message   

Return to Index


Yes, interesting

by lawgin (no login)

I had always thought that x\y was the same as INT(x/y), but not the case as you pointed out.

Posted on May 3, 2013, 3:03 PM

Respond to this message   

Return to Index


You have no business doing business programs!

by Mr. Business (Login The-Universe)
Admin

Next time come to me. I'll be happy to give you the business!

Pete happy.gif

Posted on May 3, 2013, 4:54 PM

Respond to this message   

Return to Index


Integer division

by Solitaire (no login)

'Integer division seems to round out
'if first digit after the decimal point is a 9

CLS
A = 5.9
B = 6.6
C = 6.2
PRINT A / B
PRINT A \ B
PRINT A / C
PRINT A \ C

------------------------
Output is:
.8939394
0
.9516159
1

Posted on May 4, 2013, 8:41 AM

Respond to this message   

Return to Index


5.9 \ 6.2 = 1 That's just absurd, no matter how it's rationalized...

by (Login qb432l)
R

To me, integer division and MOD have very specialized purposes -- they shouldn't be merely "casual division for people who don't like decimals". How many 7's in 45? 6. How many 7's in 48.999999? 6.

Thanks, Solitaire.
-Bob



    
This message has been edited by qb432l on May 4, 2013 11:18 AM

Posted on May 4, 2013, 11:11 AM

Respond to this message   

Return to Index


Here's a common use for integer division and MOD

by lawgin (no login)

CLS
PRINT "You have 316 donuts and 52 boxes. ": PRINT
PRINT "Put"; 316 \ 52; "donuts in each box"
PRINT "There are"; 316 MOD 52; "donuts left."
PRINT "Eat them."

Posted on May 4, 2013, 12:12 PM

Respond to this message   

Return to Index


Sure...

by (Login qb432l)
R

Unfortunately, that's all it's really reliable for. On the other hand, a better function (check my code in the post above, "I didn't forget..."), could also handle donuts.

-Bob

Posted on May 4, 2013, 12:28 PM

Respond to this message   

Return to Index


Re: Sure...

by lawgin (no login)

Integer division and MOD should be used with integer arguments. Your method finds the remainder when one or both arguments are non-integer.

Posted on May 4, 2013, 2:22 PM

Respond to this message   

Return to Index


*Of course -- the point is, my method also works with integers. Anyway, no biggie.

by (Login qb432l)
R

*

Posted on May 4, 2013, 6:10 PM

Respond to this message   

Return to Index


How to insure no matter what method you use you have zero donuts leftover...

by Pete (Login The-Universe)
Admin

Throw Pete into the equation!

Pete happy.gif

Posted on May 4, 2013, 12:46 PM

Respond to this message   

Return to Index


What do you get from eating too many jelly donuts?

by lawgin (no login)

A jelly belly.

Posted on May 4, 2013, 2:23 PM

Respond to this message   

Return to Index


Lawgin, I didn't open your post, but I'm going to bet it's...

by Pete (Login The-Universe)
Admin

... a jelly ache!

Pete happy.gif

Posted on May 4, 2013, 3:13 PM

Respond to this message   

Return to Index


*Close, but it's a rhyme, not a pun

by lawgin (no login)

Posted on May 4, 2013, 3:19 PM

Respond to this message   

Return to Index


Tried same code in VB.NET

by Solitaire (no login)

I got the same results, BUT only with Option Strict Off.
With Option Strict On, it refuses to convert type Single to type Long. That's because it would have to "narrow" the conversion, which could result in lost data.

So that's what seems to be happening with QB integer division. It's losing data because of a "narrow" conversion, from a greater range to a smaller one.

I tried using Integer values and got the correct result in both VB and QB:

99 / 100 comes to 0.99
99 \ 100 comes to 0

In C# (and all the C languages), Option Strict is always on (there is no such option to turn it off), and is even stricter than VB with Option Strict On. But QB lacks such an option.

Posted on May 4, 2013, 5:29 PM

Respond to this message   

Return to Index


*Interesting - thanks.

by (Login qb432l)
R

*

Posted on May 4, 2013, 6:07 PM

Respond to this message   

Return to Index


There is no integer division symbol in C

by Solitaire (no login)

Forgot to mention this in my above post. In the C family of languages, there is only one symbol for division. In order to do integer division , both operands need to be integers. If one or both operands are real (floating point) numbers, then regular division is performed. Unless a number is declared as double or float and assigned a value, then it is necessary to add .0 to the number if it doesn't happen to have a decimal portion, in order for it to be designated as a real number.

Posted on May 4, 2013, 9:40 PM

Respond to this message   

Return to Index


C++ allows some implicit type conversions.

by (Login MCalkins)
Moderator

Some conversions can be implicit, others must be explicit. C++ is stricter than C.

In the case of floating point to integer:

http://msdn.microsoft.com/en-us/library/fb7fdy7e.aspx


------

#include <stdio.h>

int intdiv(int x, int y) { return x / y; }

int main() {
printf("%i\n", intdiv(5.9 + .5, 6.2 + .5));
return 0;
}

------

Note the
+ .5
as C++ truncates instead of rounds. (Note that this still doesn't duplicate CLNG, as CLNG distinguishes between even and odd numbers in deciding which way to round. (Unless I'm mistaken, CLNG reflects the x87 hardware.))

Compile with:
QB64 SDL:
internal\c\bin\g++ -O3 -s -Wall delme.cpp -o delme.exe
QB64 GL:
internal\c\c_compiler\bin\g++ -O3 -s -Wall delme.cpp -o delme.exe
MSVC++:
cl /O2 /MD /Wall delme.cpp

QB64 SDL's g++ compiles it without warning or error.

cl compiles it without error, but with warnings, including:

\c\delme.cpp(6) : warning C4244: 'argument' : conversion from 'double' to 'int',
possible loss of data
\c\delme.cpp(6) : warning C4244: 'argument' : conversion from 'double' to 'int',
possible loss of data

c:\c\delme.cpp(6) : warning C4711: function 'int __cdecl intdiv(int,int)' select
ed for automatic inline expansion

Regards,
Michael



    
This message has been edited by MCalkins on May 5, 2013 3:31 AM
This message has been edited by MCalkins on May 5, 2013 3:29 AM

Posted on May 5, 2013, 3:25 AM

Respond to this message   

Return to Index


Re: Integer division (Edited. changed CINT to CLNG)

by (Login MCalkins)
Moderator

Thanks to TheBOB for pointing this out. If I knew this, I had forgotten it.

floatnumber \ floatnumber

I believe is the same as:

CLNG(floatnumber) \ CLNG(floatnumber)

So, as Solitaire pointed out, the conversion to integer is done before the division.

I use \ and MOD fairly often. But I do so with integer data types. (I very rarely use floats at all.)

It should be noted that division tends to be slower than multiplication on hardware. Therefore floating point multiplication should be preferred over floating point division.

Integer division would usually be done by the x86 processor using the DIV or IDIV instructions. These do both integer division and modulus at the same time.

Float division can be done with the x87 FPU using the FDIV, FDIVP, FDIVR, or FDIVRP instructions.

I just noticed that the x87 FPU also has FIDIV and FIDIVR:

----- from old nasm doc:
`FIDIV' divides `ST0' by the 16-bit or 32-bit integer stored in the
given memory location, and stores the result in `ST0'. `FIDIVR' does
the division the other way up: it divides the integer by `ST0', but
still stores the result in `ST0'.
-----

I wouldn't assume that to mean that it is integer division. More likely, it is just dividing by an integer.

If a compiler can see that you are dividing or multiplying by a constant power of 2, it can change it to a bit shift operation.

Likewise, a MOD by a constant power of 2 can become an AND operation.

A compiler could optimize a multiplication by a constant 3 into a left shift and an add.

Regards,
Michael

P.S. Because BASIC lacks bit shift operators, I tend to use \ and * as substitutes.



    
This message has been edited by MCalkins on May 5, 2013 2:59 AM
This message has been edited by MCalkins on May 5, 2013 2:55 AM
This message has been edited by MCalkins on May 5, 2013 2:50 AM

Posted on May 5, 2013, 2:48 AM

Respond to this message   

Return to Index


CINT and CLNG, rounding mode

by (no login)

CINT or CLNG: The manual says: "Converts a numeric expression to an integer
(or long integer) by rounding the fractional part of the expression."
Not stated, but the rounding mode used is Bankers' Rounding.

Regards..... Moneo

PS: Taken from my rounding tutorial MONEORND.DOC

Posted on May 18, 2013, 4:35 PM

Respond to this message   

Return to Index


Yes.

by (Login MCalkins)
Moderator

Which happens to be the default rounding mode of the x87 FPU.

The code below changes the rounding mode in the x87 control word. It seems to have no effect on CLNG in QBASIC 1.1 or compiled programs in QB 4.5. However, if you run the program from the QB4.5 IDE (without compiling), the middle one is a 3 instead of a 4.

(The x87 control word also controls floating point exception masking.)

Regards,
Michael

DECLARE FUNCTION h2b$ (h AS STRING)
CLS
TYPE codetype
 storecontrolword  AS STRING * 17
 loadcontrolword AS STRING * 20
END TYPE

DIM oldword AS INTEGER
DIM newword AS INTEGER
DIM t AS STRING
DIM code AS codetype

t = "55" '             push bp
t = t + "89E5" '       mov bp,sp
t = t + "1E" '         push ds
t = t + "53" '         push bx
t = t + "C55E06" '     lds bx,[bp+6]
t = t + "9BD93F" '     fstcw [bx]
t = t + "5B" '         pop bx
t = t + "1F" '         pop ds
t = t + "C9" '         leave
t = t + "CA0400" '     retf 4

code.storecontrolword = h2b(t)

t = "55" '             push bp
t = t + "89E5" '       mov bp,sp
t = t + "1E" '         push ds
t = t + "53" '         push bx
t = t + "C55E06" '     lds bx,[bp+6]
t = t + "9BDBE2" '     fclex
t = t + "9BD92F" '     fldcw [bx]
t = t + "5B" '         pop bx
t = t + "1F" '         pop ds
t = t + "C9" '         leave
t = t + "CA0400" '     retf 4

code.loadcontrolword = h2b(t)
DEF SEG = VARSEG(code)

PRINT CLNG(3.5)

CALL absolute(SEG oldword, VARPTR(code.storecontrolword))
newword = oldword OR &HC00
CALL absolute(SEG newword, VARPTR(code.loadcontrolword))

PRINT CLNG(3.5)

CALL absolute(SEG oldword, VARPTR(code.loadcontrolword))

PRINT CLNG(3.5)
SYSTEM

FUNCTION h2b$ (h AS STRING)
 DIM i AS INTEGER
 DIM t AS STRING
 t = SPACE$(LEN(h) \ 2)
 FOR i = 0 TO LEN(h) \ 2 - 1
  MID$(t, 1 + i, 1) = CHR$(VAL("&h" + MID$(h, 1 + 2 * i, 2)))
 NEXT
 h2b = t
END FUNCTION

Posted on May 18, 2013, 5:57 PM

Respond to this message   

Return to Index


Re: Yes.

by (no login)

Michael,

Thanks for the info.

It's amazing how you can whip out assembler code at the drop of a hat.

Regards.....Moneo

Posted on May 19, 2013, 11:15 AM

Respond to this message   

Return to Index


Integer Division, rounding mode

by (no login)

INTEGER DIVISION: The manual says: "Before integer division is performed,
operands are rounded to integers or long integers..."
Not stated, but the rounding mode used is Bankers' Rounding.

Regards..... Moneo

Posted on May 18, 2013, 4:26 PM

Respond to this message   

Return to Index


Sprites in QB45

by (no login)

Ok so I'm learning how to code QBasic 4.5 in my first year programming class. As a final project everyone needs to make a game. Most people are making easy stuff like 'pong' or card games, I decided to challenge myself and do Pokemon. (Not the whole game just the champion battle in emerald) And one thing I'm having trouble with is loading sprites. I was using screen 12 but switched to 13 for more color variety and I've loaded sprites in QB64 and I haven't found a way to load sprites in QB45 (if even possible)

Also, is there a program anywhere out there that converts images to DATA statements?

Posted on May 2, 2013, 12:23 PM

Respond to this message   

Return to Index


It is possible to load BMP files in QB45

by Jim (no login)

which are files made with MS Paint. you could fairly easily write a program to represent bitmaps with DATA statements, I would not recommend storing graphics inside your code like that. They are better left as external files which can be loaded/unloaded. BLOAD/BSAVE is the fastest & most efficient for this purpose.

here is a simple bmp loader i used. it's from one of my programs, & i haven't tested it, but it should work. There are plenty of more complicated BMP loaders/shitters in the programs you are proud of section as well as TheBOB's tutorials.

This tutorial I found a simplest & best guide to BMPs in QB:
http://www.petesqbsite.com/sections/tutorials/zines/qbcm/12-bmps.html


f$ = "bird.bmp"
SCREEN 13
DIM r AS STRING * 1, g AS STRING * 1, b AS STRING * 1
OPEN f$ FOR BINARY AS #1
GET #1, 19, x
GET #1, 23, y
GET #1, 29, bpp
PRINT bpp

GET #1, 54, b
OUT &H3C8, 0
FOR i = 0 TO 255
GET #1, , b
GET #1, , g
GET #1, , r
OUT &H3C9, ASC(r) \ 4
OUT &H3C9, ASC(g) \ 4
OUT &H3C9, ASC(b) \ 4
GET #1, , b
NEXT
IF x AND 3 THEN z$ = SPACE$(4 - (x AND 3))
FOR yy = y - 1 TO 0 STEP -1
FOR xx = 0 TO x - 1
GET #1, , b
PSET (xx, yy), ASC(b)
NEXT
GET #1, , z$
NEXT
CLOSE
xx = x
yy = y
SYSTEM

Posted on May 2, 2013, 2:41 PM

Respond to this message   

Return to Index


DEFINT A-Z

by Jim (no login)

Posted on May 2, 2013, 2:47 PM

Respond to this message   

Return to Index


didnt work in qb64 but might in qb45

by Brian (no login)

This didn't work for me but I'm on QB64 right now and I know that some OUT commands don't work, i'l have to try it tomorrow on qb45 at school

Posted on May 2, 2013, 2:56 PM

Respond to this message   

Return to Index


* It works with DEFINT and W/O SYSTEM to see it

by (Login burger2227)
R

Posted on May 2, 2013, 4:51 PM

Respond to this message   

Return to Index


What you need is BSAVE/BLOAD for maximum speed in QuickBASIC...

by (Login qb432l)
R

Everything you want to know about graphics in QBasic/QuickBASIC is available here:

http://www.network54.com/Realm/page_files/Graphics_tutorials.html

Download both QBG1.zip and QBG2.zip. After unzipping, run QBG.EXE. Lessons 8 through 10 deal with loading and saving images and animation/sprites.

BTW, the graphic you see on that page just shows you what the program looks like, it is not the information I was referring to (in case there was some confusion).

-Bob



    
This message has been edited by qb432l on May 3, 2013 10:12 AM

Posted on May 3, 2013, 10:09 AM

Respond to this message   

Return to Index


Screen 13 Color list?

by (no login)

Hey guys, I'm a first year coder and I'm learning QBasic as a learning language. I'm getting into more advanced graphics and 16 colors just isn't cutting it. Does anyone have a list/link to a chart that shows the color numbers?
I'm not looking for the hex values I'm looking for the qbasic "COLOR" statement values.

Ex. In screen 12 "COLOR 4" = RED
In screen 13 "COLOR 160" = ?



Btw Pete if you're reading this I've been trying to get an account on QB64.net for 2 weeks or so now, I suggest the email confirmation should be removed but that's just me :P

Posted on May 1, 2013, 1:24 PM

Respond to this message   

Return to Index


http://upload.wikimedia.org/wikipedia/commons/6/66/VGA_palette_with_black_borders.svg

by . (no login)

Posted on May 1, 2013, 3:15 PM

Respond to this message   

Return to Index


Use SCREEN 13 and roll your own chart

by (Login burger2227)
R

SCREEN 13

FOR clr = 1 TO 255
COLOR clr: PRINT STR$(clr);
NEXT

Color RGB values can be changed using OUT



    
This message has been edited by burger2227 on May 2, 2013 9:33 AM

Posted on May 2, 2013, 9:31 AM

Respond to this message   

Return to Index


-

by (no login)

yeah i know you can do that, just wanted something like the other posted (but with numbers)

Posted on May 2, 2013, 12:16 PM

Respond to this message   

Return to Index


For the numbers

by lkt153 (no login)

SCREEN 13
FOR i = 0 TO 63
OUT &H3C7, i
r = INP(&H3C9)
g = INP(&H3C9)
b = INP(&H3C9)
NEXT i

I'm a bit rusty in QB and don't have a compiler on me, but I'm pretty sure the register numbers are right, and the code should work.

lkt153

Posted on Jun 2, 2013, 11:26 AM

Respond to this message   

Return to Index


II'll send you a combo compiler / blowgun for x-mas.

by Pete (Login The-Universe)
Admin

results are: r,g,b 63,31,39

Enjoy the blowgun, just be careful when you upload!

Pete happy.gif

Posted on Jun 2, 2013, 11:37 AM

Respond to this message   

Return to Index


Preferred way to traverse filesystem in QB64

by TimV (no login)

To get some old source code running again, I'm looking for the best way to get a list of files in the current directory (and if possible list files recursively). What's the best way to do this in QB64? In QBasic I've used a piece of code which was part of RealDir (http://www.ocf.berkeley.edu/~horie/realdir.bas), however, that code doesn't seem to be working in QB64- probably since it's not (completely) emulating those DOS calls/interrupts. So I'd like to replace that code. Using 'FILES' and scraping the result of the screen sounds really bad and error prone to me. I've been thinking of creating a library myself in C++ (using Boost for example). However, if there is an easy and robust way of doing this, I'd like to know. Thanks!

Posted on May 1, 2013, 1:32 AM

Respond to this message   

Return to Index


Re: Preferred way to traverse filesystem in QB64

by Pete (Login The-Universe)
Admin

A couple of references:

http://en.wikipedia.org/wiki/List_of_DOS_commands#dir

http://www.easydos.com/dir.html

In QB64 DIR is usable.

SHELL _hide "DIR"

For example:

To find all the subdirectories and .bas files in your qb64 folder in Windows...

cls
shell _hide "DIR /x /s c:\qb64\*.bas > shell-files.txt"
shell "notepad shell-files.txt"

The code above will open the results in notepad. If you need to poll those results, you would simply open the for for INPUT and LOOP through the input lines. Of course you would have to parse the input, to find what you want.

The /x switch just adds the MS_DOS 8 short file names. Remove it, and the output of the short file names will not be included.'

The /s switch is what tells the process to look for any sub-directories in the directory being searched.

ANOTHER EXAMPLE WITHOUT SWITCHES TO PRINT FILES TO SCREEN:

cls
shell _hide "DIR c:\qb64\*.bas > shell-files.txt"
open "shell-files.txt" for input as #1
do until eof(1)
line input #1,a$
if instr(lcase$(a$),".bas") <> 0 then
a1$ = mid$(a$,40)
print a1$
end if
loop
close #1
end

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

I may be offline for a day or two, but I'm sure others can be of assistance if you have further questions.

Pete

Posted on May 1, 2013, 2:11 AM

Respond to this message   

Return to Index


you can use windows API with declare library

by George (no login)

FindFirstFile, FindNextFile and FindClose

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

There are some crappy dir listing routines using FILES in the wiki as well, which may suffice for you
http://qb64.net/wiki/index.php?title=FILES

Posted on May 1, 2013, 2:11 AM

Respond to this message   

Return to Index


What about an OS independent way

by TimV (no login)

Thanks for the suggestions so far. I will have a look at them later. Is there any OS independent way? I'm using OS X as well (I think it's great that QB64 supports OS X) and I'd like my tool to work on both OS X and Windows.

Posted on May 1, 2013, 2:27 AM

Respond to this message   

Return to Index


At present, I don't believe so.

by Pete (Login The-Universe)
Admin

QB64 has the FILES statement, but that only puts a list on the screen

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

files "c:\qb64\*.bas"

You can check the WIKI for examples of more complex SHELL programs for directories.

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

But none are independent.

Pete



    
This message has been edited by The-Universe on May 1, 2013 3:15 AM

Posted on May 1, 2013, 3:13 AM

Respond to this message   

Return to Index


If you can, try asking at the other place

by (Login MCalkins)
Moderator

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

There is probably more Posix knowledge over there than here. Specifically, Galleon or DSMan could probably help you.

QB64 has some built in abstraction to try to abstract the DOS/Windows vs Posix differences, but how much that applies to searching, I don't know. I suspect that you will need to have one solution for Windows, and another for Posix.

QB64 does have a _FILEEXISTS function, but that won't directly help you here.

Regards,
Michael

P.S. Anything that involves trying to read the results of FILES from the screen strikes me as extremely hackish and unreliable.



    
This message has been edited by MCalkins on May 1, 2013 4:57 AM

Posted on May 1, 2013, 4:54 AM

Respond to this message   

Return to Index


I made a utility to read files from the screeen once, but...

by Pete (Login The-Universe)
Admin

It was just for fun, and to demonstrate that when a folder has more files than can fit on the screen, it scrolls, so you miss seeing, and therefor miss reading, some files!

The only use I had for the FILES statement was to use it with a RESUME NEXT error trap to test for the existence of wildcard files, where the names were not specifically known. QB64 has the _FILEEXISTS statement, that does the same thing.

Pete

Posted on May 1, 2013, 8:21 AM

Respond to this message   

Return to Index


I'll try, currently I'm still awaiting admin approval.

by TimV (no login)

I need _FILEEXISTS as well, so that's pretty useful. Also, Posix would be an option - I could use Cygwin for Posix support on Windows.

Posted on May 1, 2013, 8:36 AM

Respond to this message   

Return to Index


I'll post a message on QB64.net for you.

by Pete (Login The-Universe)
Admin

It will point Galleon to this thread. He is a mod here, but hasn't been as much, here, or at his own forum, due to business related issues. He is also looking at a little downtime I think, after releasing Android support this week. I bet he has well over 5000 hours in QB64 to date. Also, he switched to Admin approval to deal with spam. Someone serious about programming, like yourself, will get approval, it's just a question of when. I will ask Galleon to have a look at doing that, too.

Pete

Posted on May 1, 2013, 8:50 AM

Respond to this message   

Return to Index


Re: Preferred way to traverse filesystem in QB64

by (Login MCalkins)
Moderator

The traditional easy way is by SHELLing to dir, redirecting to a file. Slight variations of this can be made to work in both Windows and DOS.

If you want to do it the "proper" way for Windows, you can use the Win32 API functions, like FindFirstFile and FindNextFile. These can be used with DECLARE LIBRARY.

http://msdn.microsoft.com/en-us/library/aa364418(v=vs.85).aspx (FindFirstFile)
http://msdn.microsoft.com/en-us/library/aa364428(v=vs.85).aspx (FindNextFile)
http://msdn.microsoft.com/en-us/library/aa365740(v=vs.85).aspx (WIN32_FIND_DATA)
http://msdn.microsoft.com/en-us/library/ms724284(v=vs.85).aspx (FILETIME)
http://msdn.microsoft.com/en-us/library/gg258117(v=vs.85).aspx (File Attribute Constants)
http://msdn.microsoft.com/en-us/library/aa364413(v=vs.85).aspx (FindClose)
http://www.qb64.net/forum/index.php?topic=4527.0 (partial DECLARE DYNAMIC LIBRARY tutorial)



'public domain

CONST MAX_PATH = 260
CONST INVALID_HANDLE_VALUE = -1
CONST ERROR_FILE_NOT_FOUND = 2
CONST ERROR_NO_MORE_FILES = &H12

DECLARE DYNAMIC LIBRARY "kernel32"
 FUNCTION FindFirstFileA~%& (BYVAL lpFileName~%&, BYVAL lpFindFileData~%&)
 FUNCTION FindNextFileA& (BYVAL hFindFile~%&, BYVAL lpFindFileData~%&)
 FUNCTION FindClose& (BYVAL hFindFile~%&)
 FUNCTION GetLastError~& ()
END DECLARE

TYPE FILETIME
 dwLowDateTime AS _UNSIGNED LONG
 dwHighDateTime AS _UNSIGNED LONG
END TYPE

' On x86 32 bit, you could use _UNSIGNED _INTEGER64 directly instead of
' FILETIME, but on some other platforms, that could cause an alignment fault.

' Alternately, you could put 4 bytes of padding at the start of the structure,
' and add 4 bytes to the offset that you pass to Windows. That should align
' the fts, assuming that QB64 aligns structures, which it probably doesn't
' currently, but would have to on the affected platforms.

TYPE WIN32_FIND_DATAA
 dwFileAttributes AS _UNSIGNED LONG
 ftCreationTime AS FILETIME
 ftLastAccessTime AS FILETIME
 ftLastWriteTime AS FILETIME
 nFileSizeHigh AS _UNSIGNED LONG
 nFileSizeLow AS _UNSIGNED LONG
 dwReserved0 AS _UNSIGNED LONG
 dwReserved1 AS _UNSIGNED LONG
 cFileName AS STRING * MAX_PATH
 cAlternateFileName AS STRING * 14
END TYPE

DIM t AS _UNSIGNED _INTEGER64
DIM finddata AS WIN32_FIND_DATAA
DIM hfind AS _UNSIGNED _OFFSET
DIM filename AS STRING

DO
 PRINT "See http://msdn.microsoft.com/en-us/library/aa364418(v=vs.85).aspx for notes."
 PRINT "blank line to exit."
 LINE INPUT "filename? "; filename
 IF 0 = LEN(filename) THEN EXIT DO
 filename = filename + CHR$(0)

 hfind = FindFirstFileA(_OFFSET(filename), _OFFSET(finddata))
 IF INVALID_HANDLE_VALUE = hfind THEN
  PRINT "Error. 0x" + hexd(GetLastError)
 ELSE
  DO
   PRINT
   PRINT "Attributes:", "0x" + hexd(finddata.dwFileAttributes)

   ' you could use _MEMCOPY to copy from the filetime to the _UNSIGNED _INTEGER64
   ' however, a shift is easier.

   t = finddata.ftCreationTime.dwHighDateTime * &H100000000~&& OR finddata.ftCreationTime.dwLowDateTime
   PRINT "Creation:", "0x" + hexq(t)
   t = finddata.ftLastAccessTime.dwHighDateTime * &H100000000~&& OR finddata.ftLastAccessTime.dwLowDateTime
   PRINT "Last access:", "0x" + hexq(t)
   t = finddata.ftLastWriteTime.dwHighDateTime * &H100000000~&& OR finddata.ftLastWriteTime.dwLowDateTime
   PRINT "Last write:", "0x" + hexq(t)
   ' with the file size, _MEMCOPY would be less pratical, because the high dword
   ' is first
   t = finddata.nFileSizeHigh * &H100000000~&& OR finddata.nFileSizeLow
   PRINT "Size", "0x" + hexq(t)
   PRINT "Reserved0:", "0x" + hexd(finddata.dwReserved0)
   PRINT "Reserved1:", "0x" + hexd(finddata.dwReserved1)
   PRINT "Filename: ", LEFT$(finddata.cFileName, INSTR(finddata.cFileName, CHR$(0)) - 1)
   PRINT "Alternate: ", LEFT$(finddata.cAlternateFileName, INSTR(finddata.cAlternateFileName, CHR$(0)) - 1)
   PRINT
   SLEEP 1
  LOOP WHILE FindNextFileA(hfind, _OFFSET(finddata))
  PRINT "Error. 0x" + hexd(GetLastError)
  IF 0 = FindClose(hfind) THEN PRINT "FindClose. Error. 0x" + hexd(GetLastError): END
 END IF
 PRINT
LOOP
SYSTEM
'$include:'hexx.bi' ' http://www.qb64.net/forum/index.php?topic=4491.0


Regards,
Michael

Posted on May 1, 2013, 3:21 AM

Respond to this message   

Return to Index


* I posted before seeing the other responses.

by (Login MCalkins)
Moderator

Posted on May 1, 2013, 3:25 AM

Respond to this message   

Return to Index


QB64.net

by (no login)

I also need to be admin approved to post on QB64.net :/ it's taking forever

Posted on May 1, 2013, 1:19 PM

Respond to this message   

Return to Index


Forget the i-walker, I've invented the i-comb!

by Pete (Login The-Universe)
Admin

It's a comb attached to a mobile phone! My new QB64 app allows the user to activate the front end camera, to keep track of combing! Now Clippy will be able to comb-over his embarrassing bald spot in confidence, before he goes on Skype! A hair out of place? No problem for the i-comb, it comes with an extra port that holds hairspray!

OK, I'm getting giddy. I'm ordering a Nexus 7 in July, new release, actually something portable enough to take with me, but larger than a mobile phone so it is actually useful without endless scrolling / enlarging. Amazing that by then or before all of us will be able to have our QB apps running on these things. Three cheers for Rob on this one, QB64 on Android will be a game changer for BASIC users.

Pete

- The i-comb, available at GOP registration centers everywhere, voter ID required, sorry, food stamps not accepted.

Posted on Apr 28, 2013, 10:36 AM

Respond to this message   

Return to Index


Re: Forget the i-walker, I've invented the i-comb!

by lawgin (no login)

I'd buy one, but only if it came with a nose hair attachment.

Posted on Apr 28, 2013, 11:34 AM

Respond to this message   

Return to Index


Geese! The next thing you'll ask for is a mouth wash dispenser

by Pete (Login The-Universe)
Admin


And dammit lawgin, I'm a chiropractor, not an i-nose and throat specialist!

LOL@nose clipper attachment!

Pete happy.gif

Posted on Apr 28, 2013, 11:42 AM

Respond to this message   

Return to Index


*No,no--I don't want to clip it, I want to comb it

by lawgin (no login)

Posted on Apr 28, 2013, 1:04 PM

Respond to this message   

Return to Index


* Nice to have another Italian on the board!

by Pete (Login The-Universe)
Admin

Posted on Apr 28, 2013, 1:06 PM

Respond to this message   

Return to Index


*Spooky, but you're right

by lawgin (no login)

Posted on Apr 28, 2013, 2:00 PM

Respond to this message   

Return to Index


My newest Politically Incorrect game for QB64...

by Pete (Login The-Universe)
Admin

cls
randomize timer
locate 11, 33: print "BOP THE LIBERALS!"
sleep 2
print
locate , 32: print "Lets get started!!!!"
sleep 2
cls
title$ = "Move the question mark over a liberal and cursor key down to bop it!"
locate 2, 41-len(title$) / 2: print title$
indent = 35
qpos = 0
lbnds = 0
rbnds = 13
x = 12
locate x + 1, indent: print "__ __ __ __ __"
locate x + 2, indent: print space$(2) + "L" + space$(2) + "L" + space$(2) + "L" + space$(2) + "L"
locate x, indent: print "?";: locate , pos(1) - 1

z1 = timer: z1cnt = timer
b$ = inkey$: REM clear buffer
_delay 1
do
_limit 30
b$ = inkey$
select case b$
case chr$(27)
end
case chr$(0) + "K"
if qpos > lbnds then qpos = qpos - 1: flag = pos(1)
case chr$(0) + "M"
if qpos < rbnds then qpos = qpos + 1: flag = pos(0)

case chr$(0) + "P"
if qlev = 0 then qlev = -1: flag = pos(1)
end select
if flag <> 0 then
bypass = -1
locate x, flag: print " ";: locate x-qlev, indent + qpos: print "?";:locate ,pos(1)-1
flag = 0
if qlev <> 0 then
_delay .3
locate x-qlev, indent + qpos: print " ";
qlev = 0
locate x - qlev, indent + qpos: print "?";: locate , pos(1)-1
end if
end if
z2 = timer
z2cnt = timer
if z2cnt < z1cnt then z2cnt = z2cnt + 86400
if z2cnt - z1cnt > 3 then
z1cnt = timer
if cnt < 10 then cnt = cnt + 1
if cnt = 3 then x1 = csrlin: y1 = pos(1): locate 17, 22: print "Those Liberals keep ducking the question!": locate x1, y1
if cnt = 7 then x1 = csrlin: y1 = pos(1): locate 17, 1: print space$(80): locate x1, y1
if cnt = 8 then x1 = csrlin: y1 = pos(1): locate 17, 32: print "Ducking Liberals!!!!": locate x1, y1
end if
if z2 < z1 then z2 = z2 + 86400
if z2 - z1 > 1 or bypass <> 0 then
bypass = 0
select case pos(1)
case indent + 2
nogo = 1
case indent + 5
nogo = 2
case indent + 8
nogo = 3
case indent + 11
nogo = 4
end select
x1 = csrlin: y1 = pos(1)
z1 = timer: dsp1$ = "": dsp2$ = ""
for i = 1 to 4
liberals(i) = int(rnd * 4)
if liberals(i) = 0 and i <> nogo then liberalup$ = "L": liberalducker$ = " " else liberalup$ = " ": liberalducker$ = "L"
dsp1$ = dsp1$ + "__" + liberalup$
dsp2$ = dsp2$ + space$(2) + liberalducker$
next
dsp1$ = dsp1$ + "__"
locate x + 1, indent + lbnds: print dsp1$;
locate x + 2, indent + lbnds: print dsp2$;
locate x1, y1
end if
loop



    
This message has been edited by The-Universe on Apr 26, 2013 6:20 PM

Posted on Apr 26, 2013, 6:08 PM

Respond to this message   

Return to Index


Don't you mean "GOP the Liberals"?

by (Login burger2227)
R

Greed Obsessed Party

Posted on Apr 26, 2013, 9:05 PM

Respond to this message   

Return to Index


Sur beets the DNC...

by Bill E. Bob (Login The-Universe)
Admin

Don't No Crap!

- Hee-Hee-Hee

Posted on Apr 26, 2013, 9:11 PM

Respond to this message   

Return to Index


* Please keep politics in the appropriate subforum.

by (Login MCalkins)
Moderator

Posted on Apr 26, 2013, 9:40 PM

Respond to this message   

Return to Index


* You tell Billy Bob, Michael!

by (Login burger2227)
R

Posted on Apr 26, 2013, 10:01 PM

Respond to this message   

Return to Index


* Lucky fur me, I got friends in low places. Check the forum heading.

by Bill E. Bob (Login The-Universe)
Admin

Posted on Apr 26, 2013, 11:27 PM

Respond to this message   

Return to Index


*This place been hijacked by idjits

by Alfred E. Neuman (no login)

z

Posted on Apr 27, 2013, 10:05 AM

Respond to this message   

Return to Index


ROFL

by Pete (Login The-Universe)
Admin

What's the "z" for, the Mark of Zorro?

Well at least it reminds me of the fun we used to have around here, in the past. Right now, the place is reminding me more of a closed high school, that still holds reunions for its graduated alumni.

It will be cool when we start making Android apps in a bit. I discussed this a bit at QB64. "...But speaking of stalls, I wonder how the one that's home to the FB horse is fairing? I heard when it got word of QB64 on Android, the FB developers had to contact the White House to announce a new shovel ready job."

Well, it will be nice when things pick up in the community a bit. I still want to keep this place social, fun, and hopefully not have it get too far out of hand at times.

I'll undo the title change tonight.

Pete



Posted on Apr 27, 2013, 2:16 PM

Respond to this message   

Return to Index


need help with a qb64 program

by dee (no login)

have a problem making a program email me at bumfft789a@sbcglobal.net

Posted on Apr 26, 2013, 5:59 PM

Respond to this message   

Return to Index


* Please post your code, and a description of your problem.

by (Login MCalkins)
Moderator



    
This message has been edited by MCalkins on Apr 26, 2013 7:41 PM

Posted on Apr 26, 2013, 7:41 PM

Respond to this message   

Return to Index


Oh dee, dee, dee. Come on Michael, re-read the post...

by Pete (Login The-Universe)
Admin

The OP doesn't want help making a program, The OP is asking for others who need help making a QB64 program to email the OP.

I got a kick out of how this post was written, because actually, it could be taken either way.

Pete happy.gif

Posted on Apr 26, 2013, 9:06 PM

Respond to this message   

Return to Index


Hey Bob, look, BMP support!

by Pete (Login The-Universe)
Admin

Rob just posted the next Windows release, it includes bitmap support.

Also. an Android version was just released. Seems like we were just discussing that. Oh no, you don;t think he's trying to steal my i-walker next?!!!

Pete

Posted on Apr 25, 2013, 11:57 PM

Respond to this message   

Return to Index


*Good news about QB64 -- but he's too late for the i-walker (evil laugh).

by (Login qb432l)
R

*

Posted on Apr 26, 2013, 5:07 AM

Respond to this message   

Return to Index


*The Universe is full of good ideas!

by Super G (no login)

Posted on Apr 30, 2013, 4:58 AM

Respond to this message   

Return to Index


QB64 and utility programs

by Pete (Login The-Universe)
Admin

QB64 has become every bit as good as QB was for utility programs, in my opinion. I have recently been put off by some limitations in Windows Live mail and spreadsheet programs. I've been able to write utility programs with QB64 to overcome those limitations. I consider utility programs to be short, under 200-lines of code most of the time. They usually require little to no debugging, which is great, because so far, we don;t have a QB64 interpreter.

So out of curiosity, are most people here predominantly using QB64, or still using QB on an older OS or DOSBOX for smaller programs and utilities?

Pete

Posted on Apr 25, 2013, 12:56 PM

Respond to this message   

Return to Index


Exclusively QB64 for me ...

by (Login qb432l)
R

I've written a great many graphics utilities in QB64 which I must run constantly to check progress. I'm quite comfortable with the compile time, now - even enjoy the anticipation. It's like home movies from a couple decades ago - waiting for the film to come back from Kodak was half the fun.

Mostly kidding on that one, but even still, the benefits far outweigh any limitations as far as I'm concerned; the convenience of working in a Windows environment is alone worth any wait. I mean, God bless the guys at DOSBox, but it's a bit unpredictable, and involves a lot of extra "stuff".

-Bob

Posted on Apr 25, 2013, 5:35 PM

Respond to this message   

Return to Index


Future

by Pete (Login The-Universe)
Admin

Other than the addition of an interpretor, I think Rob has taken this project as far or further than if MS didn't abandon BASIC in the first place. In fact, I'll give the edge to Rob, because I'm pretty sure the MS people wouldn't have made a Linux version!

I'm certainly glad the compiler time has significantly improved. I remember waiting an hour for my 80,000+ line program to compile a few years back. Same code now takes just a couple of minutes.

I think an Android version is the next major step to insure the language will still be usable in the near future. I think at my age, that's all I really need be concerned about. For a much younger generation, I don't know. BASIC? I have my doubts there will be those who will appreciate building programs from the ground up by the the time they reach my age.

Unfortunately, I think more beginner languages are being designed for the sheeple. I think these languages are creating the slowgrammers of the current oops generation. Let's hope I'm wrong about that, and that since thinks tend to be cyclical, someday in the not too distant future, BASIC will regain popularity. Darn, I wish the founders would have called it ADVANCED! No one would want to give up on being an ADVANCED programmer, oh well.

Pete

Pete

Posted on Apr 25, 2013, 10:38 PM

Respond to this message   

Return to Index


I certainly think QB64 has a future...

by (Login qb432l)
R

Cavemen cooked over open fires and so do modern day bass fishermen. That's because a crackling fire is timeless. Same with hobby programming. Software companies may need big apps in a hurry, but for sheer fun, there's nothing like building a program from the ground up. QB64 gives you all of that and a lot that BASIC never thought of.

-Bob

Posted on Apr 25, 2013, 10:57 PM

Respond to this message   

Return to Index


I think it's a hard sell...

by Pete (Login The-Universe)
Admin

Case in point is that when we were young, a 2-D tank shooting at another 2-D tank was a big deal. You could actually program that with QB! Today, you need to compete with a 1st person shooter, who looks like your next door neighbor... you know, that guy cooking fish on an open fire!

My kid isn't interested in QB, because he can't see going from point a to this new finish line anytime, soon.

I thought QB64 might find a niche in schools, but Rob has lost a bit of leverage in that arena, recently. Unfortunately, education in the US has tightened up too much, and does not include hardly any elective courses, anymore. That means it would take some real in=place people to usher in a non-company BASIC language to a school system. Also, an interpretor would be so important to make the language easier to learn.

I think it might have a brighter future in programmers who are excited about writing mobile apps. That means the Android development is the best growth potential, if I'm correct.

Pete

Posted on Apr 25, 2013, 11:38 PM

Respond to this message   

Return to Index


*You may have a point, but we bass fishermen are a tenacious bunch.

by (Login qb432l)
R

*

Posted on Apr 26, 2013, 5:08 AM

Respond to this message   

Return to Index


Maybe so, but you have to get off your bass, eventually.

by Pete (Login The-Universe)
Admin

We remaining QBers are really a tenacious bunch. I still love the language, and I'm glad I waited for QB64, rather than switching to some other language like Ruby or Python. PowerBasic had issues, even at the Vista stage, so I'm even glad I didn't go there either. Most of the QB ship jumpers went to FreeBasic, which wasn't the complete answer either, more a little piece of ship, than the entire vessel. I'd call it a C-class vessel at that, or better still, the short ship to "C". Best advice, never take a short ship to sea. One big wav file could be your undoing, but I digress...

I sure some would say we are beating a dead horse, and I agree, I think we left FreeBasic in the dust years ago, too. And Rob has just released the first Android version, and PB hasn't even gotten that far, yet. I just don't have a sense of the user base increasing very much, even with all the growing language's ability.

QB64 has been great for us old-timers, that's for sure. It would really be even greater if a new generation could somehow be introduced to it. QB64 makes it easy to program anything the way you want it, not just limited to what's available in a library, but that seems to be a hard sell in this drag and drop and have something phase of computing. I guess Leonardo just needs to learn how to paint faster.

Anyway, good luck with your fishing. Me, I'll stick to my golf. Hey, maybe you can cut 18 smaller holes in the ice, and invite me up for a round. I'm sure your countrymen, who get a chance to watch me play, will all be asking themselves, why's that ice-hole golfer in Canada?

Pete

Posted on Apr 26, 2013, 10:34 AM

Respond to this message   

Return to Index


I'm with QB64, but it never got finished

by (Login burger2227)
R

Now it is GL and Android or bust. Wish we could get the little bit left to do done.

I'm not worried about an interpreter, QB64 compiles and runs fast enough for me.

Posted on Apr 26, 2013, 10:37 AM

Respond to this message   

Return to Index


And it isn't going to get finished any FNtime, soon.

by Pete (Login The-Universe)
Admin

Kidding aside, I think compatibility-wise, it is finished. Rob is more justifiably concerned about answering the query, "What can QB64 run on and do?" over "Why doesn't QB64 support multi-modular programming and FN?" I jumped ship on waiting to be able to run my multi-modular on QB64 almost instantly, years ago. Converted them to single programs, and converted all FN statements to real functions. I'm glad I did, as all those programs run on QB64 now.

In my new e-book, It Sucks to be Rob, I explain how many an accomplished programmer has to battle with the fact that there is just so much time in day to get things done, and how the best need to constantly pick and chose, and make sacrifices. Hmmm, I wonder if Hebrew programmers sacrifice RAM? But I digress.

Things change over time and any scientist will tell you that adaptation is the keystone of evolution. I'm glad to see QB64 going mobile, but unless it also learns how to knock on doors and introduce itself, I don't really see the "If you build it, they will come" bit working. That's probably because this field is pretty much limited to pioneering and big company droids. Look at the following .Net has, for instance. I downloaded that language once, and wasn't even able to program a gun to shoot myself for trying it.

Pete

Posted on Apr 26, 2013, 2:46 PM

Respond to this message   

Return to Index


Well at least we don't need to learn OOP

by (Login burger2227)
R

That's what killed VB for me. They took away control arrays too. It took me months to learn how to use controls arrays and once I got it, I loved using them. Good old M$...

Galleon needs help with development now that he is starting his own business. You know how that goes I imagine. I wish that we had somebody to clean up the odds and ends.

Posted on Apr 26, 2013, 6:43 PM

Respond to this message   

Return to Index


What's wrong with learning?

by Jim (no login)

Posted on Apr 26, 2013, 6:47 PM

Respond to this message   

Return to Index


Put an asterisk in you message title if the post is empty.

by Pete (Login The-Universe)
Admin

I mean since you're not opposed to learning, right?

I can't even tell if that was a rhetorical question or not, but...

Personally, I hate the use of blanket idioms. I'm sure Hitler was a beautiful baby, etc., Learning isn't all that important compared to thinking. Thinking implies discernment.

Pete



Posted on Apr 26, 2013, 7:05 PM

Respond to this message   

Return to Index


not rhetorical

by Jim (no login)

It seems the only reason to avoid using modern tools is due to the lack of effort to learn them. It also seems that people are inherently biased to the things they know or use.

There are far better tools for utilities like string/text parsing, file manangment and so on rather than the clumsy for loops and left$, mid$, etc.

Posted on Apr 27, 2013, 9:39 AM

Respond to this message   

Return to Index


* Exclusively QuickBASIC for me.

by Moneo (no login)

Posted on Apr 26, 2013, 4:07 PM

Respond to this message   

Return to Index


*What are you running it with?

by Pete (Login The-Universe)
Admin

Posted on Apr 26, 2013, 4:29 PM

Respond to this message   

Return to Index


* XP of course. Wonder if Android can do that?

by (Login burger2227)
R

Posted on Apr 26, 2013, 7:34 PM

Respond to this message   

Return to Index


Clippy, I meant Moneo.

by Pete (Login The-Universe)
Admin

I love QuickBasic, but it's too small for a lot of what I do and I'm fresh out of older systems to run it on. Running it on DOSBox actually sucks. You can't get the INTERRUPT calls, some debugging is lost, so on, and so forth.

I just a bit curious what some of the QuickBasic users will do if they cannot find anymore older computers to use?

Pete

Posted on Apr 26, 2013, 7:46 PM

Respond to this message   

Return to Index


Well at least we still have this old forum to use

by (Login burger2227)
R

Don't you wish that new posts moved to the top?

Don't you wish that indentation worked?

Don't you wish?

What happened to your 98? I still have mine, but I seldom fire it up. I have 3 XP's now too. I haven't fired up the Win 7 machine for months. I can wait.

Posted on Apr 26, 2013, 9:03 PM

Respond to this message   

Return to Index


Like the saying goes, "This place is like an old shoe"

by Pete (Login The-Universe)
Admin

It stinks! (Just kidding.)

A comfortable fit, at least I think that's how that saying goes. Anyway...

I hate having to remember to turn off formatted text before posting code. I did that OK yesterday, when posting Bop the Liberals. LOL @ GOP the Liberals, that was funny, but I had to edit it and change the program, to substitute SPACE$(2) for quotes around two blank spaces!

Although the excessive use of the quote feature in modern forums is a bit of a miss, all the other features they include trump this old-style threaded format, in my opinion.

The reason I never "upgraded" is because N54 doesn't offer any upgrades to modern message boards. Moving to a new server, and I mean server, as I don't need a "forum service" to run a forum, would mean archiving everything here, and starting a new board. I'm fine with that, too, but it would be great if we could just borrow some of that Liberal fairy dust from your party and "upgrade" the boards right here. I'd have to buy a good set of gloves first, because I'm pretty sure I know which orifice Barack Obama blows that stuff out of. (Michael, don't you dare move this post!)

Political joking aside, I'm with you on this one; but I've polled the community over the years, and that actual "old shoe" saying pretty much applies to how others feel. I think they can appreciate QB as more of a nostalgic part of the past, and this format embellishes those feelings.

Hey, at least we can post images here! We could at 64... hey, 64, maybe we should ask that lazy Rob dude to start a company called Network64 and host us there!

Pete



Posted on Apr 28, 2013, 9:53 AM

Respond to this message   

Return to Index


Running QuickBASIC

by Moneo (no login)

I have an old computer running Windows XP. All my programs and utilities are compiled using the QuickBASIC compiler. However, I must admit that I hardly do any programming lately, just run my old utilities.

Regards..... Moneo

Posted on Apr 30, 2013, 5:51 PM

Respond to this message   

Return to Index


I do miss my XP at times.

by Pete (Login The-Universe)
Admin

I saved the hard drive, and run it in a slave drive if I ever need to look at some old files, emails, etc. Unfortunately, slave drives can't be used to load the operating system, but Win 7 has been a blessing. I've even gotten used to Windows Live Mail, although I liked Outlook Express, better. I can still manipulate Windows Live Mail with QB, so that keeps me happy.

Pete

Posted on Apr 30, 2013, 6:10 PM

Respond to this message   

Return to Index


I use QB64 often for utilities,

by Dav (no login)

It's really good for quickly working up a command-line tool or testing an idea. I haven't fired up QB45 in a long time. QB64 has replaced it on my PC's.

- Dav

Posted on Apr 27, 2013, 6:32 AM

Respond to this message   

Return to Index

 Copyright © 1999-2014 Network54. All rights reserved.   Terms of Use   Privacy Statement