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



qbasic for windows 7-8

by (no login)

I've been using qbasic to write pgms. The computer I use had the mother board fail. Fortunatly I have another one that runs windows xp and moved all the pgms to that computer. What happens when I no longer have an xp system? Is there a version of qbasic that will run on the new windows or do I need to learn another lanquage like C. I have a teach yourself C but I don't see any commands to allow me to read data from the parallel ports like I can with qbasic. Anyone have any sugestions?
Leon

Posted on Dec 11, 2013, 1:21 PM

Respond to this message   

Return to Index


Use QB64 instead

by (Login burger2227)
R

QB64 can do most of the old Qbasic stuff plus it can do sound files and 32 bit images and screens. It can also communicate on the internet.

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

Posted on Dec 11, 2013, 4:03 PM

Respond to this message   

Return to Index


qb64

by Leon Schrecengost (no login)

Will the qbasic code run or will it have to be modifyed?
Thanks for the info Leon

Posted on Dec 12, 2013, 8:56 AM

Respond to this message   

Return to Index


Yes

by Jason Micha (no login)

Yes Qb64 pretty much works just like Qbasic. It also has alot of other really neat features. I had started working on a little text adventure game couple years ago and I switched over to QB64 with no problem. It looks and feels just like qbasic it just works with newer OS.

Posted on Dec 15, 2013, 10:10 AM

Respond to this message   

Return to Index


You could also try DosBOX

by Dave (no login)

DosBOX is a dos emulator that will allow you to run older programs like QBasic. QB64 works good too, but if you want the old debugging features of QBasic you might want to try DosBOX.

Posted on Dec 15, 2013, 7:34 PM

Respond to this message   

Return to Index


Sound isn't working

by (no login)

This program is supposed to play sounds but when I run it and press 'a' it outputs the letter 'a' on the screen rather than playing the note C.What is going wrong?
*********************

CLS
PRINT "Welcome to HomeRow Keyboard!"
PRINT "Each key on homerow will play a coresponding note that would be on a keyboard."
INPUT "Do you want to more instruction?", Answer$
Firstletter$ = LEFT$(Answer$, 1)
IF Firstletter$ = "y" OR Firstletter$ = "Y" THEN
PRINT " A on homerow is equal to C on a piano. "
PRINT "S=D, D=E, F=F, G=G, H=A, J=B, K=C"
INPUT "Let's do a test. Press A", A$

KeyboardSub


END IF
PRINT
PRINT "Start Playing! Press q to quit"

INPUT "", Ans$
KeyboardSub



SUB KeyboardSub

SELECT CASE Ans$
CASE "a"
PLAY "c"
CASE "s"
PLAY "d"
CASE "d"
PLAY "e"
CASE "f"
PLAY "f"
CASE "g"
PLAY "g"
CASE "h"
PLAY "a"
CASE "j"
PLAY "b"
CASE "k"
PLAY "c"
END SELECT
END SUB

Posted on Dec 10, 2013, 1:49 PM

Respond to this message   

Return to Index


Couple of problems...

by (Login qb432l)
R

The reason your program doesn't work is that you're not sending any information to the sub program. The "a", etc., that is printed is really the "a" pressed by the user for the INPUT statement.

What you have to do is use a direct method of inputting information. Here is what I recommend instead of INPUT ""; Ans$

Ans$ = INPUT$(1)

This will assign the input letter immediately to Ans$ without printing it. What's more the user doesn't have to press ENTER in order to play the note.

Your SUB heading should be:

KeyboardSub (NOTE$)

...and the call to the sub program should be:

KeyboardSub Ans$

Now the sub program has a letter to work with and will respond the way you want it to.

Also the input statement should be in a loop so that your program doesn't end after the first note is played:

DO
Ans$ = INPUT$(1)
KeyboardSub Ans$
LOOP UNTIL Ans$ = "Q" OR Ans$ = "q"
END

-Bob

Posted on Dec 10, 2013, 2:32 PM

Respond to this message   

Return to Index


Still no sound

by Wendy (no login)

Okay, I think I have made the changes you suggested but it will doesn't play sound.What am I doing wrong?
CLS

PRINT "Welcome to HomeRow Keyboard!"
PRINT "Each key on homerow will play a coresponding note that would be on a keyboard."
INPUT "Do you want to more instruction?", Answer$
Firstletter$ = LEFT$(Answer$, 1)
IF Firstletter$ = "y" OR Firstletter$ = "Y" THEN
PRINT " A on homerow is equal to C on a piano. "
PRINT "S=D, D=E, F=F, G=G, H=A, J=B, K=C"
INPUT "Let's do a test. Press A", A$

KeyboardSub (NOTE$)


END IF

PRINT
PRINT "Start Playing! Press q to quit"

DO
Ans$ = INPUT$(1)
KeyboardSub Ans$
LOOP UNTIL Ans$ = "Q" OR Ans$ = "q"
END




SUB KeyboardSub (NOTE$)

SELECT CASE Ans$
CASE "a"
PLAY "c"
CASE "s"
PLAY "d"
CASE "d"
PLAY "e"
CASE "f"
PLAY "f"
CASE "g"
PLAY "g"
CASE "h"
PLAY "a"
CASE "j"
PLAY "b"
CASE "k"
PLAY "c"
END SELECT
END SUB






Posted on Dec 11, 2013, 7:16 AM

Respond to this message   

Return to Index


That was my fault, Wendy...

by (Login qb432l)
R

I made the argument in the KeyboardSub "NOTE$", but your SELECT CASE is testing for "Ans$". Just change it to SELECT CASE NOTE$ and you should be okay. Sorry about that.

Another thing you might try is placing a PLAY statement before the whole thing begins - for example, after the instructions END IF

PLAY "T120 o3 L4"

This will initialize the PLAY statement and set the note duration and octave. It will sound a little better and respond more quickly - especially the first note. You might also change your top C-note (CASE "k") to:

CASE "k"
PLAY "o4 c o3"

That way it will play a high-c rather than repeat the low-c. The second octave command (o3) returns it to octave 3 for subsequent notes.

-Bob

Posted on Dec 11, 2013, 8:53 AM

Respond to this message   

Return to Index


Thanks!

by Wendy (no login)

That did the trick! I also appreciate your other suggestions. Thanks for all the help.

Posted on Dec 12, 2013, 12:55 PM

Respond to this message   

Return to Index


*yw!

by (Login qb432l)
R

*

Posted on Dec 12, 2013, 5:33 PM

Respond to this message   

Return to Index


Bob, I'm curious about something...

by (Login Kewbie)
R

Keeping in mind that I know NOTHING about QB64, is the variable Ans$ actually necessary, or would coding

KeyboarSub INPUT$(1)

work just as well?

Just curious.

Kew

Posted on Dec 12, 2013, 9:18 AM

Respond to this message   

Return to Index


You're right, of course...

by (Login qb432l)
R

It would work just as well. You'd have to use a different exit method since there would be no variable to test for ending the loop, but that could be handled in the sub program, I suppose.

Perhaps a little too "elegant" for a newbie, but it certainly would work.

-Bob

Posted on Dec 12, 2013, 5:30 PM

Respond to this message   

Return to Index


QB64 Window Sizing

by OLD_COBOL_APP_PGMR (no login)

I have some old QB programs in which I pop a window from the program by using the "INPUT" statement. When the window appears, it's very small. How can I get the QB64 environment to make such a screen pop bigger? Is that something within QB64 settings, or is that a Microsoft Windows setting I need to change?

Thanks.

Posted on Dec 8, 2013, 9:43 AM

Respond to this message   

Return to Index


Re: QB64 Window Sizing

by Pete (Login The-Universe)
Admin

You need to manipulate font size to manipulate window sizes in SCREEN 0. Here is an example I helped write. I see it has changed some, but it looks like it still demonstrates how increasing the font size will increase the size of the window...

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

Posted on Dec 8, 2013, 1:00 PM

Respond to this message   

Return to Index


If you tried to join the QB64 Forum READ THIS

by (Login burger2227)
R

If you have tried to join the QB64 Forum and have not had a reply, please send an email to galleondragon@gmail.com requesting approval.

In your email, include your USER NAME requested when you registered. Due to high volumes of SPAM registrations, the forum approval process has been blocked.

If you still do not get a reply then email me!

Posted on Dec 8, 2013, 7:27 AM

Respond to this message   

Return to Index


Thanks

by David (no login)

I will try an e-mail. I am having great difficulty with _loadfont. For some TTF fonts it works and for others it does not.
(it works for times but not for courier)

Posted on Dec 11, 2013, 11:04 AM

Respond to this message   

Return to Index


Still no response

by David (no login)

It is hard to believe that spam is a problem those "captha" (sp?) things are difficult for even a human to see.

Posted on Dec 14, 2013, 4:45 PM

Respond to this message   

Return to Index


Some fonts will not work in the text mode SCREEN 0

by (Login burger2227)
R

Text wants MONOSPACE. Try a graphic screen mode like SCREEN 12.

Posted on Dec 15, 2013, 1:39 AM

Respond to this message   

Return to Index


The answer was in the wiki

by David (no login)

The windows TTF fonts do not display their correct names when you bring them up using a windows screen.
I found to get their true names you have to go into "command prompt" and use DOS dir command.
You can't get their names from looking at properties as it says in the QB64 wiki.
So what displays as courier.ttf is actually called cour.ttf and what is displayed as "times new roman.ttf" is actually just called times.ttf on the disk. Here's a sample showing how it works

IX& = 800&: IY& = 1000&
FTHT = 14 'FONT SIZE
SCREEN _NEWIMAGE(IX&, IY&, 2)
font1& = _LOADFONT("c:windowsfontsCOUR.ttf", FTHT)
font2& = _LOADFONT("c:windowsfontsTIMES.ttf", 24, "bold")
_font font1&
'now printing courier regular 14pt
_font font&2
'now printing times new roman 24pt bold

