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



Code doesn't return correctly in QB64. Do I have double precision ok?

by (no login)

This code, opening a data file in line 9010, returning to the main program to get a record # R, and then collecting data in line 9020, works perfectly in GWBasic but not in QB64. The values C,S,SG,DY returned are all zero in QB64.

I have change the open statement to:

OPEN "Moneyrec.dat" for random as #1 Len=32
but no improvement.

Any help is appreciated. Thanks
----------------------------------------------

9010 OPEN "R", #1, "MONEYREC.DAT", 32: FIELD #1, 8 AS C$, 8 AS S$, 8 AS SG$, 8 AS DY$: LOR = LOF(1) / 32: RETURN

9020 GET #1, R: C = CVD(C$): S = CVD(S$): SG = CVD(SG$): DY = CVD(DY$): RETURN

Posted on Apr 23, 2014, 4:37 PM

Respond to this message   

Return to Index


How many files open at once in QB64

by (Login Kanga85)

I have a Basic program running perfectly in GWBasic on an XP machine. It has 4 files open at any one time. (GWBasic /F:4). I have compiled it in QB64, but it now doesn't find the data in an opened file. How many open files can I have in QB64, and do I need to specify the number to be opened before I compile the program?

Thanks for any help.

Posted on Apr 22, 2014, 7:56 PM

Respond to this message   

Return to Index


Re: How many files open at once in QB64

by SMcNeill (no login)

We just had a long discussion about this a month or so ago over on the Qb64 forums. QB64 can open and access a LONG's worth of files at any given time: IF your computer has the memory to support them. Each open file uses 4 bytes of memory and 4 BILLION files causes out of memory errors on most any computer. (You'd need to compile in x64 mode and use over 16GB of ram to hold all the file handles....)

But 4 files? That shouldn't be an issue at all, on any system that can run QB64. ;)


As for numbering the files, either use 1,2,3,4 or use _FREEFILE with a variable, and you shouldn't have any issues. (FREEFILE automatically gives you the next available file handle.)

Posted on Apr 23, 2014, 11:06 AM

Respond to this message   

Return to Index


thanks

by (no login)

Thanks SMcNeill. Helpful and encouraging.

Posted on Apr 23, 2014, 4:39 PM

Respond to this message   

Return to Index


Qbasic program to store student data permanently in a file and search it

by (Login diwesh87)

Hi i am a complete newbie to Qbasic and am looking for help . I need to create a program that stores the student records in a file and can search it later from the file using the student name or id . I wrote a little program but doesn't work well .


Posted on Apr 22, 2014, 1:40 AM

Respond to this message   

Return to Index


Here is what i coded

by (Login diwesh87)

REM This program will create a sequential file named INFO.DAT.
REM The file will then be used to store input data supplied
REM by the user and then to retreive the data contained in
REM in the file.
REM
REM PROGRAMMER: Diwesh
REM DATE LAST UPDATED: 22-5-2014

OPEN "INFO.DAT" FOR OUTPUT AS #1

CLS

REM Get input from user
INPUT "Do you wish to enter student information (Y/N)"; answer$

DO WHILE answer$ = "Y" OR answer$ = "y"
INPUT "Enter student name: ", name$
INPUT "Enter student id: ", id
INPUT "Enter student gpa: ", gpa

REM Write current input to temporary buffer storage 1
WRITE #1, name$, id, gpa

INPUT "Do you wish to enter new student information (Y/N)"; answer$
LOOP

REM Transer data from temporary buffer 1 to actual INFO.DAT
CLOSE #1

OPEN "INFO.DAT" FOR INPUT AS #2

PRINT "STUDENT LISTING"
PRINT "----------------------------------------"

DO WHILE NOT EOF(2)
INPUT #2, name$, id, gpa
PRINT
PRINT "STUDENT NAME: "; name$
PRINT " STUDENT ID:"; id
PRINT " STUDENT GPA:"; gpa
LOOP

CLOSE #2

END

Posted on Apr 22, 2014, 1:42 AM

Respond to this message   

Return to Index


File extension and searching

by Solitaire (no login)

Your program works. I would suggest changing the file extension from .DAT to .TXT.

What is it about the program that doesn't work well for you?

In order to implement search functions, after you list the data, ask the user to enter the name and/or the id to search for. Then reopen the file for input and use another loop with an IF block to find a match for the name or the id. If found, it will then print out the data.


Posted on Apr 22, 2014, 10:06 AM

Respond to this message   

Return to Index


Graphical input routine

by Steve (no login)

I'm working on a program where I have a number of variables listed on the screen. I'm trying to revise it to the point where my variables are inside a box and if the mouse cursor is over that box it highlights and then increases or decreases the variable with the scroll wheel. At the moment I have about 20 lines checking keypresses to increase and decrease the variables. Is there a subroutine someone has or knows about that I can learn from and modify to fit into my program?

Posted on Apr 1, 2014, 10:14 AM

Respond to this message   

Return to Index


*Do you already have a mouse routine that covers x/y and scrollwheel?

by (Login qb432l)
R

*

Posted on Apr 1, 2014, 11:32 AM

Respond to this message   

Return to Index


2048 game

by deanm (no login)

