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



Fractal

by Lisztfr (no login)

http://library.thinkquest.org/26242/full/types/ch7.html

I know why someone said my Sierpinsky fractal wasn't a real one, i guess because it was not made from a plain triangle. However, look here, they say that all odds numbers in a Pascal triangle make a Sierpinsky ?

"However, if we color all odd numbers in this triangle a different color...

... we get a fractal! Indeed, the pattern formed is the same as the one in the Sierpinski Triangle. Isn't it amazing with all the places where you can find fractals? "

That's a surprise.. Ok, Odd, but not prime numbers.

Posted on Oct 30, 2010, 3:06 AM

Respond to this message   

Return to Index


as

by (no login)

Posted on Oct 15, 2011, 12:13 AM

Respond to this message   

Return to Index


IDE module error

by (no login)

I've just unzipped and executed the QBasic program (qb64.exe) from the download version qb64v0922-win on Windows 7 Professional (32 Bit), but I get: "IDE module error" at start up.
Can someone please tell me how to fix this problem?
Thanks!

Posted on Oct 29, 2010, 7:53 PM

Respond to this message   

Return to Index


The Unzip program missed a folder...

by (Login The-Universe)
Admin

Use Explorer to open your QB64 folder.

Now open the "internal" folder

In the internal folder, there should be a folder called "temp" but I bet there isn't.

If not, simply right click in the window of the "internal" folder and select "New" then click "Folder" and when the New Folder appears, rename it as: temp

Once you have the empty temp folder made, your QB64.exe program should work.

If not, you may have t make a sero length file called temp.bin in that temp folder. You can make one with the same reight click procedure, but select text file under "new" and rename the text file as temp.bin.

If the first and second recommendation fail, post back for more help.

If this does work, I'd like to know the name of the unzip utility you used. I use 7-zip.

Welcome to the forum,

Pete






Posted on Oct 29, 2010, 8:35 PM

Respond to this message   

Return to Index


RE: The Unzip program missed a folder...

by (no login)

Thanks for your response Pete.
The qb64\internal\temp folders were all present already.
The temp folder has two files: "options.bin" (2kb) and "temp.bin" (0kb).
Any other suggestions?

BTW I used the Windows native extractor from the right click menu options.
I also have 7-zip but arbitrarily elected to use Windows extractor.

I greatly appreciate your assit!

Thanks!

Jeff

Posted on Oct 29, 2010, 9:12 PM

Respond to this message   

Return to Index


Re: RE: The Unzip program missed a folder...

by (Login The-Universe)
Admin


I would recommend removing the present QB64 folder, and doing another download from the official qb64.net site. Use 7-zip and see if it will work correctly. In the past, it has been an incomplete unzip that has caused this problem, specifically with the missing temp folder.

I would also recommend unziping to the root drive, so you would have c:\qb64 or whatever your root drive letter is.

If a second unzip on the root drive doesn't work, then we have a new problem that I don't believe has been encountered before, and the developer should be alerted. He and his wife just had a baby this week, so it might not be an immediate response, but he always investigates such matters.

Pete



Posted on Oct 30, 2010, 6:28 AM

Respond to this message   

Return to Index


Re: IDE module error

by (no login)

Hey, thanks Pete!

I unzipped the qb64 file in the C: root directory as you suggested -- and it WORKED!
The IDE is up and running!

Thanks so much for your help. I'm greatly appreciative!

Jeff

Posted on Nov 3, 2010, 12:43 PM

Respond to this message   

Return to Index


how to make temp folder empty

by (no login)

hi pete,
as your suggestion i find temp folder. but i don't know how to make temp folder empty. please suggest me. My problem is I can not close the window(qbasic window screen).




thanking you,
Lok

Posted on Dec 27, 2013, 11:29 PM

Respond to this message   

Return to Index


* Empty folder means to delete everything inside of the folder.

by (Login burger2227)
R

Posted on Dec 28, 2013, 8:55 AM

Respond to this message   

Return to Index


qb64 and btrieve library

by (no login)

hi, excuse my bad English.
I have some programs written in QuickBasic extended v.7 using Btrieve as records manager
I used to load the library QBX / l btr
how can I load the btr.lib library with qb64?

thanks

Posted on Oct 29, 2010, 6:14 AM

Respond to this message   

Return to Index


Re: qb64 and btrieve library

by (Login codeguy)
R

as of right now, external libraries are not usable with qb64.

Posted on Oct 29, 2010, 7:53 PM

Respond to this message   

Return to Index


You can run QBX in DOSBOX

by (Login Mikrondel)
R

If you've upgraded your computer and find that QBX doesn't work, you should try running it in DOSBOX.

Perhaps you should write a program in QBX to export your data into a new database format.

Posted on Oct 29, 2010, 11:16 PM

Respond to this message   

Return to Index


plurality consistancy in a string$

by (no login)

Sorry if the title makes no sense since I couldn't think of a good way to describe my problem, which is why I failed to search for a similar post. I'm not really good with strings. Here is a line of code from my enormously long and complex program:

input: "It only happened 1 times."

IF RIGHT$(rText$, 9) = " 1 times." THEN rText$ = (LEFT$(rText$, LEN(rText$) - 2)) + "." ELSE

output: "It only happened 1 time."

This line is near the beginning of a sub that gets strings from all over the program where the numbers come from numeric values and " times." is added to the end of them. I could put a conditional statement after every single occurrence throughout my program, but it would probably put it over the limit, so you see, I added this.

What I'm wondering is if there's a way to change " 1 times" to " 1 time" no matter where it appears in the string (without overwhelming the poor wittle qbasic memory allocation).

input: "Bob had to hit his head 1 times before deciding the door jam was too low."
output: "Bob had to hit his head 1 time before deciding the door jam was too low."

Due to the enormous size of my program, it doesn't take much to run into "out of memory" or "module too large" type errors, but I haven't blown my stack yet.

Posted on Oct 28, 2010, 3:52 PM

Respond to this message   

Return to Index


INSTR

by (Login Mikrondel)
R

location = INSTR(text$, "1 times")
WHILE location
text$ = LEFT$(text$, location + 5) + MID$(text$, location + 7)
location = INSTR(text$, "1 times")
WEND


Notes:
-The WHILE means that even if it occurs multiple times in a string, all occurences will be fixed.
-You could replace the WHILE with an IF if you know there's only one occurence.

Posted on Oct 28, 2010, 4:08 PM

Respond to this message   

Return to Index


Thank you!

by (no login)

Perfect! Changed 5 and 7 respectively to 6 and 8, but otherwise, worked with no change (aside from variable name of course). Though I don't think my program would generate a string with more than one of those in it, I didn't see the harm in leaving the WHILE -- WEND just in case. AND it didn't tell me I'm out of memory either! =3 I just never did learn much about strings for some reason. I should practice them deliberately I guess.

Posted on Oct 28, 2010, 5:14 PM

Respond to this message   

Return to Index


And another idea...

by (Login Mikrondel)
R


PRINT "Something happened " + xtimes$(1) + "!"



FUNCTION xtimes$(x AS INTEGER)

IF x = 1 THEN
times$ = "once"
ELSEIF x = 2 THEN
times$ = "twice"
ELSE
times$ = LTRIM$(STR$(x)) + " times"
END IF

END FUNCTION

Posted on Oct 28, 2010, 9:40 PM

Respond to this message   

Return to Index


I did something similar

by (no login)

Just this morning, I thought of the once and twice thing, so I did this:

location = INSTR(rText$, " 1 times")
WHILE location
rText$ = LEFT$(rText$, location) + "once" + MID$(rText$, location + 8)
location = INSTR(rText$, "1 times")
WEND
location = INSTR(rText$, " 2 times")
rText$ = LEFT$(rText$, location) + "twice" + MID$(rText$, location + 8)
location = INSTR(rText$, " 2 times")
WEND

I need to pick the " 1 times" out of an existing string, but I guess I could in the same way pick the "1" out of the " 1 times" (or "2" as the case may be) .. oof, too many variables!

I thought of combining the loops, but that would only save me like 39 characters, and I was afraid when one of the locations didn't exist and the other did, I'd get an error when it would try to fix the location that didn't exist, and the error correction would be just as large as the second loop unless I made both corrections conditional, but that would stack three times instead of two, and and adding two conditions would add more than 39 characters and an additional variable (once vs twice), so whatever, not that I'm having a stack problem. =D

Do you ever re-write a paragraph over and over trying to make it shorter, and every time you re-write it, it's longer than before?

But if I could make a combined version work reeeeeeally efficiently, I could add more conditions, like if it says " 1 things" or whatever (just for concept illustration). I don't need to cause this is working great!

Posted on Oct 29, 2010, 10:35 AM

Respond to this message   