Posted on Dec 16, 2013, 4:47 AM

Respond to this message   

Return to Index


*you will notice that the back slashes have been removed

by David (no login)

Posted on Dec 16, 2013, 5:46 AM

Respond to this message   

Return to Index


Semi colon doesn't prevent the line from breaking

by (no login)

I have this code which is straight forward but for some reason the line breaks after 'Justin loves you..' and moves to the next line rather than it all printing on the same line 'Justin loves you... his next concert he is going to give you VIP backstage passes! You will be the first person ever to be awarded this!. I have used a semicolon so it should remain on the same line but it doesn't. How can I fix this?

CLS
INPUT "Enter a celebrity name: ", Name$
INPUT "Enter your name: ", Person$
IF Name$ = "Justin Bieber" THEN
PRINT "Justin loves you "; Person$; " his next concert he is going to give you VIP backstage passes! You will be the first person ever to be awarded this!";

ELSE
PRINT ; Name$; " is an amazing person, they donate extreme amounts of money to charities"; " every year!"
END IF

Posted on Nov 27, 2013, 1:40 PM

Respond to this message   

Return to Index


2 quick solutions:

by (Login SMcNeill)
R

The simplest solution -- Change the semicolons into pluses instead. This will have QB64 (and presumably QB45 also) treat the sentence as a single sentence and it will follow the basic wrapping routine. (Which I find lacking, as it separates words in half and such, and looks all messy.)

CLS
Name$ = "Justin Bieber"
Person$ = "Steve"
IF Name$ = "Justin Bieber" THEN
PRINT "Justin loves you " + Person$ + " his next concert he is going to give you VIP backstage passes! You will be the first person ever to be awarded this!";

ELSE
PRINT ; Name$; " is an amazing person, they donate extreme amounts of money to charities"; " every year!"
END IF


*********************************************
*********************************************

Solution 2: Write up your own simple Wordwrap type routine and have it break the line at the proper spot and display things all nice and neat and pretty for you. The demo below is assuming you're running under QB64, as it relies on QB64 specific EXIT FOR, and some other QB64 syntax. It wouldn't be that hard to write up for QB45 for someone more familiar with which keywords to use and whatnot, and shouldn't be hard for someone to translate down to QB45 if you need.

Name$ = "Justin Bieber"
Person$ = "Steve"
IF Name$ = "Justin Bieber" THEN
Wordwrap "Justin loves you " + Person$ + " his next concert he is going to give you VIP backstage passes! You will be the first person ever to be awarded this!"
ELSE
PRINT ; Name$; " is an amazing person, they donate extreme amounts of money to charities"; " every year!"
END IF


SUB Wordwrap (text$)
Limit = _WIDTH 'Limit should equal _WIDTH (backslash, since the forums loses them) _FONTWIDTH if you're using a graphic mode and not SCREEN 0.
DO UNTIL LEN(text$) FOR i = Limit TO 1 STEP -1
t$ = MID$(text$, i, 1)
SELECT CASE t$
CASE " ", ",", ";", "-", "/", CHR$(13), CHR$(10) 'Suitable line break characters == feel free to add or alter these as needed.
EXIT FOR
END SELECT
NEXT
IF i = 0 THEN i = Limit
PRINT LEFT$(text$, i)
text$ = MID$(text$, i + 1)
DO
good = -1
IF LEFT$(text$, 1) = CHR$(13) THEN text$ = MID$(text$, 2): good = 0
IF LEFT$(text$, 1) = CHR$(10) THEN text$ = MID$(text$, 2): good = 0
IF RIGHT$(text$, 1) = CHR$(13) THEN text$ = LEFT$(text$, LEN(text$) - 1): good = 0
IF RIGHT$(text$, 1) = CHR$(13) THEN text$ = MID$(text$, LEN(text$) - 1): good = 0
LOOP UNTIL good
LOOP
PRINT text$
END SUB

Posted on Nov 27, 2013, 3:44 PM

Respond to this message   

Return to Index


You didn't do anything incorrectly...

by (Login qb432l)
R

It's a wrap problem. If, for example, the sentence was short enough that it didn't have to wrap, it would continue after the semicolon. Since it is long, it wraps, but the choice of where to break the string is chosen by QBasic as the last construction break - the semicolon. This will happen in both QB64 as well as QBasic.

To get around this, you will have to build a string:

New$ = "Blah, blah, blah, " + Person$ + " blah, blah, blah."
PRINT New$

Now you have a single string and it will wrap conventionally.

Incidentally, there is another possible problem, namely, that it will wrap in the middle of a word if that's where it reaches the end of the print zone. To avoid that, you'll have to deconstruct the sentence, determining where YOU want the string to wrap and building multiple strings. Can get complicated.

Good luck,
-Bob

Posted on Nov 27, 2013, 3:49 PM

Respond to this message   

Return to Index


*Sniffle* Bob must not love me... Or like my examples at least. Wah!! ;)

by (Login SMcNeill)
R

Posted on Nov 27, 2013, 4:10 PM

Respond to this message   

Return to Index


*LOL - actually, I thought your answer was better than mine. I posted before seeing yours.

by (Login qb432l)
R

*

Posted on Nov 27, 2013, 9:32 PM

Respond to this message   

Return to Index


Thanks!

by Wendy (no login)

Thanks for both of your suggestions. I appreciate the help with this. I think I have now fixed my problem.:)

Posted on Nov 28, 2013, 7:40 AM

Respond to this message   

Return to Index


status bar

by (no login)

Hi all

I want to design a system used with qbasic or qb64 that will mesure the TOTS left in a bottle. Eg if there is 32 tots in a bottle and a key is pressed it must minus the tots from 32. The afore mentioned is not the problem what I would like to know is how would I design this by having the program ask the discription and how many tots the discription will contain (up to 12) I can do this as a fixed state what I need help with is that the program remembers the discription with the TOTS status and a seprate menue that will give srats as to the time and date each tot was used please steer me in a direction

Thank you

Posted on Nov 21, 2013, 2:58 AM

Respond to this message   

Return to Index


You will need to create a data file...

by (Login qb432l)
R

Probably the simplest would be to create a DATA type which includes beverage name as a string, number of remaining tots as integer, and most recent "sip" date as a string (updated using DATE$ at the time of the sip). Create an array with 12 components/beverage names/sip totals. When the user drinks, the array is changed accordingly and the file is updated. When the program is re-run, the array is loaded from the file, and so on.

Hope that's what you needed.

-Bob

Posted on Nov 21, 2013, 6:17 AM

Respond to this message   

Return to Index


Re: You will need to create a data file...

by don (no login)

Hi bob

Would it be possible to assist with a sample code maby on two bevrages just to get a pattern of some sort.

Thanx in advance

Posted on Nov 21, 2013, 6:58 AM

Respond to this message   

Return to Index


Re: You will need to create a data file...

by (Login SMcNeill)
R

Here's a very simple little demo for you of how to check for:

if a file exists
If so -- update that file
if not -- then create that file
And if the tots become 0, delete that file (as we drank the whole bottle!)

Feel free to use, abuse, and modify the code in any way which would be useful for your purpose, as this is nothing more than a freeware example of what it sounds like you need. wink.gif



DO
CLS
PRINT "Give me a whisky name. =>";
INPUT name$
PRINT 'An extra line just for formatting

name$ = name$ + ".txt" 'Turn that bottle into a text file

IF _FILEEXISTS(name$) THEN
'We already have a bottle of that open!
OPEN name$ FOR INPUT AS #1
INPUT #1, tots
CLOSE #1
PRINT "As of last count, there were "; tots; " number of tots left in that bottle."
ELSE
PRINT "That must be a new bottle of whiskey. It's not in my list."
END IF

PRINT "How many tots are in it now? => ";
INPUT tots
OPEN name$ FOR OUTPUT AS #1
PRINT #1, tots
CLOSE #1
IF tots = 0 THEN KILL name$ 'Let's delete the file on the bottle when it's empty.
PRINT
PRINT "Do Another (Y/N)"
DO
_LIMIT 30 'No need to be resource heavy. Checking for user input 30 times a second is MORE than enough here.
a$ = UCASE$(INKEY$)
LOOP UNTIL a$ = "Y" OR a$ = "N"
LOOP UNTIL a$ = "N"

Posted on Nov 21, 2013, 10:39 AM

Respond to this message   

Return to Index


TOTS? How many tots are in the bottle?

by (Login burger2227)
R

What kind of computer device will read your lips? happy.gif

Posted on Nov 21, 2013, 1:27 PM

Respond to this message   

Return to Index


2014 - Moving on to other things...

by Pete (Login The-Universe)
Admin

I'll be leaving the forum up, probably with ads, but not posting or visiting much in 2014. Lots of other things happening to focus my attention on. I don't see much happening in the way of QB64 development for now. The project is caught up in several directions. Mobile QB64 would have been fun, but I don't think the project will get there next year, unless Rob finds a lot more free time to develop it.

I have my doubts that QB will ever be the same. Good old-school QB questions have become a thing of the past. More and more I see questions involving library usage, Linux OS implementation, licensing issues between SDL and GL, and, of course, new keywords involving additions to things like graphics that I never had any interest in using.

I do want to credit what Rob has created. It is amazing to see QB working, and working well, in modern operating systems. Rob essentially reinvented the wheel, so QB enthusiasts didn't have to learn and convert code into other languages.

I'm happy that N54 has consistently serviced these forums, but I'm also a bit disappointed that they will not update to a better format. Just recently we lost the ability to post code with backslashes. That, and the inability to use code boxes and indent code makes it difficult for others to come here and post in the future.

As for the forum content, it is an amazing accumulation of QB history and resources. QB64 has made a lot of many of the original work-arounds obsolete, but they were very clever for their time. It's nice to know people can find this place, use, and build on the code examples here.

I can hardly believe I've been actively associated with this forum even longer than the years I have spent in schools, and that is even when factoring in my 3 tries to graduate the sixth grade! Kidding aside, it has been a great 20 years here, lots of friends made, and great information shared.