' Move the tiles using the arrow keys
' Join the numbers and get to the 2048 tile!
DEFINT A-Z
RANDOMIZE TIMER
DIM grid(1 TO 4, 1 TO 4)
DO
CLS
placed = 0
DO
x = INT(RND(1) * 4) + 1
y = INT(RND(1) * 4) + 1
IF grid(x, y) = 0 THEN grid(x, y) = 2 + 2 * INT(RND(1) * 2): placed = 1
LOOP UNTIL placed = 1
lose = -1: win = 0
FOR i = 1 TO 4
PRINT "+-----+-----+-----+-----+"
PRINT "|";
FOR j = 1 TO 4
IF grid(i, j) = 2048 THEN win = -1: lose = 0
IF grid(i, j) = 0 THEN lose = 0: PRINT " |"; ELSE COLOR 0, LOG(grid(i, j)) / LOG(2): PRINT USING "#####"; grid(i, j); : COLOR 7, 0: PRINT "|";
NEXT
PRINT
NEXT
PRINT "+-----+-----+-----+-----+"
IF win THEN PRINT "You Win!!!": END
IF lose THEN PRINT "You Lose!": END
x$ = "": WHILE x$ = "": x$ = INKEY$: WEND
SELECT CASE x$
CASE CHR$(27)
END
CASE CHR$(0) + CHR$(72)' up
FOR i = 3 TO 1 STEP -1
FOR j = 1 TO 4
IF grid(i, j) = 0 THEN grid(i, j) = grid(i + 1, j): grid(i + 1, j) = 0
IF grid(i, j) = grid(i + 1, j) THEN grid(i, j) = grid(i, j) * 2: grid(i + 1, j) = 0
NEXT
NEXT
CASE CHR$(0) + CHR$(75) 'left
FOR i = 1 TO 4
FOR j = 3 TO 1 STEP -1
IF grid(i, j) = 0 THEN grid(i, j) = grid(i, j + 1): grid(i, j + 1) = 0
IF grid(i, j) = grid(i, j + 1) THEN grid(i, j) = grid(i, j) * 2: grid(i, j + 1) = 0
NEXT
NEXT
CASE CHR$(0) + CHR$(77)' right-
FOR i = 1 TO 4
FOR j = 2 TO 4
IF grid(i, j) = 0 THEN grid(i, j) = grid(i, j - 1): grid(i, j - 1) = 0
IF grid(i, j) = grid(i, j - 1) THEN grid(i, j) = grid(i, j) * 2: grid(i, j - 1) = 0
NEXT
NEXT
CASE CHR$(0) + CHR$(79) ' down
FOR i = 2 TO 4
FOR j = 1 TO 4
IF grid(i, j) = 0 THEN grid(i, j) = grid(i - 1, j): grid(i - 1, j) = 0
IF grid(i, j) = grid(i - 1, j) THEN grid(i, j) = grid(i, j) * 2: grid(i - 1, j) = 0
NEXT
NEXT
END SELECT


LOOP

Posted on Mar 25, 2014, 3:04 PM

Respond to this message   

Return to Index


MS-DOS source code now available from Microsoft

by Billy G (no login)

http://blogs.technet.com/b/microsoft_blog/archive/2014/03/25/microsoft-makes-source-code-for-ms-dos-and-word-for-windows-available-to-public.aspx

Posted on Mar 25, 2014, 1:47 PM

Respond to this message   

Return to Index


Cool

by (Login MCalkins)
Moderator

But the license is for non-commercial research. It allows derivation, but not redistribution.

Still waiting for the day when they release QBASIC 1.1, or Windows 95 through 98SE, or even 2000 SP4 under either LGPL, or something like 2-clause BSD. (Yeah, dream on...)

Regards,
Michael

Posted on Mar 26, 2014, 8:31 AM

Respond to this message   

Return to Index


We don't need the code. Galleon already did most of that.

by (Login burger2227)
R

The 16 bit stuff is lost anyhow. We will never go back.

I see somebody saw that link at QB64 too.



    
This message has been edited by burger2227 on Mar 26, 2014 10:26 AM

Posted on Mar 26, 2014, 10:25 AM

Respond to this message   

Return to Index


Updated to a new key input routine.

by Pete (Login The-Universe)
Admin

I decided to try out the newer QB64 statements, and made another key input program that can be customized. I posted it at QB64.net to avoid the hassle and probably "sign" bug mishaps N54 forums produce.

http://www.qb64.net/forum/index.php?topic=11727.0

QB64 has the advantage of dropping PEEk / POKE to map 2-key presses with INKEY$, but the trade off is more code in the way of conditional statements to achieve the same goal. That's OK, as the days of needing to optimize to save memory are no longer an issue with QB64.

Have a look, if you're interested.

Pete

Posted on Mar 18, 2014, 7:38 AM

Respond to this message   

Return to Index


*Very impressive. Never wrote a text editor, but if I ever do, you da man!

by (Login qb432l)
R

*

Posted on Mar 18, 2014, 3:44 PM

Respond to this message   

Return to Index


Nice, but I like QB64's INP arrays better

by (Login burger2227)
R

QB64 does not have those INP(96) Number Lock and Caps Lock limitations that QB did. Plus it now includes the Windows and Menu keys.

http://www.qb64.net/wiki/index.php/Keyboard_scancodes



    
This message has been edited by burger2227 on Mar 20, 2014 7:41 AM

Posted on Mar 20, 2014, 7:38 AM

Respond to this message   

Return to Index


I don't see a text use advantage, but...

by Pete (Login The-Universe)
Admin

I'm curious if it tests faster than _KEYHIT. If so, it would be a better gaming choice. BTW - Did you design that particular wiki page? If so, very impressive layout.

Pete

Posted on Mar 20, 2014, 9:08 AM

Respond to this message   

Return to Index


Yes I did.

by (Login burger2227)
R

Thanks, I just put the keyboard layouts all in one place for easy reference.

I never tested for any speed difference because I'm not fast enough anymore... happy.gif

Posted on Mar 20, 2014, 5:10 PM

Respond to this message   

Return to Index


*From my testing, _KEYHIT offers the fastest response times.

by SMcNeill (no login)

Posted on Mar 20, 2014, 5:41 PM

Respond to this message   

Return to Index


Needing some help

by (no login)

Let me clarify, this is my Programming MidTerm. Not asking for it to be finished for me, but asking help for ideas. Or hints to get my program finished. I am at a wall at this moment.

I finished almost all parts of the MidTerm, but now I must have it output the highest grade average out of the four students, then output it to a line.
"Search the grades array for the highest grade average and output it with the appropriate student name and class name."

I have notes and other examples from class, but I can't seem to figure what to use.If anything looks sloppy, let me know how to adjust it. I want to learn not to be told. If you understand what I am meaning.


CLS

