Author Topic: QB64-Steves v0.954c1/d3  (Read 1682 times)

SMcNeill

  • Hero Member
  • *****
  • Posts: 2414
    • Email
Re: QB64-Steves v0.954a2
« Reply #15 on: January 12, 2013, 06:19:57 AM »
Quote from: Galleon on January 12, 2013, 05:49:50 AM
Quote
This version allows for the use of CONST PI = 4 * ATN(1), as per Clippy's request.
I'd like to welcome you to QB64, SMcNeill, not as a member, user or programmer, but as a developer. Did/Will you add support for any other functions to constants?

You're gonna make me blush!  :)

At the moment, I've also got CONST running where you can use it with _RGB and _RGBA commands for any screen you might like.

Example:
CONST Red = _RGB0(255,0,0) ' This will set RED to 4, as a CONST.
CONST Red = _RGB13(255,0,0) ' This will set RED to 40, as a CONST.

I explain the whole process here: http://www.qb64.net/forum/index.php?topic=10244.0

It doesn't quite follow the same syntax as the rest of qb64 (as there's no _RGB0, _RGB1, .... 13, 256 modes for anything else in QB64, but those commands ARE used in CONST now as well.), but it's a process that I'm quite pleased with.   I can't remember the correct number for all the different color modes, for every color in every screen, and this means I won't need to any more.   I really hope you'll consider adding it to the GL version as well.  :D

(Some day, I'm going to delve more into the CONST command, and skip it out to a unique sub somewhere for extensive preprocessing like this, and see if I can add complete formula support.   It's just hard to always find the time to get into the middle of a large project like that, and I don't want to get started on it and leave off half finished where I'd just confuzzle the bejeebers out of myself when I went back later to work on it again.)

Is there anything in particular that you'd like me to try and play around with some?  I'm actually getting fairly well acquainted with the source now, and don't mind running around inside it looking for things to alter if needed.   I don't promise success with anything, but I'm willing to take a shot at everything at least once.   :)
http://bit.ly/TextImage -- Library of QB64 code to manipulate text and images, as a BM library.
http://bit.ly/Color32 -- A set of color CONST for use in 32 bit mode, as a BI library.

http://bit.ly/DataToDrive - A set of routines to quickly and easily get data to and from the disk.  BI and BM files

OlDosLover

  • Hero Member
  • *****
  • Posts: 3860
  • OlDosLover
    • Email
Re: QB64-Steves v0.954a2
« Reply #16 on: January 12, 2013, 06:22:25 AM »
Hi all,
    Congrats Steve! Well deserved!
OlDosLover.

Clippy

  • Hero Member
  • *****
  • Posts: 16440
  • I LOVE π = 4 * ATN(1)    Use the QB64 WIKI >>>
    • Pete's Qbasic Site
    • Email
Re: QB64-Steves v0.954a2
« Reply #17 on: January 12, 2013, 08:56:37 AM »
Those aren't colors, those are attributes using a palette when not used in 32 bit. _RGB returns either.
QB64 WIKI: Main Page
Download Q-Basics Code Demo: Q-Basics.zip
Download QB64 BAT, IconAdder and VBS shortcuts: QB64BAT.zip
Download QB64 DLL files in a ZIP: Program64.zip

DSMan195276

  • Hero Member
  • *****
  • Posts: 1986
  • Yes
    • Email
Re: QB64-Steves v0.954a2
« Reply #18 on: January 12, 2013, 11:45:06 AM »
I've been meaning to test this on Linux, but I never got a chance until now. And I'm happy to say that it all compiles fine except that you have the case wrong for two to the file names (Which is easily fixed). I'll include my very slightly modified version of the source below, but literally I just changed two lines from ".BAS" to ".bas", nothing major at all, and it all looks like it works. Very nice work :)

Matt
"Cast your cares on the Lord and he will sustain you; he will never let the righteous be shaken" -- Psalm 55:22
QB64 Linux Installer

SMcNeill

  • Hero Member
  • *****
  • Posts: 2414
    • Email
Re: QB64-Steves v0.954a2
« Reply #19 on: January 12, 2013, 12:02:26 PM »
Thanks for testing that Matt.  I don't have access to a Linux/Mac PC everyday, so I was curious if anything was off for those systems.  I'll go in and update the source to use proper case and then put it back up for download later this evening.  I'm glad to see everything works as it should on Linux.  :D
http://bit.ly/TextImage -- Library of QB64 code to manipulate text and images, as a BM library.
http://bit.ly/Color32 -- A set of color CONST for use in 32 bit mode, as a BI library.

http://bit.ly/DataToDrive - A set of routines to quickly and easily get data to and from the disk.  BI and BM files

DSMan195276

  • Hero Member
  • *****
  • Posts: 1986
  • Yes
    • Email
Re: QB64-Steves v0.954a2
« Reply #20 on: January 12, 2013, 12:16:24 PM »
Quote from: SMcNeill on January 12, 2013, 12:02:26 PM
Thanks for testing that Matt.  I don't have access to a Linux/Mac PC everyday, so I was curious if anything was off for those systems.  I'll go in and update the source to use proper case and then put it back up for download later this evening.  I'm glad to see everything works as it should on Linux.  :D