Return to Index


This is how I would do it:

by Solitaire (Login Solitaire1)
S

CLS
DIM win AS STRING, plural AS STRING
INPUT "How many games did you win? ", win$
IF win$ = "1" THEN plural$ = "" ELSE plural = "s"
PRINT "You won "; win$; " game"; plural; "."
END

Posted on Oct 29, 2010, 6:16 PM

Respond to this message   

Return to Index


out of memory

by (no login)

Yeah I'd do it that way too if it were a smaller or simpler program, but this is in a sub that takes intact strings from all over the program and displays them on screen in a certain way. I decided to add a plurality correction to it as an afterthought (since it made me look uneducated before). Correcting each case as it's created throughout the program would increase the size of the program substantially, most likely beyond QBasic memory limits. Thanks though.

Posted on Oct 29, 2010, 11:06 PM

Respond to this message   

Return to Index


So why is it that big?

by (Login Mikrondel)
R

What does the program do?


By the way, have you tried using QB64?

Posted on Oct 30, 2010, 12:41 AM

Respond to this message   

Return to Index


What the program does

by (no login)

Sorry, I must have forgotten to check the box to email responses.

The program simulates the lives of two creatures in every possible detail I can fit into QBasic's puny memory. I simulate every organ and how they interact along with a crude basic ai for the creatures. I was originally thinking perhaps I should put my medical knowledge to good use, so since I knew I was squeamish about certain things, I decided to write this program to test whether I had the stomach to go to nursing or medical school.

As I continued to add more and more detail, the creatures sorta became like pets. My mom keeps saying I should have pets, but when I had pets before, they died after a while, and it made me so sad! But when these guys die, they can come back from the dead since they're stored on my computer that way, so it doesn't make me so sad when they die.

Now, I'm just trying to polish it up a bit and mostly clean it up so people don't think I'm some sick pervert if they find it (remember, I simulated EVERY organ in their bodies, including the .. um, special .. ones).

The creatures are fairly crude in appearance, drawn with a few lines and psets to save memory and processing time, and a well-maintained field of grass, and some status bars on the top and bottom of the screen. I've given the ability to save, reset, quit, change a few settings, "scorpion" (causes all bodily waste to magically and instantly disappear and their general health status to become perfectly ideal when I press shift+1 just in case somebody comes in here), and I think that's about it. Mostly, it's there to watch or to run like a screen saver or something, or a fish tank.

I haven't made it so big it won't run at all yet. Sometimes I add a few lines and it says it's out of memory or a module is too large, but I just quit qbasic and open it again and it works fine as long as I don't change anything.

Posted on Nov 7, 2010, 8:21 PM

Respond to this message   

Return to Index


Have a look at the replies to Nightmare's recent post (*URL)

by (Login Mikrondel)
R

http://www.network54.com/Forum/648955/message/1288812211/Black+Jack+Game

Might give you some ideas on shortening your program and saving memory.

Posted on Nov 7, 2010, 10:29 PM

Respond to this message   

Return to Index


QB64 will give you plenty of extra memory...

by (Login The-Universe)
Admin


I'm working on one now with 90,000 lines of code. If you try that in QBaisc, it returns ERROR -1 "Are you freakin' kidding me?"

Pete

Posted on Oct 30, 2010, 6:31 AM

Respond to this message   

Return to Index


QB64

by (no login)

Perhaps I should read about that sometime. I have in the past tried a few supposedly modernised alternatives to qbasic that were supposed to take my old qbasic programs and run them in modern operating systems, but the ones I tried didn't work. Once I discovered DOSBox, I no longer felt the need to try to replace QBasic, so I stopped looking at that time. Maybe it would be worth it to give that one a look though since I seem to be out-growing QBasic. I can't make heads or tails out of visual programming though. I even went to school and stuff trying to learn it, so I hope I can take my old code that works fine in qbasic and just open it as is and it'll work without being edited. That way, I can gradually learn anything new it might have while still being able to do stuff I already know how to do.

=3

Posted on Nov 7, 2010, 8:26 PM

Respond to this message   

Return to Index


All other previous alternative, except Power Basic, sucked.

by (Login The-Universe)
Admin


Of course that is just my opinion, but everybody is entitled to my opinion. (A member at QB64 posted that a while back, and it really cracked me up.)

Anyway, QB64 can run my 90,000 line program, and I only noted a couple of incompatibilities. They get reported, Rob fixes them, and eventually, the program will run unaltered. Of course I did have to reconstruct several modules into one giant program, as QB64 does not support multi-modular programming. Rob could give to that support, but it really isn't necessary. QB only did so to allow for larger programs to compile. QB program size maxed at around 250K. My current QB64 program is nearly 3MB.

Pete

Posted on Nov 7, 2010, 10:17 PM

Respond to this message   

Return to Index


In my opinion multi-module support is necessary

by (Login Mikrondel)
R

and you're all entitled to my opinion :D

Posted on Nov 7, 2010, 10:38 PM

Respond to this message   

Return to Index


But seriously, how can you be serious?

by (Login The-Universe)
Admin

If you are proficient enough to make a multi-modular program, then you are proficient enough to un-multi-modularize it. It doesn't take too much time, and QB64 can run whatever you can throw at it, size-wise.

So other than the direct handling of larger QB multi-modular programs, which I'd estimate there are very few out there, this would be a big undertaking for Rob where his time could be better spent doing other QB64 related activity.

Pete

- You're no longer entitled to my opinion, now you have to earn it. XD

Posted on Nov 7, 2010, 10:50 PM

Respond to this message   

Return to Index


Program size isn't the only reason to split a program into multiple files

by (Login Mikrondel)
R

Advantages of breaking a program into modules:


-It can make the code more organised. This makes it easier to find what you want. Some people may not mind looking at reams of code but I find scrolling for too long breaks my concentration.

-It reduces the need to have multiple copies of the same code. Copy-pasting some code doesn't take long if you only have to do it once. But it can get tedious if you use something (say a BMP loader) in lots of your programs and you need to include this code each time. With modules, if you (or someone else!) fixes a bug in the module then you don't need to go and apply the change to all the files that use it. This is good for collaboration.

-Multi-modular programs encourage better program design, particularly the use of simple, clean interfaces. These are important in the development of larger programs, and lead to less bugs. They also make it easier to collaborate with others.

I think fostering collaboration is important to QB64's success as collaboration is a powerful community builder.

Posted on Nov 7, 2010, 11:36 PM

Respond to this message   

Return to Index


Multi-modular

by (no login)

Sorry if this sounds dumb since I've been doing this solo for .. must have been 15 years or so, so I don't know the proper grammar, but is a module like a sub, or is it like a secondary program that runs on another instance of qbasic? If it's a sub, I'm a bit worried (don't exaggerate this) since the easiest way I can think of to adapt my programs that have loads of "declare sub"s in them is to add sub-names to the ends of the sub variables and turn the subs into gosubs, which I've made a very well ingrained habit out of not using under any circumstances, so much so that I don't even know how to return anything from them (though I'd probably figure it out if I had to). But then, for all I know, a module isn't a sub at all, and I don't have anything to worry about since combining several program instances as I (used to) call them would be quite simple for me to do. In those circumstances, I never use the same variable name for two different things. I learned this early on, not because I gave a rip about programming ethics (I never expected anybody but me to see my code), but because I discovered it confused the expletive out of me. =D

Posted on Nov 8, 2010, 9:49 AM

Respond to this message   

Return to Index


Network 54 Chrome bug will not allow users to post here

by (no login)

The Help Forum has already locked posts about Chrome users not being able to post anywhere. Watch out, the "help" staff bruises easily!

ADD THAT to the other problems, like having to continually enter your name and email address with EVERY post and I'd say paying $20 a year for AD-free Forums is WAY too much! I've seen better sites made by 6 year olds...

They should write a book on killing forums! That seems to be the ONLY thing they are good at!

Posted on Oct 27, 2010, 11:52 PM

Respond to this message   

Return to Index


Join the Hive, resistance is futile.

by (Login The-Universe)
Admin


No scratch that, a real Borg would just throw you in the wood chipper. That would be mulch appreciated.

And it cost a lot more than 20 a year to host ad-free.

Have you tried Safari yet? I'll gladly ship you to Africa.

N54 supports Opera, it's easy to post with it, except it doesn't like Bob's smiley collection unless you turn JavaScript off. Just don't put any of your good glass wear next to the speakers, when you visit a "C" forum.

How about FireFox? FireFox lets you post here and it only updates itself every 5 nano-seconds.

My post is there are a lot of browsers out there you can use to post with, but all have there idiosyncrasies when it comes to N54, but at least you can post with them.

Pete Lo-cute-ascii.