Anyway, nothing set in stone at the moment, but I did want to make this post, prior to the year ending, to share my thoughts, and express my thanks to Rob at QB64.net, and to all of those who visit and contribute here.

Pete

Posted on Nov 16, 2013, 12:46 AM

Respond to this message   

Return to Index


I think that's a good call, Pete...

by (Login qb432l)
R

I personally want to thank you for taking over and keeping the forum ad-free after Mac died. As you suggest, the place is becoming a bit of an anachronism and it may be time to move on -- for me, too.

I'd also like to thank Galleon -- he gave QB a whole new life for me -- I still use it all the time in personal programs.

Auld Lang Syne, eh? Ah, but heck, even with ads, the debates(?) collection involving yourself, Clippy and Steve, will be just as exciting - lol. Scholars in years to come, as with Pepys diary, will find them a wonderful insight into the Obama years.

Thanks again,
-Bob happy.gif

P.S. Yeah, the sixth grade was a lot more difficult to get through back in the 30's.

Posted on Nov 16, 2013, 6:26 AM

Respond to this message   

Return to Index


* Well said.

by (Login MCalkins)
Moderator

Posted on Nov 16, 2013, 7:10 AM

Respond to this message   

Return to Index


Why doom this site by telling everybody you are leaving?

by (Login burger2227)
R

I still see you occasionally at the QB64 site (you are a mod there) so why declare something that you will probably not adhere to anyhow? To get us to agree to advertisements? If you really want to leave then give the site to somebody else. They can decide whether to keep it ad free or not.

I'll miss you like the plague! happy.gif

[linked image]

Stay out of the ten Companies Paying Americans the Least:

http://www.huffingtonpost.com/2013/11/16/companies-pay-americans_n_4288090.html?ncid=edlinkusaolp00000003

Posted on Nov 16, 2013, 8:04 AM

Respond to this message   

Return to Index


Sorry to see you go,

by Solitaire (no login)

but best wishes and all the luck in your future endeavors.

Posted on Nov 16, 2013, 9:08 AM

Respond to this message   

Return to Index


We'll miss ya Pete, ...

by (Login SMcNeill)
R