DIM course(1 TO 2) AS STRING
DIM student(1 TO 4, 1 TO 2) AS STRING
DIM grades(1 TO 4, 1 TO 3, 1 TO 2) AS INTEGER
DIM class, person, Grade AS INTEGER
DIM average(1 TO 4) AS INTEGER
DIM format AS STRING


FOR class = 1 TO 2
INPUT "Enter course name: ", course(class)
FOR person = 1 TO 2
INPUT "Enter the student's name: ", student(person, class)
FOR Grade = 1 TO 3
PRINT "Enter grade #"; Grade; "for "; student(person, class);
INPUT ": ", grades(person, Grade, class)
NEXT Grade
NEXT person
NEXT class

average(1) = (grades(1, 1, 1) + grades(1, 2, 1) + grades(1, 3, 1)) / 3
average(2) = (grades(2, 1, 1) + grades(2, 2, 1) + grades(2, 3, 1)) / 3
average(3) = (grades(1, 1, 2) + grades(1, 2, 2) + grades(1, 3, 2)) / 3
average(4) = (grades(2, 1, 2) + grades(2, 2, 2) + grades(2, 3, 2)) / 3

CLS
SCREEN 12
format = "###.##"

PRINT "Class"; TAB(10); "Student"
PRINT "Number"; TAB(10); "Number"; TAB(19); "Grade 1"; TAB(27); "Grade 2";
PRINT TAB(35); "Grade 3"; TAB(44); "Average"

PRINT TAB(3); "1"; TAB(13); "1"; TAB(21); grades(1, 1, 1); TAB(29); grades(1, 2, 1);
PRINT TAB(37); grades(1, 3, 1); TAB(44); average(1)
PRINT TAB(13); "2"; TAB(21); grades(2, 1, 1); TAB(29); grades(2, 2, 1);
PRINT TAB(37); grades(2, 3, 1); TAB(44); average(2)
PRINT
LINE (1, 70)-(400, 70), 15
PRINT TAB(3); "2"; TAB(13); "1"; TAB(21); grades(1, 1, 2); TAB(29); grades(1, 2, 2);
PRINT TAB(37); grades(1, 3, 2); TAB(44); average(3)
PRINT TAB(13); "2"; TAB(21); grades(2, 1, 2); TAB(29); grades(2, 2, 2);
PRINT TAB(37); grades(2, 3, 2); TAB(44); average(4)
PRINT
LINE (1, 120)-(400, 120), 15
PRINT



PRINT student(1, 1); "'s average grade in "; course(1); " is:"; USING format; average(1)

PRINT student(2, 1); "'s average grade in "; course(1); " is:"; USING format; average(2)

PRINT student(1, 2); "'s average grade in "; course(2); " is:"; USING format; average(3)

PRINT student(2, 2); "'s average grade in "; course(2); " is:"; USING format; average(4)
PRINT



END


Posted on Mar 11, 2014, 9:39 AM

Respond to this message   

Return to Index


Highest to lowest is accomplished with a bubble sort.

by Pete (Login The-Universe)
Admin

There are different types of sort algorithms. The type I use is fairly simple...

DIM myname$(5), mygrade(5)

myname$(1) = "Steve"
myname$(2) = "Pete"
myname$(3) = "Michael"
myname$(4) = "Clippy"
myname$(5) = "Patrick"

mygrade(1) = 2.0
mygrade(2) = 4.0
mygrade(3) = 3.0
mygrade(4) = 0
mygrade(5) = 1.0

for i = 1 to 5
for j = 1 to 5
if mygrade(i) > mygrade(j) then swap mygrade(i), mygrade(j): swap myname$(i), myname$(j)
next
next

for k = 1 to 5
print myname$(k); mygrade(k)
next

End

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

The SWAP statement keeps swapping out numbers, organizing them from highest to lowest. Note we also had to swap the names, so the names kept the correct grades.

Try and apply this type of sorting technique to our program and see if you can get your names and grades reported according to your assignment.

- Pete




    
This message has been edited by The-Universe on Mar 11, 2014 11:08 AM

Posted on Mar 11, 2014, 11:07 AM

Respond to this message   

Return to Index


Get the highest value

by Solitaire (Login Solitaire1)
S

If you only need to get the highest average, then you can simply use the first number in the array and arbitrarily assign the HIGH value to it. Then compare all the rest of the averages to HIGH. If another number is higher, then reassign that number to HIGH.

Here is an example using random values assigned to an array, so you can see how it works.

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

CLS
DIM average(1 TO 4) AS INTEGER
DIM x AS INTEGER, high AS INTEGER, ndx AS INTEGER
RANDOMIZE TIMER
FOR x = 1 TO 4  'assign random values to the array
   average(x) = INT(RND * 100) + 1
   PRINT average(x); "  ";   'display the 4 averages
NEXT x

high = average(1)  'assign arbitrary value to high
ndx = 1
FOR x = 2 TO 4      'compare remaining values with high
    IF average(x) > high THEN
        high = average(x)
        ndx = x
    END IF
NEXT x
PRINT : PRINT "The highest average is "; high
PRINT "The index is "; ndx
END



    
This message has been edited by Solitaire1 on Mar 11, 2014 1:25 PM
This message has been edited by Solitaire1 on Mar 11, 2014 1:23 PM

Posted on Mar 11, 2014, 1:03 PM

Respond to this message   

Return to Index


My post being suppressed

by (no login)

My posts from Apr 7 2013, where is it ? now i can't retrieve my own files because i lost the names.

Google tells something, meaning the post have existed once :

http://www.network54.com/Forum/648955/thread/1365343620/Alarmclock+just+ringing+!

It was about getting the right and left direction, without using the draw command.

Thanks, L

Posted on Mar 5, 2014, 2:56 AM

Respond to this message   

Return to Index


lost & found

by (no login)

Well it was this :

http://www.network54.com/Forum/648955/message/1364120408/Circee+now+working+!

i always intended to use this routine inside a recursive triangle building fratal, but it seems to hard to do. I wanted to draw this, the von koch' curve...