No problem. I didn't test all of your fixes but the CONST stuff works and doesn't generate errors like it would on the regular QB64 would, so I assume everything is working as expected, All my projects that compiled in QB64 compiled in your version.

Matt
"Cast your cares on the Lord and he will sustain you; he will never let the righteous be shaken" -- Psalm 55:22
QB64 Linux Installer

SMcNeill

  • Hero Member
  • *****
  • Posts: 2414
    • Email
Re: QB64-Steves v0.954a2
« Reply #21 on: January 12, 2013, 12:27:39 PM »
Quote from: DSMan195276 on January 12, 2013, 12:16:24 PM
I didn't test all of your fixes but the CONST stuff works and doesn't generate errors like it would on the regular QB64 would, so I assume everything is working as expected, All my projects that compiled in QB64 compiled in your version.

Matt

If you type in CONST Red = _RGB....   Watch the message at the bottom giving IDE status.  From keystroke to keystroke, it should tell you what it's expecting from that point on to generate proper results.  It'll say "please add (" or "please enter valid number from 0 - 255 for Red".  It's got a good bit of error trapping in there now to help diagnose what might go wrong with your input...

The Const Pi doesn't do error checking.  Either you get it right with CONST Pi = 4 * ATN(1), or CONST Pi = Pi, or else it just bugs out and doesn't work.  I figured it was a simple enough format people wouldn't get it wrong very often, so left it to the default error handling routines to catch.  :)
http://bit.ly/TextImage -- Library of QB64 code to manipulate text and images, as a BM library.
http://bit.ly/Color32 -- A set of color CONST for use in 32 bit mode, as a BI library.

http://bit.ly/DataToDrive - A set of routines to quickly and easily get data to and from the disk.  BI and BM files

Omega

  • Sr. Member
  • ****
  • Posts: 377
    • Recall site..
    • Email
Re: QB64-Steves v0.954a2
« Reply #22 on: January 13, 2013, 11:22:38 AM »
Well i'm glad too see a great addition to the team.

SMcNeill

  • Hero Member
  • *****
  • Posts: 2414
    • Email
Re: QB64-Steves v0.954a3
« Reply #23 on: January 14, 2013, 05:27:16 PM »
v 0.954a3 brings quite a few changes to what we can do with CONST in QB64. 

For starters, it removes the old CONST PI = 4 * ATN(1) and CONST PI = PI commands.  They've been replaced with something much prettier and shinier -- the _MATH parameter for CONST!

Inside our math function, we can now use any of the following:

COS  -- cosine
SIN -- sine
TAN -- tanget
ATN -- arctanget
LOG --- log
SQR -- square root
SEC -- secant
CSC -- cosecant
COT -- cotangent
PI -- pi

One thing this expects, is for the user to USE one of these commands in the MATH function.   If you just use CONST x = _MATH(1), it doesn't like that.   I could go in and change this behavior, but I'm not going to.   WHY would someone want to call out to a function to delay things, when they don't need to?

This calculates your values for you as you type, and then sends them back to be processed as a valid input, so on longer instances of code it will make editing in the IDE a bit slower.   (Anything extra for the IDE to process makes it slower...)   Why increase the burden by running it through a function that will basically do nothing, and then send it to process your input, when you can simply send it directly to process your input?

If you need a CONST for 1 + 3 then for goodness sake, type in CONST x = 1 + 3.   Don't try and bog it down with CONST x = _MATH(1 + 3).   Now, CONST x = _MATH(1 + 3 * COS(30)) would work and run fine, as we're actually using the math function.

Some do's and don't's:

DO use one of our 10 functions with _MATH.
DO expect to see an error until you use one of those functions, then the IDE will let you know it's happy, or for you to finsish typing in the rest of the formula...
DON'T try and use this to stack CONST of more than 1 variable per a line.   CONST x = 3, y = 4 works normally.   CONST x = _MATH(COS(30)), y = 4  will NOT.  You've been warned here first.
DON'T give it variables to reference, or even other CONST.  It won't work with those things.  (Though later I'd like to add support for using constants in a constant.  It just doesn't do it -- YET.)
DO expect to see error messages if you try and give it something impossible to solve -- like a SEC that would involve 1/ 0 errors.   Infinity can't be a CONST...


And really, that's about all I can think of.   A good bit of expanded support, and I don't think it's too "unbasic" of a way to use them.   I wish I could have  just plugged these in directly to QB64's normal processes, but that turned out to be a crazier process than I'd want to admit to, and I ended up just abandoning it.   Tossing it into a sub-function really was the simplest way (for me at least), and from all my testing so far, it works as expected now.

Honestly, I'm quite proud of all the little abilities this code adds for us to use with CONST.   And best of all:  it's easily upgradeable and expandable, if I need to go in and teach it something else.   


Example usage:

CONST x = _MATH(1 + COS(30))

It's that simple.  :)

NOTE:   I haven't tried to teach it to do math inside our values yet (and I probably never will really), so don't try and use CONST x = _MATH(COS(14+12*2)).  It won't like that at all and will go blabbity-blah at you and error out...

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