- I should really get a butt-tuck.) Wow, they shouldn't put the "F""T" key so damn close to the "F" key. That was a close one.


Posted on Oct 28, 2010, 2:28 AM

Respond to this message   

Return to Index


You ain't kidding!

by Clippy (no login)

Those two keys ARE close together! :-P

You are right about FF too. I updated Java this morning and EVERY time I restart it, I get another notice. Doesn't it remember? Then it comes back up and asks you to restart again to uninstall the old Java. I installed our Code Copying Add-on and it keeps telling me about it with a button to uninstall it.

Chrome never bothers me at all, PLUS I can go back to ANY page if I forget something or forget to save a WIKI edit. IE always denied access.

I knew it was more than $20, but I wouldn't give them that much! You already know how I feel about them. But I can understand why you don't want to move too. Artelius said he had plenty of space though...

Ted





Posted on Oct 28, 2010, 4:11 AM

Respond to this message   

Return to Index


Outputting Single Character Help

by (no login)

100 ' *******************************************************
110 ' * PROGRAM NAME: EMPLOYEE SALARY CLASSIFICATION *
120 ' * PROGRAMMED BY: ANDREW HUSH, LEVI HAYS, JEREMY ISON *
130 ' * DESCRIPTION: THIS PROGRAM CLASSIFIES AN EMPLOYEES' *
140 ' * SALARY AS EITHER A, B, OR C. *
150 ' *******************************************************
160 ' ***** BEGIN PROGRAM CODE *****
170 CLS
180 READ NAME$, SALARY
190 IF NAME$ = "EOF" THEN END
200 IF SALARY <= 10000 THEN
210 CLASS = A
220 ELSEIF SALARY > 10000 AND SALARY < 30000 THEN
230 CLASS = B
240 ELSEIF SALARY > 30000 THEN
250 CLASS = C
260 END IF
270 IF CLASS = A THEN
280 TAX = SALARY * .15
290 ELSEIF CLASS = B THEN
300 TAX = SALARY * .15
310 ELSEIF CLASS = C THEN
320 TAX = SALARY * .3
330 END IF
340 PRINT NAME$, CLASS, TAX
350 GOTO 180
360 END
370 ' ***** PROGRAM DATA BEGINS HERE *****
380 DATA "ANDREW HUSH", 5000
390 DATA "LEVI HAYS", 10000
400 DATA "JEREMY ISON", 30000
410 DATA "MARK WOLTZ", 15000
420 DATA "EOF", 0

Posted on Oct 27, 2010, 5:04 PM

Respond to this message   

Return to Index


Re: Outputting Single Character Help

by duberry (no login)

Sorry for responding to my own post, but I forgot to mention this is my first post here. Also my problem is the salary classification keeps coming up as zeros when I run the program. Any help would be appreciated.

Posted on Oct 27, 2010, 5:07 PM

Respond to this message   

Return to Index


I'm curious, where is your school?

by (Login The-Universe)
Admin

Most schools don't teach QBasic anymore. I'm wondering if your instructor would like to phase in QB64. www.qb64.net

Welcome to the forum,

Pete

Posted on Oct 27, 2010, 8:02 PM

Respond to this message   

Return to Index


No reply, I knew it...

by (Login The-Universe)
Admin


He's another one of those Chinese spies, trying to steal our modern advanced top secret QBasic computer technology! I miss the old Soviet spies, at least you could see them coming. "I need QBasic with help. Please help you me."

Pete happy.gif

Posted on Oct 28, 2010, 9:18 AM

Respond to this message   

Return to Index


Re: No reply, I knew it...

by (no login)

I never saw your post. My school is in central Ohio. I really don't know why we are learning Qbasic, it seems so outdated and weak.

Posted on Nov 2, 2010, 7:30 PM

Respond to this message   

Return to Index


Is there anything wrong with learning to drive in an old car?

by (Login Mikrondel)
R

A lot of what you learn in QBasic is applicable in many other programming languages.

But you probably haven't seen many of QBasic's more interesting features? You can make programs like Tetris or Paint in QB. And then there's QB64 which gives you so much more power. We have lots of programs you could try.

Posted on Nov 3, 2010, 2:20 AM

Respond to this message   

Return to Index


* MOST boring teachers start with LET and GOTO! From there it is all downhill!

by (Login burger2227)
R

Posted on Nov 3, 2010, 7:22 AM

Respond to this message   

Return to Index


LET your teacher know about QB64 and tell him to GOTO QB64.com for details.

by (Login The-Universe)
Admin


And thanks for the reply.

BASIC is an ineradicably easy language to learn and apply, and if you learn enough of it, you can build just about anything. The point with BASIC is you actually get to build, rather than just borrow from other people's work, by dragging and dropping libraries, calling dll's, etc. The fun in BASIC is the ability to build things your way and it provides that ability without the need to learn more complicated programming languages like ASM and the dreaded Machine code!

If your teacher would like to continue to use QB, the QB64 project will make that possible to do on all new systems. The only drawback so far is that it won't have an interpreter for about two more years. It does have an IDE and an amazing compiler that translates BASIC to C and runs the program in an SDL window. For more info, visit www.qb64.net

Pete

Posted on Nov 3, 2010, 7:53 AM

Respond to this message   

Return to Index


Welcome

by (Login Mikrondel)
R

SALARY, CLASS and TAX are all numeric variables.

What you haven't realised is that A, B and C are numeric variables also. Since you never assigned anything to A, B, or C, their values are all 0. So when you do

CLASS = A

you are really achieving:

CLASS = 0


I'll leave you to ponder what to do about this.


Your use of ELSEIFs is also problematic. What if SALARY is exactly 30000? Then it won't be classified as A, B or C. I suggest something more like this:

IF SALARY < 10000 THEN
...
ELSEIF SALARY < 30000 THEN 'The previous condition guarantees that SALARY is 10000 or more
...
ELSE 'The previous condition guarantees that SALARY is 30000 or more
...
END IF


Do what you have to do to meet your teacher's requirements, but be aware that not only are line numbers optional in QBasic, they also have been regarded as bad practice for a long time (along with GOTOs). If you wish to do programming outside of class then don't bother with them.

Posted on Oct 27, 2010, 6:34 PM

Respond to this message   

Return to Index


Why the line numbers?

by Solitaire (Login Solitaire1)
S

Is this a QBasic program or the outdated GWBASIC?

As Artelius stated below, line numbers in QBasic are not needed, and GOTOs are frowned upon. Use a structured programming block such as a DO loop to repeat a section of code.

What textbook are you using in class?

Posted on Oct 28, 2010, 9:24 AM

Respond to this message   

Return to Index


Thank you

by (no login)

I got it sorted out. I had to DIM CLASS as a string and put all the As, Bs, and Cs in quotations. We aren't using a text book, he just kinda gives us assignments. Also I don't really see a problem with GOTOs but a DO Loop would work just as well. Thanx for the tips.

Posted on Nov 2, 2010, 7:33 PM

Respond to this message   

Return to Index


Do Loops

by (no login)

Personally since I program for myself and generally don't share my code since up until a few days ago I thought I was using an obsolete language, I didn't really see a problem with gotos, and I find line numbers have their place, but using a do - loop whenever possible makes my code enormously easier to navigate when I'm working on it, and having a whole program full of line numbers makes it look extraordinarily confusing to me in most cases. Besides, when you decide to add more code for whatever reason between two line numbers, if you're compelled to assign line numbers to your new code and haven't left enough space between your line numbers, you have to go back and re-number a bunch of lines and make sure you don't have any gotos going to any of the line numbers you've changed. If it works for you, then that's great, but you should be warned if you ever start sharing your code, it will be hard to share it if it's a bunch of line numbers and IF A = 7 THEN GOTO 963 stuff like that =D

Um, hope all that makes sense ^_^

Posted on Nov 10, 2010, 8:07 PM

Respond to this message   

Return to Index


snoopin' about

by (Login PhyloGenesis)
R

Posted on Oct 26, 2010, 12:47 AM

Respond to this message   

Return to Index


Attention all personell.. The Chat Room now open to the public. God help us all...

by (Login The-Universe)
Admin


Some Chatty Cathys over at QB64 wanted a place to chat; so, the Chat Room is now open to the general public. YOu don't need to be a general to use it, you could even be a private, although chatting about private matters may not be in your general interest.

That is a all,

Radar

Posted on Oct 25, 2010, 4:51 PM

Respond to this message   

Return to Index


*Oh, great -- I hope you moved my still, Corporal.

by (Login qb432l)
R

*

Posted on Oct 25, 2010, 7:48 PM

Respond to this message   

Return to Index


* Oh take your unicode and shove it up your ascii, Pierce.

by (Login The-Universe)
Admin

Posted on Oct 25, 2010, 8:12 PM

Respond to this message   