L


Alos im' wondering how one can replace some loops with assembler, for example FOR loop, i mean in some places one could optimize a program, when it's just about counting and increasing some variable.

Thanks, L

Posted on Mar 5, 2014, 3:02 AM

Respond to this message   

Return to Index


Re: lost & found

by (Login MCalkins)
Moderator

How you would go about using custom Assembly code would depend on whether you are using QBASIC or QB64. It's possible either way, but it would be done quite differently.

If you could point out which FOR loop you want converted, I could try to do it. However, in QBASIC, I would not be able to do anything with graphics except in SCREEN 13 (because it has 1 plane), nor would I be able to make custom function calls. In QB64, it would be easier to make function calls. Also, in QB64, it's easier to work with arrays greater than 64KB than in QBASIC.

Also, I can't guarantee much performance improvement over optimized C++ code. Specifically, by manually optimizing the C++ code which QB64 outputs, and also enabling compiler optimization, one can get pretty good performance.

Regards,
Michael



    
This message has been edited by MCalkins on Mar 5, 2014 11:23 AM

Posted on Mar 5, 2014, 11:22 AM

Respond to this message   

Return to Index


It's replies like this one that make me think...

by Pete (Login The-Universe)
Admin

... it's about time to pass the QB Forum torch to Michael.

Pete

Posted on Mar 5, 2014, 11:27 PM

Respond to this message   

Return to Index


:-P

by (Login MCalkins)
Moderator

I've not been very active here. I just check the index every few days...

I'm not doing much programming nowadays either. Almost nothing in BASIC. Although off-and-on since December, I have been working on a Win32 GUI C++ program which I've actually gotten paid pretty well for. The code is pretty ugly, but I intend to clean it up and post it eventually.

I've been preoccupied with other things. I've been pretty busy on various social media sites, and I've been mentally and emotionally preoccupied with things in my personal life. I do not feel that I'm in a position to give this forum the attention that it deserves. Also, for some time, I've been doubting the relevance of BASIC in the modern programming world. I got enthusiastic about QB64 for a while, but that has mostly worn off. I'm even starting to doubt the relevance of Win32, as the world moves to mobile devices.

Regards,
Michael

Posted on Mar 6, 2014, 11:11 AM

Respond to this message   

Return to Index


My bet is along the same lines...

by Pete (Login The-Universe)
Admin

Mobile is the future. I wish QB64 already had OpenGL, as that project really needs iOS and Android full function to stay in the game.

I just don't see BASIC anymore,like it used to be, even though Rob has done an outstanding job trying to preserve it. Fewer people care about the building blocks, and now that advanced graphics and engines are becoming available, it makes sense that is the new motivator for new coders.

If it wasn't for QB64, this forum would be more of a historical site than a programming site. Provided the code here can be utilized, I like the idea of keeping the site going, but in truth, Network54 would have to overcome their antiquated message board to be able to post code anymore. Even with the fully paid option, you can't get code with <> signs to post correctly.

Moving it would require a lot of time and motivation, so hopefully, for now, it is functional enough to make the few who post and read it happy. I still code, but I'm not interested in pursuing the newer stuff, and still have no interest in graphics. I really do appreciate how fast I can build apps with QB64 for all the stuff I donate my time towards and enjoy. I'm happy I don't have to use QuickBasic on DoSBox, because it just isn't the same ease as using QB on 16-bit systems.

Glad to find you are making some money coding, and I think you are on the right track looking towards what you will need to work with in the future.

Pete

Pete

Posted on Mar 6, 2014, 2:15 PM

Respond to this message   

Return to Index


* :-)

by (Login MCalkins)
Moderator

Posted on Mar 6, 2014, 4:46 PM

Respond to this message   

Return to Index


For me qb is very useful

by (no login)

As said Pete once, qb rocks for chain character management.

This can be very useful when formatting datas for programs, for statistical computation like here :

http://cibois.pagesperso-orange.fr/Trideux.html

Also correct .srt files for movies.

mobile is the future ? i have a tablet and it's already in the drawer. Google was so kind to place a fake flash player in it so one couldn't get flash to work ! So much for android, adding that there is nothing regarding P2P.

L

Posted on Mar 8, 2014, 7:22 AM

Respond to this message   

Return to Index


* qb ****** sucks man

by Jim (no login)

(edited for obscenity and lack of asterisk for title-only post)



    
This message has been edited by MCalkins on Mar 10, 2014 4:50 PM

Posted on Mar 9, 2014, 6:44 PM

Respond to this message   

Return to Index


*If you feel that way, then why bother visiting a QB Forum? Troll much?

by SMcNeill (no login)

Posted on Mar 9, 2014, 10:07 PM

Respond to this message   

Return to Index


Yes, it can be.

by (Login MCalkins)
Moderator

Last year I wrote a group of small QB64 programs to help me WGET large numbers of high resolution photos from Flickr.

It does have its usefulness, at least as a hobby language.

Regards,
Michael



    
This message has been edited by MCalkins on Mar 10, 2014 4:53 PM

Posted on Mar 10, 2014, 4:52 PM

Respond to this message   

Return to Index


QBasic

by (Login PhyloGenesis)
Moderator

What is "chain character management"?

Unfortunately, as much as I love QB and DREAD the idea of it being completely dead and gone, I have no use for it and no time. sad.gif
I remember many years ago the first time I had real use for my ability to program, and used QBasic to accomplish a task.

I was trying to move an mp3 file from one computer to another via floppy disks and couldn't get any program to properly split then reassemble the file (it took three transfers for one mp3), so I busted out my sick QBasic skilliaz and did it myself and it worked beautifully.

However, I've since found C# and started working, so my time is so heavily focused on staying relevant in the tech field I don't have time for anything else. sad.gif
Also, C# is just as easy to write but comes with a stupidly large, extremely well developed, maintained, and updated library of functionality. When it comes to, "I just want a program to...", it is amazing. C# becomes immensely easier to write given that you have Visual Studio (which strictly speaking of IDE's is incredible), and when you add ReSharper it's crazy easy. It's gotten so easy actually that the coding itself is almost trivial. o.O