but I understand where you're coming from. Myself, I've always enjoyed learning, growing, and expanding my abilities. I was delighted when I first stumbled across QB64, as it breathed new life into an old language. Taking time to teach myself the new underscore commands; to figure out how the libraries work; and sorting out the nuances of cross-platform compatibility was a lot of fun for me. (I know, most of those things you don't care about as our SCREEN 0 Wizard, but I found them fun to learn. :P )

My problem with QB64 is that I've ran out of ways to push it, and myself any further. Now, don't get me wrong: it's a wonderful language for what it DOES do; it allows us to continue to use the BASIC language we all grew up with and love on modern operating systems. My personal problem is that I like to learn, strive, and grow -- and QB64 has stalled.

I was beginning to delve into the GL side of things, so I could learn how to use OpenGL commands natively inside QB64, and from what I can tell they're a mess. QB64-GL isn't anywhere near ready for use. Even something as simple as INPUT will cause QB64GL to become unstable and crash if we try and use any of the GL commands at all. Since it seems that I'm not going to be able to play around and expand my abilities with the GL side of QB64-GL, and since I feel like I've learned more or less all I need to from the rest of QB64, that leaves me with the same question: "Where to go from here, and what to do?"

Lately I've been working on a QB64-IRC Chatbot which I'm planning on using in the future (The 1st of January or so is when I want to start) to help me host an IRC-chat style RPG. (Think D&D, but instead of pen and paper while sitting around the kitchen table, this will be the same thing but over the IRC channels...) This will help me burn some free time and creativity, but I'm only going to be hosting it once a week (or maybe bi-weekly depending on the players commitment and schedules), so I'm still left with that burning question of, "What else am I going to do?"

To which, at this point, I really don't know. I don't foresee any real developments happening in QB64 to change it. GL still has a LONG ways to go to catch up and do the things that SDL used to do for us. The GL commands have to be tested and reworked so that they don't corrupt or conflict with existing QB64 commands or keywords. Cross-platform development needs to continue so we can use QB64 on Android and iPad devices. We need to see a x64 version of QB64 brought to completion. (I've had a 64-bit version up and running for everything but DATA statements, so Galleon shouldn't have much to do to finish the project off.) GL has pushed forward in so many different directions, that it's going to be some time before things settle and stabilize once more with the language.

So what's left for me to do here now? Very little as things stand now. sad.gif

Starting the New Year, I'll probably be "moving on" quite a bit as well. I've never learned Python, but from what I hear it's an amazingly flexible language and easy to learn. I'll probably take some time off to tinker around in it and see what I can do with it. Of course, I'm going to also take time to expand on my C skills themselves, as they're still not up to the level where I'd want them to be. (I get lost trying to sort through the C side of QB64...) I've even thought about trying to learn Japanese just for the heck of it. (I like a lot of their anime and manga, and it'd be nice to enjoy them in their native language I think.)

So, I can definitely understand why you wouldn't post or visit as often in 2014. Truth is, I probably won't be around near as much either. I'll be here -- on and off -- to try and keep up with things, but I don't think you'll be seeing a dozen posts from me every day or anything.

It sounds like 2014 is going to be bringing a lot of changes all the way around! happy.gif

Let's just all hope that they end up being changes for the better -- for everyone. ;D

Posted on Nov 16, 2013, 3:43 PM

Respond to this message   

Return to Index


QB64 GL unstable ???

by (no login)

I used this to write an extensive application th handle HL7X12 270/271 files and noticed none of this??? I am running these on windows XP and windows 7; what are you talking about?

Posted on Jan 25, 2014, 12:41 PM

Respond to this message   

Return to Index


Pete, you will be missed

by Moneo (no login)

Pete,
It certainly has been a pleasure working with you. Thanks for sharing your vast knowledge.
Best of luck with your new challenges.
Warm regards..... Moneo

Posted on Nov 20, 2013, 7:06 PM

Respond to this message   

Return to Index


Wish you the best, Pete.

by Dav (no login)

I appreciate your contributions (code & help, etc) to the QB scene all these years. And I think a 20 year habit is gonna be hard to break....

- Dav

Posted on Nov 22, 2013, 4:50 PM

Respond to this message   

Return to Index


Beep sound from program

by (Login sarah_victor)

I am not sure what is causing this but while coding the program, suddenly a beep sound starts. It's a continuous shrill beep. I am unable to mute it and the only way to stop the sound is to turn the laptop off. The Basic program is very simple - is printing a string. I feel that some key combination is triggering the beep sound, but am unable to recreate it.

Would really appreciate any help in this regard.
Thanks
Sarah Victor

Posted on Nov 14, 2013, 8:10 AM

Respond to this message   

Return to Index


* Post your code.

by Solitaire (no login)

Posted on Nov 14, 2013, 9:01 AM

Respond to this message   

Return to Index


Re: Beep sound from program

by (Login MCalkins)
Moderator

Are you using QBASIC or QB64? (I assume QBASIC.)

What Windows version are you using?

Does it only happen in QBASIC? Are you running in DOSBox or NTVDM?

Are you filling up the keyboard buffer?

Could it be a hardware problem with your laptop?

You can get a beep sound by printing chr$(7), but I suspect that this is something else.

Regards,
Michael

Posted on Nov 14, 2013, 9:01 AM

Respond to this message   

Return to Index


Re: Beep sound from program

by sarah Victor (no login)

QB64 version.
Windows 7
It happens only in QBasic. I think I am running DOSBox not NT.
Not sure if keyboard buffer filling up.
Certainly not a hardware problem with my laptop.

I am not able to recreate this problem.

Posted on Nov 18, 2013, 10:00 AM

Respond to this message   

Return to Index


*Of course, it's always possible that you were leaning on the space bar -- a thought.

by (Login qb432l)
R

*

Posted on Nov 18, 2013, 1:46 PM

Respond to this message   

Return to Index


*or had a pizza crumb holding a key down....

by SMcNeill (no login)

Posted on Nov 18, 2013, 1:52 PM

Respond to this message   

Return to Index


Re: Beep sound from program

by (Login MCalkins)
Moderator

I agree with Solitaire: please post the program.

Which QB64 version? The current "SDL" QB64 is version 0.954. The current "GL" QB64 is version 0.980.

You're not running QB64 in DOSBox or NTVDM. That would have been if you were running actual QBASIC.

So, this happens while you are typing in QB64's editor? Can you continue typing after it starts?

Doesn't the beeping stop if you close QB64? (You will certainly be able to forcibly close QB64. There is no way that it can prevent itself from being terminated.) Can you still move the mouse? If the computer becomes unresponsive, then you most likely have either a driver problem or a hardware problem, or possibly a major resource leak.

You might try running ProcessExplorer (from Microsoft Sysinternals) while running QB64, and see what happens. Look at the processor usage, in general and for QB64. Also, look at the memory usage.

What kind of processor do you have? How many cores?

Regards,
Michael

Posted on Nov 18, 2013, 4:18 PM

Respond to this message   

Return to Index


Are you part of the healthcare.gov development team?

by Pete (Login The-Universe)
Admin

Just asking.

Pete happy.gif

Posted on Nov 14, 2013, 5:09 PM

Respond to this message   

Return to Index


Re: Are you part of the healthcare.gov development team?

by (Login burger2227)
R

[linked image]

Baby Boehner after the Veto...

Posted on Nov 15, 2013, 12:03 PM

Respond to this message   

Return to Index


Linux IDE change font size?

by (no login)

Hello,

Just started using qb64 in Linux Lubuntu and great 'cos I can quickly convert the suite of programs developed using JustBasic.

The problem is that the IDE/editor font size is too small and I need to make larger otherwise I'll go blind!

I did try to place a font in what I thought was the correct folder but it didn't work.

I have also tried to set up Gedit with gedit tools to use that as an IDE which would be the best option but got in a mess because I don't think it could locate the program/or compiler. I did copy down the lang file to the correct folder under qb64 path.

If anyone could give me a quick fix for the font problem then great but even better if I could set up Gedit properly as this would be the best solution.

Regards,

NigelH

Posted on Nov 8, 2013, 9:33 AM

Respond to this message   

Return to Index


Re: Linux IDE change font size?

by Pete (Login The-Universe)
Admin

I use Windows. I open the IDE, go to OPTIONS, click DISPLAY, and there is a box to check for custom fonts. In windows a TTF font, like c:/windows/fonts/Lucon.ttf can be typed in, then you just use the other input box to set the size. Note you can also set the size of the IDE, in the boxes above.

I'm not sure what monospace TTF font would work for Linux, or the directly, but if you can find one, it is worth a shot.

We also have a few users here, who use Linux, who may respond, and you are welcome to ask in the Linux subforum, as wellhttp://www.network54.com/Forum/554399/

Pete



Posted on Nov 8, 2013, 6:02 PM

Respond to this message   

Return to Index


Linux qb64

by nigelH (no login)

Pete,

Thanks for the message. I can get to the 'display options' in the IDE but can't locate the location of the font folder in the Linux implementation.

I'll try the linux group as I'm sure it's a linux specific problem.

Thanks

NigelH

Posted on Nov 12, 2013, 11:36 PM

Respond to this message   

Return to Index


couple of problems with qb64 code

by (no login)

Been working on a text adventure with QB64 and trying to figure a couple of things out. The first one isn't exactly game breaking but I am trying to figure out a way to load a couple of title screens with an unforced delay.

an example of how I have it set up is:

'start example code
1 CLS
in& = _SNDOPEN("intro.mid")
IF in& = 0 THEN BEEP ELSE _SNDPLAY in&
_FULLSCREEN
SCREEN 12
st& = _LOADIMAGE("qb64logo.jpg")
_PUTIMAGE , st&
_DELAY 5
input "Press ENTER to continue";j
CLS
_FREEIMAGE st&


ii& = _LOADIMAGE("trilogo.jpg")
_PUTIMAGE , ii&
_DELAY 5
input "Press ENTER to continue";j
CLS
_FREEIMAGE ii&
'END example code

This works fine as far as putting a 5 second delay However you are forced to wait the 5 seconds. Also it seems like if the user gets excited (and we know they will) and starts pressing the ENTER key over and over again it ends up skipping several lines once the program starts. I guess if nothing else I could remove the _delay statements but what I would really like is a 5 second delay that can be interrupted at any point by pressing ENTER (or any key for that matter).

My other problem seems to be with loading midi music files. I have been careful to make sure I don't have more than 1 _sndopen going at a time and I always _sndclose the files when I am done with them. Its easy enough to debug if it crashes the program every time but my intro music isn't just randomly causing problems.

'START example code
6 CLS
in& = _SNDOPEN("intro.mid")
IF in& = 0 THEN BEEP ELSE _SNDPLAY in&

7 CLS
part1$ = "0"
menu$ = "0"
LET bs = 0' score
LET bo = 100' health
COLOR 5, 1: CLS
PRINT "****************************************************************************"
COLOR 2: PRINT " The Mystery of the Mushroom Mines "
PRINT
PRINT
COLOR 3: PRINT " 1- Chapter 1 - Prologue"
PRINT
IF chapter < 2 THEN COLOR 8: PRINT " 2- Chapter 2 - (Locked)": COLOR 3
IF chapter > 1 THEN PRINT " 2- Chapter 2 - The Discovery"
PRINT
IF chapter < 3 THEN COLOR 8: PRINT " 3- Chapter 3 - (Locked)": COLOR 3
IF chapter > 2 THEN PRINT " 3- Chapter 3 - The Plunge"
PRINT
IF chapter < 4 THEN COLOR 8: PRINT " 4- Chapter 4 - (Locked)": COLOR 3
IF chapter > 3 THEN PRINT " 4- Chapter 4 - The Hidden Truth"
COLOR 7
PRINT
PRINT " R- Reset Game N- Change Name"
PRINT
PRINT " 6- View Collected Notes A- View Achievements Q- Quit"
PRINT
COLOR 5
PRINT "****************************************************************************"
PRINT
COLOR 3
20 INPUT "What would you like to do"; a2$
COLOR , 0
IF a2$ = "a" OR a2$ = "A" THEN GOTO 40
IF a2$ = "R" OR a2$ = "r" THEN _SNDSTOP in&: _SNDCLOSE in&: GOTO 60
IF a2$ = "N" OR a2$ = "n" THEN _SNDSTOP in&: _SNDCLOSE in&: GOTO 22
IF a2$ = "1" THEN _SNDSTOP in&: _SNDCLOSE in&: GOTO 100: REM chapter 1
IF a2$ = "2" AND chapter > 1 THEN _SNDSTOP in&: _SNDCLOSE in&: GOTO 235: REM chapter 2
IF a2$ = "3" AND chapter > 2 THEN _SNDSTOP in&: _SNDCLOSE in&: GOTO 2000: REM chapter 3
IF a2$ = "4" AND chapter > 3 THEN _SNDSTOP in&: _SNDCLOSE in&: GOTO 2500: REM chapter 4
IF a2$ = "6" GOTO 1000: REM note menu.
IF a2$ = "Q" OR a2$ = "q" THEN _SNDstop in&: _sndclose in&: GOTO 70: REM end
GOTO 7
'end example code

PRoblem I have is any option that involves the _sndstop and _sndclose commands sometimes they work, sometimes they give illegal function call. The options that don't have a _sndstop in them do not open or play any music before returning to the above menu. The options that do shut the music off either end the program or eventually lead to a different music file playing. I also made sure that all music has its own variable.

Posted on Nov 6, 2013, 9:10 AM

Respond to this message   

Return to Index


Re: couple of problems with qb64 code

by SMcNeill (no login)

I don't use the SND coo and that often, so I have no idea what the issue there might be. However, for the DELAY issue, replace it with a SLEEP statement and see if that won't do what you'd like better.

SLEEP 5

Posted on Nov 6, 2013, 10:12 AM

Respond to this message   

Return to Index


Re: couple of problems with qb64 code

by (no login)

Sleep that is what I was looking for. I knew there was another way. Thanks

Posted on Nov 6, 2013, 12:41 PM

Respond to this message   

Return to Index


Be careful with INPUT and INKEY$ after SLEEP

by (Login burger2227)
R

SLEEP will proceed with a key press, but the key press is saved in the keyboard buffer. The key press can end up in subsequent INPUT, INPUT$ or INKEY$ entries.

You can clear the keyboard buffer by using an INKEY$ loop after the SLEEP:

SLEEP 5 'allows key press to continue

WHILE INKEY$ <> "": WEND

Posted on Nov 6, 2013, 3:41 PM

Respond to this message   

Return to Index


qbasic program

by (no login)

is there anyone that can help me with a area calculation program? i set up the whole menu but i think one of my sub programs are interfering with calculating the area. can someone take a look?

Posted on Nov 5, 2013, 2:51 PM

Respond to this message   

Return to Index


Post your code. *

by Pete (Login The-Universe)
Admin

Posted on Nov 5, 2013, 6:13 PM

Respond to this message   

Return to Index


functions in QB64

by Jim (no login)

why does the following line produce an error and does not compile

FUNCTION fac (x AS DOUBLE) as double

Posted on Oct 26, 2013, 12:47 AM

Respond to this message   

Return to Index


Re: functions in QB64

by (Login SMcNeill)
R

QB64 doesn't accept function definition with the AS statement.

Change it to the following and it'll work with no problem:

*********************************
PRINT fac(12.2)

FUNCTION fac# (x AS DOUBLE)
fac = 1.234 * x
END FUNCTION
**********************************

Notice: You only need to use the proper symbol when declaring the function. (FUNCTION fac#) After that the program will track all references to the function name for you automatically, and the type symbol becomes optional.

Posted on Oct 26, 2013, 1:32 AM

Respond to this message   

Return to Index


There's a fix that should have been in the Repository long ago*

by (Login burger2227)
R

Posted on Oct 26, 2013, 1:47 PM

Respond to this message   

Return to Index


*Work it up and add it for us. I'm certain a lot of people would appreciate it. :)

by (Login SMcNeill)
R

Posted on Oct 27, 2013, 6:11 AM

Respond to this message   

Return to Index


Are you kidding? The last project Clippy contributed to was healthcare.gov! *

by Pete (Login The-Universe)
Admin

Posted on Oct 27, 2013, 12:30 PM

Respond to this message   

Return to Index


That's more than you ever contributed to anything...

by (Login burger2227)
R

Giving is not your middle name stingy happy.gif

Posted on Oct 27, 2013, 6:19 PM

Respond to this message   

Return to Index


Really? I spend a good deal of my retirement...

by Pete (Login The-Universe)
Admin

Giving you the finger!

Pete happy.gif

Posted on Oct 27, 2013, 6:47 PM

Respond to this message   

Return to Index


* It is not valid in QBASIC 1.1 either. (although QB64 should be changed to accept it.)

by (Login MCalkins)
Moderator

Posted on Oct 26, 2013, 1:20 PM

Respond to this message   

Return to Index


Sorry Jim, you need In and Out Burger for that.

by Pete (Login The-Universe)
Admin

That's the only place I know you can order a Double-Double.

[linked image]

Pete

Posted on Oct 26, 2013, 1:30 PM

Respond to this message   

Return to Index


MYSQL

by (no login)

Hi all

How database programs are done with MYSQL dll ?

Elico

Posted on Oct 16, 2013, 12:17 PM

Respond to this message   

Return to Index


There's a whole topic on MySQL usage in QB64

by (Login SMcNeill)
R

Galleon woorked up some MySQL stuff over on the QB64 boards at:http://www.qb64.net/forum/index.php?topic=4445.0 You might find something in there that can help you. wink.gif

Does it have to be SDL? I've also worked up a QBDbase program which lets us make QB64 specific databases with all sorts of nice capabilities, so we can code them to do anything we might want them to do for us. If you just need an dBase type program, and SDL isn't required as the program, check out the link here for the QBDbase Library:http://www.qb64.net/forum/index.php?topic=7151.msg73369#msg73369

Both require QB64 to work, so if you're trying to use MySQL in QB45 or QBASIC, I'm afraid neither of those links would be the most help. It's been ages since I did much actual programming in QB45 or older BASICs, and I don't know of any handy resource available to work databases with them.

Posted on Oct 16, 2013, 2:04 PM

Respond to this message   

Return to Index


A QBASIC math processing system

by (Login SMcNeill)
R

A friend of mine saw that we had a working calculator of sorts for the QB64 IDE now, and asked me if I could work up a similar system for use in QBASIC. I told him I didn't think it'd be that difficult to convert, and he's went off on vacation. I've got me a working program now, with no QBASIC to test it on, and he won't be back until next week or so.

Can anyone with a working QBASIC copy test this for me? Right now it's a simple little thing where we toss a small formula into a string, and it then tries to evaluate it. All we work with currently is ^, *, /, , +, -, SQR, COS, but it should be enough to see if the process translates over.

The rest of our commands are just simply plugging them into the OOO array (for Order Of Operations), and then tossing in the actual math functions where we EvaluateNumbers at... This should parse the input already, separate things for us, and have us all set up to add as many math commands as we want in the future.

The QB64 process we use would be a little different than this (thanks to REDIM _PRESERVE, we can have much smaller and smarter arrays), but the general process is the same.

Code follows for whomever can test it in a QBASIC environment, and many thanks in advance. :D

***********************************
***********************************

REDIM SHARED OOO(100) AS STRING 'Order of Operations, redim to a larger size if you ever create more than 100 operators.
Set_OrderOfOperations

x$ = "1+SQR((1+2)^2)"
'x$ = "1 / 0"

PRINT x$
y$ = Evaluate(x$)
PRINT x$; " = "; y$


SLEEP
SYSTEM


FUNCTION Evaluate$ (e$)
'First strip all spaces
FOR i = 1 TO LEN(e$)
IF MID$(e$, i, 1) <> " " THEN t$ = t$ + MID$(e$, i, 1)
NEXT
'Then make all caps so we can process things easier
t$ = UCASE$(t$)
'Deal with brackets first
exp$ = "(" + t$ + ")" 'Starting and finishing brackets for our parse routine.
DO
e = INSTR(exp$, ")")
IF e > 0 THEN
c = 0
DO UNTIL e - c <= 0
c = c + 1
IF e THEN
IF MID$(exp$, e - c, 1) = "(" THEN EXIT DO
END IF
LOOP
s = e - c + 1
IF s < 1 THEN PRINT "ERROR -- BAD () Count": END
eval$ = " " + MID$(exp$, s, e - s) + " " 'pad with a space before and after so the parser can pick up the values properly.
ParseExpression eval$
eval$ = LTRIM$(RTRIM$(eval$))
IF LEFT$(eval$, 5) = "ERROR" THEN Evaluate$ = eval$: EXIT SUB
exp$ = LEFT$(exp$, s - 2) + eval$ + MID$(exp$, e + 1)
END IF
LOOP UNTIL e = 0
c = 0
DO
c = c + 1
SELECT CASE MID$(exp$, c, 1)
CASE "0" TO "9", ".", "-" 'At this point, we should only have number values left.
CASE ELSE: exp$ = "ERROR - Unknown Diagnosis"
END SELECT
LOOP UNTIL c >= LEN(exp$)

Evaluate$ = exp$
END FUNCTION

SUB ParseExpression (exp$)
DIM num(10) AS STRING
'We should now have an expression with no () to deal with
FOR p = 1 TO UBOUND(OOO)
IF OOO(p) = "EOO" THEN EXIT FOR
DO
op = INSTR(exp$, OOO(p))
IF op THEN
'Get the number after op. A simple space should be the break for it
e = INSTR(op + 1, exp$, " ")
c = 0
DO
c = c + 1
SELECT CASE MID$(exp$, op - c, 1)
CASE "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "." 'Valid digit
CASE "-" 'We need to check if it's a minus or a negative
c1 = c
bad = 0
DO
c1 = c1 + 1
SELECT CASE MID$(exp$, op - c1, 1)
CASE "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "."
bad = -1
EXIT DO 'It's a minus sign
CASE ELSE
'It's a negative sign and needs to count as part of our numbers
END SELECT
LOOP UNTIL op - c1 <= 0
IF bad THEN EXIT DO 'We found our seperator
CASE ELSE 'Not a valid digit, we found our separator
EXIT DO
END SELECT
LOOP UNTIL op - c <= 0
s = op - c
num(1) = MID$(exp$, s + 1, op - s - 1) 'Get our first number
num(2) = MID$(exp$, op + LEN(OOO(p)), e - op - LEN(OOO(p)) + 1) 'Get our second number
num(3) = EvaluateNumbers(p, num())
IF LEFT$(num(3), 5) = "ERROR" THEN exp$ = num(3): EXIT SUB
exp$ = LEFT$(exp$, s) + LTRIM$(num(3)) + MID$(exp$, e)
END IF
op = 0
LOOP UNTIL op = 0
NEXT
END SUB



SUB Set_OrderOfOperations
i = i + 1: OOO(i) = "COS"
i = i + 1: OOO(i) = "^"
i = i + 1: OOO(i) = "SQR"
i = i + 1: OOO(i) = "*"
i = i + 1: OOO(i) = "/"
i = i + 1: OOO(i) = "" 'N64 Forums removed the backslash from here for integer division
i = i + 1: OOO(i) = "+"
i = i + 1: OOO(i) = "-"


i = i + 1: OOO(i) = "EOO" 'End of Operators code
END SUB

FUNCTION EvaluateNumbers$ (p, num() AS STRING)
DIM n1 AS _FLOAT
SELECT CASE OOO(p) 'Depending on our operator..
CASE "COS"
n1 = COS(VAL(num(2)))
CASE "^"
n1 = VAL(num(1)) ^ VAL(num(2))
CASE "SQR"
n1 = SQR(VAL(num(2)))
CASE "*"
n1 = VAL(num(1)) * VAL(num(2))
CASE "/":
IF VAL(num(2)) = 0 THEN EvaluateNumbers$ = "ERROR - Division by 0": EXIT FUNCTION
n1 = VAL(num(1)) / VAL(num(2))
CASE ""
IF VAL(num(2)) = 0 THEN EvaluateNumbers$ = "ERROR - Division by 0": EXIT FUNCTION
n1 = VAL(num(1)) VAL(num(2))'N64 Forums removed the backslash from here for integer division
CASE "+"
n1 = VAL(num(1)) + VAL(num(2))
CASE "-"
n1 = VAL(num(1)) - VAL(num(2))
CASE ELSE
EvaluateNumbers$ = "ERROR - Bad operation (We shouldn't see this)"
END SELECT
EvaluateNumbers$ = RTRIM$(LTRIM$(STR$(n1)))
END FUNCTION

Posted on Oct 14, 2013, 3:42 PM

Respond to this message   

Return to Index


First problem encountered...

by (Login qb432l)
R

QBasic (under DOSBox) doesn't seem to care for your underscore:

Set_OrderOfOperations

...and refuses to recognize it as a sub. I don't think it's an N54 problem, since it pasted fine into Notepad, but the underscore and what follows it are missing when I open it in QBasic. I tried typing it back in, but it still got an error. Not sure why.

Same problem with _FLOAT.

-Bob

Posted on Oct 14, 2013, 5:27 PM

Respond to this message   

Return to Index


I see two problems.

by Pete (Login The-Universe)
Admin

There is no _FLOAT in QBasic.

Underscores won;t work in sub names, so Set_OrderOfOperations would not work.





Posted on Oct 14, 2013, 5:32 PM

Respond to this message   

Return to Index


That explains that, but...

by (Login qb432l)
R

Why does QBasic eliminate everything following an underscore?

-Bob

Posted on Oct 14, 2013, 5:35 PM

Respond to this message   

Return to Index


Serves me right for sending my response US Mail, while...

by Pete (Login The-Universe)
Admin

TheBOB uses that Canadian firm, you know, SledEX.

I think QB takes an underscore and handles it like NotePad, in that it thinks it is a line break. At least that's what I recall from many years back.

Pete

Posted on Oct 14, 2013, 5:38 PM

Respond to this message   

Return to Index


I've seen a few things left after an underscore meets Qbasic

by (Login burger2227)
R

But it most likely won't run very well.

Posted on Oct 14, 2013, 6:30 PM

Respond to this message   

Return to Index


Regarding underscores...

by (Login Kewbie)
R

It seems to me that I remember something about underscores from when I was writing QBB. IF I remember correctly, (and that's a big if,) QB can add underscores when it saves long program lines, but they can't be entered manually to continue lines during code entry.

Again, if memory serves, the behavior was some kind of holdover from the QuickBASIC days.

Well, that's about all I can remember about it. Sorry there isn't any more.

Kew

Posted on Nov 3, 2013, 2:35 PM

Respond to this message   

Return to Index


*Appreciate it, Kewb. Weird, though.

by (Login qb432l)
R

*

Posted on Nov 3, 2013, 7:40 PM

Respond to this message   

Return to Index


For now, I've went back to the QB64 drawing board...

by (Login SMcNeill)
R

I was generating errors with order of precedence, and double negatives and such, so decided to drop back to working in QB64-code for now. Once I get all the kinks worked out and it working properly in an environment I'm used to and comfortable with, THEN I'll hunt down the minor changes needed to try and revert back to an earlier working BASIC.

If anyone is interested, and wants to follow progress as I work the bugs out, the code can be found on the QB64 forums under the link here: http://www.qb64.net/forum/index.php?topic=11475.msg98333#msg98333

Posted on Oct 14, 2013, 6:47 PM

Respond to this message   

Return to Index


fun project

by Ben (no login)

here is a good way to do it

http://en.wikipedia.org/wiki/Shunting-yard_algorithm

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>


typedef struct rpnstruct {
char *syms;
double *nums;
} rpn;

rpn makerpn(char *in);
double evalrpn(rpn outx, double x, double y, double z, double t, double u, double v);


rpn makerpn(char *in)
{
rpn ret;

int i;
char out[1000];
int o=0;
char stack[1000];
int s=0;
char num[1000] = "";
double nums[1000];
int n=0;

int last = 1;

for(i = 0; i <= strlen(in); i++) {
if((in[i] >= '0' && in[i] <= '9') || in[i] == '.') {
strncat(num, &in[i], 1);
continue;
}
else if(strlen(num) > 0) {
sscanf(num, "%lf", &nums[n++]);
out[o++] = '#';
num[0] = 0;
last = 0;
}

if(in[i] >= 'a' && in[i] <= 'z') {
/* functions */
if(!memcmp("sin", in+i, 3)) { stack[s++] = 's'; i+=2; }
else if(!memcmp("cos", in+i, 3)) { stack[s++] = 'c'; i+=2; }
else if(!memcmp("tan", in+i, 3)) { stack[s++] = 'j'; i+=2; }
else if(!memcmp("abs", in+i, 3)) { stack[s++] = 'a'; i+=2; }
else if(!memcmp("sqrt", in+i, 4)){ stack[s++] = 'r'; i+=3; }
else if(!memcmp("ln", in+i, 2)) { stack[s++] = 'l'; i+=1; }

/* variables & constants */
else if(strchr("xyztuv", in[i])) { out[o++] = in[i]; last = 0; }
else if(in[i] == 'e') { out[o++] = 'e'; last = 0; }
else if(!memcmp("pi", in+i, 2)) { out[o++] = 'p'; last = 0; }
}
else if(strchr("+-", in[i])) {
if(last) {
if(in[i] == '-') stack[s++] = '_';
}else{
if(s > 0 && strchr("_+-*/^scjarl", stack[s-1]))
out[o++] = stack[--s];

stack[s++] = in[i];
last = 1;
}
}
else if(strchr("*/", in[i])) {
if(s > 0 && strchr("_*/^scjarl", stack[s-1]))
out[o++] = stack[--s];

stack[s++] = in[i];
last = 1;
}
else if(in[i] == '^') {
if(s > 0 && strchr("_^scjarl", stack[s-1]))
out[o++] = stack[--s];

stack[s++] = in[i];
last = 1;
}
else if(in[i] == '(') {
stack[s++] = in[i];
}
else if(in[i] == ')') {
while(s > 0) {
if(stack[--s] != '(') {
out[o++] = stack[s];
}
else{
break;
}
}
}
}

--s;
while(s > 0) out[o++] = stack[--s];
out[o] = 0;

ret.syms = malloc(o+1);
strncpy(ret.syms, out, o);

ret.nums = malloc(n * sizeof(double));
memcpy(ret.nums, nums, n * sizeof(double));

return ret;
}

double evalrpn(rpn outx, double x, double y, double z, double t, double u, double v)
{
char *out = outx.syms;
double *nums = outx.nums;
int o = strlen(out);

double numstack[1000];
int ns=0;
int n =0;
int i;

for(i=0; i < o; i++) {
switch(out[i]) {
case '#': numstack[ns++] = nums[n++]; break;

/* variables & constants */
case 'x': numstack[ns++] = x; break;
case 'y': numstack[ns++] = y; break;
case 'z': numstack[ns++] = z; break;
case 't': numstack[ns++] = t; break;
case 'u': numstack[ns++] = u; break;
case 'v': numstack[ns++] = v; break;
case 'p': numstack[ns++] = M_PI; break;
case 'e': numstack[ns++] = M_E; break;

/* operators */
case '_': numstack[ns-1] = -numstack[ns-1]; break;
case '+': numstack[ns-2] += numstack[ns-1]; ns--; break;
case '-': numstack[ns-2] -= numstack[ns-1]; ns--; break;
case '*': numstack[ns-2] *= numstack[ns-1]; ns--; break;
case '/': numstack[ns-2] /= numstack[ns-1]; ns--; break;
case '^': numstack[ns-2] = pow(numstack[ns-2], numstack[ns-1]); ns--; break;

/* functions */
case 's': numstack[ns-1] = sin(numstack[ns-1]); break;
case 'c': numstack[ns-1] = cos(numstack[ns-1]); break;
case 'j': numstack[ns-1] = tan(numstack[ns-1]); break;
case 'l': numstack[ns-1] = log(numstack[ns-1]); break;
case 'a': numstack[ns-1] = fabs(numstack[ns-1]); break;
case 'r': numstack[ns-1] = sqrt(numstack[ns-1]); break;
}
}

return numstack[0];
}

Posted on Oct 14, 2013, 7:36 PM

Respond to this message   

Return to Index


That looks a lot like the one in my IDE

by (Login SMcNeill)
R

It uses a modified shunt system for order of operations and all, but I decided to redo it to something more ERROR friendly. I've got a running example of my new code up here: http://www.qb64.net/forum/index.php?topic=11475.msg98339#msg98339 on the QB64 boards, and it's a LOT more user friendly and error-resistant.

The code used in the IDE is the following, in case you want to compare the 2 routines.

The old uses a system like you posted, the new actually works our string out like a kid would in school. 3 + (10 -2) * 4 becomes 3 + 8 *4 becomes 3 + 24 becomes 27... We can even print out each step along the way to watch what's going on, if we really wanted to. ;D

Old system follows, new system at the link above:
*****************************************************
*****************************************************



TYPE operator
func AS LONG 'The number of function to use
params AS LONG 'The number of parameters the function takes
assoc AS _BYTE '-1 if left assosicative
prec AS LONG 'Precedence
func_flag AS LONG 'If -1, then uses function syntax, like SIN()
END TYPE

REDIM SHARED OPS(20) AS operator, op_names$(20), op_count AS LONG


x$ = "10*COS(30)"
? Evaluate_Expression(x$)


FUNCTION get_token$ (n$)
alphanumeric$ = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_"
numeric$ = "1234567890."
split$ = "(),:;+/*^=-"
n$ = LTRIM$(n$)
f$ = LEFT$(n$, 1)
IF INSTR(alphanumeric$, f$) THEN
count = 0
DO
count = count + 1
f$ = MID$(n$, count, 1)
LOOP UNTIL INSTR(alphanumeric$ + numeric$, f$) = 0 OR count > LEN(n$)
tok$ = MID$(n$, 1, count - 1)
ELSEIF INSTR(numeric$, f$) THEN
count = 0
DO
count = count + 1
f$ = MID$(n$, count, 1)
LOOP UNTIL INSTR(numeric$, f$) = 0 OR count > LEN(n$)
tok$ = MID$(n$, 1, count - 1)
ELSEIF INSTR(split$, f$) THEN
tok$ = f$
ELSEIF f$ = "<" OR f$ = ">" THEN
f2$ = MID$(n$, 2, 1)
IF f2$ = "=" THEN
tok$ = f$ + f2$
ELSEIF (f$ = "<" AND f2$ = ">") THEN
tok$ = f$ + f2$
ELSE
tok$ = f$
END IF
ELSEIF f$ = CHR$(34) THEN
tok$ = MID$(n$, 1, INSTR(MID$(n$, 2), CHR$(34)) + 2)
IF INSTR(MID$(n$, 2), CHR$(34)) <= 0 THEN EXIT FUNCTION
END IF
n$ = MID$(n$, LEN(tok$) + 1)
get_token$ = tok$
' debug_output "Token: " + tok$
END FUNCTION

'Implements a slightly modified shuting-yard algorithm
FUNCTION evaluate_expression$ (expression$)
STATIC setup
IF setup = 0 THEN: setup_op_table: setup = -1

op_stack$ = ""
eval_stack$ = ""
e$ = expression$
DO WHILE e$ > ""
last_tok$ = t$

t$ = get_token$(e$)
found_flag = 0
num = 0
ut$ = UCASE$(t$)
op_num = get_op_num&(ut$)
IF ut$ = "-" THEN
'Special case for '-' sign
IF get_op_num&(last_tok$) > 0 OR last_tok$ = "(" THEN
t$ = "_"
ut$ = "_"
op_num = get_op_num&(t$)
END IF
END IF
IF op_num > 0 THEN
IF op_stack$ > "" THEN
prev_op$ = stack_pop$(op_stack$)
IF prev_op$ <> "(" THEN
prev_op_num = get_op_num&(prev_op$)
IF OPS(prev_op_num).prec >= OPS(op_num).prec THEN
t = stack_push_op_to_eval(eval_stack$, prev_op_num)
ELSE
stack_push op_stack$, prev_op$
END IF
ELSE
stack_push op_stack$, prev_op$
END IF
stack_push op_stack$, ut$
ELSE
stack_push op_stack$, ut$
END IF
ELSE
SELECT CASE LEFT$(ut$, 1)
CASE "("
found_flag = -1
stack_push op_stack$, "("

CASE ")"
found_flag = -1
DO
v$ = stack_pop$(op_stack$)
IF v$ <> "(" THEN t = stack_push_op_to_eval(eval_stack$, get_op_num&(v$))
LOOP UNTIL v$ = "(" OR op_stack$ = ""
IF op_stack$ = "" AND v$ <> "(" THEN EXIT FUNCTION
IF op_stack$ > "" THEN
last_op$ = stack_pop$(op_stack$)
last_op_num = get_op_num&(last_op$)
IF OPS(last_op_num).func_flag THEN
t = stack_push_op_to_eval(eval_stack$, last_op_num)
ELSE
stack_push op_stack$, last_op$
END IF
END IF
CASE "0" TO "9", "&", "."
stack_push eval_stack$, t$

CASE "," 'edit to allow use of commas

CASE ELSE
'v$ = get_define_value_from_array(define_list, t$)
'stack_push eval_stack$, v$
EXIT FUNCTION

END SELECT
END IF
LOOP

DO WHILE op_stack$ > ""
t$ = stack_pop$(op_stack$)
t = stack_push_op_to_eval(eval_stack$, get_op_num&(t$))
LOOP

evaluate_expression$ = eval_stack$
END FUNCTION

SUB stack_push (stack$, t$)
stack$ = t$ + CHR$(0) + stack$
END SUB

'NOTE: returns -1 on success, else returns one of the following:
' >1 -- Returns greater then '0' if eval_stack$ doesn't have enough tokens
' on it to evaluate the number. returned is equal to the number of tokens needed
' -- Reports an error if the operator doesn't have enough tokens on the stack
FUNCTION stack_push_op_to_eval (eval_stack$, op AS LONG)
REDIM poped_values$(10)
ops_needed = OPS(op).params
FOR x = 1 TO ops_needed
poped_values$(x) = stack_pop$(eval_stack$)
IF eval_stack$ = "" AND x < ops_needed THEN stack_push_opp_to_eval = ops_needed - x: EXIT FUNCTION
NEXT x
v$ = execute_op$(op, poped_values$())
IF v$ > "" THEN
stack_push eval_stack$, v$
END IF
END FUNCTION

FUNCTION str_t$ (v AS _FLOAT)
str_t$ = RTRIM$(LTRIM$(STR$(v)))
END FUNCTION

FUNCTION stack_pop$ (stack$)
IF INSTR(stack$, CHR$(0)) THEN
stack_pop$ = MID$(stack$, 1, INSTR(stack$, CHR$(0)) - 1)
stack$ = MID$(stack$, INSTR(stack$, CHR$(0)) + 1)
ELSE
stack_pop$ = stack$
stack$ = ""
END IF
END FUNCTION

'Returns the number in ops() that the operater is
'Else returns -1 if the op isn't in the list
FUNCTION get_op_num& (op$)
o$ = UCASE$(op$)
FOR x = 1 TO op_count
IF op_names$(x) = o$ THEN
get_op_num& = x
EXIT FUNCTION
END IF
NEXT x
get_op_num& = -1
END FUNCTION

SUB setup_op_table ()
add_new_op "NOT", 1, 0, 6, 0
add_new_op "+", 2, -1, 8, 0
add_new_op "-", 2, -1, 8, 0
add_new_op "*", 2, -1, 10, 0
add_new_op "/", 2, -1, 10, 0
add_new_op "", 2, -1, 10, 0
add_new_op "^", 2, -1, 12, 0
add_new_op "MOD", 2, -1, 9, 0
add_new_op "AND", 2, -1, 5, 0
add_new_op "OR", 2, -1, 4, 0
add_new_op "XOR", 2, -1, 3, 0
add_new_op "IMP", 2, -1, 1, 0
add_new_op "EQV", 2, -1, 2, 0
add_new_op "=", 2, -1, 7, 0
add_new_op "<>", 2, -1, 7, 0
add_new_op ">", 2, -1, 7, 0
add_new_op "<", 2, -1, 7, 0
add_new_op ">=", 2, -1, 7, 0
add_new_op "<=", 2, -1, 7, 0
add_new_op "_", 1, 0, 11, 0 'Special: Negation
add_new_op "SIN", 1, 0, 13, -1
add_new_op "COS", 1, 0, 13, -1
add_new_op "TAN", 1, 0, 13, -1
add_new_op "LOG", 1, 0, 13, -1
add_new_op "EXP", 1, 0, 13, -1
add_new_op "ATN", 1, 0, 13, -1
add_new_op "SQR", 1, 0, 13, -1
add_new_op "PI", 0, 0, 13, -1
add_new_op "SEC", 1, 0, 13, -1
add_new_op "CSC", 1, 0, 13, -1
add_new_op "COT", 1, 0, 13, -1
add_new_op "ABS", 1, 0, 13, -1
add_new_op "INT", 1, 0, 13, -1
add_new_op "D2R", 1, 0, 13, -1
add_new_op "D2G", 1, 0, 13, -1
add_new_op "R2D", 1, 0, 13, -1
add_new_op "R2G", 1, 0, 13, -1
add_new_op "G2D", 1, 0, 13, -1
add_new_op "G2R", 1, 0, 13, -1
add_new_op "_RGB", 4, 0, 13, -1
add_new_op "_RGBA", 5, 0, 13, -1
add_new_op "_RED", 2, 0, 13, -1
add_new_op "_GREEN", 2, 0, 13, -1
add_new_op "_BLUE", 2, 0, 13, -1
add_new_op "_ALPHA", 2, 0, 13, -1
add_new_op "_RED32", 1, 0, 13, -1
add_new_op "_GREEN32", 1, 0, 13, -1
add_new_op "_BLUE32", 1, 0, 13, -1
add_new_op "_ALPHA32", 1, 0, 13, -1
END SUB

FUNCTION execute_op$ (func AS LONG, poped_values$())

SELECT CASE func
CASE 1: execute_op$ = str_t$(NOT VAL(poped_values$(1)))
CASE 2: execute_op$ = str_t$(VAL(poped_values$(2)) + VAL(poped_values$(1)))
CASE 3: execute_op$ = str_t$(VAL(poped_values$(2)) - VAL(poped_values$(1)))
CASE 4: execute_op$ = str_t$(VAL(poped_values$(2)) * VAL(poped_values$(1)))
CASE 5: execute_op$ = str_t$(VAL(poped_values$(2)) / VAL(poped_values$(1)))
CASE 6: execute_op$ = str_t$(VAL(poped_values$(2)) VAL(poped_values$(1)))
CASE 7: execute_op$ = str_t$(VAL(poped_values$(2)) ^ VAL(poped_values$(1)))
CASE 8: execute_op$ = str_t$(VAL(poped_values$(2)) MOD VAL(poped_values$(1)))
CASE 9: execute_op$ = str_t$(VAL(poped_values$(2)) AND VAL(poped_values$(1)))
CASE 10: execute_op$ = str_t$(VAL(poped_values$(2)) OR VAL(poped_values$(1)))
CASE 11: execute_op$ = str_t$(VAL(poped_values$(2)) XOR VAL(poped_values$(1)))
CASE 12: execute_op$ = str_t$(VAL(poped_values$(2)) IMP VAL(poped_values$(1)))
CASE 13: execute_op$ = str_t$(VAL(poped_values$(2)) EQV VAL(poped_values$(1)))
CASE 14: execute_op$ = str_t$(VAL(poped_values$(2)) = VAL(poped_values$(1)))
CASE 15: execute_op$ = str_t$(VAL(poped_values$(2)) <> VAL(poped_values$(1)))
CASE 16: execute_op$ = str_t$(VAL(poped_values$(2)) > VAL(poped_values$(1)))
CASE 17: execute_op$ = str_t$(VAL(poped_values$(2)) < VAL(poped_values$(1)))
CASE 18: execute_op$ = str_t$(VAL(poped_values$(2)) >= VAL(poped_values$(1)))
CASE 19: execute_op$ = str_t$(VAL(poped_values$(2)) <= VAL(poped_values$(1)))
CASE 20: execute_op$ = str_t$(-VAL(poped_values$(1)))
CASE 21: execute_op$ = str_t$(SIN(VAL(poped_values$(1))))
CASE 22: execute_op$ = str_t$(COS(VAL(poped_values$(1))))
CASE 23: execute_op$ = str_t$(TAN(VAL(poped_values$(1))))
CASE 24: execute_op$ = str_t$(LOG(VAL(poped_values$(1))))
CASE 25: execute_op$ = str_t$(EXP(VAL(poped_values$(1))))
CASE 26: execute_op$ = str_t$(ATN(VAL(poped_values$(1))))
CASE 27: execute_op$ = str_t$(SQR(VAL(poped_values$(1))))
CASE 28: execute_op$ = str_t$(3.14159265359##)
CASE 29: execute_op$ = str_t$(1 / COS(VAL(poped_values$(1))))
CASE 30: execute_op$ = str_t$(1 / SIN(VAL(poped_values$(1))))
CASE 31: execute_op$ = str_t$(1 / TAN(VAL(poped_values$(1))))
CASE 32: execute_op$ = str_t$(ABS(VAL(poped_values$(1))))
CASE 33: execute_op$ = str_t$(INT(VAL(poped_values$(1))))
CASE 34: execute_op$ = str_t$(0.0174532925 * (VAL(poped_values$(1)))) 'D2R
CASE 35: execute_op$ = str_t$(1.1111111111 * (VAL(poped_values$(1)))) 'D2G
CASE 36: execute_op$ = str_t$(57.2957795 * (VAL(poped_values$(1)))) 'R2D
CASE 37: execute_op$ = str_t$(0.015707963 * (VAL(poped_values$(1)))) 'R2G
CASE 38: execute_op$ = str_t$(0.9 * (VAL(poped_values$(1)))) 'G2D
CASE 39: execute_op$ = str_t$(63.661977237 * (VAL(poped_values$(1)))) 'G2R
CASE 40: 'RGB
scrn = INT(VAL(poped_values$(1)))
IF scrn < 0 THEN execute_op$ = "Bad Screen": EXIT FUNCTION
IF scrn > 2 AND scrn < 6 THEN execute_op$ = "Bad Screen": EXIT FUNCTION
IF scren > 13 AND scrn <> 32 AND scrn <> 256 THEN execute_op$ = "Bad Screen": EXIT FUNCTION
wi& = _NEWIMAGE(240, 120, scrn)
_DEST wi&: _SOURCE wi&
clr~& = _RGB(VAL(poped_values$(4)), VAL(poped_values$(3)), VAL(poped_values$(2)))
_DEST 0: _SOURCE 0
_FREEIMAGE wi&
execute_op$ = STR$(clr~&)
EXIT FUNCTION
CASE 41: 'RGBA
scrn = INT(VAL(poped_values$(1)))
IF scrn < 0 THEN execute_op$ = "Bad Screen": EXIT FUNCTION
IF scrn > 2 AND scrn < 6 THEN execute_op$ = "Bad Screen": EXIT FUNCTION
IF scren > 13 AND scrn <> 32 AND scrn <> 256 THEN execute_op$ = "Bad Screen": EXIT FUNCTION
wi& = _NEWIMAGE(240, 120, scrn)
_DEST wi&: _SOURCE wi&
clr~& = _RGB(VAL(poped_values$(5)), VAL(poped_values$(4)), VAL(poped_values$(3)), VAL(poped_values$(2)))
_DEST 0: _SOURCE 0
_FREEIMAGE wi&
execute_op$ = STR$(clr~&)
EXIT FUNCTION
CASE 42, 43, 44, 45 'Red/Green/Blue/Alpha
scrn = INT(VAL(poped_values$(1)))
IF scrn < 0 THEN execute_op$ = "Bad Screen": EXIT FUNCTION
IF scrn > 2 AND scrn < 6 THEN execute_op$ = "Bad Screen": EXIT FUNCTION
IF scrn > 13 AND scrn <> 32 AND scrn <> 256 THEN execute_op$ = "Bad Screen": EXIT FUNCTION
wi& = _NEWIMAGE(240, 120, scrn)
_DEST wi&: _SOURCE wi&
SELECT CASE func
CASE 42: execute_op$ = STR$(_RED(VAL(poped_values$(2)))) 'Red
CASE 43: execute_op$ = STR$(_GREEN(VAL(poped_values$(2)))) 'Green
CASE 44: execute_op$ = STR$(_BLUE(VAL(poped_values$(2)))) 'Blue
CASE 45: execute_op$ = STR$(_ALPHA(VAL(poped_values$(2)))) 'Alpha
END SELECT
_DEST 0: _SOURCE 0
_FREEIMAGE wi&
CASE 46: execute_op$ = STR$(_RED32(VAL(poped_values$(1)))) 'Red32
CASE 47: execute_op$ = STR$(_GREEN32(VAL(poped_values$(1)))) 'Green32
CASE 48: execute_op$ = STR$(_BLUE32(VAL(poped_values$(1)))) 'Blue32
CASE 49: execute_op$ = STR$(_ALPHA32(VAL(poped_values$(1)))) 'Alpha32
END SELECT

END FUNCTION







SUB add_new_op (nam$, params AS LONG, assoc AS LONG, prec AS LONG, func_flag AS LONG)
STATIC func
func = func + 1
op_count = op_count + 1

IF op_count > UBOUND(ops) THEN
REDIM _PRESERVE OPS(UBOUND(ops) + 10) AS operator
REDIM _PRESERVE op_names$(UBOUND(ops) + 10)
END IF
op_names$(op_count) = nam$

OPS(op_count).func = func
OPS(op_count).params = params
OPS(op_count).assoc = assoc
OPS(op_count).prec = prec
OPS(op_count).func_flag = func_flag
END SUB

FUNCTION replace$ (s$, r$, n$)
e$ = s$
DO WHILE INSTR(e$, r$)
e$ = MID$(e$, 1, INSTR(e$, r$) - 1) + n$ + MID$(e$, INSTR(e$, r$) + 1)
LOOP
replace$ = e$
END FUNCTION

Posted on Oct 15, 2013, 3:35 AM

Respond to this message   

Return to Index


You need to update your math function, Steve.

by Pete (Login The-Universe)
Admin

It should be able to handle 3 * 4 = 11... and then explain how it got that incorrect answer.

Pete happy.gif

Posted on Oct 15, 2013, 9:14 AM

Respond to this message   

Return to Index


Any MATH gurus out there? Who also use QB64??

by (Login SMcNeill)
R

My little calculator project has grown up nicely in my spare time over the last few days. It's now doing several of the "more advanced" math functions, but as I explained on the QB64 boards my skills in some of these areas has gotten quite rusty.

Is there anyone out there in N54-land who can download and check my formulas and such and make certain I've got things proper?

http://www.qb64.net/forum/index.php?topic=11476.msg98342#msg98342

My little calculator now handles:
PI
ARCCOS, ARCSIN, ARCSEC, ARCCOT
SECH, CSCH, COTH
COS, SIN, TAN, ATN
SEC, CSC, COT
LOG, EXP, INT
D2R, D2G, R2D, R2G, G2D, G2R (Degree, Radian, Grad conversion)
^,SQR
*,/

MOD
+,-
,=,,=
AND, OR, XOR, NOT, IMP, EQV commands.

And it's growing in functionality all the time... I'd REALLY appreciate a collaboration with someone with a background in math to double check the formula and processes in here. The job doesn't pay much (anything really), but I'll be happy to put your name on the credits once it's all finished if you want. :D

(As an aside, is there any other math type functions that I should add into this thing that people like/use? Give a list of what you'd like to see added now, and I'll see what I can do to expand it to include those additional functions others might want also. )

Posted on Oct 15, 2013, 11:22 AM

Respond to this message   

Return to Index


Steve meant: Any MATH gurus out there, who also use QB64??

by English Guru (Login The-Universe)
Admin

I do miss the good old days of the Grammar Police around here.

OK, I'm about where Steve is at in the rust dept, probably 20 years further along. I can still keep up with my algebra and geometry, probably because that is what my kid is studying in high school, but trig has all but left my building.

Steve, I would think Michael, Phylogenesis, or ComputerGhost would be your best help, if they read this post.

Somewhere I have my own amortization routine I built. I actually figured out the algorithm from scratch, using geometric progressions, a few years before the first PC's even hit the market. It became one of my first programs. Added the Rule of 78 with it, to calculate most time payments.

Anyway, good luck with it, it looks like it would be fun to build.

Pete

Posted on Oct 15, 2013, 11:44 AM

Respond to this message   

Return to Index


Progress:

by (Login SMcNeill)
R

"Anyway, good luck with it, it looks like it would be fun to build."

I've had a lot of fun getting this little thing up and going. It's been a nice break from everything else, and the project is coming along nicely now. It processes a TON of math things for us, and now it's expanding outward into a command line processing tool...

So far it works with any of the following:


&H hex values
&B binary values
PI
%
ARCCOS, ARCSIN, ARCSEC, ARCCOT
SECH, CSCH, COTH
COS, SIN, TAN, ATN
SEC, CSC, COT
LOG, EXP
INT, _ROUND, FIX
ABS, SGN
D2R, D2G, R2D, R2G, G2D, G2R (Degree, Radian, Grad conversion)
^,SQR, ROOT
*,/

MOD
+,-
<,>,=,<>,<=,>=
AND, OR, XOR, NOT, IMP, EQV commands.

DATE$ -- gives us the current date
TIME$ -- gives us the current time
COMMAND$ -- gives us the command parameters that were passed when our program started, if any
WIKI -- opens up the wiki in our web browser
QB64 -- opens up the main QB64 homepage
FORUMS -- opens up the forums for QB64
WEBCHAT -- a link to the IRC webchat program which can be used to help communicate with people in real time for instant help and sharing of ideas.

D2R$ -- the FUNCTION to turn Deg to Rad
D2G$ -- the FUNCTION to turn Deg to Grad
R2D$ -- the FUNCTION to turn Rad to Deg
R2G$ -- the FUNCTION to turn Rad to Grad
G2R$ -- the FUNCTION to turn Grad to Rad
G2D$ -- the FUNCTION to turn Grad to Degree

RUN:, RETURN -- to execute and get values from single line QB64 code.

SET -- To set a user variable of name A& - Z&, and store a vaule in it.
ANS -- Our previous answer, stored for ease of use and expansion.
A& - Z& -- User variables that hold whatever value they wish to associate with them.

Posted on Oct 16, 2013, 11:39 PM

Respond to this message   

Return to Index


suggestions

by Ben (no login)

Since you have expression parsing down, you could try adding symbolic math stuff. Solve algebric equations, find symbolic derivatives, integrals, simplify expressions, etc. Also, return answers as fractions of integers and products/sums of irrational numbers, etc

Posted on Oct 18, 2013, 11:04 AM

Respond to this message   

Return to Index


Re: suggestions

by (Login SMcNeill)
R

You're getting a little more complex than I needed. I started out working on it for a friend, got wrapped up in the process, and have finally inserted the whole dang thing into the QB64 IDE for ease of access with our code. It does a ton of math things, does some command line processing, stores user variables for future use, allows for 26 quick-insert files/strings, and even works as a command line compiler for single line QB64 programs and returns values from it for us..

It does Math, and a whole lot more! ;D

It'll be up to someone else to teach it algebra though. I've got it where it does all I'd ever want it to do, but the code is open source and free for modification if anyone wants to make changes for their own future projects. happy.gif

Posted on Oct 19, 2013, 8:26 PM

Respond to this message   

Return to Index


QB64 SDL update

by (Login SMcNeill)
R

For those who are still using the SDL version of QB64, I've released another update to the Steve versions of SDL.

http://www.qb64.net/forum/index.php?topic=10251.msg83928#msg83928

v 0.954e1 gives us a new ASCII tool, as well as a new MATH tool. We also add color to the quotes and comments so the text in our IDE looks a little prettier. Things should work in Linux as well as Windows, but I have no way of testing. Give it a shot, see if the new tools would be useful for you, and let me know on the QB64 topic if something errors out or doesn't seem to work as advertised.

I don't check here that often for code and stuff, but I do try and keep current on the QB64 main forums. (I like the code boxes there a lot more than the mess we deal with here with code...)

Enjoy. ;D

Posted on Oct 13, 2013, 3:13 PM

Respond to this message   

Return to Index

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