Special thanks to Matt (DSMan195276) for helping to test this version, offer feedback, and help find and locate some of the bugs that were in it.  Thanks also for pointing out the issues that were affecting the Linux version of the source as well, as I've also made certain to go in and fix those also.
http://bit.ly/TextImage -- Library of QB64 code to manipulate text and images, as a BM library.
http://bit.ly/Color32 -- A set of color CONST for use in 32 bit mode, as a BI library.

http://bit.ly/DataToDrive - A set of routines to quickly and easily get data to and from the disk.  BI and BM files

codeguy

  • Hero Member
  • *****
  • Posts: 3552
  • what the h3ll did i name that code?
    • stuff at dkm
    • Email
Re: QB64-Steves v0.954a3
« Reply #24 on: January 15, 2013, 12:44:58 PM »
i suggest NatLogBase, otherwise known as exp(1), which is useful in decay rates, financial calculations and the like. it is easy enough to calculate, but this constant would be helpful for the reasons i have presented.
http://denteddisk.forums-free.com/make-an-appointment-with-the-resident-code-guru-f34.html

SMcNeill

  • Hero Member
  • *****
  • Posts: 2414
    • Email
Re: QB64-Steves v0.954a4
« Reply #25 on: January 21, 2013, 04:21:01 AM »
Update a4:

All credit for this update goes to Matt (DSMan195276).  He basically tweaked the tweak that added _MATH support for our const command, and fixed it so that it can work recursively with itself.

In our last version we could use CONST x = _MATH(COS(30)), but we couldn't use CONST x = _MATH(COS(10 + COS(30))).    Now, we can.   Feel free to stack one command inside another as much as you want.

Many thanks for this Matt!  It's a much appreciated improvement.  :)
http://bit.ly/TextImage -- Library of QB64 code to manipulate text and images, as a BM library.
http://bit.ly/Color32 -- A set of color CONST for use in 32 bit mode, as a BI library.

http://bit.ly/DataToDrive - A set of routines to quickly and easily get data to and from the disk.  BI and BM files

codeguy

  • Hero Member
  • *****
  • Posts: 3552
  • what the h3ll did i name that code?
    • stuff at dkm
    • Email
Re: QB64-Steves v0.954a4
« Reply #26 on: January 24, 2013, 09:03:36 AM »
and in Bit-Twiddling functions, i have a built-in Pi calculator that can calculate pi to the limits of memory or patience, whichever comes first. ;D http://www.qb64.net/forum/index.php?topic=1742.msg15797#msg15797
http://denteddisk.forums-free.com/make-an-appointment-with-the-resident-code-guru-f34.html

OlDosLover

  • Hero Member
  • *****
  • Posts: 3860
  • OlDosLover
    • Email
Re: QB64-Steves v0.954a4
« Reply #27 on: January 25, 2013, 01:45:43 PM »
Hi all,
    Thanks for the update Steve.
OlDosLover.

SMcNeill

  • Hero Member
  • *****
  • Posts: 2414
    • Email
Re: QB64-Steves v0.954a5
« Reply #28 on: January 29, 2013, 01:32:08 AM »
Update v954a5:

An alteration to the _RGB routines which we use inside our CONST.    In the past versions, we were stuck to only one _RGB command per line, but not anymore.

CONST x = _RGB32(255,0,0), y = 3, Steve = "Awesome", z = _RGB256(255,0,0)    will ALL fit onto one line and assign the proper values to our 4 variables here.  (x, y, Steve, z)

Note: This doesn't affect the _MATH function yet, so keep using it with 1 _MATH command per line like you were before.   Hopefully sometime soonish we'll either expand _MATH to work with multiple calls on one line, or else we'll come up with a way to avoid using it completely since it seems to bother some people so much.   
http://bit.ly/TextImage -- Library of QB64 code to manipulate text and images, as a BM library.
http://bit.ly/Color32 -- A set of color CONST for use in 32 bit mode, as a BI library.

http://bit.ly/DataToDrive - A set of routines to quickly and easily get data to and from the disk.  BI and BM files

small no more

  • Sr. Member
  • ****
  • Posts: 252
  • Ask and you will receive, Seek and you will find
    • not launched
Re: QB64-Steves v0.954a5
« Reply #29 on: January 29, 2013, 01:12:16 PM »
Steve,

Is there any way to put Clippy's  currency functions in your QB64 version.



FUNCTION MKC$ (CurrVal AS _FLOAT) 'converts currency amount to PDS or VB currency string
DIM CVal AS _INTEGER64
CVal = CurrVal * 10000 ' multiply float value by 10 thousand
MKC = _MK$(_INTEGER64, CVal)
END FUNCTION



FUNCTION CVC## (CurrStr AS STRING) 'converts currency string to a _FLOAT currency amount
DIM CV AS _INTEGER64
CV = _CV(_INTEGER64, CurrStr)
CVC = CV / 10000 ' divide by 10 thousand
END FUNCTION
« Last Edit: January 29, 2013, 01:20:41 PM by small no more »
A good teacher must be able to put himself in the place of those who find learning hard.


                                           Eliphas Levi