Aaaanyway, this wasn't meant to be a C# ad! I think the biggest reason is that everything I want to make is too big/complicated to make in QBasic (it could be done, but I'd have to reinvent SO much). One of the biggest obstacles is that new stuff can't use QBasic because new stuff needs so much supporting technology at this point and it just hasn't been built for QBasic, such as a REST API caching layer, or database integration.

Speaking of this all, does anyone have a modern-ish website that runs off of QBasic (even if rarely used)?

Sorry for the awful writing style, and nice to see everyone still lurking! happy.gif
- QBasic Rules - Mac (RIP)

Posted on Mar 28, 2014, 8:20 PM

Respond to this message   

Return to Index


Re: QBasic

by (Login MCalkins)
Moderator

Thanks for checking in. I'm glad to still see the old timers here. Also, I'm glad to hear that you're still programming and working in the field.

Regards,
Michael

Posted on Mar 28, 2014, 11:49 PM

Respond to this message   

Return to Index


Hi PG,

by Pete (Login The-Universe)
Admin

Nice to see you are working in the field. I agree with a lot of what you posted about, concerning the ease of more modern languages. Naturally, that is mostly due to the works of others, in the contribution of libraries. I recently made an updated keyboard input one for QB64, nearly 700 lines. I still want to add some things, which will probably bring it to around 1200. So sure, the fun of BASIC was always to figure out and code things to work on a computer, but to get anything accomplished, it is too slow. We would have very few usable applications these days, if everyone had to code from scratch.

I don't know if Galleon will ever get the following to eventually see library development and library integration well enough documented that QB64 can achieve a similar outcome. Naturally, it is a translator, so in a way anyone who is that interested in developing large applications would more than likely consider learning C languages, .Net, etc.

For me personally, I still enjoy the ease of BASIC, in the manner of which it feels like I'm speaking English when coding, instead of Port-uguese. I have no interest in gaming, so SCREEN 0 still suits may app needs, perfectly. I would like to go into some html integration, but no, I have not yet looked into using QB64 for running a website. Although it will run scripts, my servers are Apache,which means I would want to get more comfortable with the Linux platform, first, or switch servers to a Windows host. So far, no immediate interest to do either.

Pete

PS, I still miss Mac, too. Thanks for mentioning him in your post.



    
This message has been edited by The-Universe on Mar 29, 2014 1:48 AM

Posted on Mar 29, 2014, 1:46 AM

Respond to this message   

Return to Index


simple graphics commands

by Steve (no login)

Trying to find an easy programming language to show me a graphical representation of oiling a bowling lane. I'm fairly proficient in old apple basic but the resolution and dim limitations won't allow what I need. If I read qbasic(s) correctly I can tell if a screen pixel is on or off? as an example I have a block 10x12 pixels. I want to slide the block across the long side of the screen in 12 pixel increments each time leaving behind 90% of the pixels (randomly selected) in the 10x12 area colored yellow. After it reaches the end of the screen I want to reverse it and move it back to the start. This time it selects 90% of the pixels inside the area and if it is a pixel already picked on the forward pass then it changes the color to blue. If it is a random pixel not selected on the forward pass then it set it to green. I have other variables involved...the blocks are 8 in all of varying widths, the 90% selection value will vary depending on the speed of the block and if the block is "layng oil" or not but if I can get a little help just showing that first basic idea in qbasic I can extrapolate the rest of it.

Posted on Feb 28, 2014, 2:12 PM

Respond to this message   

Return to Index


As far as graphics in QBasic are concerned...

by (Login qb432l)
R

There is a graphics tutorial here for just about everything possible in QBasic.

Go to the top of the main forum page and click "QB Links and Downloads". Once there, download "QB-Graphics Tutorial". After unzipping, run QBG.EXE

It will run in Windows (compiled in QB64). Everything is there from basics to advanced graphics using QBasic.

You might also consider looking into QB64 if you're interested in programmed graphics. It's free and runs under Windows and has a lot more potential than QBasic.

http://www.qb64.net/


Good luck!
-Bob

Posted on Feb 28, 2014, 3:26 PM

Respond to this message   

Return to Index


try this

by Saul (no login)

SCREEN 12
FOR i = 0 TO 640 STEP 20
FOR j = 0 TO 300
x = RND * 20
y = RND * 20
PSET (x + i, y), 14
NEXT
NEXT
FOR i = 620 TO 0 STEP -20
FOR j = 0 TO 300
x = RND * 20
y = RND * 20
IF POINT(x + i, y) <> 0 THEN PSET (x + i, y), 9 ELSE PSET (x + i, y), 10
NEXT
NEXT

Posted on Mar 1, 2014, 2:49 AM

Respond to this message   

Return to Index


Fun little project -

by AlGoreIthm (no login)


It took about an hour to create a program from your specifications.
It will be posted in a few weeks, in case this is a homework project.

The final graphic looks like this:

Blue Pixels - have been colored twice - they were colored yellow on the first pass, and changed to blue on the second
Yellow Pixels - were colored on the first pass, but not selected on the second pass so remained unchanged
Green Pixels - have been only colored once - on the second pass - they were not selected on the first pass and finally colored on the second pass
Black Pixels - have not been colored, even after 2 passes



Posted on Mar 1, 2014, 10:29 AM

Respond to this message   

Return to Index


and here it is -

by AlGoreIthm (no login)

SCREEN 12

RANDOMIZE TIMER

LOCATE 28, 7: PRINT "Hit any key to begin:"

y% = 5 ' adjust for vertical visibility on your monitor
boxwidth% = 12
boxheight% = 45
percent = .9

calculation% = boxwidth% * boxheight% / 6
DIM block(calculation%)
total% = (boxwidth% * boxheight%) * percent

SLEEP
LOCATE 28, 7: PRINT " "