Return to Index


*thanks

by (Login MCalkins)
Moderator

Posted on Oct 27, 2010, 3:56 AM

Respond to this message   

Return to Index


Word frequency program any ?

by Lisztfr (no login)

Sorry i didn't start coding, since no one helped finishing my fractal program... i have some routines to order line length frequency. I would by glad to read a smart program i Qbasic. thanks, L

Posted on Oct 25, 2010, 1:02 AM

Respond to this message   

Return to Index


Hash table based

by (Login Mikrondel)
R

Just whacked this together quickly. It's hash table based so that inserts are quick. Let me know if you have any questions.

CONST COLL = 4
DIM strs(0 TO 255, 0 TO COLL) AS STRING
DIM counts(0 TO 255, 0 TO COLL) AS INTEGER
DIM SHARED hashStep(0 TO 255) AS INTEGER
DIM i AS INTEGER, t AS INTEGER
t = 17
FOR i = 0 to 255
hashStep(i) = t XOR 148
t = ((t * 17)+1) AND 255
NEXT

DO
READ s$
IF s$ = "END" THEN EXIT DO
s$ = LCASE$(s$)
h = hash(s$)
FOR i = 0 to COLL
IF strs(h, i) = "" THEN
strs(h, i) = s$
EXIT FOR
ELSEIF strs(h, i) = s$ THEN
EXIT FOR
END IF
NEXT
IF i <= COLL THEN
counts(h, i) = counts(h, i) + 1
ELSE
PRINT "Too many collisions for " + s$
SYSTEM
END IF
LOOP

FOR i = 0 TO 255
FOR j = 0 to COLL
IF strs(i, j) = "" THEN EXIT FOR
PRINT strs(i, j), counts(i,j)
NEXT
NEXT

DATA This,is,a,test,This,is,more,test,Just,one,more,END



FUNCTION hash%(s AS STRING)
DIM t AS INTEGER
FOR I = 1 TO LEN(s)
t = (t + ASC(MID$(s, I, 1))) AND 255
NEXT
t = hashStep(t)
FOR I = 1 TO LEN(s)
t = hashStep((t + ASC(MID$(s, I, 1))) AND 255)
NEXT
hash% = t
END FUNCTION

Posted on Oct 25, 2010, 2:33 AM

Respond to this message   

Return to Index


Very interesting program

by Lisztfr (no login)

I would never had think about hash tables...

XOR and AND are working like MOD here ? on a 2 ^ n basis ?

The hash Function ?

You'r sure that t never exceed 255 ? why ...
Why you made such a complex Function ?

strs is for storing the strings, counts for counting them...

IF strs(i, j) = "" THEN EXIT FOR

why this exit for ? nothing else to print on this COLL ?

Ok...

Posted on Oct 25, 2010, 5:13 AM

Respond to this message   

Return to Index


Answers

by (Login Mikrondel)
R

> XOR and AND are working like MOD here ? on a 2 ^ n basis ?

AND is. XOR is just used to shake it around a bit.

> You'r sure that t never exceed 255 ? why ...

Because I keep using AND 255.

> Why you made such a complex Function ?

Seems pretty simple to me. Much simpler than MD5.http://www.network54.com/Forum/178387/thread/1231532861/last-1231538625/ProgramList+Artelius

I wanted the results to be fairly balanced.

> strs is for storing the strings, counts for counting them...

Yes.

> IF strs(i, j) = "" THEN EXIT FOR
> why this exit for ? nothing else to print on this COLL ?

Yes. The 2nd index of the array is to deal with hash collisions, which will be quite likely to occur with only 256 hash values. Slots that haven't been used yet contain "", and of course if one contains "" then all the later ones on that row do as well.

Posted on Oct 25, 2010, 3:28 PM

Respond to this message   

Return to Index


You set the COLL to 4 to detect 4 collisions ?

by Lisztfr (no login)

So if for some words there are 3 collisions... h = same value, but s$ isn't the same... what's then ?

Still i like it very much ;) thanks.

2 improvements i see :

filter out small words,
chaining location for avoiding collisions, said in Wkp :

Separate chaining

Hash collision resolved by separate chaining.

In the strategy known as separate chaining, direct chaining, or simply chaining, each slot of the bucket array is a pointer to a linked list that contains the key-value pairs that hashed to the same location

Posted on Oct 26, 2010, 4:35 AM

Respond to this message   

Return to Index


... h

by Lisztfr (no login)

one 1 56
a 1 92
is 2 159
just 1 181
this 2 241
test 6 241
more 2 255

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


for "this" and "test", h is the same. Very good point.

Posted on Oct 26, 2010, 4:40 AM

Respond to this message   

Return to Index


5 collisions actually

by (Login Mikrondel)
R

0 to 4 = 5

Using a linked list is a good option but QB doesn't support lists, or pointers. It can be done using array indices. I think in practice my program will work pretty well, maybe COLL needs to be adjusted up a bit.


> filter out small words,

If you like. It was just a quick example which you're free to extend.

Posted on Oct 26, 2010, 3:57 PM

Respond to this message   

Return to Index


It even works on words I commonly use all day...

by Mary F. N. Poppins (Login The-Universe)
Admin


Like Supercalifragilisticexpialidocious!

Posted on Oct 25, 2010, 10:28 AM

Respond to this message   

Return to Index


*...or "garn!" (no wait, that was Eliza Doolittle).

by (Login qb432l)
R

*

Posted on Oct 25, 2010, 10:42 AM

Respond to this message   

Return to Index


*the sound of that is something quite atrocious!

by (Login codeguy)
R

Posted on Oct 26, 2010, 11:28 AM

Respond to this message   

Return to Index


good qbasic website

by Ben (no login)

it says that this website is gonna be closed
http://thunder.prohosting.com/~oasys/frameex1.htm
I like the website and its not good that it will be closed

Posted on Oct 21, 2010, 7:39 PM

Respond to this message   

Return to Index


Re: good qbasic website

by angros47 (no login)

I've updated ArchiveTeam:

http://archiveteam.org/index.php?title=Deathwatch#Pining_for_the_Fjords

Thanks

Posted on Oct 22, 2010, 12:17 PM

Respond to this message   

Return to Index


Math problem help

by Zack (no login)

Hi, I am kinda new to Basic, and I was trying to build a calculator. I got it to add, subtract, multiply, or divide two numbers, but I wanted it to do more complex problems.
I made it so that the user can enter a statement like 4-7*8/2. But I can't figure out how to tell the program to solve what they typed in.
I would appriciate any help, Thanks

Posted on Oct 20, 2010, 1:55 PM

Respond to this message   

Return to Index


It can be done

by (Login Mikrondel)
R

Without knowing what level of skill you are at, it's hard for us to give you good advice.

If you post some programs you have written, it would be much easier for us to give you help and advice.

As a starting point, read about the MID$, LEFT$, RIGHT$, LEN, and INSTR functions if you are not already familiar with them.

Posted on Oct 20, 2010, 4:51 PM

Respond to this message   

Return to Index


Hey again

by Zack (no login)

My level is kinda very low, I can only really use Print and Input commands efficiently.
I looked up the commands that you send me and it looks like they are for Visual Basic. Are there any commands that can acomplish this on QBasic7.1?

Posted on Oct 21, 2010, 2:58 AM

Respond to this message   

Return to Index


Those are all QBasic functions...

by (Login qb432l)
R

Basically, what you have to do is break down the input string to determine what numerical values and operators are in the string. This is intermediate level coding, and if you're not comfortable with it, why not make your calculator a bit more like a conventional one?