FOR x% = 0 TO 639 - boxwidth% STEP boxwidth%'612
LINE (x%, y%)-(x% + boxwidth%, y% + boxheight% - 1), 7, BF


'SLEEP ' necessary to slow down the process to make it visible

LINE (x%, y%)-(x% + boxwidth%, y% + boxheight% - 1), 0, BF
count% = 0

DO
x1% = FIX(RND * boxwidth%) + x%
y1% = FIX(RND * boxheight%) + y%
IF POINT(x1%, y1%) = 0 THEN PSET (x1%, y1%), 14: count% = count% + 1
LOOP WHILE count% < total%

NEXT

g% = 0

' because 639 pixels across don't divide evenly by 12 (the width of the box)
' x% must be set at 636 in order for the work to end at x%=0 (53 X 12 = 636)
' such an adjustment will always be required, depending on the width of the
' box being used

FOR x% = 636 - boxwidth% TO 0 STEP -boxwidth%

GET (x%, y%)-(x% + boxwidth%, y% + boxheight% - 1), block: g% = 1
LINE (x%, y%)-(x% + boxwidth%, y% + boxheight% - 1), 7, BF
' SLEEP ' might be necessary to slow down the process to make it visible
IF g% = 1 THEN PUT (x%, y%), block, PSET
count% = 0

DO
x1% = FIX(RND * boxwidth%) + x%
y1% = FIX(RND * boxheight%) + y%
IF POINT(x1%, y1%) = 14 THEN PSET (x1%, y1%), 6: count% = count% + 1
IF POINT(x1%, y1%) = 0 THEN PSET (x1%, y1%), 10: count% = count% + 1
LOOP WHILE count% < total%

NEXT x%


END


Posted on Apr 2, 2014, 7:33 AM

Respond to this message   

Return to Index


Programs under windows 7

by John Fin (no login)

I wrote some programs under xp, compiled them and they worked pretty good. One program was a file manager and created directories and files via a shell. Well in 7 there is no shell and the program wont run. Can I run my older programs in 7?

Posted on Feb 28, 2014, 10:26 AM

Respond to this message   

Return to Index


Yes, QBasic doesn't run in Windows 7...

by (Login qb432l)
R

XP was the last Windows version to run QBasic, and even then you couldn't run graphics programs if it was XP 64-bit. Fortunately, there's QB64 (free) which is 100% compatible with QBasic code and will compile it to run in Windows 7.

http://www.qb64.net/

-Bob



    
This message has been edited by qb432l on Feb 28, 2014 3:39 PM

Posted on Feb 28, 2014, 3:31 PM

Respond to this message   

Return to Index


Re: Yes, QBasic doesn't run in Windows 7...

by (Login MCalkins)
Moderator

QBasic will run in NTVDM, but not full screen, in 32 bit versions of Windows, including XP 32 bit, Vista 32 bit, and "7" 32 bit. (QBASIC used to run full screen in XP, but a Windows security update broke the ability.)

QBASIC will not run in 64 bit or ARM versions of Windows, as they lack NTVDM, including XP 64 bit, Vista 64 bit, "7" 64 bit, and Windows RT (ARM).

However, you can still use DOSBox, or like you said, QB64.

Regards,
Michael

Posted on Mar 2, 2014, 12:49 PM

Respond to this message   

Return to Index


*That's interesting, Michael. I didn't know there was a 32-bit Windows 7. Thanks :-)

by (Login qb432l)
R

*



    
This message has been edited by qb432l on Mar 2, 2014 3:58 PM

Posted on Mar 2, 2014, 3:57 PM

Respond to this message   

Return to Index


*yes, yw. It's used, for example, on some Intel Atom netbooks.

by (Login MCalkins)
Moderator

Posted on Mar 3, 2014, 12:06 AM

Respond to this message   

Return to Index


QBASIC SCREEN 1 graphics problem

by (no login)

I am amazed that this site still exists. I used to program qbasic back when I was about 12 years old. I recently came across my qbasic files again and decided to get back into it after about 8 years.

Anyway, so I felt like making something retro with CGA graphics (screen 1 in qb) and I've ran into an interesting problem. I haven't used QB in a while so...

Problem is when I change the graphics mode to screen 1, the graphics that I'm drawing with POKE have 1 or 2 pixel vertical gaps in between. I can't figure out how to draw a solid sprite. The interesting thing I've demonstrated in the code is that drawing using qbasic's built in functions (like line, circle, etc) works fine with no gaps. Any idea why this occurs?

Here is my code:

CLS
SCREEN 1
COLOR 1
'you can ignore this data. you can see im not using below
DATA 00,00,00,02,02,02,14,14,14,14,14,14,14,14,14,04,04,04,00,00
DATA 00,00,14,14,14,14,14,14,14,14,14,14,14,14,14,14,04,04,04,00
DATA 00,14,14,14,14,14,14,14,05,05,14,14,14,14,14,14,04,04,04,00
DATA 00,14,14,14,14,14,14,14,14,14,14,14,14,14,14,04,04,04,00,00
DATA 00,14,14,14,14,04,04,04,00,00,00,00,00,00,00,00,00,00,00,00
DATA 00,14,14,14,14,04,04,04,00,00,00,00,00,00,00,00,00,00,00,00
DATA 00,14,14,14,14,14,04,04,04,00,00,00,00,00,00,00,00,00,00,00
DATA 00,14,14,14,14,14,14,04,04,04,00,00,00,00,00,00,00,00,00,00
DATA 00,14,14,14,14,14,14,14,04,04,04,00,00,00,00,00,00,00,00,00
DATA 00,14,14,14,14,14,14,14,04,04,04,00,00,00,00,00,00,00,00,00
DATA 00,14,14,14,14,14,14,14,04,04,04,00,00,00,00,00,00,00,00,00
DATA 00,14,14,14,14,14,14,14,04,04,04,00,00,00,00,00,00,00,00,00
DATA 00,14,14,14,14,14,14,14,04,04,04,00,00,00,00,00,00,00,00,00
DATA 00,14,14,14,14,14,14,14,04,04,04,00,00,00,00,00,00,00,00,00
DATA 00,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,04,04,04,00
DATA 00,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,04,04,04
DATA 00,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,04,04,04
DATA 00,00,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,04,04,04
DATA 00,00,00,14,14,14,14,14,14,14,14,14,14,14,14,14,04,04,04,00
DATA 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00