Have the user enter numbers and operators (/*+-) in sequence, pressing Enter after each separate input. That way you can calculate the answer as you go along, rather than parse an entire string. For example, 2 (Enter) / (Enter) 5 (Enter) * (Enter) 40 (Enter) = (Enter).

-Bob

Posted on Oct 21, 2010, 7:18 AM

Respond to this message   

Return to Index


Here is an example, then

by (Login Mikrondel)
R

'Program to determine whether the input is a palindrome

'(reads the same forwards and backwards)
INPUT "Please enter a word or sentence: ", in$
PRINT

'Construct the string clean$ by considering one letter of in$ at a time

clean$ = ""
FOR i = 1 TO LEN(in$)
letter$ = LCASE$(MID$(in$, i, 1))
IF letter$ >= "a" AND letter$ clean$ = clean$ + LCASE$(letter$)
END IF
NEXT

PRINT "In lowercase and with non-letters removed: "; clean$

reverse$ = ""
FOR i = 1 TO LEN(clean$)
reverse$ = MID$(clean$, i, 1) + reverse$
NEXT

PRINT "In reverse: "; reverse$
PRINT

IF clean$ = reverse$ THEN PRINT "You entered a palindrome" ELSE PRINT "You didn't enter a palindrome"



Read about the LEN and MID$ functions. (If your QB help doesn't work let me know.) Then study this program and try to understand how it works.

If you have any questions at all please post them.

Also, please don't be afraid of posting your programs. We're here to help.

Posted on Oct 22, 2010, 3:46 AM

Respond to this message   

Return to Index


Thanks, but I have another question

by Zack (no login)

Thank you very much, I got my calculator to work, and now I am started with something new. I made a very large IF THEN statement, and it told me that it was too large and then it wouldn't work. Is there another program that works like QBasic that can support larger files? If not then is there a way to make the program link itself to other files. Like

IF A = 453 THEN
OPEN blah453.bas

Thanks for any help.

Posted on Oct 23, 2010, 6:12 PM

Respond to this message   

Return to Index


Look up SELECT CASE

by (Login The-Universe)
Admin


INPUT a
SELECT CASE a
CASE 1: PRINT "First"
CASE 2: PRINT "Second"
CASE 3: PRINT "Third"
CASE 4, 5: PRINT "This is getting old..."
CASE 6
PRINT "You cant put more than one..."
PRINT "statement in a case."
CASE ELSE
PRINT "ELSE handles everything else."
END SELECT


Posted on Oct 23, 2010, 8:10 PM

Respond to this message   

Return to Index


Ok

by Zack (no login)

I know how to use case but what I wanted to know was if you could make the program open a text document of something. Not actually open it, but rather follow the commands within it, so it would not be too large.

Posted on Oct 23, 2010, 8:42 PM

Respond to this message   

Return to Index


Yes, but that would be a little weird...

by (Login The-Universe)
Admin


1) Creat the text document.

2) Open to read...

REM ORIGPROG.BAS
OPEN "MYTEXT.TXT" FOR INPUT AS #1
OPEN "MYFILE.BAS" FOR OUTPUT AS #2
DO UNTIL EOF(1)
LINE INPUT #1, txt$
IF VAL(txt$) = x THEN PRINT #2, txt$
LOOP
CLOSE #1, #2

CHAIN "MYTEXT.BAS"

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

YOu would need to make the txt file something like:

1 "PRINT "HELLO WORLD!"
1 "CHAIN ORIGPROG.BAS"

2 "PRINT "12345"
2 "SOUND 1000, 1"
2 "END"

etc...

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

My quest would be how large are you planning to make your program, because I would just use SUB calls, or multi-modular programming in QB. YOU can get up to around 350K with that nethod. But for programs over 50K, I would recommend you convert them to QB64, www.qb64.net

Pete

Pete


Posted on Oct 24, 2010, 3:13 AM

Respond to this message   

Return to Index


Share some code!

by (Login Mikrondel)
R

Show us your calculator program. I'm curious how you approached the problem. We would also be able to give you feedback and suggest improvements.

> now I am started with something new

Tell us more.


> I made a very large IF THEN statement, and it told me that it was too large and then it wouldn't work.

This is a strong indication that you're taking the wrong approach to solving a problem.

Do you know how to use arrays? What about subroutines? They're important tools in the creation of concise, well-designed programs. I could give you more specific advice if you tell us more about what you want to achieve.

Posted on Oct 25, 2010, 1:24 AM

Respond to this message   

Return to Index


You're going to need parenthesis brackets for operation order too.

by (Login burger2227)
R

4 - 7 * 8 /2 = 4 - 56 / 2 = 4 - 28 = -24

OR

(4 - 7) * 8 / 2 = -3 * 4 = -12


Posted on Oct 20, 2010, 8:52 PM

Respond to this message   

Return to Index


Good example using parenthesis, Ted.

by Moneo (no login)

In the first example, the operations follow the old rule of: "Multiply and divide before add and subtract".

In the second example, by using parenthesis you can change the order with which operations are performed.

In either case, parsing the input string into it's components, can get rather tricky. You also have to be able to detect many possible input errors including unmatched sets of parentheses.

Regards... Moneo

Posted on Oct 21, 2010, 4:24 PM

Respond to this message   

Return to Index


support Hebrew inside QBX 7.1

by YanR (no login)

Hello ppl,

i'm using QBX 7.1 with Hebrew Enabled XP And
i have a problem with hebrew support under QuickBasic
that's under Dos,

i can't type hebrew Char's in the qbx program
but under dos i can,
and i need to print hebrew Char's in the ".bas" file

so to get around the problem i opend the "File.bas"
with notepad, and wrote there hebrew text
only within "PRINT" statment afcourse.
but when i try to open it with QBX, it shows
scrambled signs, & no hebrew is shown

my question is like this what hebrew font does QBX
support, or maybe i should change the font in DOS window
i tried to change the hebrew font of the file.
but didn't find any heb font that qbx support all scrambled!!!

Thanks,
For All,
YanR,

Posted on Oct 15, 2010, 6:45 AM

Respond to this message   

Return to Index


You cannot even type ASCII characters into Notepad!

by Clippy (Login burger2227)
R

Use the DOS text editor by typing Edit filename.txt

Save it as text and try opening with QBX, but I doubt it will work.

QB64 can use Unicode characters, but I don't know about Hebrew stuff.

Become a member and post in Discussions Forum:

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

Posted on Oct 15, 2010, 7:30 AM

Respond to this message   

Return to Index


no hebrew support in "edit"

by YanR (no login)

no sorry i tried opening edit program
under dos, it doesnt have hebrew support
i have anthor notepad called "Lister"
it is located in "Total Commander" program
there i can save any text format file

but i need to know which hebrew format
QBX 7.1 support!

Thanks,
For all,
YanR,

Posted on Oct 15, 2010, 1:00 PM

Respond to this message   

Return to Index


QB does not support Hebrew

by (Login Mikrondel)
R

However that doesn't mean what you want is impossible.

Please tell us more about what you are trying to achieve. With some specialised font routines or unicode encoders/decoders it may be possible.

Have a look at the program I wrote available here:http://www.network54.com/Forum/13959/message/1204086957/FINE!

Posted on Oct 15, 2010, 4:02 PM

Respond to this message   

Return to Index


maybe load heb font support in CMD

by YanR (no login)

hello Artelius,

i tried the program u linked me but it output's nothing
i need to have a hebrew font support in "QBX 7.1" that's
starts in "Command Prompt", maybe there's
a hebrew font load program that load's
hebrew support under "Command Prompt".

that way i will be able to see hebrew font
in "QBX 7.1" that starts in "Command Prompt"

Thanks,
For All,
YanR,

Posted on Oct 16, 2010, 6:13 AM

Respond to this message   

Return to Index


Try again

by (Login Mikrondel)
R

> i tried the program u linked me but it output's nothing

Make sure you extract ALL the files and they are available in the current directory. If the files are not in the right place the program will not work. It will create empty files instead.


> i need to have a hebrew font support in "QBX 7.1"

Sorry, there is none.

> maybe there's a hebrew font load program that load's hebrew support under "Command Prompt".

Not for QBX.

Posted on Oct 16, 2010, 5:11 PM

Respond to this message   

Return to Index


found a soultion for Hebrew problems under QB45

by YanR (no login)

hello Artelius,

i found a soultion for hebrew support problems
in QB45,
and also i found out that the main and easy path is also the right one.

to support hebrew in QB45 i needed to load hebrew font's in "CMD"
and load the correct "code page" in "CMD".
and after i did that it opened me full hebrew support
so that i could type in hebrew under "CMD" window.

well, i guess i was right after all(when i said theres a need to load hebrew font in "CMD").

so Thanks to all responses
but no thanks ;)

as the song goes: "I did it.. My.. Way"

Yan R.

Posted on Jan 27, 2011, 8:46 AM

Respond to this message   

Return to Index


As far as I know, no version of QB supports Hebrew. (See PS below.)

by Solitaire (no login)

There may have been several foreign language editions of QB, but that would be mostly the Help file. I don't know if they support fonts other than the usual ASCII characters. There were probably several versions in Latin alphabets, but I doubt that a Hebrew version existed. Also remember that QB is 20 years old, and it came out long before a lot of modern improvements.

In order to display foreign language fonts on your computer, you need to use the equivalent foreign language version of the operating system, but I don't know if QBasic (or QBX) can even accommodate that. In the .NET programming languages, the font display is referred to as the "culture."

I tried doing a Google search for QBasic + Hebrew. I came up with something, but it's an old post and the url no longer works. However, you might try the email and see if it's still active. Maybe that person can help you. Otherwise, do your own search. Good luck.

Here is a copy of the reference:

=============================================================================
Site Name: qbasic in Israel ( some hebrew)
Description: here is some applications in qbasic in hebrew. since many read english, they should like our site, and we like theirs.
Submitted by: staff
email: qbasic@judsonalumni.com
site url (click): www.progarea.co.il/qbasic/links.htm
Date Posted: Tue Jul 30 19:00:03 2002
=============================================================================

PS: Other than that, you can take Artelius' advice and copy your program to QB64. From there you can figure out how to use UNICODE to display the Hebrew characters. UNICODE is a lot more recent than the last version of QB, which could only use ASCII.

Posted on Oct 16, 2010, 10:19 AM

Respond to this message   

Return to Index


Actually

by (Login Mikrondel)
R

> you can take Artelius' advice and copy your program to QB64.

That was actually Clippy's advice. I (currently) know nothing about how Unicode works in QB64.

> UNICODE is a lot more recent than the last version of QB, which could only use ASCII.

Actually Unicode took form around 1988. The last version of QBX was released in 1990.

Posted on Oct 16, 2010, 5:18 PM

Respond to this message   

Return to Index


*The update to QB64 next week supports codepages like Hebrew(CP862)

by (no login)

Posted on Oct 19, 2010, 11:44 AM

Respond to this message   

Return to Index


*UPDATE: This been implemented and Hebrew can now be used.

by (no login)

Posted on Oct 20, 2010, 3:37 AM

Respond to this message   

Return to Index


* i thought unicode made codepages obsolete...

by (Login MCalkins)
Moderator

Posted on Oct 20, 2010, 1:16 PM

Respond to this message   

Return to Index


*Sure does. QB64 has an ASCII<->UNICODE mapper for legacy reasons.

by Galleon (no login)

Posted on Oct 21, 2010, 12:26 AM

Respond to this message   

Return to Index


* LEGACY? Don't do it on my account...:-)

by (Login burger2227)
R

Posted on Oct 22, 2010, 2:21 AM

Respond to this message   

Return to Index


I'm interested in this

by (Login Mikrondel)
R

Are there any details about this documented? Or could you give a brief explanation?

Posted on Oct 22, 2010, 6:26 PM

Respond to this message   

Return to Index


Questions Regarding flags, END IF, and the INPUT command:

by Negative (no login)

Questions Regarding flags, END IF, and the INPUT command:
Sorry for the mass amount of questions, and thank you for the previous answers, but i got more =]

-What is a flag, same thing as a Boolean?
-I seen in a lot of QBasic code, they don't always use the END IF command after IF. Is this correct? If so when should you use the END IF command and when not?

-Whenever I use the INPUT command like this: "INPUT a%", and on the Output screen I type in text it gives me the "Redo from start" error. However when I type in "d" or "e" it doesn't give me an error, instead it reacts like if you'll type in numbers.

-Having multiple variables after the INPUT command causes problems:
CLS
INPUT A, B, C
It gives me the "Redo from start" error no matter what i type (numbers or text), why? I believe I tried this and it worked before..

Posted on Oct 14, 2010, 7:35 PM

Respond to this message   

Return to Index


Some more answers:

by Solitaire (Login Solitaire1)
S

A flag is a type of variable that is used to signal that something has taken place, or when a certain condition is true. It should get one of two values, either true or false, 0 or 1, etc. You initialize the flag to be down, or false, or 0 to start. When the event takes place, you put the flag up by making it true, or 1. After processing the information, you put the flag down again so that it can be reused.

For example:
==================================================================
DIM flag AS INTEGER
CLS
flag = 0
PRINT "You must pass at least one out of three tests."
FOR x = 1 TO 3
    INPUT "Enter P or F: ", test$
    IF UCASE$(test$) = "P" THEN flag = 1
NEXT x
IF flag = 1 THEN
    flag = 0
    PRINT "OK"
ELSE
    PRINT "Failed"
END IF
PRINT
PRINT "Now you must pass all three tests."
FOR x = 1 TO 3
    INPUT "Enter P or F: ", test$
    IF UCASE$(test$) = "F" THEN flag = 1
NEXT x
IF flag = 0 THEN
    PRINT "OK"
ELSE
    PRINT "Failed"
END IF
END
===================================================================

A single-line IF statement should not end with END IF. Only a block of code needs a terminator. The IF block uses a separate line after the THEN keyword. ELSE goes on a line by itself. The block needs to be terminated with END IF.

You should avoid using a multiple INPUT statement. It's very confusing to the user. Each of the parameters requires a separate response separated by a comma. For Example, if you use
INPUT A, B, C
the user needs to respond with three answers separated by commas.

QBasic regards the "e" as an exponent and the "d" as a double-length exponent. Both are used with scientic notation.

It is best to use only strings for INPUT. If you need a number, use the VAL() function to convert the string into a number. Then you will never get a "Redo from start" message. Example:

DIM snum AS STRING, mynum AS INTEGER
INPUT "Enter an integer: ", snum$
mynum = VAL(snum$)

Posted on Oct 14, 2010, 8:38 PM

Respond to this message   

Return to Index


i modified the first example a bit

by (Login MCalkins)
Moderator

i don't have qbasic on this computer, but i think that this should work:

DIM flag AS INTEGER
CLS
flag = 0
PRINT "You must pass at least one out of three tests."
FOR x = 0 TO 2
INPUT "Enter P or F: ", test$
flag = (UCASE$(test$) = "F") OR flag
NEXT x
IF flag THEN
flag = 0
PRINT "OK"
ELSE
PRINT "Failed"
END IF
PRINT
PRINT "Now you must pass all three tests."
FOR x = 0 TO 2
INPUT "Enter P or F: ", test$
flag = (UCASE$(test$) = "F") OR flag
NEXT x
IF flag THEN PRINT "Failed" ELSE PRINT "OK"
END


regards,
michael

p.s. edited and fixed a bug after testing.

Posted on Oct 27, 2010, 4:47 AM

Respond to this message   

Return to Index


Re: sorry

by (Login Mikrondel)
R

> Sorry for the mass amount of questions

If you want to make it up to us, post a program you wrote :D

Posted on Oct 15, 2010, 12:25 AM

Respond to this message   

Return to Index


Where?

by Negative (no login)

If I need help on a program and it is about 600-700 lines of code, where do i post it? Here, or the source code section?

Posted on Oct 28, 2010, 11:02 AM

Respond to this message   

Return to Index


Re: Where?

by (Login The-Universe)
Admin

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

Post it there and post a link to it in this thread.

Pete

Posted on Oct 28, 2010, 12:46 PM

Respond to this message   

Return to Index


Questions Regarding Booleans, commands, functions and statements

by Negative (no login)

-So are the values of a boolean type: 0 (False) & 1 (True) or
0 (False) & -1 (True) and any other number besides 0 (True)?
Or does it depend on the programming language?

-What's the difference between a command, function, and statement?

Posted on Oct 13, 2010, 9:21 PM

Respond to this message   

Return to Index


*rtfw

by (Login codeguy)
R

Posted on Oct 13, 2010, 9:40 PM

Respond to this message   

Return to Index


*not very welcoming

by Ben (no login)

Posted on Oct 13, 2010, 10:08 PM

Respond to this message   

Return to Index


Re: *not very welcoming

by (Login codeguy)
R

we have already stated our policy that we adhere to. even if you only have the start of a program you wrote or just wanna post a segment of code you're having difficulty with, then by all means post it and we will see if we can help you get it fixed. otherwise with no code, we have nothing to work with. i do not generally check my email except very infrequently. the best way to reach me is qb64.net or here at n54. we have far too many attempts by people to have us do their work for them, even though they have been informed of the homework policy.

Posted on Oct 13, 2010, 11:19 PM

Respond to this message   

Return to Index


* Goofball, you are in the wrong thread!

by Clippy (Login burger2227)
R

Posted on Oct 13, 2010, 11:35 PM

Respond to this message   

Return to Index


Maybe, but next time codeguy, rtfp...

by (Login The-Universe)
Admin


If you read the "forum" post codeguy, I would see it as a valid QB question. If there was a "Do my homework for me post" that would be denied. If Clippy is right, and you confused this thread with another one, well, oops. Also, this forum does not have a WIKI, just a link to the QB64 one, so it would be a little confusing for the OP to return and read the "forum" WIKI.

Pete

Posted on Oct 14, 2010, 9:47 AM

Respond to this message   

Return to Index


Re: Maybe, but next time codeguy, rtfp...

by (Login codeguy)
R

oops! my bad i thought i was in the c++ compilation error thread! sorry!

Posted on Oct 14, 2010, 2:25 PM

Respond to this message   

Return to Index


* Qbasic returns -1 when true, 0 false. What you do is your business!

by Clippy (Login burger2227)
R

Posted on Oct 13, 2010, 11:37 PM

Respond to this message   

Return to Index


Some answers to Negative's questions:

by Solitaire (Login Solitaire1)
S

There is no true Boolean type in QBasic. You can simulate it by declaring a constant as FALSE equal to 0, and TRUE equal to NOT FALSE.

Here is an example program you can try out:

=====================================================================
CONST FALSE = 0
CONST TRUE = NOT FALSE
'NOT 0 is the same as -1
CLS
PRINT "Flags are usually BOOLEAN type -- either TRUE or FALSE."
flag = FALSE
PRINT "FALSE flag value = "; flag
flag = TRUE
PRINT "TRUE flag value = "; flag
INPUT "Enter a number: ", num
IF num = FALSE THEN
    PRINT "False"
ELSE
    PRINT "True"
END IF
END
=====================================================================

A statement is a line of instruction in the code. It tells the computer what action must be taken at that position in the sequence of program execution. A statement may contain keywords, operators, expressions, variables, declarations, assignments, etc.

A command is an instruction that makes use of a keyword. (It's part of a statement, or could mean the same as a statement.)

A user-defined function is a subprogram that returns a value to the caller. It is prepared by the programmer. There are also dozens of built-in functions that are part of the QBasic library. They also return a value of the specified type. The programmer must be familiar with how the built-in functions work, what type they return, what the arguments are and how they are used.

Posted on Oct 14, 2010, 10:36 AM

Respond to this message   

Return to Index


QB can also evaluate NOT 0 as a true statement.

by Clippy (Login burger2227)
R

'The following will determine if there is a number value entered:

INPUT "Enter a number or press enter: ", answer$

number = VAL(answer$)

IF number THEN
PRINT "You entered a value that was not zero!"
ELSE PRINT "You pressed enter didn't you?"
END IF

END

Posted on Oct 14, 2010, 10:51 AM

Respond to this message   

Return to Index


Tutorial I wrote a while back re True/False. Hope it helps.

by Moneo (no login)

TRUE/FALSE TESTING
==================

Testing conditions or switches for TRUE or FALSE can be confusing, so first let's look at some QBasic/QuickBasic (QB) rules:

RULE #1: A boolean expression: any expression that evaluates as follows:
* to TRUE (nonzero)
* to FALSE (zero)

RULE #2: Conditional statements like IF, DO...LOOP, WHILE...WEND test a boolean expression and will execute, branch or loop based on whether the boolean expression is TRUE (nonzero) or FALSE (zero).

RULE #3: However, when a boolean expression is used as a value, assigned to a variable or output in any way, QB will convert the result, after evaluation, to TRUE (-1) or FALSE (0).

EXAMPLES:
x=2
if x then print "is true" .....Will print because x is TRUE (nonzero)
if x-2 then print "is true" ...Will not print because x-2 is FALSE (zero)
if x-5 then print "is true" ...Will print because x-5 is -3 is TRUE (nonzero)
result = (x=2) ...............result will be -1 (TRUE) because x=2 is true
result = (x>0) ...............result will be -1 (TRUE) because x>0 is true
result = (x<0) ...............result will be 0 (FALSE)

EXAMPLE OF TESTING A SWITCH WITH AN IF STATEMENT:

if switch then goto switchon

The boolean expression containing the variable "switch" is evaluated for zero or non-zero in accordance with Rule #2.
* If the result is non-zero, the condition is considered TRUE, and the goto takes place.
* If the result is zero, the condition is considered FALSE, and the goto does not take place.

Let me stress a point regarding the value of "switch". The above IF would do the goto under many nonzero circumstances, including:
* A value of -1
* A value of 1

The fact that the IF works for -1 or 1 tricks some people into thinking that either of these can always be considered as TRUE. It depends, see Rules #2 and #3 above.

EXAMPLE OF STRAIGHTLINE VERSUS TRICKY BOOLEAN CODE:

Here's a straightforward line of code. If the code is 1 then we want to increment count1 by 1.
if code=1 then count1=count1+1

A clever, but confusing alternative is:
count1 = count1 - (code1=1)

Here's how it works. The boolean expression (code1=1) is evaluated and the result is either TRUE (-1) or FALSE (0), in accordance with Rule #3.
* If it's TRUE (-1), count1 will be incremented because -(-1) is +1.
* If it's FALSE (0), count1 will not be incremented because -(0) is 0.

This kind of cleverness dates back to assembly language where IF-type conditional logic was avoided. With today's languages, you don't need to be so cute. You'll only be confusing yourself or the next programmer doing maintenance.

EXAMPLE OF OVER-SIMPLIFYING CODE WITH BOOLEAN EXPRESSIONS:

The following is the code I use to determine if a year is leap year. The resultant variable Isleap is set to TRUE (-1) or FALSE (0).

IsLeap = (Y MOD 4 = 0 AND Y MOD 100 <> 0) OR (Y MOD 400 = 0)

The logic is fairly straightforward following the standard definition of leap year which says:
If the year is evenly divisible by 4 and not divisible by 100,
or if the year is evenly divisible by 400,
then it is a leap year.

The code has two boolean expressions enclosed in quotes to comply with the definition. So, if either expression is true, it is a leap year.

Here's another implementation of the same logic which at first glance looks a little simpler.

Isleap = (Y MOD 4 = 0) - (Y MOD 100 = 0) + (Y MOD 400 = 0)

This code, which also works by the way, has three boolean expressions enclosed in quotes. Taking into account that TRUE is -1 and FALSE is 0, arithmetic is performed on the results of these expressions to produce a final TRUE/FALSE condition.

It took me a while to understand this code, and I tested it with a little program. I'll let you figure it out. Again, the second version of the code looks simpler, but I consider it more complicated. Like Albert Einstein said: "We have to make things simple, but not simpler."

RECOMMENDATIONS:

1) Be aware of Rule #2 when writing conditional statements, that is, TRUE is nonzero and FALSE is zero.

2) If you're going to use or assign the results of boolean expessions, remember that TRUE is -1 and FALSE is 0.

3) If you're going to use switches, avoid using 1 for on, and 0 for off, even if that seems to make more sense to you. Use -1 for on, and 0 for off.

The recommended and more explicit way of handling switches is as follows:

CONST FALSE = 0
CONST TRUE = NOT(FALSE) ..... this is equal to -1

if somecondition then switch is TRUE

if switch = TRUE then goto swon
if switch = FALSE then goto swoff

To flip a switch, turn it off if on, or turn it on if off:

switch = not(switch)

*****

Posted on Oct 14, 2010, 12:33 PM

Respond to this message   

Return to Index


*"enclosed in quotes"? I don't see any quotes.

by A ninny mouse (no login)

*

Posted on Oct 16, 2010, 10:23 AM

Respond to this message   

Return to Index


Re: *"enclosed in quotes"? I don't see any quotes.

by Moneo (no login)

You're right. It should say "enclosed in parentheses", which I'm sure you have already figured out.

Regards.... Moneo

Posted on Oct 24, 2010, 4:56 PM

Respond to this message   

Return to Index


* Moneo, he is just ACTING like a NINNY, get it? ninny...:-)

by (Login burger2227)
R

Posted on Oct 25, 2010, 12:10 AM

Respond to this message   

Return to Index


rule #3

by (Login MCalkins)
Moderator

hello, moneo:

i believe you had included part of the above post in a qbasic express magazine some time back. i had made a response to it that rule #3 should probably be reworded to something more like:

the result of any relational operation (=, <>, <, <=, >, >=) will be 0 for false, and -1 for true.

the reason why i wouldn't say "However, when a boolean expression is used as a value, assigned to a variable or output in any way, QB will convert the result, after evaluation, to TRUE (-1) or FALSE (0)." is because the logic operators (and, or, xor, not) are boolean, but they are also bitwise.

regards, michael

Posted on Oct 20, 2010, 1:13 PM

Respond to this message   

Return to Index


Re: rule #3

by Moneo (no login)

Hi Michael, long time no see!

I'm not quite sure I understand the point you're making about Rule #3. Maybe it has to do with my choice of words.

Anyway, did you check the examples immediately following the text of Rule #3? I think that these examples speak for themselves.

Best regards..... Moneo

Posted on Oct 21, 2010, 4:34 PM

Respond to this message   

Return to Index


Re: rule #3

by (Login MCalkins)
Moderator

yes, it has been a while.

it probably is a matter of wording. as has been pointed out by the other posters, and as i'm sure you're already aware, the logical operators and, or, xor, not are bitwise. they are also boolean. so the statement "when a boolean expression is used as a value, assigned to a variable or output in any way, QB will convert the result, after evaluation, to TRUE (-1) or FALSE (0)" is not correct.

print 5 or 3

5 or 3 is a boolean expression, and it is evaluated to 7.

it is relational operators, which are also boolean, but are not bitwise logical operators, that always evaluate to 0 or -1.

i doubt that you were unaware of this, so i believe the issue here was just a terminology issue.

I am reluctant to write too much on this subject here, because the posters here before me pretty much covered everything. (i had seen this thread on my mobile phone before there were any proper responses, but it was impossible to post a sufficient reply from my phone.) i will say this though: i believe it is possible to over complicate this subject. it is really quite simple, as long as you pay attention to what you are doing. i personally dislike the idea of declaring constants true = -1 and false = 0 and then using them in the program. for one thing, the programmer should already know what is true and what is false, and shouldn't need to rely on those constants. also, it seems that it could introduce confusion if anything other than 0 or -1 is encountered. qbasic does not have a boolean data type, nor does it need one.

regards, michael

Posted on Oct 27, 2010, 4:28 AM

Respond to this message   

Return to Index


Re: rule #3 more

by Moneo (no login)

Michael,

I appreciate your good comments. Looks like my old tutorial needs a re-write.

However, I don't agree with you about not using
CONST FALSE = 0, TRUE = NOT(FALSE). To a very knowledgeable programmer, like you, these constants may seem an unnecessary crutch, but they have always helped me.

Regards.... Moneo

Posted on Oct 29, 2010, 11:39 AM

Respond to this message   

Return to Index


Constants add meaning to numbers.

by (Login Mikrondel)
R

Say you see:

X = -1

That -1 could be meant as a "Boolean true". But it could also just be plain old -1, perhaps later to be used in a multiplication.

X = TRUE

on the other hand, makes it quite clear what that -1 is for. When browsing over the code, this makes bugs more obvious!

That being said, I seldom go to this extent when defining constants, because it is extra effort.

Posted on Oct 29, 2010, 11:47 PM

Respond to this message   

Return to Index


More latecomer answers

by (Login Mikrondel)
R

Solitaire and Moneo pretty much covered everything, so I'll just add some colour and meaning and cross-language observations where I can.

> Or does it depend on the programming language?

It depends on the language. Many programming languages have a boolean data type. Even in those that don't, we may still talk about "booleans" or "boolean expressions" to describe variables or expressions, even though the language is not capable of checking this for us.

Computers operate on binary numbers. 0000000000000000 is binary for 0 and 1111111111111111 is binary for -1, as far as we're concerned. The AND, OR, XOR, NOT, EQV and IMP operators are all bitwise, that is, they act independently on each binary digit. Suffice to say that if you take 0 as false and -1 as true, everything turns out as you expect when using these operators.

On the other hand the C language will give you 0 for false and 1 for true. To make up for it, C has logical operators which QB does not have.

Perhaps you will learn assembly language one day. Then you would discover "what really happens" in the computer. Ultimately all programming languages must produce something which the computer can carry out, so obviously despite their differences, no programming language is incompatible with the computers it can run on.


> What's the difference between a command, function, and statement?

All programming languages have rules and structure, which are the language's "grammar". In fact a document that clearly describes the structure of a programming language is called a grammar. Programming language purists might say that "a statement is whatever the grammar defines it to be". Which is kind of like saying "a question is a sentence that ends in a question mark". It may help you recognise one, but it doesn't tell you what a question actually is.

Basically a statement is any complete "thought" in a programming language. Just as "There is a great" is not a complete statement in English,

var = var - (

is not a complete statement in BASIC. Also

PRINT "Hello"
a = a + 1

is not considered a statement; it's a sequence of two statements.

However, a larger construct such as

IF X > 1 THEN
    PRINT "X > 1"
ELSE
X = 2
END IF

is also considered a statement (in addition to the PRINT and assignment statements embedded within). This is because without the last two lines it would be incomplete. Loops are considered statements in a similar way.

Note that in C, functions do not need to return values. A C function that returns nothing is equivalent to a SUB in QB. A C function that returns a value is equivalent to a FUNCTION in QB. If this seems strange to you, remember that in the real world people argue about who's right and what to name things.

Feel free to ask about anything I've mentioned...

Posted on Oct 15, 2010, 12:20 AM

Respond to this message   

Return to Index


To expand on Artelius' statement about QB's logical operators

by A ninny mouse (no login)

I've gotten myself in trouble a number of times with them BECAUSE they are bitwise operators. Take the following code segment:

X% = 2
y% = 1

IF x% OR y% THEN PRINT "T" ELSE PRINT "F" 'T'

IF x% AND y% THEN PRINT "T" ELSE PRINT "F" 'F'

At first glance, it seems 'logical' that both statements should produce 'T'.

But when you consider the bit patterns that evaluate to 1 and 2, it becomes clear:

1 = '01'
2 = '10'
AND.'00' (False)
OR..'11' (True)

Fortunately, the statements can easily be changed from bitwise to logical with a simple modification:

IF x% <> 0 OR y% <> 0 THEN PRINT "T" ELSE PRINT "F" 'T'

IF x% <> 0 AND y% <> 0 THEN PRINT "T" ELSE PRINT "F" 'T'

This works because:

x% <> 0 = '11'
y% <> 0 = '11'
AND.......'11' (True)
OR........'11' (True)

Did I make things clearer, or only muddy the logical waters?

Nin

Posted on Oct 16, 2010, 10:49 AM

Respond to this message   

Return to Index


* That is why I mentioned that ANY value other than 0 could be evaluated as True.

by Clippy (Login burger2227)
R

Posted on Oct 16, 2010, 11:58 AM

Respond to this message   

Return to Index


But you didn't explain it, at least from a perspective that would help a newbie.

by A Ninny Mouse (no login)

Which is what I was attempting to do.

Posted on Oct 22, 2010, 8:28 AM

Respond to this message   

Return to Index


Then SPLAIN to me why you are called a NINNY!

by (Login burger2227)
R

Cause NINNY's are TOO particular and get LOST in the details, that's why!

Posted on Oct 22, 2010, 5:16 PM

Respond to this message   

Return to Index


*It's a take-off on Anonymous -- get it now?

by A Ninny Mouse (no login)

Posted on Oct 29, 2010, 6:59 AM

Respond to this message   

Return to Index


C++ compilation failed

by (no login)

Hello,

I have an old qbasic program which used to work, but I cannot
compile here. I need help. Please send me an email so I may send the source and maybe you can offer
a suggestion.

Many thanks
Anthony Moisidis

Posted on Oct 13, 2010, 5:10 PM

Respond to this message   

Return to Index


* Post the code in the Big Program forum or send to me. NO EXE files! BAS ONLY!

by (Login burger2227)
R

Posted on Oct 13, 2010, 7:22 PM

Respond to this message   

Return to Index


get him clippy

by (Login codeguy)
R

No, we will NOT help you if you don't post the code that's giving you problems. we do not have esp and we do not write other people's programs for them. that is the policy. it will remain the policy at n54, and qb64 forum. and i don't do email for this.

Posted on Oct 13, 2010, 9:44 PM

Respond to this message   

Return to Index


I think you should be a bit nicer to newcomers

by (Login Mikrondel)
R

Someone doesn't deserve to be jumped on just because he didn't realise that without code it's hard to help him -- unless he is a repeat offender who seems to ignore what is told him.

It's in our interests to make newcomers feel welcome, so if there is some deficiency in their question, calmly explain it and do your best to address the question anyway.

Posted on Oct 16, 2010, 5:34 PM

Respond to this message   

Return to Index


I think this was some kind of misundrstanding...

by (Login The-Universe)
Admin


I'm not sure why Donny thought the OP was asking for someone to do his work for hi, as clearly the post shows he is new and thought if someone wanted to help him, they would email him so he could send them his code. All that was needed is a post: Someone can probably help you, but our policy is to have you post the code, rather than using email.

Pete

Posted on Oct 16, 2010, 6:45 PM

Respond to this message   

Return to Index


* Well, you have to admit. At least I always attacked the correct people!

by Clippy (Login burger2227)
R

Posted on Oct 16, 2010, 8:51 PM

Respond to this message   

Return to Index


Speaking of attacking the right people...

by (Login qbasicfreak)
R

Has mik3ca ever come back???

Posted on Oct 20, 2010, 2:57 PM

Respond to this message   

Return to Index


*LOL

by (Login burger2227)
R

Posted on Oct 20, 2010, 8:42 PM

Respond to this message   

Return to Index


Re: C++ compilation failed

by (Login codeguy)
R

also, please remain informed that we do not have esp and we do not do your work for you. you have been asked to post code or we will NOT help you. please don't waste our time if you're not gonna submit code.

Posted on Oct 13, 2010, 11:23 PM

Respond to this message   

Return to Index


* RESOLVED! Qbasic found FOR J = TO variable. He never ran it in QB I guess.

by (Login burger2227)
R

Posted on Oct 14, 2010, 5:08 PM

Respond to this message   

Return to Index

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