CONST pwidth = 20
CONST pheight = 20
DIM a((pwidth * pheight) / 2 + 2) AS INTEGER
a(0) = pwidth * 8
a(1) = pheight
DEF SEG = VARSEG(a(2))
offset& = VARPTR(a(2))
FOR y = 0 TO pheight - 1
FOR x = 0 TO pwidth - 1
READ col
'POKE offset& + y * pwidth + x, col
POKE offset& + y * pwidth + x, 1
NEXT x, y

'this shows gaps
PUT (50, 50), a(0), PSET
'this is solid
LINE (0, 0)-(50, 50), 1, BF
LOCATE 13, 5: PRINT "Why the gaps?"
LOCATE 14, 5: PRINT "Try screen 13 instead. It's good."
LOCATE 15, 5: PRINT "How can I fix this?"

Posted on Feb 23, 2014, 9:00 PM

Respond to this message   

Return to Index


screen 1 is 8 bits per pixel

by Jim (no login)

Posted on Feb 24, 2014, 7:41 AM

Respond to this message   

Return to Index


I meant 1 bit per pixel: screen 13 is 8 bits per pixel

by Jim (no login)

Posted on Feb 24, 2014, 7:42 AM

Respond to this message   

Return to Index


Re: I meant 1 bit per pixel: screen 13 is 8 bits per pixel

by SMcNeill (no login)

Screen 1 is 4 BPP (bits per pixel), whereas Screen 13 is 8 BPP, which is what's causing the gaps you're seeing. In screen 4, you're basically writing information to half the pixels (every 8 bits instead of 4).

Try setting a value of 17 instead of 1 and see what happens.

Bit 1 (1) = 1
Bit 2 (2) = 0
Bit 3 (4) = 0
Bit 4 (8) = 0
Bit 5 (16) = 1 'set this one as well
Bit 6,7,8 are all set to 0...

And I'm thinking the gap should be gone.

Posted on Feb 24, 2014, 9:00 AM

Respond to this message   

Return to Index


Re: I meant 1 bit per pixel: screen 13 is 8 bits per pixel

by Paul (no login)

I tried 17 and it made the gaps 1 pixel instead of 2, so it looked a bit better, but not good enough. I decided to make the program loop from 0 to 255, to see if any of them worked. So far I found the first one to produce a solid cyan block is 85.

Posted on Feb 26, 2014, 6:50 PM

Respond to this message   

Return to Index


Re: I meant 1 bit per pixel: screen 13 is 8 bits per pixel

by Paul (no login)

The numbers are 85, 170, and 255 for all three CGA colors. There are no gaps using these numbers. Only problem is the pixels are 2 or 3 wide.

Posted on Feb 26, 2014, 7:19 PM

Respond to this message   

Return to Index


qbasic

by (no login)

why the qbasic is not commming i want qbasic or you download and give because i want to practice for today's exam

Posted on Feb 24, 2014, 5:30 PM

Respond to this message   

Return to Index


QB64 Forum sign-ups should be working again.

by (Login SMcNeill)
R

As per the latest post from Galleon, it seems as if there was a problem with people signing up for the forums over at QB64, but that issue should be resolved now. http://www.qb64.net/forum/index.php?topic=11676.msg90572;topicseen#new

If you've tried to register in the past, you can see if things work as they should for you now. wink.gif

Posted on Feb 21, 2014, 3:40 PM

Respond to this message   

Return to Index


Re: QB64 Forum sign-ups should be working again.

by Jason (no login)

Yea I got a confirmation abit ago. I tried to sign up there several months ago. This has been an issue for a very long time...

Posted on Feb 22, 2014, 10:25 AM

Respond to this message   

Return to Index


Games from Teutoburgo

by Pierre Blanc (no login)

I invite you to visit the web page:
http://www.teutoburgo.tk/giochi/indexgiochiEnFrame.html

There is a GNU GPL version of Tic Tac Toe, as well as several games in italian language. The Tic Tac Toe one has 3 levels, and has also a complete "opening book" (as it happens with chess programs) in order to reach perfect play.
Enjoy it!

Pierre Blanc


------------------------------------------------------------
http://www.teutoburgo.tk
Teutoburgo - A forest to navigate

http://www.site-map.tk
Site Map Generator

http://www.pierreblanc.tk
The Pierre Blanc's home page
------------------------------------------------------

Posted on Feb 8, 2014, 6:57 AM

Respond to this message   

Return to Index


Where is the code?

by Solitaire (Login Solitaire1)
S

This forum is about programming, not about playing games.

Posted on Feb 8, 2014, 8:16 AM

Respond to this message   

Return to Index


here!

by Pierre Blanc (no login)

http://www.teutoburgo.tk/giochi/gnutictactoe.zip

in the zip archive there are the executable as well as the source code.
Hello!
Pierre

------------------------------------------------------------
http://www.teutoburgo.tk
Teutoburgo - A forest to navigate

http://www.site-map.tk
Site Map Generator

http://www.pierreblanc.tk
The Pierre Blanc's home page
------------------------------------------------------

Posted on Feb 8, 2014, 1:37 PM

Respond to this message   

Return to Index


SIN(x): GWBASIC vs QBASIC

by Francesco S. (no login)

Hi there. This code works on GWBASIC but does not work on QBASIC. Why?

10 x = 633763952693320.1#
20 PRINT x
30 PRINT SIN(x)

Posted on Feb 5, 2014, 1:47 PM

Respond to this message   

Return to Index


try this

by Keith (no login)

10 x# = 633763952693320.1#
20 PRINT x
30 PRINT SIN(x)

Posted on Feb 5, 2014, 3:19 PM

Respond to this message   

Return to Index


or perhaps:

by (Login MCalkins)
Moderator

x# = 633763952693320.1#
PRINT x#
PRINT SIN(x#)

or:

DEFDBL A-Z
x = 633763952693320.1#
PRINT x
PRINT SIN(x)

or:

DIM x AS DOUBLE
x = 633763952693320.1#
PRINT x
PRINT SIN(x)

Regards,
Michael

Posted on Feb 5, 2014, 8:13 PM

Respond to this message   

Return to Index


Re: or perhaps:

by Francesco S. (no login)

The same result. "ILLEGAL QUANTITY ERROR" on QBASIC...

Posted on Feb 6, 2014, 2:07 AM

Respond to this message   

Return to Index


Re: or perhaps:

by Francesco S. (no login)

Also QuickBasic4.5 fails.

Posted on Feb 6, 2014, 9:48 AM

Respond to this message   

Return to Index


Re: or perhaps:

by (Login MCalkins)
Moderator

Why do you need to be finding the SIN of such huge numbers? Isn't Sine cyclic, such that you could get the modulus from dividing the number by some multiple of pi, and then do the Sine and get the correct results?

Regards,
Michael

Posted on Feb 6, 2014, 4:36 PM

Respond to this message   

Return to Index


Re: or perhaps:

by Francesco S. (no login)

It's a calculated value within a complex program

Posted on Feb 7, 2014, 4:02 AM

Respond to this message   

Return to Index


What is the correct answer, anyway?

by lawgin (no login)

I tried 2 online sine calculators and got 0.07661881
The calculator that comes with windows gives 0.05167014

If I use Michael's approach and divide by 2*pi,then take the fractional part of that division and multiply it times 2*pi, I wind up with .05169316 radians. sin(.05169316) on my hand calculator is 0.05167014, confirming that the windows calculator is correct.

I don't think it's possible to find the answer using floating point math with either qb or qb64. There isn't enough precision.

Posted on Feb 7, 2014, 2:10 PM

Respond to this message   

Return to Index


Visual Basic results

by Solitaire (Login Solitaire1)
S

I ran this program in Visual Basic.NET

Dim x As Double
x = 633763952693320.12
Console.WriteLine(x)
Console.WriteLine(Math.Sin(x))


This was the output:

633763952693320
0.076618812661275

Posted on Feb 7, 2014, 4:27 PM

Respond to this message   

Return to Index


Re: Visual Basic results

by lawgin (no login)

It looks like I was wrong about the accuracy of the Windows calculator. I did it in Python and got the same results as you did in vb:

import math
x=633763952693320.1
y=math.sin (x)
print (x)
print (y)


Output was:
633763952693320.1
0.07661881266127499

Posted on Feb 8, 2014, 10:02 AM

Respond to this message   

Return to Index


Rounding errors

by David (no login)

The value you are trying to get the sine of is not sufficiently accurate.
The sine function essentially runs from 0 to 2pi. The value given is only to one decimal place so unless the value is actually ...320.1000 I'm not surprised at the variable values obtained.
The answer is actually 0.0516702

Posted on Feb 9, 2014, 6:12 AM

Respond to this message   

Return to Index


Answer in QB4.5

by David (no login)

CLS 'still a bit of error
x# = 633763952693320#
y# = 8# * ATN(1#)
k# = 628318530717958#
z# = x# - k#
z# = z# + .1 - .648
j# = z# / y#
j# = j# - INT(j#)
j# = z# / y#
m# = y# * (j# - INT(j#))
PRINT USING "#.######"; CSNG(SIN(m#))

Posted on Feb 9, 2014, 8:30 AM

Respond to this message   

Return to Index


Re: Rounding errors

by lawgin (no login)

When I did this problem by hand I got essentially the same answer as you (0.05167014). This is also the result obtained from the Windows calculator. But when coded in 3 different programming languages, it seems damn odd that they would each give the same result and that it would be wrong.

qb64 version:

DIM x AS DOUBLE
x = 633763952693320.1
PRINT SIN(x)

output is 0.0766188...
same as in visual basic and python versions.

Maybe converting fractional decimals to binary introduces inaccuracies.


Posted on Feb 10, 2014, 9:50 AM

Respond to this message   

Return to Index


Strange results

by Solitaire (Login Solitaire1)
S

I ran the program in GWBASIC. Here is the output:

RUN
6.33764E+14
.8876396
OK

In QB, I tried DIM x AS DOUBLE
but it resulted in an illegal function call with the PRINT statement. Tried assigning y AS DOUBLE to SIN(x) with similar results.

Commented out the illegal statement and got this output for the value of x:
63376395269332

so it didn't even save the value of x correctly. It started out as:
633763952693320.1

GWBASIC saved it in scientific notation.
So I changed the QB code to:
x = 6.33764E+14

It still gave an illegal function call, but after commenting it out, the output for x was:
633764032020480

Strange, indeed.


Posted on Feb 6, 2014, 12:50 PM

Respond to this message   

Return to Index


It depends on the implementation of SIN

by John Connor (no login)

One method of implementing the sine function is a truncated Taylor series:

sin(x) = 1 - x^3/3! + x^5/5! - x^7/7! + ...

Large numbers may overflow when raised to such powers.

Posted on Feb 7, 2014, 8:26 PM

Respond to this message   

Return to Index


typo

by John Connor (no login)

sin(x) = x - x^3/3! + x^5/5! - x^7/7! + ...

Posted on Feb 7, 2014, 8:27 PM

Respond to this message   

Return to Index


Ignore my previous replies

by John Connor (no login)

That approximation only works in the range -pi < x < pi

Posted on Feb 8, 2014, 11:46 AM

Respond to this message   

Return to Index


Edit

by (Login SMcNeill)
R

EDIT - Redoing code as the forum loses some keystrokes. GRRRR



    
This message has been edited by SMcNeill on Feb 10, 2014 9:18 AM

Posted on Feb 10, 2014, 9:14 AM

Respond to this message   

Return to Index

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