QB64.org Forum

Active Forums => QB64 Discussion => Topic started by: Richard on March 02, 2020, 01:22:57 am

Title: v1.5 128 bit (and beyond) math *** COMPILER ERROR ***
Post by: Richard on March 02, 2020, 01:22:57 am
The preferred method for feature requests AND bugs etc is the link below

https://github.com/QB64Team/qb64/issues (https://github.com/QB64Team/qb64/issues)


When editing an include file for use with the current QB64 program being edited in the IDE - the .exe file generated does not use the latest include file version (unless the programmer remembers to also "edit" the line (and immediately restores the line) where the include file is mentioned).

Feature request - option to auto update to latest versions of any include files referenced when compiling

Summary github
#142   Multi instance launch problem     by Richard   bug
#135   _COPYIMAGE(x, 33) returns -16777214     by all-other-usernames-were-taken   .
#133   PUT with variable length string element UDT (binary)    by FellippeHeitor bug
#131   +=-= etc. operators     by omerhizai404   feature request <wontfix> CLOSED
#126   AutoUpdate for include file     by Richard   feature request
#124   Type suffixed constants not processed by READ statemente     by dkearns
#116   QB64 quits on MacOS Big Sur and won't open again     by loudar CLOSED
#109   problem passing _mem(var) as an argument to a subroutine     by BlameTroi
#104   Unable to Open Source Code     by GeorgeMcGinn
#101   _KEYDOWN shift bug causing keys to stick pressed down     by johannhowitzer bug input handling
#99   OPEN COM flow handling paramters are fragile     by flukiluke bug
#93   QB64 is Slow in Processing     by Barthdry CLOSED
#91   not in repositories     by n3gwgdkearns feature request
#89   PRINT USING HEX output   by Richard   feature request   CLOSED
#88   Option no Title Bar when not in FullScreen mode   by Richard   feature request   CLOSED
#87   AudioUnitInitialize failed   by pforpond
#86   Set Start directory same as file directory   by omerhijazi404   feature request   CLOSED
#85   REDIM (no _PRESERVE) not clearing _BYTE values from array defined AS UDT   by FellippeHeitor   CLOSED
#83   TUI scales to 1/4 of the console window on macOS   by jedixo
#81   Proposal to remove the cberbit.tiff file   by flukiluke   feature request   CLOSED
#79   ENVIRON$() does not work as expected in a for loop when using long DATA statements   by abusetech   bug CLOSED
#78   _CINKEY$   by PQCraft   feature request input handling
#77   Wrong scaling on MacOS   by emlyn
#76   Windows 10 Reqired Program to be ran as Administrator   by RCcola1987
#74   Linux console bug   by PQCraft
#73   binary F##/CHR font format support for text modes   by TheRealHamtaro126   feature request
#72   Implement falcon.h functionality/fixes into QB64   by FellippeHeitor   feature request
#71   Improvments to print unicode content   by douyuan   feature request
#70   Pure TUI mode   by mdpkh   feature request   CLOSED
#69   Cannot see full TUI, weird scaling   by jagot
#68   Code-collapsing/expanding   by loudar   feature request
#67   OPTION EXPLICIT: with paramters   by loudar   feature request   CLOSED
#66   -q flag for quite compilation   by flikiluke   feature request   CLOSED
#63   Length of SUBs / FUNCTIONs in F2 view   by loudar   feature request
#65   _NEWIMAGE color mode additions   by ParzivalWolfram   CLOSED
#64   Variable length strings in types don't compile on macOS   by flukiluke   bug   CLOSED
#62   Crash: abort with empty random access file with fields   by twogood   bug
#61   Script not found error   by elasmojs   CLOSED
#60   QB64 Linux Mint Debian Edition   by ghost
#59   Ability to remove asynchronus.   by real2two   feature request   CLOSED
#58   Tui library   by patrickw99   feature request   CLOSED
#57   Clarify situation about Microsoft copyright on example programs   by ssb22   CLOSED
#56   Modifying an array element in a SUB   by ghost   feature request   CLOSED
#54   PAINT's tiling pattern string   by ghost   feature request   CLOSED
#53   Alternate TUI layout   by lighth7015   feature request
#52   $VERSIONINFO missing product version   by SpriggsySpriggs
#51   TYPE within a TYPE changing string to numerical   by SpriggsySpriggs   CLOSED
#50   Popup showing available elements in a TYPE declaration   by SpriggsySpriggs   feature request
#49   _MOUSEMOVEMENTX and _MOUSEMOVEMENTY don't work.   by PQCraft
#47   Extend to UHD and 5K test for Mac computers.   by familygw   feature request   CLOSED
#46   ACCEPTFILEDROP not working when elevated (run as administrator)   by SpriggsySpriggs   CLOSED
#44   Mac: $PATH issue when converting QB4.5 files in another directory   by johnkharvey   CLOSED
#42   WPF Message Boxes in QB64!   by SpriggsySpriggs  CLOSED
#39   Not sure how to use INKEY$ with _DEST _CONSOLE   by SpriggsySpriggs   CLOSED
#36   Maximize button not functioning as expected   by SpriggsySpriggs
#35   Update Wiki Page for SHELL (function)   by SpriggsySpriggs   CLOSED
#34   Make a CLIPBOARD$() array since Windows 10 has Clipboard   by SpriggsySpriggs   feature request
#33   ALL Sound not working on OSX/macOS   by Pirachy  CLOSED
#32   Clipboard contents my lead to QB64 to crash at startup on MacOS   by Lisias   CLOSED
#31   Cannot use $NOPREFIX and $COLOR in the same code   by SpriggsySpriggs   CLOSED
#29   Allow sound data to be accessible (_MEMSOUND?)   by FellippeHeitor   feature request
#16   EXIT-Code   by bhuebschen   CLOSED
#15   Metacommand to disable program-termination prompt   by bhuebschen   CLOSED
#14   Compilation for macOS devices with Retina displays needs attention   by FellippeHeitor   bug   CLOSED
#12   Optional parameters to SUBs/FUNCTIONs   by QB64Bot   feature request  low priority   CLOSED
#11   Allow definable keyword prefix   by QB64Bot   feature request   CLOSED
#10   SHELL command requiring cmd /c in some scenarios   by QB64Bot   glitch   CLOSED
#9    Compile with -O2 by default   by QB64Bot   enhancement   CLOSED
#8     Allow SHELL to capture stdout of command   by QB64Bot   enhancement
#7     Improve resolution of paths for DECLARE LIBRARY   by QB64Bot   enhancement
#6    `_STDOUT`,`_STDERR` methods?   by QB64Bot   feature request
#5    Array in User Type   by QB64Bot   feature request
#4    No warning is shown when non-_MEM type variable is used with some _MEM functions   by QB6Bot   glitch   CLOSED
#3    `REDIM _PRESERVE` multi-dimensional array shifts data   by QB64Bot   bug
#2    *WIP* Make-based build system   by QB64Bot

Previous Topic Title
v1.5 128 bit (and beyond) math
v1.5 multi instance launch problem  https://github.com/QB64Team/qb64/issues #142
QB64v1.5 AutoUpdate for include file  https://github.com/QB64Team/qb64/issues
QB64 v1.5   Auto update for compiling when include file changed
QB64 v1.5   reply to SpriggsySpriggs challenge answer (re bytes free)

(Previous Topic Title … Fellippe's interpreter option)
QB64 v1.5 Feature Request - interpreter options + other things (quiz QB64 stats))
QB64 v1.5 Feature Request - (from archives) interpreter  + ...(quiz QB64 stats)) 
QB64 v1.5 Feature request - A meaningless request for IDE
                                        - Meaningless IDE request,multiwindows,[abandoned, outdated and now likely malicious qb64 dot net website - don’t go there] stats
                                        - new string functions
                                        - new string functions, multi-variable FOR-NEXT
QB64 v1.5 Feature -new string fns, multi-var FOR-NEXT,autofill block statements)
QB64 v1.5 -new string fns,multi-var FOR-NEXT, autofill block statements, var debug)
QB64 v1.5 stringFns,multi-varFOR-NEXT,autofill░statements,debug, IDE auto refresh
QB64 v1.5 $Fns,multivarFOR-NEXT,autofill░statements,debug,IDErefresh, TITLE bar
QB64 v1.5      MOVe   &   REName    statements for files and directories
QB64 v1.5 MOVE & RENAME statements files/directories,   IDE hotkey expansion
QB64 v1.5 MOVE & RENAME files/directories,IDE hotkey expansion,   Win KB->bytes
QB64 v1.5   Statement(s) force program run on selected physical/logical processors
QB64 v1.5   Additional Code Select Options (for Forum Reply / New Topic)

QB64 v1.5   IDE help

QB64 v1.5   PRINT USING HEX output   (https://github.com/QB64Team/qb64/issues)

Would be useful to have Fellippe's interpreter as part of QB64 even if for only testing out small code fragments at a time.
Title: Re: QB64 v1.5 Feature Request - Fellippe's interpreter option
Post by: freetrav on March 02, 2020, 08:35:31 am
There's no +1 button on the forums!  I need a +1 button!
Title: Re: QB64 v1.5 Feature Request - Fellippe's interpreter option
Post by: TempodiBasic on March 04, 2020, 09:48:44 am
Hi
now I can say my thought...

the  Fellippe's interpreter of Qb64 is very fun! It can be cool!

Generally
I think that it is not so good to use an interpeter like in the old old old times...
I remember that using the Qbasic.exe  (an interpeter that cannot make and exe)
I was used to write quickly some code and press F5 without make any project of code...
so I think that an immediate interpreter,  I know  only Basic like this,
let you take easily the habit to project poorly your application...
and in this point of view I think about this affirmation
https://www.brainyquote.com/quotes/edsger_dijkstra_201164 (https://www.brainyquote.com/quotes/edsger_dijkstra_201164)
https://softwareengineering.stackexchange.com/questions/7747/do-you-think-that-exposure-to-basic-can-mutilate-your-mind (https://softwareengineering.stackexchange.com/questions/7747/do-you-think-that-exposure-to-basic-can-mutilate-your-mind)
an immediately interpreter let you prefer the "Type and Run" despite the think, plan, type and run.

So the presence of interpreter into the QB64IDE as a fix part and not as an optional part that can be activated on request of user  can add quicksand to the IDE thinking about who is not a veteran of programming but he is just a beginner.
:-) who beginner driver doesn't drive a spider car if he has available it?

Reference
Spider https://rcs.cdn.publieditor.it/w640/M1313_00.jpg (https://rcs.cdn.publieditor.it/w640/M1313_00.jpg)
https://rcs.cdn.publieditor.it/w640/M1137_00.jpg (https://rcs.cdn.publieditor.it/w640/M1137_00.jpg)
Title: Re: QB64 v1.5 Feature Request - Fellippe's interpreter option
Post by: bplus on March 04, 2020, 12:06:53 pm
Is that what you guys are looking for, an Immediate Window?

So you can test a snippet of code.
Title: Re: QB64 v1.5 Feature Request - Fellippe's interpreter option
Post by: freetrav on March 05, 2020, 07:03:51 am
Is that what you guys are looking for, an Immediate Window?

So you can test a snippet of code.

That's part of it; another part of it is for scribbling up quick-and-dirty one-offs - the kind of thing that other people might do in bash, powershell, python, windows batch, etc.
Title: Re: QB64 v1.5 Feature Request - Fellippe's interpreter option
Post by: bplus on March 05, 2020, 12:38:08 pm
That's part of it; another part of it is for scribbling up quick-and-dirty one-offs - the kind of thing that other people might do in bash, powershell, python, windows batch, etc.

When I first came back to BASIC in Sept, 2014, I used SmallBASIC, pure interpreter, Types are automatic including User Defined. For "scribbling up quick-and-dirty one-offs", you could do worse + it's in our familiar Basic that is also branch off from QB45. But, I don't know I do these all the time with QB64 now too.

QB64 IDE Help does math, did you know?
Title: Re: QB64 v1.5 Feature Request - Fellippe's interpreter option
Post by: dbosely on March 23, 2020, 11:32:06 pm
What I would like is the ability to step through my running code, and check variables as they are encountered.  I have programmed for over 40 years (Now my age is 84 and still programming) and I have used many of the flavors of Basic (Commodore, GWBasic, QB, QB 4.5, VB For Dos, VB 3.0, 4.0 and 6.0, etc).  The ability to step-through code as part of the IDE is a tremendous help when debugging an app.  Also the ability to set break points and check the state of variables during a 'run' greatly facilitates debugging.  I really, really miss that in QB64!

As a work-around I insert code to display variables along with a 'Sleep' statement. A poor solution, though.

Just my two cents.

Darrell
Title: Re: QB64 v1.5 Feature Request - Fellippe's interpreter option
Post by: bplus on March 23, 2020, 11:42:56 pm
Hi dbosely,

Wow 84, cool! There is now a $CONSOLE option, Ashish was using to good effect in Smart Snake thread.

Oh Fellippe has made vWatch for watching variables as you step through program but for me, a little tricky to figure out.

VB for DOS one of my favorites.
Title: Re: QB64 v1.5 Feature Request - Fellippe's interpreter option
Post by: Richard on March 24, 2020, 12:32:48 am
Prior to QB64 I used Microsoft PDS 7.1 (essentially an upgrade from QB45) which had the features dbosely mentioned.

Overall, if programming without the very nice improvements of QB64, I still prefer PDS 7.1 because of the above features mentioned. In the early days I used to write the code on paper first - but now I always keyboard the code instead. Whereas on paper I could put "circles and arrows", I can rapidly do changes (with comments) on screen - and save some trees in the process.

I have briefly used Fellippe's  vWATCH, but personally found it to be lacking for my taste, beside the fact that it is not automatically integrated as part of the QB64 package.

Yes QB64, by its "C" nature apparently has to be  "compiled first", whereas PDS 7.1 was interpreted based (but automatically produced compiled exe). However because QB64 as a guess has been "run" millions of times, it is justifiable to have "advanced debugging capabilities - such as program tracing, watchpoints etc. vWATCH sort of showed it was possible to have these debugging features - maybe vWATCH could be integrated into the IDE as default (option selectable?).

It was interesting to read, from so long ago, that when Galleon was developing QB(64) in the very early days - at one stage he actually used PDS 7.1 to create the QB(64) builds - but eventually PDS 7.1 could not handle the greatly increased QB(64) files. However, sadly Galleon did not want to, it seems, incorporate advanced features of PDS 7.1 and stuck only with QB45 (QB) features (which are a subset of PDS 7.1).

There will be those who would argue that the program should be "well thought out" before keying in - however in my case, where programs run into thousands of lines long it is impossible to predict all programming situations and the result being an massively "inflated" program size from my original program concepts. 

I have experimented  running two instances of QB64 simultaneously (on the one computer) - the first instance was my original program (this instance ONLY for program editing) - the second instance "imported" the program, did some minor changes (such as putting in "Line Numbers", "Trace Points", etc) and ran this slightly modified program and gave me a "TRON-TROFF" simulation (with vast improvements such as in addition to showing line numbers (which correspond to the IDE line numbers of the first instance of QB64 (i.e. the "editing" instance) - it also displayed the actual program line code as well, etc). This approach was quite workable for me.
Title: Re: QB64 v1.5 Feature Request - Fellippe's interpreter option
Post by: CBTJD on March 24, 2020, 01:27:56 pm
For my two cents...
Being able to quickly enter a snippet of code and run it through an interpreter instead of compiling in order to gain a better understanding of certain commands or constructs sounds very appealing.
Title: Re: QB64 v1.5 Feature Request - Fellippe's interpreter option
Post by: STxAxTIC on March 24, 2020, 06:37:45 pm
I'm with Tempodibasic on this one - I like the concept of being able to pause what code you're working on, go to another area, and quickly test some short code without disrupting your flow... Don't we all like that? Hopefully nobody is dunning DOS anymore, and we all have a system that can multitask, so honestly it would be redundant and unnecessarily difficult to implement and maintain anyone's interpreter as embedded in the IDE. Just pop open a new window and have a ball, right?
Title: Re: QB64 v1.5 Feature Request - Fellippe's interpreter option
Post by: Richard on March 24, 2020, 08:11:16 pm
In theory it may sound nice to just try a "snippet of code" in a "stand alone" testing environment.

In the case of "dynamic testing program enhancements" (for want of a better phrase) - it would be time consuming and fairly difficult (I claim) to mimic the effect (as say  "static testing program enhancements" - by way of independent snippets). For my programs, the program is still running (until it reaches preset "breakpoints", "flags", etc) and various files are open, arrays preloaded, etc - (and can take some hours to reach certain conditions).  Independent snippets, in my case, would need to access these same "opened" files,etc - and the same file, etc being accessed (and open) at the same time by two program instances (same calling program or different calling programs) NEVER plays well for me. If I close my program, to close the opened files, etc I may have to restart my long-running program using initial conditions.

In my case with a program thousands of lines long, "new things" need to be done/tested after say a thousand lines of code.  To replicate the effect to be tested into a stand alone code snippet might require the snippet to be many hundreds of lines (of course everyone would have varying degrees of code snippet sizes).



If one was simply wanting to know "what if I did …" say     Print &HFFFFFFFF& AND OR NOT XOR NEG &HFFFFFFFF&&      (as a silly example) then an independent code snippet environment (one line long in this case) may be sufficient.
Title: Re: QB64 v1.5 Feature Request - Fellippe's interpreter option
Post by: STxAxTIC on March 24, 2020, 09:04:21 pm
I'm totally with you man - so all I can say is keep his interpreter open in a second window.

I'm not being cheeky, either. This is for a deeply technical reason. I have no clue what I'm really saying, but it makes a lot of sense. So QB64 is compiled, sent off to C++-land, where your original source code, at run time, is basically meaningless. Without something like vWATCH, you can't pause and go line-by-line in QB64 code like you could in the old days. How does vWATCH achieve this? A whole lot of work. It's not taking advantage of anything native in QB64 that lets you interrupt and go line by line.

Why rant about that at all? This reason: If we attach an interpreter, it'll be a separate animal than QB64 itself. Yes, an embedded interpreter could be maintained to do the same behavior as QB64, basically doubling Fellippe's work (or worse). Or perhaps combining the interpreter with vWATCH technology, one can conceive of a borg-cube-like IDE that lets you pause your code, make changes as its going, run snippets as you've paused - all that. It can be done. I can even see it happening with what we already have.

But we're doing some Tower of Babel stuff there. It might get too high, and God may come down, smash the project, and send us our separate ways, speaking other languages. How fitting an image.
Title: Re: QB64 v1.5 Feature Request - Fellippe's interpreter option
Post by: Richard on March 24, 2020, 11:14:48 pm
Thanks STxAxTIC for your reply.

I will give Fellippe's vWATCH another "try" (and also try to refine my dual QB64 instance approach).

Previously, whenever I had used vWATCH it was always only when a new "version" of QB64 was released. For some reason I always had trouble installing vWATCH - the problem being that the vWATCH files did not go to the proper folders.

Could Fellippe please tell me exactly where each vWATCH file has to go (in the QB64 v1.4 folder set) - so that I can double check that the vWATCH unzipping process was correct for me? Often I was one or two folder levels out preventing proper running of vWATCH.

Could Fellippe please have vWATCH as part of the QB64 zip file - so that it is guaranteed that vWATCH is installed in the correct folders (even if QB64 does not access vWATCH)?

Some thirty years ago, PDS 7.1 was released and I am still impressed with all that it could do (though pales in comparison with QB64) and to work with 640K RAM. Like so many MS products, "if it works then replace it with something that does not work as well". It is difficult to find a working computer (x16) so to run PDS 7.1 I use DOSBox (but there are limitations).

Imagine if the present computer hardware advances we take for granted today were present some thirty years ago … We might have had PDS 10.1 today, using the programming methodology of PDS 7.1 with even many more features than QB64 present and in the pipeline.

I will, for myself, follow the PDS 7.1 "Tower of Babel" approach (but using existing QB64 features as the backbone - by way of dual instances of QB64). The "PDS 7.1 Tower of Babel" did not really fall down - just got "lost" in time. Who knows, maybe one day QB64 will take on some "proven" programming concepts from PDS 7.1.

Title: Re: QB64 v1.5 Feature Request - Fellippe's interpreter option
Post by: Richard on April 02, 2020, 06:35:22 am
Just some further information which may be of interest to some.

Below is a "Dynamic HTML file" (I do not know how to convert this file to a "Static HTML file) - so it will not be "pretty" (sorry).

Quote


 

   
News:
Instructions for creating Android Apps:
http://www.[abandoned, outdated and now likely malicious qb64 dot net website - don’t go there]/forum/index.php?topic=13162.0

Home
Help
Search
Login
Register

QB64 Community »
General »
Beginner's Help (Moderators: Galleon, OlDosLover, SMcNeill, Kobolt) »
Testing is slowed down by creating the executable every time

« previous next »
Print
Pages: [1]
 Author Topic: Testing is slowed down by creating the executable every time  (Read 1510 times)
ascii
Newbie

Posts: 25

 
Testing is slowed down by creating the executable every time
« on: January 05, 2016, 06:22:02 am »

Every time I change a single thing in my program, it creates an exe if run. It takes a 'lot' of time. In a previous BASIC, such wasn't the case. It ran instantly.
Can't I skip making the exe?

 Logged

Johny B.
QB64 Partner Site Owner
Hero Member

 
Posts: 1539

 
Re: Testing is slowed down by creating the executable every time
« Reply #1 on: January 05, 2016, 06:25:50 am »

Short answer: nope, that's just not the way QB64 works. It's purely a compiler.

I'm sure someone else will give you the longer answer.

 Logged

DonW
Jr. Member

Posts: 70

 
Re: Testing is slowed down by creating the executable every time
« Reply #2 on: January 06, 2016, 12:00:32 am »

I agree with ascii...to be truly useful in debugging a complex program, QB64 needs an interpreter in addition to a compiler.

I have taken complex QB45 programs that run/compile just fine with QB45.  But often times when I load the same .bas code into QB64, I get an "OK", however, when I compile the code, the .exe often times executes with improper results.  There seems to be no way to debug things in a manner like the QB45 interpreter.

 Logged

notemeal
Full Member

 
Posts: 160
I think I may have coded myself into a comma,,,

 
Re: Testing is slowed down by creating the executable every time
« Reply #3 on: January 06, 2016, 04:26:17 pm »

Maybe the solution is to get a more capable machine.  I got a used Toshiba laptop running Windows 10 with an older core i7-2670QM processor, maxed out the memory from 6 to 8 gb and dropped in a 256 gb SSD. This thing kicks butt.  I have been doing some work on a program that is about 2300 lines and an attached library of about 700 lines giving a total of about 3000 lines.  I think that each time I change something in the program, with the exception of when I am editing (in other words after editing the current line is done), it reloads the library in case it has changed.  That is where the large memory comes into play as the library is already in a buffer in memory and only takes a fraction of a second to load.  You know your program is getting large when, upon hitting F5,  the status line reads "Checking program   (editing will cancel request)" or something like that.

When I hit F5 to recompile and run the program, it takes about 2 or 3 seconds which, in my book is acceptable.   If I do that a second time right after the program is run, it runs instantly as both the program and library are in memory and there is an almost unnoticeable lag.  If it were 10 or 15 seconds or more, that would be unacceptable.

Contrast that with an older HP laptop I have running XP with 1 gig of memory and a regular 120 gb HDD.  Under the best of circumstances where I am running only QB64 there is a noticable lag even when I am just editing a large program.  So just for laughs, in order to consume a bunch of memory, I fired up Chrome (Chrome eats up memory quicker than anything else) and had less memory available.  It got to the point that, after each edit, there was a noticable lag before I could do anything else!  For even more laughs I loaded up enough tabs in Chrome so that I only had a few megabytes of Physical Memory left and I knew that the machine would have to use virtual (hard drive) memory.  It took well over a minute to compile and run!  Now, THAT is a pain in the rear, especially when you remember that one little edit your forgot before pushing F5 which means that you have to edit and recompile it again.  I would find programming in QB64 much less enjoyable on that machine.

So the upshot of this is that, if you could find a good laptop  I got the Toshiba for about $200 and paid $30 for the memory and about $90 for the SSD you could have a machine where it really makes no difference if you are running an interpreted or compiled BASIC.


 Logged
There would be a signature here but the signature-generating app is offline due to a cloud malfunction and various TCP/IP proxy anomalies due to the UN name server errors on the various internets.

bobtheunplayer
Full Member

 
Posts: 134
I'd rather be coding.

 
Re: Testing is slowed down by creating the executable every time
« Reply #4 on: January 06, 2016, 07:42:00 pm »

GCC itself is pretty fast.  I've got some C programs that are several thousand lines in size spread out over many files and I use Make to compile after changes and at most its 3 seconds to compile.

With QB64 the time consuming issue is the translation of QB64 code into C++ code then GGC compiles the translator output.  If the translator could be further optimized for speed, the perceived compile performance would be significantly improved.

Code: [Select]
--------------------    -------------------    -------    ----------
| QB64 Source Code | -> | QB64 Translator | -> | GCC | -> | Binary |
--------------------    -------------------    -------    ----------
 
But for now, you might take notemeal's advice and get a faster computer (>= i5 and SSD).

~b

 Logged

Johny B.
QB64 Partner Site Owner
Hero Member

 
Posts: 1539

 
Re: Testing is slowed down by creating the executable every time
« Reply #5 on: January 06, 2016, 08:28:27 pm »

When the IDE says "..." or "checking program" it's producing C++ code; when it says "creating .exe file" or "creating executable" it's running g++.

 Logged

notemeal
Full Member

 
Posts: 160
I think I may have coded myself into a comma,,,

 
Re: Testing is slowed down by creating the executable every time
« Reply #6 on: January 06, 2016, 09:23:21 pm »

Thanks for that Johnny B Good.  I was wondering about that, especially the "...".  Why not just indicate "Making C++ Code"...
Also, what is g++  (that is the first time in my life that I have used a smiley and the reason is my question mark is not working as I accidentally spilled some coffee in that area of the keyboard - never drink and code or comment - I should just sign off and put the machine in the dryer on fluff for half an hour...)  Also, I tried the alt key code thing and it did not work.  Funny thing is, I always got it to work under DOS with the 3-digit codes but for whatever reason I can't with the Windows 4-digit codes.

 Logged
There would be a signature here but the signature-generating app is offline due to a cloud malfunction and various TCP/IP proxy anomalies due to the UN name server errors on the various internets.

bobtheunplayer
Full Member

 
Posts: 134
I'd rather be coding.

 
Re: Testing is slowed down by creating the executable every time
« Reply #7 on: January 06, 2016, 10:52:17 pm »

Quote
...what is g++...


g++ is the GNU C++ compiler.
http://gcc.gnu.org/

 Logged

Dark Star
Hero Member

 
Posts: 1029

 
Re: Testing is slowed down by creating the executable every time
« Reply #8 on: January 07, 2016, 12:00:50 am »

As far as I am concerned (take this as you will any other opinion), the extra compilation time is simply the price we pay for having access to the full potential of a modern 32 or 64-bit machine with BASIC.  As has been mentioned, intelligent use of _TITLE statements, PRINT and SLEEP, custom-written debug files, etc. more than makes up for the lack of ability to assign breakpoints and such.  Don't get me wrong; I love breakpoints, but I can live without them.  If I were more familiar with C/C++ and the translation of BASIC to C++ then I might be able to make use of gdb or other means, but for a hobbyist programmer such as myself the above-mentioned methods are more than sufficient.  What must change is the programmer's state of mind.  It's almost like the transition from driving a stick shift to an automatic car, you give up control, but you gain ease-of-use.  To put it another way, do any of us really want to go back to the limitations of DOS and QB45?  Hell no.   

 Logged

ascii
Newbie

Posts: 25

 
Re: Testing is slowed down by creating the executable every time
« Reply #9 on: January 07, 2016, 12:10:34 am »

Quote
Maybe the solution is to get a more capable machine.

I already have an 8-core i7 with 16GB and a 250GB SSD. But I don't use Win10; I use Win7. I really see no pro's for me, in Win10.

In fact, I had QB64 reside on my HDD; not on the SSD. I just moved it to the SSD. Result: the creating of the exe isn't faster (at the moment it is even slower). I have a small program (maybe 50 lines of code); on the HDD it takes about 3 to 6 seconds to create the exe (I don't know why it differs); on the SSD it took 5 seconds (well, I only tested once on the SSD).
Can I disable graphics in QB64 itself, so that, when creating the exe, it will go faster?

 Logged

notemeal
Full Member

 
Posts: 160
I think I may have coded myself into a comma,,,

 
Re: Testing is slowed down by creating the executable every time
« Reply #10 on: January 07, 2016, 01:34:14 am »

@american standard code for information interchange:

I don't know why you would have any lag at all with your machine specs. Yes there is always a momentary lag but that is necessary with the translation and compilation(s) that take place when you hit F5.  Maybe you were just too used to using something like QB45 where the program did indeed run instantaneously as it was dynamically translated to binary and was resident all the time on the machine.  There is a subtle but important distinction between instant and a lag of even a couple of seconds.  All I can say is that, over time, I have got used to that second or two lag and I am in agreement with Dark Star that, given the new bells and whistles that come with QB64, I do not even think of using QB45.  And yes, breakpoints and watchpoints etc were great but I still feel that, given the capabilities of QB64 we come out ahead.  Maybe we can take up a collection to buy enough pizza and coke to lock up one of the resident geniuses (4+ stars) on this board and force them to code a credible Debug menu for the QB64 IDE.

@Dark Star
It never occurred to me to use _TITLE as a way of dynamically displaying variable values much the way watchpoints were used in QB45.  That was the kind of thing I was looking to accumulate in the thread I started a few days ago "for noobs like me".  I saw it as a way to transition noobs from say QB45 to QB64 and kind of fill in oh so missed breakpoints and watchpoints.

Finally, in other news, even after tossing this laptop in the dryer for a half hour, my arrow keys and question mark slash slash key is not working so I can pose no further questions until I get the keyboard I ordered off eBay.  The major change I noticed is that my screen is now oval...

 Logged
There would be a signature here but the signature-generating app is offline due to a cloud malfunction and various TCP/IP proxy anomalies due to the UN name server errors on the various internets.

ascii
Newbie

Posts: 25

 
Re: Testing is slowed down by creating the executable every time
« Reply #11 on: January 07, 2016, 02:34:40 am »

Quote from: notemeal on January 07, 2016, 01:34:14 am
Finally, in other news, even after tossing this laptop in the dryer for a half hour

What kind of dryer do you use? When a family member dropped a photo camera in a river, I used a hair dryer on it for a few hours. It functioned reasonably well, after.
But maybe something burned through, in your case.

On topic:
I just did a test with this program:
 print "Hello, world"
It took about 11 seconds before it showed result.
Another run: about 25 seconds!
« Last Edit: January 07, 2016, 02:42:26 am by ascii »
 Logged

notemeal
Full Member

 
Posts: 160
I think I may have coded myself into a comma,,,

 
Re: Testing is slowed down by creating the executable every time
« Reply #12 on: January 07, 2016, 04:40:27 am »

Wow, there is something definitely wrong there.  I actually copied an pasted your code ( print "Hello, world" ) in a fresh QB64 window and literally timed it.  It ran a fraction after 3 seconds and instantly the second time I pressed F5.  Do you have any other machines around where you might be able to compare times (question mark)

As for the dryer thing, I was merely trying to bring a moment of levity to an otherwise staid, formal setting.  The spill part is true, the dryer is not.  I hope that the forum gods will let it slide as I don't want to get locked up somewhere and forced to code until I come up with a Debug item for the QB64 IDE...

 Logged
There would be a signature here but the signature-generating app is offline due to a cloud malfunction and various TCP/IP proxy anomalies due to the UN name server errors on the various internets.

DonW
Jr. Member

Posts: 70

 
Re: Testing is slowed down by creating the executable every time
« Reply #13 on: January 07, 2016, 12:08:59 pm »

Quote
What must change is the programmer's state of mind.  It's almost like the transition from driving a stick shift to an automatic car, you give up control, but you gain ease-of-use.  To put it another way, do any of us really want to go back to the limitations of DOS and QB45?


The only real limitation to QB45 was memory limitations, not coding/debugging.  Of course, one could not use it for "true" windows applications, but for creating applications for doing real work, it was just fine.

QB64 has long been promoted as being a QB45 compatible compiler as in the following banner on the home page:
Quote
Over 50 years of BASIC compatibility and (as close as we can get without being an emulator like DOSBOX) 100% compatible with MS QBASIC/QB4.5 code


However, I have found this not to be entirely true.  I have been able to take some of my QB45 programs, compile them with QB64, and see that .exe's work as expected.  However, I have also experienced instances of loading very large and complex QB45 programs, get an "OK" in the IDE (which I take means no syntax errors), but when I compile them, they don't execute properly.  I don't get any run-time errors...they just don't work correctly and give me extraneous results.

So if there is a way to set break points and examine variable values in real time (like with the QB45 interpreter) in order to debug incorrect results, I'd appreciate someone pointing me to that methodology with QB64.  Thanks.

 

 Logged

bobtheunplayer
Full Member

 
Posts: 134
I'd rather be coding.

 
Re: Testing is slowed down by creating the executable every time
« Reply #14 on: January 10, 2016, 01:05:57 am »

Quote
I just did a test with this program:
 print "Hello, world"
It took about 11 seconds before it showed result.


Maybe you have a virus or something hogging up your resources?

I got a two-year-old macbook and a simple print "hello world" showed in about 2 seconds.

~b

 Logged

Print
Pages: [1]
« previous next »
QB64 Community »
General »
Beginner's Help (Moderators: Galleon, OlDosLover, SMcNeill, Kobolt) »
Testing is slowed down by creating the executable every time

 


SMF 2.0.3 | SMF © 2011, Simple Machines
XHTML
RSS
WAP2

Title: Re: QB64 v1.5 Feature Request - interpreter options
Post by: Richard on April 21, 2020, 05:35:30 am
Looking back to others attempts to an interpreter...

Extract from dynamic HTML below:-

Quote



 

   
News:
Instructions for creating Android Apps:
http://www.[abandoned, outdated and now likely malicious qb64 dot net website - don’t go there]/forum/index.php?topic=13162.0

Home
Help
Search
Login
Register

QB64 Community »
Programs (.BAS), Tutorials and Libraries ($INCLUDE, DECLARE LIBRARY, ...) »
Sample Programs (Moderators: Galleon, OlDosLover, SMcNeill, Kobolt) »
Return of the possibly useless interpreter

« previous next »
Print
Pages: [1]
 Author Topic: Return of the possibly useless interpreter  (Read 620 times)
rks
Newbie

Posts: 34

 
Return of the possibly useless interpreter
« on: December 07, 2015, 09:47:22 am »

This is an interpreter I've written based (very) loosely on ASM, I dust it off occasionally and tinker with it, this is one of those occasions.  I've also written an editor to go with it this time.  Unzip it all in a folder, compile the interpreter with or without the editor and have at it.  There are some demo scripts and a game.  It's something to kill time with when things are slow.

r


 sscript21.zip (39.36 kB - downloaded 63 times.)
« Last Edit: December 07, 2015, 02:08:59 pm by rks »
 Logged

FellippeHeitor
QB64 Partner Site Owner
Hero Member

 
Posts: 1806
LET IT = BE

 
Re: Return of the possibly useless interpreter
« Reply #1 on: December 07, 2015, 10:23:39 am »

Looks like it was a lot of work. Everything worked as expected here. Congrats!
« Last Edit: December 07, 2015, 10:34:36 am by FellippeHeitor »
 Logged
- InForm for QB64 http://qb64.org/inform

- vWATCH64 (debugger for QB64) http://bit.ly/vWATCH64v1-103

- Games: http://bit.ly/2048_qb64 * http://bit.ly/ClonedShades_qb64source * http://bit.ly/2aqK866 * http://bit.ly/SpaceshipQB64 * http://bit.ly/2rD1pPP

FellippeHeitor
QB64 Partner Site Owner
Hero Member

 
Posts: 1806
LET IT = BE

 
Re: Return of the possibly useless interpreter
« Reply #2 on: December 07, 2015, 10:30:15 am »

You may want to correct line 94 on the script for Nightfall; it seems like it should read:
Code: [Select]
$rndm 2,12
« Last Edit: December 07, 2015, 10:35:46 am by FellippeHeitor »
 Logged
- InForm for QB64 http://qb64.org/inform

- vWATCH64 (debugger for QB64) http://bit.ly/vWATCH64v1-103

- Games: http://bit.ly/2048_qb64 * http://bit.ly/ClonedShades_qb64source * http://bit.ly/2aqK866 * http://bit.ly/SpaceshipQB64 * http://bit.ly/2rD1pPP

rks
Newbie

Posts: 34

 
Re: Return of the possibly useless interpreter
« Reply #3 on: December 07, 2015, 01:14:07 pm »

You are correct, there are several $rdm's that should have been $rndm, that was a late change and I forgot about it.  Thanks. 

r

 Logged

rks
Newbie

Posts: 34

 
Re: Return of the possibly useless interpreter
« Reply #4 on: December 07, 2015, 01:34:35 pm »

I've posted a corrected .zip file.

 Logged

Print
Pages: [1]
« previous next »
QB64 Community »
Programs (.BAS), Tutorials and Libraries ($INCLUDE, DECLARE LIBRARY, ...) »
Sample Programs (Moderators: Galleon, OlDosLover, SMcNeill, Kobolt) »
Return of the possibly useless interpreter

 


SMF 2.0.3 | SMF © 2011, Simple Machines
XHTML
RSS
WAP2



I do not have the zip file - maybe a forum member does?
Title: Re: QB64 v1.5 Feature Request - interpreter options
Post by: CBTJD on April 25, 2020, 12:49:42 pm
Thinking of other possible features for 1.5, here is one.  How about having it automatically minimize the QB64 window when you run the program and then returns when you exit the program.

Something I thought of some may also like.  Just a thought.
OOh, I like it! Sounds like a good idea.
:@)
Title: Re: QB64 v1.5 Feature Request - interpreter options
Post by: Pete on April 25, 2020, 01:00:27 pm
I wouldn't use it, but I'd like it as an option, anyway. If I'm building a program, I like to leave the IDE on the desktop, just in case the program throws an error. Then I'd just click the SEARCH tag and pop in the line number. Can you believe in 40 years of programing, I've never had to do that? If so, I've got some left over Toilet Duck you can inject.

Pete
Title: Re: QB64 v1.5 Feature Request - interpreter options + other things (quiz QB64 stats)
Post by: Richard on May 10, 2020, 08:49:11 am
Quiz Question:-


From the old [abandoned, outdated and now likely malicious qb64 dot net website - don’t go there] days what author-topic was most viewed (and approximately how many views).



The answer for the topic title does not have to exactly match and a tolerance of +/- 25% (maybe more) for the views given.

If a topic title eg "SDL" is given and this title (or very similar) has more than one author, then the post with the higher number of views is taken.

To allow time for a few replies, I plan to tell the answer say at the end of June (if there are any entries).

There is "no reward" for the most correct answer.
Title: Re: QB64 v1.5 Feature Request - interpreter options + other things (quiz QB64 stats)
Post by: luke on May 10, 2020, 09:49:24 am
I have a suspicion it was Unseen's GDK post.
Title: Re: QB64 v1.5 Feature Request - interpreter options + other things (quiz QB64 stats)
Post by: SMcNeill on May 10, 2020, 10:15:40 am
Quiz Question:-


From the old [abandoned, outdated and now likely malicious qb64 dot net website - don’t go there] days what author-topic was most viewed (and approximately how many views).



The answer for the topic title does not have to exactly match and a tolerance of +/- 25% (maybe more) for the views given.

If a topic title eg "SDL" is given and this title (or very similar) has more than one author, then the post with the higher number of views is taken.

To allow time for a few replies, I plan to tell the answer say at the end of June (if there are any entries).

There is "no reward" for the most correct answer.

Title: Re: QB64 v1.5 Feature Request - interpreter options + other things (quiz QB64 stats)
Post by: STxAxTIC on May 10, 2020, 10:39:05 am
lol, spoiler alert!
Title: Re: QB64 v1.5 Feature Request - interpreter options + other things (quiz QB64 stats)
Post by: Craz1000 on May 11, 2020, 06:34:32 pm
The biggest reason i can think of for an interpreter being built in is you can have code in an external file that is in text form that can be modified without recompile. Sort of like the old Duke3D engine had all of its mechanics in a txt file containing the C code for all the weapons and enemies. It makes it easier to mod games or use a single sprite engine to make many different games without rewriting the engine and recompiling.
Title: Re: QB64 v1.5 Feature Request - (from archives) interpreter + ...(quiz QB64 stats)
Post by: Richard on June 02, 2020, 09:51:24 pm
For those interested in trying to make their own interpreter...



o14393-01
Author Topic: Novelty Interpreters (tiny)  (Read 667 times)




Quote


 
 

   
News:

Instructions for creating Android Apps:
http://www.[abandoned, outdated and now likely malicious qb64 dot net website - don’t go there]/forum/index.php?topic=13162.0


Home
Help
Search
Login
Register

QB64 Community »
Programs (.BAS), Tutorials and Libraries ($INCLUDE, DECLARE LIBRARY, ...) »
Sample Programs (Moderators: Galleon, OlDosLover, SMcNeill, Kobolt) »
Novelty Interpreters (tiny)

« previous next »
Print
Pages: [1] 2
 Author Topic: Novelty Interpreters (tiny)  (Read 667 times)

bplus

Hero Member

 
Posts: 622
B = B + _

Novelty Interpreters (tiny)

« on: July 29, 2017, 09:23:57 am »
Hi all,

This subject was started by Aureal at the QB64.org with the BrainF*** (BF) Interpreter.

Well I have taken this tiny interpreter idea and ran with it. Now I CAN write a program for this IEN (but not BF!).

Maybe you will be as amused as I.

Here is what the Hi Lo Guessing Game looks like for IEN Interpreter. Most of the Cn's are just printing characters and so take up allot of room in the program.

Code: [Select]
P
Z100 M4 Z1 A0 F3
A4 B3 * M3
Z2 A0 B3 F3
Z1 A0 B3 + M3
[ C 69 C 110 C 116 C 101 C 114 C 32 C 97 C 32 C 103 C 117 C 101 C 115 C 115 C 32 C 102 C 111 C 114 C 32 C 109 C 121 C 32 C 110 C 117 C 109 C 98 C 101 C 114 C 32 C 98 C 101 C 116 C 119 C 101 C 101 C 110 C 32 C 49 C 32 C 97 C 110 C 100 C 32 C 49 C 48 C 48 C32 ?4
A4 B10 =
I
   X
N

A4 B3 >
I

   C 72 C 105 C 103 C 104 P
E
   <
   I
      C 76 C 111 C 119  P
   E
      C 82 C 105 C 103 C 104 C 116 C 33 P
      X
   N
N
P
]

This is full of tabs, spaces, line feeds to make it readable (well... easier) for humans. These are all stripped before the IEN Interpreter starts it's execution. IEN only works with one-liners ;-)) albeit they can be quite long!

Here is the current complete package for this ever evolving idea. My next thing will be string handling and comments.

Let me know what you think or ideas,

Mark

PS (Append): BTW, IEN stands for Is Everything Number? because that is all IEN can handle. To print text, you have to use the C command with the ASC number for the letter/digit/symbol. Letter by letter labels are displayed, yikes! (that part of things still not fun enough, YET!).
 Novelty IEN Interpreter.zip (1239.13 kB - downloaded 21 times.)
« Last Edit: July 31, 2017, 07:47:55 am by bplus »
 Logged
Will you still love me, will you still need me, when I'm (QB) 64?
bplus

Hero Member

 
Posts: 622
B = B + _

Re: Novelty IEN Interpreter

« Reply #1 on: July 29, 2017, 12:55:02 pm »
I better post the code so you don't worry it's too long. ;-))

Code: [Select]
'IEN Interpreter.bas for QB64 fork (B+=MGA) 2017-07-28 new name
RANDOMIZE TIMER
_TITLE "IEN Interpreter for QB64"

'for directory stuff
CONST ListMAX% = 20
COMMON SHARED dirList$()
COMMON SHARED DIRCount% 'returns file count if desired
DIM dirList$(ListMAX%)

CONST numChars$ = "-.1234567890"
CONST cmdChars$ = "WC?ABZMFIENP[X]%^/*~+=><()!&|"
CONST allChars$ = numChars$ + cmdChars$

CONST memsize% = 20000
COMMON SHARED memory#()
COMMON SHARED source$, code$, err$
DIM memory#(memsize%)

WHILE 1
    source$ = ""
    CLS
    ERASE dirList$
    DIM dirList$(ListMAX%)
    loadDirList "IEN*.txt"

    IF DIRCount% THEN
        FOR i% = 1 TO DIRCount%
            PRINT i%, dirList$(i%)
        NEXT
        PRINT: INPUT "Enter line number of IEN Filename you desire "; ln%
        IF ln% < 1 OR ln% > DIRCount% THEN END
        filename$ = dirList$(ln%)

        OPEN filename$ FOR INPUT AS #1
        DO
            LINE INPUT #1, FLINE$
            source$ = source$ + FLINE$
        LOOP UNTIL EOF(1)
        CLOSE #1

    ELSE
        PRINT "No IEN*.txt files found."
    END IF
    IF LEN(source$) THEN
        PRINT source$
        PRINT: INPUT "n(New)  e(Edit)  r(Run)  k(Kill)  q(Quits)  other(Files)"; menu$
    ELSE
        PRINT: INPUT "n(New) q(Quits)  other(Files)"; menu$
    END IF
    SELECT CASE UCASE$(LEFT$(menu$, 1))
        CASE "N": INPUT "Enter a title, for *IEN + title + DATE.TXT* format "; tl$
            dt$ = RIGHT$(DATE$, 4) + "-" + LEFT$(DATE$, 2) + "-" + MID$(DATE$, 4, 2)
            fname$ = "IEN " + tl$ + " " + dt$ + ".txt"
            OPEN fname$ FOR OUTPUT AS #1
            CLOSE #1
            SHELL "notepad " + fname$
        CASE "E": IF LEN(source$) THEN SHELL "notepad " + filename$
        CASE "K": IF LEN(source$) THEN KILL filename$
        CASE "Q": END
        CASE "R": IF LEN(source$) THEN CLS: runSource
    END SELECT
WEND

SUB runSource
source$ = UCASE$(source$)
'let's clean the code up, check bracket balance
bktCnt = 0: ifCnt = 0: code$ = ""
FOR i = 1 TO LEN(source$)
    char$ = MID$(source$, i, 1)
    'check to see if this is a valid instruction character
    IF INSTR(allChars$, char$) THEN
        code$ = code$ + char$
        'count brackets
        IF char$ = "[" THEN bktCnt = bktCnt + 1
        IF char$ = "]" THEN bktCnt = bktCnt - 1
        IF char$ = "I" THEN ifCnt = ifCnt + 1
        IF char$ = "N" THEN ifCnt = ifCnt - 1
    END IF
NEXT
IF bktCnt THEN 'mismatched brackets
    PRINT "Uneven brackets": SLEEP: EXIT SUB
ELSEIF ifCnt THEN
    PRINT "Uneven I N counts": SLEEP: EXIT SUB
ELSE
    PRINT code$ 'check
END IF
ERASE memory#
DIM memory#(memsize%)
cmd$ = "": ds$ = "": err$ = ""
FOR i% = 1 TO LEN(code$) 'loop through the code
    c$ = MID$(code$, i%, 1) 'get the instruction we're on
    IF INSTR("-.1234567890", c$) THEN ds$ = ds$ + c$
    IF INSTR(cmdChars$, c$) OR i% = LEN(code$) THEN 'hit next command or end
        IF cmd$ <> "" THEN 'execute unfinished command
            d# = VAL(ds$)
            'exec last cmd
            SELECT CASE cmd$
                CASE "A": memory#(1) = memory#(d#)
                CASE "B": memory#(2) = memory#(d#)
                CASE "Z": memory#(0) = d#
                CASE "M": memory#(d#) = memory#(0)
                CASE "F"
                    SELECT CASE memory#(1)
                        CASE 0: IF memory#(2) <> 0 THEN memory#(d) = 0 ELSE memory#(d) = 1
                        CASE 1: memory#(d#) = RND
                        CASE 2: memory#(d#) = INT(memory#(2))
                    END SELECT
                CASE "W": PRINT memory#(d#);
                CASE "C": PRINT CHR$(d#);
                CASE "?": INPUT memory#(d#)
            END SELECT
            cmd$ = "": ds$ = ""
        END IF 'if cmd <> ""

        'handle current cmd
        IF INSTR("WC?ABZMF", c$) THEN
            cmd$ = c$
        ELSEIF c$ = "I" THEN
            IF memory#(0) = 0 THEN i% = Findi(i%)
            IF err$ <> "" THEN PRINT err$: SLEEP: EXIT SUB
        ELSEIF c$ = "E" THEN
            i% = Findi(i%)
            IF err$ <> "" THEN PRINT err$: SLEEP: EXIT SUB
        ELSEIF c$ = "P" THEN
            PRINT
        ELSEIF c$ = "X" THEN
            bktCnt% = 1 'count the bracket we're on
            i% = i% + 1 'move the code pointer to the next char
            WHILE bktCnt% <> 0
                'count nested loops till we find the matching one
                IF MID$(code$, i%, 1) = "]" THEN bktCnt% = bktCnt% - 1
                IF MID$(code$, i%, 1) = "[" THEN bktCnt% = bktCnt% + 1
                i% = i% + 1 'search forward
            WEND
            i% = i% - 1%
        ELSEIF c$ = "]" THEN ' end a loop if loop index is 0
            bktCnt% = -1 'count the bracket we're on
            i% = i% - 1 'move the code pointer back a char
            WHILE bktCnt% <> 0
                'count nested loops till we fine the matching one
                IF MID$(code$, i%, 1) = "]" THEN bktCnt% = bktCnt% - 1
                IF MID$(code$, i%, 1) = "[" THEN bktCnt% = bktCnt% + 1
                i% = i% - 1 'search backwards
            WEND
            i% = i% + 1
        ELSEIF c$ = "%" THEN
            memory#(0) = memory#(1) MOD memory#(2)
        ELSEIF c$ = "^" THEN
            memory#(0) = memory#(1) ^ memory#(2)
        ELSEIF c$ = "/" THEN
            memory#(0) = memory#(1) / memory#(2)
        ELSEIF c$ = "*" THEN
            memory#(0) = memory#(1) * memory#(2)
        ELSEIF c$ = "~" THEN
            memory#(0) = memory#(1) - memory#(2)
        ELSEIF c$ = "+" THEN
            memory#(0) = memory#(1) + memory#(2)
        ELSEIF c$ = "=" THEN
            memory#(0) = memory#(1) = memory#(2)
        ELSEIF c$ = "<" THEN
            memory#(0) = memory#(1) < memory#(2)
        ELSEIF c$ = ">" THEN
            memory#(0) = memory#(1) > memory#(2)
        ELSEIF c$ = "(" THEN
            memory#(0) = memory#(1) <= memory#(2)
        ELSEIF c$ = ")" THEN
            memory#(0) = memory#(1) >= memory#(2)
        ELSEIF c$ = "!" THEN
            memory#(0) = memory#(1) <> memory#(2)
        ELSEIF c$ = "&" THEN
            IF memory#(1) <> 0 AND memory#(2) <> 0 THEN
                memory#(0) = -1
            ELSE
                memory#(0) = 0
            END IF
        ELSEIF c$ = "|" THEN
            IF memory#(1) <> 0 OR memory#(2) <> 0 THEN
                memory#(0) = -1
            ELSE
                memory#(0) = 0
            END IF
        END IF
    END IF ' ran into next command
NEXT
PRINT: INPUT "Run is done, enter to continue..."; temp$
END SUB

FUNCTION Findi% (i%)
cnt% = 1
FOR j% = i% + 1 TO LEN(code$)
    c1$ = MID$(code$, j%, 1)
    IF c1$ = "N" THEN
        cnt% = cnt% - 1
        IF cnt% = 0 THEN Findi% = j%: EXIT FUNCTION
    ELSEIF c1$ = "I" THEN
        cnt% = cnt% + 1
    ELSEIF c1$ = "E" AND cnt% = 1 THEN
        Findi% = j%: EXIT SUB
    END IF
NEXT
err$ = "Could not find N"
END FUNCTION

' modified function from Help files
SUB loadDirList (spec$)
CONST TmpFile$ = "DIR$INF0.INF"
IF spec$ > "" THEN 'get file names when a spec is given
    SHELL _HIDE "DIR " + spec$ + " /b > " + TmpFile$
    Index% = 0: dirList$(Index%) = "": ff% = FREEFILE
    OPEN TmpFile$ FOR APPEND AS #ff%
    size& = LOF(ff%)
    CLOSE #ff%
    IF size& = 0 THEN KILL TmpFile$: EXIT SUB
    OPEN TmpFile$ FOR INPUT AS #ff%
    DO WHILE NOT EOF(ff%) AND Index% < ListMAX%
        Index% = Index% + 1
        LINE INPUT #ff%, dirList$(Index%)
    LOOP
    DIRCount% = Index% 'SHARED variable can return the file count
    CLOSE #ff%
    KILL TmpFile$
ELSE IF Index% > 0 THEN Index% = Index% - 1 'no spec sends next file name
END IF
END SUB

 Logged
Will you still love me, will you still need me, when I'm (QB) 64?
bplus

Hero Member

 
Posts: 622
B = B + _

Re: Novelty SHN Interpreter

« Reply #2 on: July 31, 2017, 07:45:51 am »
SHN (Strings Handled Now) Interpreter coming soon!

Just have to work out the translation to QB64, piece of cake, right?

Looks to be about the same amount of commands believe it or not!
Functions will look more realistic and it will be as easy as eating pie to add your own (built-in ones, I mean).

Stay tuned...
 Logged
Will you still love me, will you still need me, when I'm (QB) 64?
Ashish

Hero Member

 
Posts: 551
Eat.... Sleep.... CODE.... Repeat.....

Re: Novelty Interpreters (tiny)

« Reply #3 on: July 31, 2017, 09:04:50 am »
Nice work bplus! I like it!
 Logged
if (Me.Success) {Me.Improve();} else {Me.TryAgain();}

aKFrameWork - http://bit.ly/aKFrameWork
p5js.bas - http://bit.ly/p5jsbas
Menu System - http://bit.ly/guiMenuBar

OpenGL Demos - http://bit.ly/openGLdemos
bplus

Hero Member

 
Posts: 622
B = B + _

Re: Novelty Interpreters (tiny)

« Reply #4 on: August 01, 2017, 09:02:42 pm »
Strings Now Handled

Code: [Select]
'SNH Interpreter.bas for QB64 fork (B+=MGA) 2017-08-01 trans
RANDOMIZE TIMER
_TITLE "Strings Now Hamdled, the SNH Interpreter (tiny)"
SCREEN 12: COLOR 7, 0: CLS

'for directory stuff
CONST ListMAX% = 20
COMMON SHARED dirList$()
COMMON SHARED DIRCount% 'returns file count if desired
DIM dirList$(ListMAX%)

CONST numChars$ = "-.1234567890"
CONST cmdChars$ = "W?ABCDFMIENP[X]%^/*~+=><()!&|"
CONST allChars$ = numChars$ + cmdChars$

CONST memsize% = 20000
COMMON SHARED m$()
COMMON SHARED source$, code$, err$
DIM m$(memsize%)
NotBeenHere% = 1
'PRINT "COMMAND$ = "; COMMAND$
'INPUT "OK, press enter "; temp$
WHILE 1
    source$ = ""
    COLOR 7, 0: CLS
    ERASE dirList$
    DIM dirList$(ListMAX%)
    loadDirList "*SNH.txt"
    IF _FILEEXISTS(COMMAND$) AND RIGHT$(UCASE$(COMMAND$), 7) = "SNH.TXT" AND NotBeenHere% = 1 THEN
        filename$ = COMMAND$: NotBeenHere% = 0
    ELSEIF DIRCount% THEN
        FOR i% = 1 TO DIRCount%
            PRINT i%, dirList$(i%)
        NEXT
        PRINT: INPUT "0 quits, Enter line number of SNH Filename you desire "; ln%
        IF ln% < 1 OR ln% > DIRCount% THEN END
        filename$ = dirList$(ln%)
    ELSE
        PRINT "No *SNH.txt files found."
        SLEEP: END
    END IF
    OPEN filename$ FOR INPUT AS #1
    DO
        LINE INPUT #1, fline$
        source$ = source$ + fline$
        'PRINT fline$
        'INPUT " OK, enter"; temp$
    LOOP UNTIL EOF(1)
    CLOSE #1
    runSource
WEND

SUB runSource
    ERASE m$
    DIM m$(memsize%)
    'note: anything above first {} is comment and ignored
    'First get m$ (string memory array) loaded with data values
    FOR i% = 1 TO LEN(source$)
        c$ = MID$(source$, i%, 1)
        IF c$ = "{" THEN
            bs% = i%
            WHILE MID$(source$, i%, 1) <> "}"
                i% = i% + 1
                IF i% = LEN(source$) THEN PRINT "Missing }": SLEEP: EXIT SUB
            WEND
            ix% = VAL(MID$(source$, bs% + 1, i% - bs% - 1))
            IF ix% < 1 THEN EXIT FOR
            b$ = "": i% = i% + 1
            WHILE MID$(source$, i%, 1) <> ";"
                b$ = b$ + MID$(source$, i%, 1)
                i% = i% + 1
                IF i% = LEN(source$) THEN PRINT "Missing ending ;": SLEEP: EXIT SUB
            WEND
            m$(ix%) = b$
        END IF
    NEXT
    source$ = MID$(source$, i% + 1)

    'OK now letters, digits or symbols from strings wont interfere with program code
    source$ = UCASE$(source$)
    'let's clean the code up, check bracket balance
    bktCnt% = 0: ifCnt% = 0: code$ = ""
    FOR i = 1 TO LEN(source$)
        char$ = MID$(source$, i, 1)
        'check to see if this is a valid instruction character
        IF INSTR(allChars$, char$) THEN
            code$ = code$ + char$
            'count brackets
            IF char$ = "[" THEN bktCnt% = bktCnt% + 1
            IF char$ = "]" THEN bktCnt% = bktCnt% - 1
            IF char$ = "I" THEN ifCnt% = ifCnt% + 1
            IF char$ = "N" THEN ifCnt% = ifCnt% - 1
        END IF
    NEXT
    PRINT "Code check: "; code$
    IF bktCnt% THEN 'mismatched brackets
        PRINT "Uneven brackets": SLEEP: EXIT SUB
    ELSEIF ifCnt% THEN
        PRINT "Uneven I N counts": SLEEP: EXIT SUB
    ELSE
        PRINT code$ 'check
        INPUT "OK, press enter... "; temp$
        CLS
    END IF

    cmd$ = "": ds$ = "": err$ = ""
    FOR i% = 1 TO LEN(code$) 'loop through the code
        c$ = MID$(code$, i%, 1) 'get the instruction we're on
        IF INSTR("-.1234567890", c$) THEN ds$ = ds$ + c$
        IF INSTR(cmdChars$, c$) OR i% = LEN(code$) THEN 'hit next command or end
            IF cmd$ <> "" THEN 'execute unfinished command
                d# = VAL(ds$)
                'exec last cmd
                SELECT CASE cmd$
                    CASE "A": m$(1) = m$(d#)
                    CASE "B": m$(2) = m$(d#)
                    CASE "C": m$(3) = m$(d#)
                    CASE "D": m$(4) = m$(d#)
                    CASE "F"
                        SELECT CASE m$(1) 'the function name m$(2) 1st para...
                            CASE "NOT": IF VAL(m$(2)) = 0 THEN m$(d#) = "-1" ELSE m$(d#) = "0"
                            CASE "RND": m$(d#) = STR$(RND)
                            CASE "INT": m$(d#) = STR$(INT(VAL(m$(2))))
                            CASE "CTR": LOCATE CSRLIN, (80 - LEN(m$(2))) / 2: PRINT m$(2);
                            CASE "CLS": CLS
                            CASE "COLOR": COLOR VAL(m$(2)), VAL(m$(3))
                            CASE "LEN": m$(d#) = STR$(LEN(m$(2)))
                            CASE "MID1": m$(d#) = MID$(m$(2), VAL(m$(3)))
                            CASE "MID2": m$(d#) = MID$(m$(2), VAL(m$(3)), VAL(m$(4)))
                            CASE "INSTR1": m$(d#) = STR$(INSTR(m$(2), m$(3)))
                            CASE "INSTR2": m$(d#) = STR$(INSTR(VAL(m$(2)), m$(3), m$(4)))
                            CASE "LOCATE": LOCATE VAL(m$(2)), VAL(m$(3))
                        END SELECT
                    CASE "M": m$(d#) = m$(0)
                    CASE "W": PRINT m$(d#);
                    CASE "?": INPUT m$(d#)
                END SELECT
                cmd$ = "": ds$ = ""
            END IF 'if cmd <> ""

            'handle current cmd
            IF INSTR("ABCDFMW?", c$) THEN
                cmd$ = c$
            ELSEIF c$ = "I" THEN
                IF VAL(m$(0)) = 0 THEN i% = Findi(i%)
                IF err$ <> "" THEN PRINT err$: SLEEP: EXIT SUB
            ELSEIF c$ = "E" THEN
                i% = Findi(i%)
                IF err$ <> "" THEN PRINT err$: SLEEP: EXIT SUB
            ELSEIF c$ = "P" THEN
                PRINT
            ELSEIF c$ = "X" THEN
                bktCnt% = 1 'count the bracket we're on
                i% = i% + 1 'move the code pointer to the next char
                WHILE bktCnt% <> 0
                    'count nested loops till we find the matching one
                    IF MID$(code$, i%, 1) = "]" THEN bktCnt% = bktCnt% - 1
                    IF MID$(code$, i%, 1) = "[" THEN bktCnt% = bktCnt% + 1
                    i% = i% + 1 'search forward
                WEND
                i% = i% - 1%
            ELSEIF c$ = "]" THEN ' end a loop if loop index is 0
                bktCnt% = -1 'count the bracket we're on
                i% = i% - 1 'move the code pointer back a char
                WHILE bktCnt% <> 0
                    'count nested loops till we fine the matching one
                    IF MID$(code$, i%, 1) = "]" THEN bktCnt% = bktCnt% - 1
                    IF MID$(code$, i%, 1) = "[" THEN bktCnt% = bktCnt% + 1
                    i% = i% - 1 'search backwards
                WEND
                i% = i% + 1
            ELSEIF c$ = "%" THEN: m$(0) = STR$(VAL(m$(1)) MOD VAL(m$(2)))
            ELSEIF c$ = "^" THEN: m$(0) = STR$(VAL(m$(1)) ^ VAL(m$(2)))
            ELSEIF c$ = "/" THEN: m$(0) = STR$(VAL(m$(1)) / VAL(m$(2)))
            ELSEIF c$ = "*" THEN: m$(0) = STR$(VAL(m$(1)) * VAL(m$(2)))
            ELSEIF c$ = "~" THEN: m$(0) = STR$(VAL(m$(1)) - VAL(m$(2)))
            ELSEIF c$ = "+" THEN: m$(0) = STR$(VAL(m$(1)) + VAL(m$(2)))
            ELSEIF c$ = "=" THEN: m$(0) = STR$(VAL(m$(1)) = VAL(m$(2)))
            ELSEIF c$ = "<" THEN: m$(0) = STR$(VAL(m$(1)) < VAL(m$(2)))
            ELSEIF c$ = ">" THEN: m$(0) = STR$(VAL(m$(1)) > VAL(m$(2)))
            ELSEIF c$ = "(" THEN: m$(0) = STR$(VAL(m$(1)) <= VAL(m$(2)))
            ELSEIF c$ = ")" THEN: m$(0) = STR$(VAL(m$(1)) >= VAL(m$(2)))
            ELSEIF c$ = "!" THEN: m$(0) = STR$(VAL(m$(1)) <> VAL(m$(2)))
            ELSEIF c$ = "&" THEN
                IF VAL(m$(1)) <> 0 AND VAL(m$(2)) <> 0 THEN m$(0) = "-1" ELSE m$(0) = "0"
            ELSEIF c$ = "|" THEN
                IF VAL(m$(1)) <> 0 OR VAL(m$(2)) <> 0 THEN m$(0) = "-1" ELSE m$(0) = "0"
            END IF ' ran into next command
        END IF
    NEXT
    PRINT: INPUT "Run is done, enter to continue..."; temp$
END SUB

FUNCTION Findi% (i%)
    cnt% = 1
    FOR j% = i% + 1 TO LEN(code$)
        c1$ = MID$(code$, j%, 1)
        IF c1$ = "N" THEN
            cnt% = cnt% - 1
            IF cnt% = 0 THEN Findi% = j%: EXIT FUNCTION
        ELSEIF c1$ = "I" THEN
            cnt% = cnt% + 1
        ELSEIF c1$ = "E" AND cnt% = 1 THEN
            Findi% = j%: EXIT SUB
        END IF
    NEXT
    err$ = "Could not find N"
END FUNCTION

' modified function from Help files
SUB loadDirList (spec$)
    CONST TmpFile$ = "DIR$INF0.INF"
    IF spec$ > "" THEN 'get file names when a spec is given
        SHELL _HIDE "DIR " + spec$ + " /b > " + TmpFile$
        Index% = 0: dirList$(Index%) = "": ff% = FREEFILE
        OPEN TmpFile$ FOR APPEND AS #ff%
        size& = LOF(ff%)
        CLOSE #ff%
        IF size& = 0 THEN KILL TmpFile$: EXIT SUB
        OPEN TmpFile$ FOR INPUT AS #ff%
        DO WHILE NOT EOF(ff%) AND Index% < ListMAX%
            Index% = Index% + 1
            LINE INPUT #ff%, dirList$(Index%)
        LOOP
        DIRCount% = Index% 'SHARED variable can return the file count
        CLOSE #ff%
        KILL TmpFile$
    ELSE IF Index% > 0 THEN Index% = Index% - 1 'no spec sends next file name
    END IF
END SUB

I threw out the file management stuff, let the Windows Explorer or Equivalent do that stuff!

Now you can drag and drop *SNH.txt programs onto the exe or select a file to run from a folder listing.

A limited set of built-in functions just to show that they All can be done.

EDIT: 2017-08-02 12:18 PM    It turns out that the NOT function did need to be fixed, -1 not 1 for True.
That and some additional *SNH.txt code files have been added to the revised SNH Pack.zip

 SNH Pack.zip (635.14 kB - downloaded 16 times.)
« Last Edit: August 02, 2017, 09:25:17 am by bplus »
 Logged
Will you still love me, will you still need me, when I'm (QB) 64?
bplus

Hero Member

 
Posts: 622
B = B + _

Re: Novelty Interpreters (tiny)

« Reply #5 on: August 02, 2017, 09:24:14 am »
Small fix made to .bas & .exe code in the SNH Pack.zip attachment in previous post.

Additional test *SNH.txt files have been added and some more edits of the Read Me.txt file.

 Logged
Will you still love me, will you still need me, when I'm (QB) 64?
bplus

Hero Member

 
Posts: 622
B = B + _

Re: Novelty Interpreters (tiny)

« Reply #6 on: February 08, 2018, 02:31:17 pm »
I have converted SmallBASIC Nano3 Interpreter to QB64 with help with Evaluate system started in JB, further developed in FB and then converted to QB64.

The Interpreter now works completely as a stand alone 6 times the size Nano was.

It is a drag and drop of source code program onto BRUN.exe. All the file management stuff is left to Windows or your OS and all editing left to NotePad++ or your favorite editor.

The BRUN Pack#1.zip has a bonus copy of source code and exe with debugger switched on so can step through each line of program and watch the variables to help track down errors.

Also included in package are 10 sample and test programs and one 000BRUN Help B.txt cheat sheet of 21 keywords and list of math functions...

New form Nano3 is variable names as long as you like, setting number variables are done with n keyword at first position in program line instead of = sign after variable name.

It might be fun to play with for short programs...

attached is zip and a few screen shots: cheat sheet and 2 calculator programs

Next up, I have to remember how to handle strings and their functions... (consulting last post here!),

I might have to give up on idea of no punctuation.

Append: Comment lines are ANY line that doesn't start with keyword, no REM or ' needed!
Printing stuff: just start line with . , or ;   no quotes needed, variable values are automatically substituted in for variable names.
You might miss having control of spaces (not ready yet) but have LOCATE sub replaced with: rc row, col and have graphics: at x, y to locate a print at any pixel.

Oh! Here is what code looks like for first calculator (to sort of look like the device, though you cant click keys (yet!))
Code: [Select]
calculator B.txt revised again for BRUN 2018-02-07 originally from:
calculator nano3.txt for Nano3.bas (B+=MGA) 2017-06-10

sub Menu
   n i -1
   at 0 80 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>__ r __<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
   at 0 120 Command Menu:
   do
      n i i + 1
      if i > 22
         exit
      fi
      n x (i % 5) * 160
      n y int( i / 5) * 50 + 160
   
      if i = 0
         at x y i = +
      fi
      if i = 1
         at x y i = -
      fi
      if i = 2
         at x y i = *
      fi
      if i = 3
         at x y i = /
      fi
      if i = 4
         at x y i = ^
      fi
      if i = 5
         at x y i = pi
      fi
      if i = 6
         at x y i = rad
      fi
      if i = 7
         at x y i = cos
      fi
      if i = 8
         at x y i = sin
      fi
      if i = 9
         at x y i = tan
      fi
      if i = 10
         at x y i = atan
      fi
      if i = 11
         at x y i = deg
      fi
      if i = 12
         at x y i = mod
      fi
      if i = 13
         at x y i = ln
      fi
      if i = 14
         at x y i = exp
      fi
      if i = 15
         at x y i = mIn
      fi
      if i = 16
         at x y i = m+
      fi
      if i = 17
         at x y i = mOut
      fi
      if i = 18
         at x y i = mClear
      fi
      if i = 19
         at x y i = # start
      fi
      if i = 20
         at x y i = quit
      fi
   loop
return

sub getC
   mark cStart
   cls
   gosub Menu
   at 0 40 Enter command number
   ? c
   if c >= 0
      if c < 23
         go cEnd
      else
         go cStart
      fi
   else
      go cStart
   fi
   mark cEnd
return

cls
at 0, 20 Enter a number for starting the calculator...
? r

do
   gosub getC
   
   if c = 0
      ? s + Enter number to add...
      n r r + s
   fi
   if c = 1
      ? s - Enter number to subtract...
      n r r  - s
   fi
   if c = 2
      ? s * Enter number to multiply...
      n r r * s
   fi
   if c = 3
      ? s / Enter divisor...
      if s <> 0
         n r r / s
      else
         . Oops, can't divide by 0
      fi
   fi
   if c = 4
      ? s ^ Enter power...
      n r r ^ s
   fi
   if c = 5
      n r pi
   fi
   if c = 6
      n r r *pi/180
   fi
   if c = 7
      n r cos( r )
   fi
   if c = 8
      n r sin( r )
   fi
   if c = 9
      n r tan( r )
   fi

   if c = 10
      n r atan( r )
   fi
   if c = 11
      n r deg( r )
   fi
   if c = 12
      ? s Enter modulus...
      n r r % s
   fi
   if c = 13
      n r log( r )
   fi
   if c = 14
      n r exp( r )
   fi
   if c = 15
      n m r
   fi
   if c = 16
      n m m + r
   fi
   if c = 17
      n r m
   fi
   if c = 18
      n m 0
   fi
   if c = 19
      ? r Enter new start number...
   fi
   if c = 20
      at 0 400 Goodbye!
      end
   fi
loop


And code for line calculator (or expressions evaluator):
Code: [Select]
Line calc by bplus for BRUN 2018-02-07
do
   at 110 40 *** Line Calculator ***
   at 10 80 arith: +, -, *, /,   constants: e, pi, random 0-1 use rnd
   at 10 100 (keep - for subtraction spaced on both sides to distinguish from neg numbers)
   at 10 120 functions modulus use %, power use ^, log, exp, sqr, int, random 0 to 1 use rnd
   at 10 140 trig (radians): sin( ), cos( ), tan( ), atan( ) conversion: rad, deg
   at 10 160 boolean: =, <>, <, <=, >, >=, and, or, not
   at 50 180 (results are displayed for 3.5 secs)
   n row int(220/16 + .5)
   rc row 2
   ? string (-42 to quit) Enter an expression to evaluate...
   if string = -42
      exit
   fi
   n result string
   at 10 250 The calculator came up with this: result
   wait 3.5
   cls
loop
cls
.
. Goodbye!
.
.
 BRUN pack #1.zip (914.47 kB - downloaded 7 times.)
 000 BRUN Help B_txt.PNG (43.7 kB - downloaded 4 times.)
 calculator B_txt.PNG (9.19 kB - downloaded 5 times.)
 line calc B_txt.PNG (14.01 kB - downloaded 4 times.)
« Last Edit: February 08, 2018, 02:56:27 pm by bplus »
 Logged
Will you still love me, will you still need me, when I'm (QB) 64?
IGetGroovy

Newbie

Posts: 23

Re: Novelty Interpreters (tiny)

« Reply #7 on: February 08, 2018, 08:15:15 pm »
I had a blast running the examples here bplus, nice job! This is a really cool project - this is the program that grew from the 100 LOC contest, right? I also messed with the line of code that reports on "EvalW" on each iteration and then re-ran everything - it's fun watching a recursive thing clamp down on an answer, agree? I also wonder if you know where this program is going next. In the spirit of separating mechanism from policy, do you intend on having a version that runs embedded in a terminal?

Now is another good chance to mention (perhaps not for the first time), do you have any aversion to hanging out in IRC #qb64? You are a vibrant member in the QB-sphere and I suspect you'd have a blast there.

 Logged
eoredson

Hero Member

 
Posts: 570
I programmed myself into a conniption..


Re: Novelty Interpreters (tiny)

« Reply #8 on: February 08, 2018, 11:08:53 pm »
I wrote an interpreter here:

http://www.[abandoned, outdated and now likely malicious qb64 dot net website - don’t go there]/forum/index.php?action=dlattach;topic=13148.0;attach=4378

Erik.
 Logged
Games: DNDDOOR - https://bit.ly/EriksDNDDoor DUNGEON - https://bit.ly/EriksDungeon
Interpreter - https://bit.ly/EriksSICK Hex Editor - https://bit.ly/EriksHexEditor
Utilities - https://bit.ly/EriksUtils Old QB64 - https://bit.ly/OldQB64
QB64 shell - https://bit.ly/QB64shell
FellippeHeitor

QB64 Partner Site Owner
Hero Member

 
Posts: 1806
LET IT = BE


Re: Novelty Interpreters (tiny)

« Reply #9 on: February 09, 2018, 05:35:52 am »
Is it interpreter sharing season? Here's mine too https://github.com/FellippeHeitor/QB64-interpreter

I'll check yours right now bplus, sounds like fun.
 Logged
- InForm for QB64 http://qb64.org/inform

- vWATCH64 (debugger for QB64) http://bit.ly/vWATCH64v1-103

- Games: http://bit.ly/2048_qb64 * http://bit.ly/ClonedShades_qb64source * http://bit.ly/2aqK866 * http://bit.ly/SpaceshipQB64 * http://bit.ly/2rD1pPP
bplus

Hero Member

 
Posts: 622
B = B + _

Re: Novelty Interpreters (tiny)

« Reply #10 on: February 09, 2018, 11:28:43 am »
Oh hey a response! Yeah!

Hi IGetGroovy,

Thanks for paying attention, yes it is Nano3 SmallBASIC code spread out into QB64 (version 2017 11 06 /82 (if I recall), sorry I forgot to add that Jack). Now I think I remember you from another name but which Luke? Bill? I can't keep track of names very well or do I mean psuedo names. Now I know where WHN? got the idea of constantly changing avatar names (and from lurking at Studio 54    ) are you all really one guy? maybe with split personality? Pete is that you!

There is talking, there is talking about coding and there is coding, I have no aversion to hanging out at IRC QB64, I do wish I could lurk a little before signing on as member, a glance into what I may be spending more time

Quote
In the spirit of separating mechanism from policy, do you intend on having a version that runs embedded in a terminal?
Plans? well embedding is not even on my radar but I asked a question about embedding at BP.org, 2 years before it went belly up, and have yet to get a decent answer: What is it? What is it good for? I've looked into it, a little, have some foggy notions but nothing is clear.

I have immediate plans for primitive graphics (got to have fun with that! specially if QB64 gives me more speed that SB) and of course strings and arrays. My plans are in To do list in opening comments of BRUN source... Long range? I usually go where the spirit takes me or am sorry I didn't.

This not BASIC, I don't want to build another BASIC interpreter, Erik and Fellippe's are likely too good to even try and better them ! It is Basic like, I guess since Basic is all I prefer to code with.

Yes! Fellippe and Erik, I have looked into both your beautiful monsters!  I suppose mine too is growing so large as to require serious study time to understand and use effectively.

BRUN (and Nano)  is very much in spirit of WHN? author of FIG, who started contest with Walter at TJP that ended up producing nascent Nano after nasty argument with him. I argue but I listen too (sometimes, specially when I respect person with whom I am arguing. Of course my idea of respect is to try and avoid foul moronic language, of course that does signal extreme frustration which is better than nothing, I guess.)

eh! I could go on and on about my child... sheeze
« Last Edit: February 09, 2018, 11:53:38 am by bplus »
 Logged
Will you still love me, will you still need me, when I'm (QB) 64?
bplus

Hero Member

 
Posts: 622
B = B + _

Re: Novelty Interpreters (tiny)

« Reply #11 on: February 09, 2018, 11:35:37 am »
Quote
Is it interpreter sharing season? Here's mine too https://github.com/FellippeHeitor/QB64-interpreter

I'll check yours right now bplus, sounds like fun.

Oh now I've seen Erik's post and understand 

Yes, Interpreter season opened up in January or before at TJP with David Taylor making all sorts of announcements with such piss and vinegar and spunk, it reignited my own spark for the subject.

The crazy thing is he is not sharing his source code, so I guess we are showing him how it's done.
 Logged
Will you still love me, will you still need me, when I'm (QB) 64?
eoredson

Hero Member

 
Posts: 570
I programmed myself into a conniption..


Re: Novelty Interpreters (tiny)

« Reply #12 on: February 09, 2018, 07:14:44 pm »
@bplus: You need to concentrate on your engine of choice first - such as a descent parser, then write the interpreter around it.

Pay certain attention on how to parse parenthesis first, then smaller structures like Do..Loop and For..Next.

Once the parser engine is written the rest will follow, including the basic commands - List, Run, Load, Save, etc.

Expect to spend alot of time on it.

Erik.
 Logged
Games: DNDDOOR - https://bit.ly/EriksDNDDoor DUNGEON - https://bit.ly/EriksDungeon
Interpreter - https://bit.ly/EriksSICK Hex Editor - https://bit.ly/EriksHexEditor
Utilities - https://bit.ly/EriksUtils Old QB64 - https://bit.ly/OldQB64
QB64 shell - https://bit.ly/QB64shell
bplus

Hero Member

 
Posts: 622
B = B + _

Re: Novelty Interpreters (tiny)

« Reply #13 on: February 09, 2018, 07:17:30 pm »
Quote from: eoredson on February 09, 2018, 07:14:44 pm
@bplus: You need to concentrate on your engine of choice first - such as a descent parser, then write the interpreter around it.

Pay certain attention on how to parse parenthesis first, then smaller structures like Do..Loop and For..Next.

Once the parser engine is written the rest will follow, including the basic commands - List, Run, Load, Save, etc.

Expect to spend alot of time on it.

Erik.

Been there done all that, did you even run a sample? just drag and drop a *B.txt file over BRUN.exe

You know this like my 6th (toy) interpreter ? and this is not traditional Basic IDE style runs.

Don't need List, Run, Load, Save ... as explained earlier, you edit your files in your favorite text editor (eliminates New, Load, List, Save, Edit), I am letting Windows or your favorite OS handle all file management (rename, cut/copy/paste to whatever folders, delete...). just end your program files with "B.txt"

The "engine" for parsing... handling expressions has been assembled and tutored at TJP under FreeBasic two threads on subject Evaluation. It does not use traditional parser techniques let alone worry about ascent and decent... yet it handles operators in regular order: preparing string for evaluation, substitutions in of constants and variable values, functions, math operators like mod and power, arith operators / then * the - then +, then booeans < = > stuff then logical conjugates "and" and "or" and finally not. True it's not the quickest most efficient system but it works.

You Run your source file, "Program name B.txt" by drag and drop onto the BRUN.exe and just like magic it runs or tells you the first line number it can't execute.

or drag and drop onto BRUN w debugger.exe and watch your code get processed line by line.

Here is a program "Count to ten B.txt"
Code: [Select]
n count 1
do
   . count
   n count count + 1
   if count > 10
       exit
   fi
loop
 count to 10.PNG (61.05 kB - downloaded 6 times.)
« Last Edit: February 09, 2018, 07:49:15 pm by bplus »
 Logged
Will you still love me, will you still need me, when I'm (QB) 64?
eoredson

Hero Member

 
Posts: 570
I programmed myself into a conniption..


Re: Novelty Interpreters (tiny)

« Reply #14 on: February 09, 2018, 07:20:13 pm »
Ok, well, if you've done all that, then, nevermind
 Logged
Games: DNDDOOR - https://bit.ly/EriksDNDDoor DUNGEON - https://bit.ly/EriksDungeon
Interpreter - https://bit.ly/EriksSICK Hex Editor - https://bit.ly/EriksHexEditor
Utilities - https://bit.ly/EriksUtils Old QB64 - https://bit.ly/OldQB64
QB64 shell - https://bit.ly/QB64shell
Print
Pages: [1] 2
« previous next »
QB64 Community »
Programs (.BAS), Tutorials and Libraries ($INCLUDE, DECLARE LIBRARY, ...) »
Sample Programs (Moderators: Galleon, OlDosLover, SMcNeill, Kobolt) »
Novelty Interpreters (tiny)
 


SMF 2.0.3 | SMF © 2011, Simple Machines
XHTML
RSS
WAP2




o14393-02
 
Quote


   
News:

Instructions for creating Android Apps:
http://www.[abandoned, outdated and now likely malicious qb64 dot net website - don’t go there]/forum/index.php?topic=13162.0


Home
Help
Search
Login
Register

QB64 Community »
Programs (.BAS), Tutorials and Libraries ($INCLUDE, DECLARE LIBRARY, ...) »
Sample Programs (Moderators: Galleon, OlDosLover, SMcNeill, Kobolt) »
Novelty Interpreters (tiny)

« previous next »
Print
Pages: 1 [2]
 Author Topic: Novelty Interpreters (tiny)  (Read 667 times)

rks

Newbie

Posts: 34

Re: Novelty Interpreters (tiny)

« Reply #15 on: February 10, 2018, 09:35:13 am »
I'll throw mine back in again, I've done some more work on it, and it's probably to big to be considered a 'tiny' anything but it is a novelty something.

r
 tascript 30.7z (46.4 kB - downloaded 12 times.)
 Logged
bplus

Hero Member

 
Posts: 622
B = B + _

Re: Novelty Interpreters (tiny)

« Reply #16 on: February 10, 2018, 10:13:11 am »
Hi rks,

Thanks I will check it out, do you have a link here where/when you've discussed what you are doing?

I see you signed up 2012 (edit year) and are already up to 30 posts! I will check out those too, maybe you are Bill.


Append: Man what a salesman you are! Got me interested hook, line and slinker!
http://www.[abandoned, outdated and now likely malicious qb64 dot net website - don’t go there]/forum/index.php?topic=13259.msg114533#msg114533
« Last Edit: February 10, 2018, 01:56:07 pm by bplus »
 Logged
Will you still love me, will you still need me, when I'm (QB) 64?
rks

Newbie

Posts: 34

Re: Novelty Interpreters (tiny)

« Reply #17 on: February 11, 2018, 09:21:21 am »
Hi bplus,

Back when I posted the first version of the interpreter (several years ago under a different name), there was some explanation, but it was so long ago I can't remember it, which is not unusual. There is a piece in the manual about what I’m doing but honestly it came about from two reasons, a desire to write my own language without actually having a clue as to how to go about it, and sufficient boredom one winter to make me start.  So I read a few articles, some of which I almost understood and with no plan in sight started coding a way to get single keystrokes followed by a way to print them.  I’ve used syntax from several different languages and made up the rest as I went, through several iterations, to reach this point.  I’m probably done with it for a while, it’s ended up a lot bigger than I intended as it strayed from it’s original purpose of a text game engine into a more general purpose language, but it’s been an interesting diversion.
And by the way, I'm not Bill, at least that I recall.

r
 Logged
bplus

Hero Member

 
Posts: 622
B = B + _

Re: Novelty Interpreters (tiny)

« Reply #18 on: February 11, 2018, 11:56:58 am »
Hi rks,

Nice docs, 8 pages is about my limit but you seem to be doing things well = how I might! ha!

I like how you map all the jump points line labels, go subs... and how you fit your IF lines to that system.

I also like how it is designed, at least originally, with a particular goal of being a text game engine. That gives one a clear idea of direction and when one is done or when one might add a new feature...

Doing a general interpreter covers too broad an area specially if one of your ideas/ideals is that the smaller the more fun to learn and use.
 Logged
Will you still love me, will you still need me, when I'm (QB) 64?
rks

Newbie

Posts: 34

Re: Novelty Interpreters (tiny)

« Reply #19 on: February 12, 2018, 09:23:18 am »
Thanks!  The docs came into being after I forgot how I was implementing something after a several day break, figured if I didn't write things down I never know where I was.  The general purposity (? new word alert!) came about from playing with ways to modify text and it's easy enough to ignore them when they aren't needed.  It doesn't hurt that the compiled size doesn't change much with or without the feature bloat, but it's sometimes difficult to keep ones fingers out of the pie.  Anyway, the layout makes things fairly simple to strip out non-essentials if needed.
I've been reading through your latest, nice!  Although BRUN brought back memories of good ole QB run times.

r
 Logged
bplus

Hero Member

 
Posts: 622
B = B + _

Re: Novelty Interpreters (tiny)

« Reply #20 on: February 12, 2018, 09:40:25 am »
Code: [Select]
Although BRUN brought back memories of good ole QB run times.
Yes, I am glad you caught that!

I hope my effort is respectful and honoring of that tradition. If not please complain and I will change name (alas poor Erik, another name to track!)

I tried some research on BRUN name, came up with zilch, no mention of QuickBasic or QBasic (and I am still trying to figure out the original name of QB version name I was using, I think QuickBasic 4.5 because it did have compiler and it was just before QBasic came free with DOS (I just learned it was DOS 5 not 6 that QBasic came free without compiler).
 Logged
Will you still love me, will you still need me, when I'm (QB) 64?
rks

Newbie

Posts: 34

Re: Novelty Interpreters (tiny)

« Reply #21 on: February 13, 2018, 09:33:54 am »
I like the name, brings back memories.  BRUN had the version number of QB as part of the name, so QB45 came with BRUN45.EXE, QB40 came with BRUN40.EXE, etc.  It also seems like QB45 was little more than an IDE update to QB40.  It was something of a shock when I upgraded from DOS 4.01 to DOS 5.0 and had QBasic instead of BASICA, that took some getting used to.
Anyway, I like the conciseness of your language, mine sprawls all over the place.

r
 Logged
bplus

Hero Member

 
Posts: 622
B = B + _

Re: Novelty Interpreters (tiny)

« Reply #22 on: February 13, 2018, 10:56:30 am »
Hi rks,

Speaking of likes, I forgot to mention I like [varaiable] to tell exe to print value instead of string (or name of variable).

I like it so much I might have to steal idea.   (if paying this compliment isn't enough).


Re: Arrays and strings

Last night I woke up at 4 AM with idea that might eliminate need for strings and arrays (as we QBers know them anyway).

I did say, might, these middle of night insights sometimes do pan out but not exactly how they were first seen...

Anyway I hope I have titillated and stirred up some imaginations with this announcement.
 Logged
Will you still love me, will you still need me, when I'm (QB) 64?
bplus

Hero Member

 
Posts: 622
B = B + _

Re: Novelty Interpreters (tiny)

« Reply #23 on: February 14, 2018, 01:08:27 am »
Hey happy Valentines Day!

Code: [Select]
simple sieve 2 B.txt for BRUN v 2 2018-02-14 adopted from:
'Simple sieve 2.bas SmallBASIC 2015-04-29 found a faster sieve with BASIC 256
n topLimit 100
n limit topLimit ^ .5
. Primes to topLimit
take care of even numbers first
n index 4
do
   put composites index 1
   n index index + 2
   if index > topLimit
      exit
   fi
loop
now do odd numbers
n index 3
do
   get test composites index
   if test = 0
      if index < limit
         n j 2 * index
         do
            put composites j 1
            n j j + index
            if j > topLimit
               exit
            fi
         loop
      fi
   fi
   n index index + 2
   if index > limit
      exit
   fi
loop
n index 2
pCount = 0
do
   get test composites index
   if test = 0
      n pCount pCount + 1
      . index
   fi   
   n index index +1
   if index > topLimit
      exit
   fi
loop
.
. There are pCount primes for the first topLimit integers.


It works!
 prime sieve 2.PNG (11.13 kB - downloaded 4 times.)
 Logged
Will you still love me, will you still need me, when I'm (QB) 64?
bplus

Hero Member

 
Posts: 622
B = B + _

Re: Novelty Interpreters (tiny)

« Reply #24 on: February 14, 2018, 07:02:34 am »
Glacial slow get and put for BRUN 2

Basic: array(Index) = someValueEvaluatedInProgramLine
BRUN 2  put syntax:
put stringArrayName numberVariableIndex valueFromNumberCalcInProgramLine

Basic: numberVariable = array(Index)
BRUN 2  get syntax:
get getValuePutUnderThisNumberVariableName fromThisStringArrayVariableName andThisNumberVariableIndex
 Logged
Will you still love me, will you still need me, when I'm (QB) 64?
rks

Newbie

Posts: 34

Re: Novelty Interpreters (tiny)

« Reply #25 on: February 14, 2018, 09:14:33 am »
You are more than welcome to use [variable], I took it from assembly language.

Without strings and arrays what would the BASIC community have to argue about making the best use of?  Does sound intriguing, though.  I've had some of those middle of the night flashes of insight, mine rarely make nearly as much sense after coffee.

There's nothing wrong with glacially slow if you get the correct answer, speed can be worked on later.

r
 Logged
bplus

Hero Member

 
Posts: 622
B = B + _

Re: Novelty Interpreters (tiny)

« Reply #26 on: February 14, 2018, 10:01:34 am »
  so that's why I drink so much coffee! to sober up from my dreams...
 Logged
Will you still love me, will you still need me, when I'm (QB) 64?
eoredson

Hero Member

 
Posts: 570
I programmed myself into a conniption..


Re: Novelty Interpreters (tiny)

« Reply #27 on: March 03, 2018, 01:33:13 am »
Quote
I hope my effort is respectful and honoring of that tradition. If not please complain and I will change name (alas poor Erik, another name to track!)

My utilities, my whatis parser, my SICK interpreter, and my QB64shell all indicate the road I've traveled down.

If you could look at them all (in my signature), I'm sure they will help and be of some aid.

Although I will admit my interpreter was born of a recursive descent parser. If you need to adapt a tokenizer or such to
your own then you are on your own.

Erik.
 Logged
Games: DNDDOOR - https://bit.ly/EriksDNDDoor DUNGEON - https://bit.ly/EriksDungeon
Interpreter - https://bit.ly/EriksSICK Hex Editor - https://bit.ly/EriksHexEditor
Utilities - https://bit.ly/EriksUtils Old QB64 - https://bit.ly/OldQB64
QB64 shell - https://bit.ly/QB64shell
Print
Pages: 1 [2]
« previous next »
QB64 Community »
Programs (.BAS), Tutorials and Libraries ($INCLUDE, DECLARE LIBRARY, ...) »
Sample Programs (Moderators: Galleon, OlDosLover, SMcNeill, Kobolt) »
Novelty Interpreters (tiny)
 


SMF 2.0.3 | SMF © 2011, Simple Machines
XHTML
RSS
WAP2


Title: Re: QB64 v1.5 Feature Request - (from archives) interpreter + ...(quiz QB64 stats)
Post by: +KZ on June 04, 2020, 02:21:08 pm
allow multiple windows on same program will be nice :)
Title: Re: QB64 v1.5 Feature Request - (from archives) interpreter + ...(quiz QB64 stats)
Post by: TempodiBasic on June 05, 2020, 11:03:18 am
Quote
Posted by: +KZ
« on: Yesterday at 02:21:08 PM »Insert Quote
allow multiple windows on same program will be nice :)
Yes I can agree
but in this case  QB64 isn't emulate QB45 and its following version of DOS ... (PDS  and VB DOS).
Title: Re: QB64 v1.5 Feature Request - A meaningless request for IDE
Post by: Richard on June 28, 2020, 12:13:02 am
Would be useful (for me anyway) to have a bit more control of spacing of program contents.

At present everything after ' is preserved but usually not relative to the '

If, with multi-program lines per IDE line, it is required to "space-out" the components (purely for visual presentation purposes only), then the only option appears to be:-

IDE > Options > OFF (Auto spacing & Upper/Lowercase Formatting)

However, if at any stage the flag for (Auto spacing & …) is changed - then all "manual" changes applied are lost forever. Also the Upper/Lowercase Formatting may be affected.

So the "Meaningless Request for IDE" is to allow preservation of manually applied spaces which will  be preserved irrespective of configuration changes to the IDE Options Menu. At present inserting a number of colons (:) is the "safest" option to space out (without resorting to using a text editor for manual formatting). If there was say a character (eg chr$(&HFF)) which does the same job as a : but does not display anything (like a space character) - this would be useful.

Hopefully a feature that effectively "does nothing" would be easy to implement.


(a silly) example:-
 

' IDE > Options >   OFF  (Auto spacing & Upper/Lowercase Formatting)

a = 1: B    =    2:      c = 3        :::  :: d = 99
aa = 1 'cannot TAB or space at beginning of this line
ccc = 0
Title: Re: QB64 v1.5 Feature Request - A meaningless request for IDE
Post by: Unseen Machine on June 28, 2020, 03:52:28 am
Quote
From the old [abandoned, outdated and now likely malicious qb64 dot net website - don’t go there] days what author-topic was most viewed (and approximately how many views).
Damnation! GDK was second!

Quote
allow multiple windows on same program will be nice :)
You can do this, either using VQB to have seperate frames in your window, my sfml lib (allows 5 screens but only works with .954(sdl)) or use RhoSigma's GUI Framework to have multiple screens.

Failing that, have a Debug flag and print your variables over your code (i use this method a  lot), or you could just dump those variables to an external .txt file.

Unseen
Title: Re: QB64 v1.5 Feature Request - A meaningless request for IDE
Post by: Cobalt on June 28, 2020, 11:36:58 am
Just want to know who the poor busterd was that made up the .3 of a male in the male to female ratio!  didn't realize we had a female component back on .NET!
Getting closer to that 2011 member stat though!

Still miss poor Clippy he was always quite a gas.(or just full of it)
Title: Re: QB64 v1.5 Feature Request - A meaningless request for IDE
Post by: davidshq on June 28, 2020, 10:49:21 pm
I'd like for Felippe's QB64 interpreter, vWatch, and InForm to all be bundled with QB64 (not the source, just binaries, folks can go grab the source from the repos if desired).

I don't know that any of these need to be part of QB64, but could be nice if one could tick a setting in QB64 IDE that would show/hide these options. Clicking on one would simply launch that application. Not a big change, but nice.
Title: Re: QB64 v1.5 Feature Request - new string functions
Post by: Richard on July 25, 2020, 09:08:51 pm
More string functions request:-

eg

Replace all instances of a string subset with a longer or shorter different string subset (MID$/INSTR can easily be used when no change in length)

eg syntax   REPLACE$(stringname$, search substring$, replacement substring$)


usage

newstring$=REPLACE$(oldstring$,"abc","abcd")

would result in a newstring$ being one character longer than oldstring$ (assuming only one instance of "abc" in oldstring$


Many variations and special cases are possible for this request such as  - delete all instances of "abc", capitalize etc)
Title: Re: QB64 v1.5 Feature Request - new string functions
Post by: TempodiBasic on July 26, 2020, 03:06:45 am
Hi Richard
here the prototype of your request
... someone that can do it he must inject this code in QB64 source adding the new Keyword

Code: QB64: [Select]
  1. FUNCTION Replace$ (InWhat AS STRING, AtPlaceOf AS STRING, WhatNew AS STRING)
  2.     ' this function replace WhatNew InWhat AtPlaceOf
  3.     ' all arguments must have at least one character
  4.  
  5.     IF LEN(InWhat) > 0 AND LEN(AtPlaceOf) > 0 AND LEN(WhatNew) > 0 THEN
  6.         DO WHILE INSTR(InWhat, AtPlaceOf)
  7.             InWhat = LEFT$(InWhat, INSTR(InWhat, AtPlaceOf) - 1) + WhatNew + RIGHT$(InWhat, LEN(InWhat) - (INSTR(InWhat, AtPlaceOf) - 1 + LEN(AtPlaceOf)))
  8.         LOOP
  9.         Replace$ = InWhat
  10.     END IF

I think that for a good gameplay  of function we can use an optional parameter that specifies what work must do the function.. CAPITALIZE characters,  normalize characters, substitute
characters... for default IMHO is this last... just to not loose the meaning of the keyword REPLACE$  (fun to think a PRINT keyword that read a data from keyboard !)
Waiting your and other feedback
Good Programming and Good Life
Title: Re: QB64 v1.5 Feature Request - new string functions
Post by: Richard on July 26, 2020, 05:35:13 am
@TempodiBasic

I like your string names.

To be more useful it is important to be able to replace a string subset with NULL and of course ALL characters 0 - 255.

REPLACE is term used by Notepad - however CHANGE is term used by the QB64 IDE, and maybe a better choice of naming. Also SUBSTITUTE may be a candidate for naming.

Features (in line with the IDE) would have Match Upper/Lowercase, whole word, change first, Change All, go backwards for say one change, etc.
Title: Re: QB64 v1.5 Feature Request - new string functions
Post by: SMcNeill on July 26, 2020, 10:30:55 am
The problem with REPLACE type commands is nobody ever agrees what to replace.

I like food; my cat likes catfood.

Now in the above, let’s replace “food” with “cheese”.  A fight just started out because one group claims catfood should change, while another group claims its not an exact match.

So a REPLACE _EXACT command is added.

Now, a fight breaks out again.   One group extoles “food;“ isn’t an exact match to “food”.  The next group claims punctutation doesn’t count.

REPLACE _EXACT _NOPUNCTUATION is born.

Now a fight breaks out because someone changed the typo to “cat-food”.  One group wants that food to change now.  The other group says it shouldn’t...

REPLACE _EXACT _NOPUNCTUATION _IGNOREHYPHON is born.

And now a group complains because the command is too long, too complicated, and no one will ever use it....

Replace is a command that has to be custom rolled, in my opinion.  There’s just no way to please the masses when implementing it.  Add it to a language, and forevermore you’ll get suggestions on “how to improve it”.
Title: Re: QB64 v1.5 Feature Request - new string functions
Post by: FellippeHeitor on July 26, 2020, 10:33:14 am
Sounds like the beginning of a collective project to be featured in the samples gallery instead.
Title: Re: QB64 v1.5 Feature Request - new string functions
Post by: bplus on July 26, 2020, 10:43:52 am
Sounds like the beginning of a collective project to be featured in the samples gallery instead.

I don't know, Steve just put forward a pretty good argument for NOT that!

Quote
Replace is a command that has to be custom rolled, in my opinion.  There’s just no way to please the masses when implementing it.  Add it to a language, and forevermore you’ll get suggestions on “how to improve it”.
Title: Re: QB64 v1.5 Feature Request - new string functions
Post by: FellippeHeitor on July 26, 2020, 10:45:38 am
His arguments - all of which make perfect sense - would be not to add it to the language itself.

Think of CircleFill, though: several decisions have had to be made in that one and now we have a major tool available for everyone to use.
Title: Re: QB64 v1.5 Feature Request - new string functions
Post by: bplus on July 26, 2020, 10:50:14 am
His arguments - all of which make perfect sense - would be not to add it to the language itself.

Think of CircleFill, though: several decisions have had to be made in that one and now we have a major tool available for everyone to use.

Yeah, OK not to the language definitely, do we have these various versions of Replace hammered out somewhere yet?

@SMcNeill do you have these versions somewhere: REPLACE _EXACT _NOPUNCTUATION _IGNOREHYPHON is born.
Title: Re: QB64 v1.5 Feature Request - new string functions
Post by: luke on July 26, 2020, 10:58:20 am
All you need is a function that does plain search replace and one that does regex matches, and all of Steve's strange desires for catfood are taken care of.

result$ = REGEXREPLACE(regex$, replacement$, subject$[, limit&])

Now let's all argue over whether we use POSIX or perl regexen.
Title: Re: QB64 v1.5 Feature Request - new string functions
Post by: bplus on July 26, 2020, 11:08:51 am
All you need is a function that does plain search replace and one that does regex matches, and all of Steve's strange desires for catfood are taken care of.

result$ = REGEXREPLACE(regex$, replacement$, subject$[, limit&])

Now let's all argue over whether we use POSIX or perl regexen.

Well for starters, I would be happy to see one version or the other :)

I assume the version TempodiBasic posted is the regular "plain" version, straight replacement regardless of before and after the string? and I can assume the straight replace is case sensitive? ie "Food" would not get replaced if "food" was to be replaced.
Title: Re: QB64 v1.5 Feature Request - new string functions
Post by: TempodiBasic on July 26, 2020, 01:48:22 pm
Hi guys
fine to meet you again
well I agree with the funny tale of Steve that brings his experience into developing a new Keyword of language, but this
I don't know, Steve just put forward a pretty good argument for NOT that!

  is one reality, not all reality...
the solution of Fellippe : make a new tool for toolbox is a good mediation between new keyword generating disaster and nothing to do for REPLACE$, so each coder does by his own.

and thanks to luke I have learned regex idea! https://en.wikipedia.org/wiki/Regular_expression (https://en.wikipedia.org/wiki/Regular_expression)
Thanks!

Yes Bplus my plain prototype is case sensitive, but it is possible to project an option panel like this one
  [ This attachment cannot be displayed inline in 'Print Page' view ]  
all we need is a large discussion going to a consensus about What to do (How should REPLACE$  be?)  and How it must be done (Is it a FUNCTION? In this case What kind of feedback does  it give? What error number feedback does it send? ....to not waste your time and your energy!
Title: Re: QB64 v1.5 Feature Request - new string functions
Post by: SpriggsySpriggs on July 26, 2020, 02:42:32 pm
Functions to remove/replace characters from a string as a built in function would be awesome if they can do that
Title: Re: QB64 v1.5 Feature Request - new string functions
Post by: +KZ on July 26, 2020, 07:42:28 pm
I realize that "for next" can only contain one variable (correct me if I'm wrong)

my suggestion is enable "for next" to contain more variables

example:

Code: QB64: [Select]
  1. 'Actual:
  2. FOR X = 1 TO 5
  3. IF z < 3 THEN z = z + 1
  4.  
  5. Y = x + z
  6.  
  7. 'My suggestion
  8.  
  9. FOR X = 1 TO 5, z = 1 TO 3                        'CAN BE:  |IF z < 3 THEN z = z + 1|  OR  |z = z + 1: IF z > 3 then z = 1|
  10.  
  11. Y = x + z
  12.  
  13.  
Title: Re: QB64 v1.5 Feature Request - new string functions
Post by: SpriggsySpriggs on July 26, 2020, 10:59:28 pm
@+KZ I like that idea.
Title: Re: QB64 v1.5 Feature Request - new string functions
Post by: SMcNeill on July 26, 2020, 11:18:34 pm
FOR X = 1 TO 5, z = 1 TO 3                       
 'CAN BE:  |IF z < 3 THEN z = z + 1|  OR  |z = z + 1: IF z > 3 then z = 1|
 
Y = x + z
PRINT Y
NEXT

I think I’m confused by the above.  The comments seem to show two completely different concepts. 

The first (IF z < 3 THEN z = z + 1), seems to indicate z would be 1, 2, 3, 3, 3, during the 5 passes of X. 

The second (z = z + 1: IF z > 3 then z = 1), seems to indicate z would be 1, 2, 3, 1, 2.

Those are vastly different results!

Wouldn’t the easy way simply be:


 
FOR X = 1 TO 5
z = z MOD 3 + 1
Y = x + z
PRINT Y
NEXT

Here, z would be 1, 2, 3, 1, 2.  If you actually wanted 1, 2, 3, 3, 3, wouldn’t that IF statement in the original be easier to understand and more readable?
Title: Re: QB64 v1.5 Feature Request - new string functions
Post by: bplus on July 27, 2020, 11:42:59 am
I realize that "for next" can only contain one variable (correct me if I'm wrong)

my suggestion is enable "for next" to contain more variables

example:

Code: QB64: [Select]
  1. 'Actual:
  2. FOR X = 1 TO 5
  3. IF z < 3 THEN z = z + 1
  4.  
  5. Y = x + z
  6.  
  7. 'My suggestion
  8.  
  9. FOR X = 1 TO 5, z = 1 TO 3                        'CAN BE:  |IF z < 3 THEN z = z + 1|  OR  |z = z + 1: IF z > 3 then z = 1|
  10.  
  11. Y = x + z
  12.  
  13.  



Quote
I think I’m confused by the above.

Agreed, I took it to mean an (x, z) array with x columns and z layers. I was ignoring "actual" and just reading the code suggestion as I would finding it in an app.
Title: Re: QB64 v1.5 Feature Request - new string functions, multi-variable for next
Post by: TempodiBasic on July 27, 2020, 07:04:36 pm
A loop FOR NEXT with more variables...
how many?
the first is the counter of loop FOR and the other variables are added variables that cannot be longer/bigger than the first one.

For my little experience I cannot imagine when a feature like this can be used and what advantages can bring with it!
But this is only my point of view.
I'm look at its use.
Title: Re: QB64 v1.5 Feature Request - new string functions
Post by: bplus on July 28, 2020, 12:09:10 am
It is curious how ", multi-variable FOR-NEXT" was slipped into the topic title.

I took it out of my posts but odd how it got in there so that the whole thread is carrying that Title.
Title: Re: QB64 v1.5 Feature - new string fns,multi-var FOR-NEXT, autofill block statements
Post by: Richard on August 19, 2020, 12:30:01 am
For "BLOCK Statements" eg

FOR … NEXT
DO … LOOP
WHILE ...WEND
SELECT CASE … END SELECT
IF … ENDIF
etc

it would save some time to let the IDE auto fill the termination of the block code.

For example, when starting off a new line of code such as    FOR I....     that the IDE auto inserts a blank line followed by another line  NEXT I...

At present the IDE "flags an error" (FOR without NEXT) - which is correct but it is practically impossible to type in the required NEXT … line before the warning message pops up - so why not let the IDE just insert the NEXT … line instead of giving an error message?

Similarly for all the other "Block Statements" as per above (and maybe other things as well).

I know this may sound to be "poor programming" - however it would make sense to automate as much as possible any repetitive (even trivial) tasks to allow focus on the "real" programming task at hand.

Title: Re: QB64 v1.5 Feature - new string fns,multi-var FOR-NEXT, autofill block statements
Post by: SMcNeill on August 19, 2020, 01:20:27 am
For "BLOCK Statements" eg

FOR … NEXT
DO … LOOP
WHILE ...WEND
SELECT CASE … END SELECT
IF … ENDIF
etc

it would save some time to let the IDE auto fill the termination of the block code.

For example, when starting off a new line of code such as    FOR I....     that the IDE auto inserts a blank line followed by another line  NEXT I...

At present the IDE "flags an error" (FOR without NEXT) - which is correct but it is practically impossible to type in the required NEXT … line before the warning message pops up - so why not let the IDE just insert the NEXT … line instead of giving an error message?

Similarly for all the other "Block Statements" as per above (and maybe other things as well).

I know this may sound to be "poor programming" - however it would make sense to automate as much as possible any repetitive (even trivial) tasks to allow focus on the "real" programming task at hand.

The problem here comes with human-computer interaction.

DO
    Stuff
    FOR
        Stuff
    NEXT
     Stuff
LOOP

Let’s say the above is my code, as I wrote it originally.

Now, let’s say I want to move that NEXT to go before my LOOP statement, after the 3rd Stuff.

I cut it...   The IDE now detects a FOR without NEXT error, so it places a NEXT statement directly after the FOR...

I paste the NEXT at the new spot where I think it should belong...  ERROR — NEXT WITHOUT FOR...

And now I have to sort out where the heck that automatically inserted NEXT appeared, just so I can delete it!
Title: Re: QB64 v1.5 Feature - new string fns,multi-var FOR-NEXT, autofill block statements
Post by: Richard on August 19, 2020, 01:30:55 am
Thanks Steve for reply.

The suggestion was for    "brand new code lines generated in real(live) time"    not for code already in existence - so feature not applicable to editing (copy/cut/paste , replacing, included files, etc.).

Similar to in the      IDE > Edit > New SUB... (or New FUNCTION...)
Title: Re: QB64 v1.5 Feature - new string fns,multi-var FOR-NEXT, autofill block statements
Post by: SMcNeill on August 19, 2020, 02:03:48 am
Thanks Steve for reply.

The suggestion was for    "brand new code lines generated in real(live) time"    not for code already in existence - so feature not applicable to editing (copy/cut/paste , replacing, included files, etc.).

Except the IDE doesn’t know the difference between a new line and an edited line.  It just checks your whole program, from first character to last character, with every keystroke and change you make in the IDE.

Personally, I’d like to see a hotkey added for quick insertion based on the error message.

ERROR — FOR WITHOUT NEXT

Say we see the above error...  A hotkey combo of CTRL-I would paste a NEXT statement wherever our cursor current sits, as a quick insert method.

This hotkey only saves a few characters typing with NEXT, LOOP, WEND, END SUB, END FUNCTION, and such, but it could be a quick and easy means to define variables when OPTION _EXPLICIT is in use.

ERROR — MyVar NOT DEFINED

Just hit Ctrl-I and presto!  DIM MyVar AS SINGLE appears.  (Or whatever the default variable type is.  QB64 tracks those types internally, so it can define them automatically for you.)

(Of course, a different hotkey might be necessary, if ctrl-i is already in use, but I personally like the idea of having control over placement of code, rather than having the IDE automatically put it where it thinks it might belong.)
Title: Re: QB64 v1.5 Feature - new string fns,multi-var FOR-NEXT, autofill block statements
Post by: Richard on August 19, 2020, 02:18:08 am
How would this work instead …


Special hot "key cluster" example -


Press and hold [Ctrl] press "I" (and still holding Ctrl) press "F" (release Ctrl)  --->   auto generates  IF  … blank line …  END IF

Press and hold [Ctrl] press "F", press "O", press "R" (now release Ctrl)     ---> auto generates    FOR … blank line … NEXT

etc

So now almost like      IDE > Edit > New SUB...      functionality
Title: Re: QB64 v1.5 Feature - new string fns,multi-var FOR-NEXT, autofill block statements
Post by: krovit on August 19, 2020, 10:27:07 am
Hi,
What an interesting discussion!

Anyone who has "studied" a bit knows that "purist" programming approaches an idea with block diagrams and flowcharts ... in fact, I don't do that... :)

It would be a good system, if you have clear - but very clear - ideas about what you want. There are so many behavioral variables and cases that it is not always easy to operate in a "scientific" and preventive way.

In programming, the natural tendency to classify, order, predict, standardize helps me a lot. In this way, unexpected events are almost always absorbed into the code without too many traumas.

The thing I miss most in QB64 is an integrated and simple system that allows the observation of variables in every moment of the data flow. In some unfortunate cases - or when I resume a complex project after a long time - I waste hours trying to identify where a certain variable takes on a value rather than another. Assuming, then, that you find it!

Fellippe did something similar but it seems too heavy and invasive for everyday use.

The second thing missing is a truly powerful editor. I use DavsIDE, which I believe is the "maximum of the minimum" possible. Certainly there would be a need for much more. For example the identification of the code. In this regard a dedicated plug-in for Notepad ++ would be useful. Has anyone ever thought about it?

The third thing that would help a lot has to do with the editor and is a system that with the simple press of a function key compresses and expands the code contained in subs, functions and routines. this way the code would look more natural.

all this was present in a fantastic basic for the motorola 68000 of the Atari ST: it was the GFA Basic. A very powerful dialect (developed in Germany, I think) with which you could do anything and very similar to QB64. Plus many native functions for calling Atari's Apple-style visual systems.

In summary:
1) variable control
2) editor
3) code compaction and identification function


Title: Re: QB64 v1.5 stringFns,multi-varFOR-NEXT,autofill░statements,debug,IDE auto refresh
Post by: Richard on August 21, 2020, 11:03:02 pm
Would be extremely useful to have option selectable   IDE loaded program auto refresh (programmable say every 60 seconds) or at least an IDE button to do manual refresh of loaded program.
Title: Re:QB64 v1.5 $Fn,multivarFOR-NEXT,autofill░statements,debug,IDErefresh, TITLEbar
Post by: Richard on September 12, 2020, 12:23:24 am
Option to modify TITLE bar to be a very short wide graphics window?


  [ This attachment cannot be displayed inline in 'Print Page' view ]  


I was thinking about changing the little icon on the left hand side to be a very wide icon instead and I would try to write a program to constantly change this in real time.

The intention is to have something like a "Windows Taskbar" or "Apple Dock" with VERY LIMITED graphics resolution - without resorting to putting same inside the program output window general graphics.

Hopefully someone can point me in the right direction in the QB64 source code to configure this specially - at this stage, depending on the format of the "very wide icon", I may not need assistance to create the "very wide icon".
Title: Re: QB64 v1.5 MOVe & REName statements for files and directories
Post by: Richard on September 25, 2020, 07:16:41 am
Unless I missed it in all the posts...


Have proper means of MOVING and RENAMING files/directories without having to resort to eg

SHELL "COPY   D:\oldfilename$   D:\newfilename$"
KILL "D:\oldfilename$"

for renaming



Similarly


SHELL  "COPY    D:\filename$   D:\TRASH\filename$"
KILL "D:\filename$"

for moving


It is important to reduce wear and tear on the HHD and SSD - especially with SSD that have a very limited rewrite cycles (factored with when rewriting to SSD - depending on the model number - up to 4 MBytes minimum is "block erased" even for say a 4KB file due to the very nature of the non-volatile silicon design). Generally speaking SSD have close to "infinite" reads, it is just the erase/rewrite procedure that is drastically reduced in the number of times it can be performed.

Maybe a Windows API procedure?
Title: Re: QB64 v1.5 MOVe & REName statements for files and directories
Post by: SMcNeill on September 25, 2020, 08:34:33 am
Unless I missed it in all the posts...


Have proper means of MOVING and RENAMING files/directories without having to resort to eg

SHELL "COPY   D:\oldfilename$   D:\newfilename$"
KILL "D:\oldfilename$"

for renaming



Similarly


SHELL  "COPY    D:\filename$   D:\TRASH\filename$"
KILL "D:\filename$"

for moving


It is important to reduce wear and tear on the HHD and SSD - especially with SSD that have a very limited rewrite cycles (factored with when rewriting to SSD - depending on the model number - up to 4 MBytes minimum is "block erased" even for say a 4KB file due to the very nature of the non-volatile silicon design). Generally speaking SSD have close to "infinite" reads, it is just the erase/rewrite procedure that is drastically reduced in the number of times it can be performed.

Maybe a Windows API procedure?

Try NAME: https://www.qb64.org/wiki/NAME

NAME "BIGBAD.TXT" AS "BADWOLF.TXT"
Title: Re: QB64 v1.5 Feature - new string fns,multi-var FOR-NEXT, autofill block statements
Post by: OldMoses on September 25, 2020, 08:36:40 am
The third thing that would help a lot has to do with the editor and is a system that with the simple press of a function key compresses and expands the code contained in subs, functions and routines. this way the code would look more natural.

I'm not sure how a function key would work on something like that, but maybe a metacommand after a SUB/FUNCTION line that would hide all code between it and its END line. Once you've finished a SUB/FUNCTION and no longer need to work on it, it would be incredibly useful to have it working in the program, but hidden in the IDE and not hogging up scrolling time and visual space when navigating through large programs. While the View/SUBs dialog will get you there all the same and maybe quicker, I still think the reduction of screen clutter would be helpful. Very large projects, I think, would benefit greatly from this.

SUB DoABlock (var AS INTEGER, etc...)
stuff
stuff
stuff
stuff
END SUB

SUB BlockImWorkingOn (var AS INTEGER, etc...)
stuff
stuff
stuff
stuff
END SUB

FUNCTION GetAResult%
stuff
stuff
stuff
stuff
END FUNCTION

becomes....

SUB DoABlock (var AS INTEGER, etc...) $Hide2End

SUB BlockImWorkingOn (var AS INTEGER, etc...)
stuff
stuff
stuff
stuff
END SUB

FUNCTION GetAResult% $Hide2End
Title: Re: QB64 v1.5 MOVe & REName statements for files and directories
Post by: SpriggsySpriggs on September 25, 2020, 11:13:26 am
(                               QB64 v1.5      MOVe   &   REName    statements for files and directories

@Richard For Move and Rename, check my API collection zip or the forum link here: https://www.qb64.org/forum/index.php?topic=3034.msg123040#msg123040 (https://www.qb64.org/forum/index.php?topic=3034.msg123040#msg123040)
I used the WinAPI to write code to allow for Move, Copy, Rename, Recycle, and Empty Recycle Bin. Maybe this is what could be used for 1.5?
Title: Re: QB64 v1.5 MOVe & REName statements for files and directories
Post by: SMcNeill on September 25, 2020, 02:49:19 pm
@Richard For Move and Rename, check my API collection zip or the forum link here: https://www.qb64.org/forum/index.php?topic=3034.msg123040#msg123040 (https://www.qb64.org/forum/index.php?topic=3034.msg123040#msg123040)
I used the WinAPI to write code to allow for Move, Copy, Rename, Recycle, and Empty Recycle Bin. Maybe this is what could be used for 1.5?

We already have the NAME command, which renames, or moves, a file.

NAME “C:\QB64\temp.bas” AS “C:\QB64\temp\temp.bas”  <— This will move temp.bas from the QB64 folder to the QB64\temp folder.



For a file copy:

OPEN “yourfile.ext” FOR BINARY AS #1
OPEN “yourcopy.ext” FOR BINARY AS #2
l = LOF(1)
temp$ = SPACE$(l)
GET #1, 1, temp$
PUT #2, 1, temp$
CLOSE
Title: Re: QB64 v1.5 MOVe & REName statements for files and directories
Post by: SpriggsySpriggs on September 25, 2020, 04:32:23 pm
For a file copy:

OPEN “yourfile.ext” FOR BINARY AS #1
OPEN “yourcopy.ext” FOR BINARY AS #2
l = LOF(1)
temp$ = SPACE$(l)
GET #1, 1, temp$
PUT #2, 1, temp$
CLOSE
@SMcNeill
That seems like a lot of lines just to say copy from here to here. At that point you might as well just SHELL and use some CMD command. Besides, since mine uses the built in Windows functions it actually gives confirmation dialogs to prevent overwrites and such. Does NAME AS create the directory if it doesn't exist or does the directory have to exist?
Title: Re: QB64 v1.5 MOVe & REName statements for files and directories
Post by: SMcNeill on September 25, 2020, 04:35:55 pm
That seems like a lot of lines just to say copy from here to here. At that point you might as well just SHELL and use some CMD command. Besides, since mine uses the built in Windows functions it actually gives confirmation dialogs to prevent overwrites and such.

Just make it a single SUB.  SHELL comes with several issues, such as OS dependency, and user permissions.  I tend to find it best to handle program execution internally, when possible, rather than just shelling out for everything.
Title: Re: QB64 v1.5 MOVe & REName statements for files and directories
Post by: SpriggsySpriggs on September 25, 2020, 04:49:27 pm
Just make it a single SUB.  SHELL comes with several issues, such as OS dependency, and user permissions.  I tend to find it best to handle program execution internally, when possible, rather than just shelling out for everything.
Which is why I used the WinAPI functions found in Shell32 so I could have all the nice things that Windows offers with the confirmation dialogs and progress bars and creation of directories if they don't already exist when doing a copy or move. I know you can write in message boxes and check for directories and files existing but why not just let Windows handle it since, after all, it is a Windows program. I don't write things for Linux or Mac because I haven't found Linux or Mac to be good solutions for me as alternative operating systems. I'm a Windows man.
Title: Re: QB64 v1.5 MOVE & RENAME statements files/directories, IDE hotkey expansion
Post by: Richard on September 25, 2020, 09:00:28 pm
Quote

Try NAME: https://www.qb64.org/wiki/NAME

NAME "BIGBAD.TXT" AS "BADWOLF.TXT"


@Steve - thanks - it even works with filenames containing spaces (without having to pre- post- attach CHR$(&H22) for SHELL … as I had to before)
Title: Re: QB64 v1.5 MOVE & RENAME statements files/directories, IDE hotkey expansion
Post by: SpriggsySpriggs on September 25, 2020, 10:21:49 pm
@Richard This is how this works:
Code: QB64: [Select]
  1. A = Move(_DIR$("desktop") + "QB64 x64\test.txt", _DIR$("desktop") + "test.txt")

 [ This attachment cannot be displayed inline in 'Print Page' view ]  
Title: Re: QB64 v1.5 MOVE & RENAME files/directories,IDE hotkey expansion, Win KB->bytes
Post by: Richard on September 25, 2020, 10:50:23 pm
This maybe beyond the scope of QB64 but...

Any way (as an option) that QB64 on startup (or in a program) override Windows File Explorer displaying of file sizes in KB, rather display as bytes (comma separated)?

I have been "caught out" many times using Windows File explorer when it shows two files as the same size (in KB) but often the file sizes differ by a few bytes. I suspect that I had problems of using the File Explorer to merge files together and it tells the files are the same size (but I guess it seems only in KB) and so I allowed Windows not to keep two files the same size (KB) etc.

To display bytes (rather than KB) would only occupy display real estate of only 1 extra character.


I know that I can use for instance DOS CMD for file sizes (bytes), also use QB64 LOF(…) for program investigation of files sizes, and also that there are 3rd party software that do this. However, for convenience, it would be nice if Windows File Explorer was "modified" to display (as an option) file sizes in bytes.

I have searched the internet on the solution - but it appears Windows does not want anyone to change file size display.

Is there a way to do this - eg Registry setting  or  even a Windows API to do this?
Title: Re: QB64 v1.5 MOVE & RENAME files/directories,IDE hotkey expansion, Win KB->bytes
Post by: SpriggsySpriggs on September 25, 2020, 11:00:46 pm
I know that I can use for instance DOS CMD for file sizes (bytes), also use QB64 LOF(…) for program investigation of files sizes, and also that there are 3rd party software that do this. However, for convenience, it would be nice if Windows File Explorer was "modified" to display (as an option) file sizes in bytes.
Is there a way to do this - eg Registry setting  or  even a Windows API to do this?

@Richard I will check all over the Internet for registry values concerning this. I remember making a C# program that edited the registry so I will see what I can do.
Title: Re: QB64 v1.5 MOVE & RENAME files/directories,IDE hotkey expansion, Win KB->bytes
Post by: SpriggsySpriggs on September 25, 2020, 11:31:18 pm
Quite unfortunately there is no way to do it. According to Microsoft, you can download a third party application to see the true file size but you cannot change the computer in any way (supposedly) to show it differently. Oh well.
Title: Re: QB64 v1.5 MOVE & RENAME files/directories,IDE hotkey expansion, Win KB->bytes
Post by: Richard on September 25, 2020, 11:49:27 pm
@SpriggsySpriggs

Thanks for trying.


As a cheap, nasty, dirty, backdoor approach to the problem...

Is there a way for QB64 (in a program) to interrogate the File Explorer currently running to "see" the "Details Pane" (ie the files/folders and which usually displays file sizes (KB)) - then in my program I would at say 6 second intervals - display my small program display window which would eg CMD do a directory listing of the CURRENT FOLDER in the "Navigation Pane".

This I could make automatic in my program to save doing it manually.


Summary:

CLIPBOARD "current FOLDER in Navigation Pane" for use by QB64?   
Title: Re: QB64 v1.5 MOVE & RENAME files/directories,IDE hotkey expansion, Win KB->bytes
Post by: bplus on September 26, 2020, 11:13:35 am
This maybe beyond the scope of QB64 but...

Any way (as an option) that QB64 on startup (or in a program) override Windows File Explorer displaying of file sizes in KB, rather display as bytes (comma separated)?

I have been "caught out" many times using Windows File explorer when it shows two files as the same size (in KB) but often the file sizes differ by a few bytes. I suspect that I had problems of using the File Explorer to merge files together and it tells the files are the same size (but I guess it seems only in KB) and so I allowed Windows not to keep two files the same size (KB) etc.

To display bytes (rather than KB) would only occupy display real estate of only 1 extra character.


I know that I can use for instance DOS CMD for file sizes (bytes), also use QB64 LOF(…) for program investigation of files sizes, and also that there are 3rd party software that do this. However, for convenience, it would be nice if Windows File Explorer was "modified" to display (as an option) file sizes in bytes.

I have searched the internet on the solution - but it appears Windows does not want anyone to change file size display.

Is there a way to do this - eg Registry setting  or  even a Windows API to do this?

You know you can read a files byte size in the Properties Window of File Explorer?

The Explorer says all the All Digit files are 1K but I get the Byte Size from properties.

Here is Luke record to All Digits solution:
  [ This attachment cannot be displayed inline in 'Print Page' view ]  
Title: Re: QB64 v1.5 MOVE & RENAME files/directories,IDE hotkey expansion, Win KB->bytes
Post by: Richard on September 26, 2020, 11:32:57 am
@B+

Thanks for the reply - yes I knew of the Windows Properties feature.

However, when "eye-balling" a list say of over a thousand files - it becomes tiring to constantly get the file properties - I might as well just go to CMD window and do a directory listing (sort of defeats the purpose of having File Explorer).
Title: Re: QB64 v1.5 MOVE & RENAME files/directories,IDE hotkey expansion, Win KB->bytes
Post by: SMcNeill on September 26, 2020, 12:20:09 pm
@B+

Thanks for the reply - yes I knew of the Windows Properties feature.

However, when "eye-balling" a list say of over a thousand files - it becomes tiring to constantly get the file properties - I might as well just go to CMD window and do a directory listing (sort of defeats the purpose of having File Explorer).

You might give this a shot: https://www.smartftp.com/en-us/sizeinbytes

It’s supposedly a tool which alters explorer to show byte size instead of kb size, but I haven’t used it, nor do I actually know the developer.  Junk like that always makes me wary of spamware, spyware, and crap which might be included with it.  If anyone has a bare bones system, or a sandbox for testing first, I’d definitely let them give it a go before trying it on my work machine.
Title: Re: QB64 v1.5 MOVE & RENAME files/directories,IDE hotkey expansion, Win KB->bytes
Post by: bplus on September 26, 2020, 12:23:11 pm
@B+

Thanks for the reply - yes I knew of the Windows Properties feature.

However, when "eye-balling" a list say of over a thousand files - it becomes tiring to constantly get the file properties - I might as well just go to CMD window and do a directory listing (sort of defeats the purpose of having File Explorer).

OK in view > details > sort by > size and the files are listed largest to smallest in bytes!

  [ This attachment cannot be displayed inline in 'Print Page' view ]  

Oh ha! Lukes is listed longest in EXE and Richard Frost as smallest but I check Properties and all 3 are exactly the same byte size in the EXE's.
Title: Re: QB64 v1.5 MOVE & RENAME files/directories,IDE hotkey expansion, Win KB->bytes
Post by: Richard on September 26, 2020, 01:02:47 pm
Quote

You might give this a shot: https://www.smartftp.com/en-us/sizeinbytes

It’s supposedly a tool which alters explorer to show byte size instead of kb size, but I haven’t used it, nor do I actually know the developer.  Junk like that always makes me wary of spamware, spyware, and crap which might be included with it.  If anyone has a bare bones system, or a sandbox for testing first, I’d definitely let them give it a go before trying it on my work machine.

@Steve - many thanks - I took a gamble and installed on my Windows 10 x64 - it did not bring any issues (yet) or any action required with my Windows Defender Folder Protection for the WHOLE of  C Drive. I will let you know of any issues if this program causes on my machine.





  [ This attachment cannot be displayed inline in 'Print Page' view ]





Downloaded the free version (at bottom of webpage) - did not need paid version (for Client stuff)

WARNING   When "installing the .MSI"   ALL INSTANCES of Windows Explorer will be terminated!!!
Title: Re: QB64 v1.5 Statement(s) force program run on selected physical/logical processors
Post by: Richard on October 03, 2020, 10:42:17 pm
It may already have been mentioned elsewhere...

Are there (or could there be statements made) to allow user control on which physical (and/or logical) processor a particular QB64 x64 program will run on Windows 10.

I have a laptop with 4 cores i7 (8 logical processors) and would like to ensure (my option) that multiple instances of QB64 (different) programs run on different processors.

I had 3 different (non-interacting with each other) QB64 programs running and because of the the very slow performance I suspect that all 3 programs were running using the same physical (+logical) processor maybe???

If statements are not (or cannot be) available - would it help to have multiple QB64 x64 installations  eg on C:\ , A:\, D:\ etc and accordingly run each program from a different QB64 installation?

Similarly if I wish to force multiple programs to run on a particular physical/logical processor (where speed is not important) - is this possible to program?
Title: Re: QB64 v1.5 Statement(s) force program run on selected physical/logical processors
Post by: luke on October 03, 2020, 11:30:00 pm
You should think long and hard about why you're smarter than the Windows task scheduler.

If you still decide you want to restrict it to running a process on a particular CPU, you can right click the process in Task Manager and Set Affinity.

I doubt you'll get a measurable performance improvement though.
Title: Re: QB64 v1.5 Statement(s) force program run on selected physical/logical processors
Post by: Richard on October 04, 2020, 12:36:58 am
@luke

Thanks for reply.

I can see the Task Manager > Details > Processor Affinity (All, 0-7 in my case).

Question now  is - can I change this setting in a QB64 program?


I would have hoped that Windows 10 x64 (via Task Manager Scheduler) would do the optimal configuration - however I have noticed progressively (say over a year) that performance has dropped for the same task at hand. I am just guessing that I may regain some performance loss by very specific "tweaking" of where the processes are running.
Title: Re: QB64 v1.5 Statement(s) force program run on selected physical/logical processors
Post by: luke on October 04, 2020, 02:56:16 am
https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-setprocessaffinitymask

But I still doubt it'll have a net benefit. You'd probably see more by fiddling with task priority instead.
Title: Re: QB64 v1.5 Additional Code Select Options (for Forum Reply / New Topic)
Post by: Richard on October 19, 2020, 07:08:57 am
It would be useful to have additional options for the Code Select Box - I was thinking of HTML (and others) if this can be made workable in the forum environment.  Although working with HTML would be much more difficult than say just text only or inserting JPG images - it could produce a much better overall appearance.

I checked the SMF forum on this and they mentioned that QB64 site had custom made the Code Select Box (options) and so any additional options would have to be done by QB64 themselves.

I was referenced over to the site below (for the Mods) and it seems that there are some 200 code options available.

https://custom.simplemachines.org/mods/index.php?mod=3070
 (https://custom.simplemachines.org/mods/index.php?mod=3070)


Quote
Description:
cb|GeSHi= -mod 1.2

cb|GeSHi-mod adds code syntax highlighting = to your forum. Powered by GeSHi, the mod= supports +200 different languages and is fully customizable for each of yo= ur themes.

Compatible with SMF 2.0 and later.

What's = new in 1.2?

- GeSHi sources updated to 1.0.8.11 which inclu= des some new languages
- Minor fix to avoid error notices in the logs wh= en running on PHP 5.4



GNU General Public License v3.0
cb|GeSHi-mod - Syntax Highlighter mod for SMF powered by GeSHi
Cop= yright (C) 2012-2013, codebirth
Website: htt= p://www.codebirth.com

Powered by GeSHi - http://qbnz.com/highlighter/

 
 [ This attachment cannot be displayed inline in 'Print Page' view ]  
Title: Re: QB64 v1.5 IDE Help
Post by: Richard on October 19, 2020, 07:18:24 am
As an addition to the information available in the IDE help window...


May be useful to have the equivalent of a "Glossary of Terms" that would assist in the explaining of say problems at hand.

For example (using text representation of a screen) - assigning simple names to the various screens/windows such as IDE window, program window, DOS shell window, etc.

Title: Re: QB64 v1.5 Additional Code Select Options (for Forum Reply / New Topic)
Post by: FellippeHeitor on October 19, 2020, 09:23:43 am
It would be useful to have additional options for the Code Select Box - I was thinking of HTML (and others) if this can be made workable in the forum environment.  Although working with HTML would be much more difficult than say just text only or inserting JPG images - it could produce a much better overall appearance.

I checked the SMF forum on this and they mentioned that QB64 site had custom made the Code Select Box (options) and so any additional options would have to be done by QB64 themselves.

I was referenced over to the site below (for the Mods) and it seems that there are some 200 code options available.

https://custom.simplemachines.org/mods/index.php?mod=3070
 (https://custom.simplemachines.org/mods/index.php?mod=3070)

  [ This attachment cannot be displayed inline in 'Print Page' view ]

Although this seems alien to this topic, let me address your issue.

The HTML support that GeSHi has is for highlighting HTML samples - for showcasing HTML source - not for formatting forum posts with HTML. Although it doesn't show in the Code dropbox when you write a post, you can simply add =html instead of =qb64 when you add a codebox - in case you'll ever need to discuss an html snippet here in the forum.

As an example, a QB64 codebox (which starts with [code=qb64]:
Code: QB64: [Select]
  1. PRINT "Hello, world!"

And an HTML codebox (which starts with [code=html]:
Code: Text: [Select]
  1. <html>
  2.     <head>
  3.         <title>A webpage written in Frontpage - Happy 1998!</title>
  4.     </head>
  5.  
  6.     <body>
  7.         <p>Hello, world!</p>
  8.     </body>
  9. </html>
Title: Re: QB64 v1.5 IDE Help
Post by: FellippeHeitor on October 19, 2020, 09:25:00 am
As fot the feature suggestions, we do read this topic (as well as all others), but the best place for adding feature requests is in the repository, as they are kept in a more organised way (not to mention this is 6 pages long already):

https://github.com/QB64Team/qb64/issues

That's the official way both for feature requests and bug reports.
Title: Re: QB64 v1.5 IDE Help
Post by: Richard on November 03, 2020, 09:15:37 pm
@ Fellippe

Thanks for reply - as suggested by you will place new feature requests in the repository - I did not know (or long time forgotten) about the preferred  place.

Just curious, if you would not mind answering, why even use a repository for features? Apart from you and maybe a few others preferring this (which is fair enough excuse) - I would have thought that say a "Feature Request sub-board in the QB64 forum" would make more sense (to me). I think from the old [abandoned, outdated and now likely malicious qb64 dot net website - don’t go there] site at some stage there was a sub-board devoted to this.

Please ignore immediate below

I am practising with html code a little bit for a little while to see if I could ever improve presentation of my replies - it may not work at all for me.

Code: Text: [Select]
  1.  
  2. <html>
  3.     <head>
  4.         <title>Ignore this test html code</title>
  5.     </head>
  6.  
  7.     <body>
  8.         <p>Hello, world!</p>
  9.         A:visited {color: Red ! important }
  10.     </body>
  11. </html>
  12.  
  13.  



A side note:-  I used the new Microsoft EDGE to create this reply and all the "Buttons" (eg Bold, Italic, etc) appear to function as expected. It took about a year or two  for MS to finally address this issue (had to use Windows Internet Explorer previously for the Button use).
Title: Re: QB64 v1.5 PRINT USING HEX output (https://github.com/QB64Team/qb64/issues)
Post by: Richard on November 23, 2020, 05:44:00 pm
The preferred method for feature requests AND bugs etc is the link below

https://github.com/QB64Team/qb64/issues (https://github.com/QB64Team/qb64/issues)

Summary

#89   PRINT USING HEX output   by Richard   feature request


Just a thought...

For those using HEX output (rather than decimal) - it would be helpful to have formatting of the HEX output strings, e.g.

FF FF FF FF FF FF FF FF

FFFF,FFFF,FFFF,FFFF

instead of using say MID$ etc to format the output string

'__________________________________________________________________________________________________________________________
.ANSWER to QUIZ "When is 32GByte not equal to 32GByte?

Answer:-  When the definition of Gbyte changes.

e.g.

32 Gbyte of RAM (memory) = 34,359,738.368 bytes
32 Gbyte usb flash memory = 32,008,695,808 bytes (on a usb stick I inspected = 29.8GB)

(Trivial) Programming challenge - write a very simple program to determine TOTAL number of bytes on USB stick (free, used, faulty etc)
       
Title: Re: QB64 v1.5 PRINT USING HEX output (https://github.com/QB64Team/qb64/issues)
Post by: SpriggsySpriggs on December 14, 2020, 01:15:57 pm
@Richard

Challenge: Accepted

Code: QB64: [Select]
  1.  
  2. CONST DRIVE_UNKNOWN = 0
  3. CONST DRIVE_NO_ROOT_DIR = 1
  4. CONST DRIVE_REMOVABLE = 2
  5. CONST DRIVE_FIXED = 3
  6. CONST DRIVE_REMOTE = 4
  7. CONST DRIVE_CDROM = 5
  8. CONST DRIVE_RAMDISK = 6
  9.  
  10.     FUNCTION GetDiskFreeSpace% ALIAS GetDiskFreeSpaceExA (lpDirectoryName AS STRING, BYVAL lpFreeBytesAvailableToCaller AS _OFFSET, BYVAL lpTotalNumberOfBytes AS _OFFSET, BYVAL lpTotalNumberOfFreeBytes AS _OFFSET)
  11.     FUNCTION GetDriveType~& ALIAS GetDriveTypeA (lpRootPathName AS STRING)
  12.  
  13. DIM totalFreeBytesOnDisk AS _UNSIGNED _INTEGER64
  14.  
  15. IF GetDiskFreeSpace("L:\", 0, 0, _OFFSET(totalFreeBytesOnDisk)) THEN
  16.     SELECT CASE totalFreeBytesOnDisk
  17.         CASE IS < 1024
  18.             PRINT USING "    ####, B Available"; totalFreeBytesOnDisk,
  19.         CASE IS < (1024 ^ 2) AND totalFreeBytesOnDisk >= 1024
  20.             PRINT USING "####,.## KB Available"; (totalFreeBytesOnDisk / 1024)
  21.         CASE IS < (1024 ^ 3) AND totalFreeBytesOnDisk >= (1024 ^ 2)
  22.             PRINT USING "####,.## MB Available"; (totalFreeBytesOnDisk / (1024 ^ 2))
  23.         CASE IS < (1024 ^ 4) AND totalFreeBytesOnDisk >= (1024 ^ 3)
  24.             PRINT USING "####,.## GB Available"; (totalFreeBytesOnDisk / (1024 ^ 3))
  25.         CASE IS < (1024 ^ 5) AND totalFreeBytesOnDisk >= (1024 ^ 4)
  26.             PRINT USING "####,.## TB Available"; (totalFreeBytesOnDisk / (1024 ^ 4))
  27.     END SELECT
  28.  
  29. SELECT CASE GetDriveType("L:\")
  30.     CASE DRIVE_UNKNOWN
  31.         PRINT "Unkown drive type"
  32.     CASE DRIVE_NO_ROOT_DIR
  33.         PRINT "Invalid path"
  34.     CASE DRIVE_REMOVABLE
  35.         PRINT "Removable media"
  36.     CASE DRIVE_FIXED
  37.         PRINT "Fixed media"
  38.     CASE DRIVE_REMOTE
  39.         PRINT "Network media"
  40.     CASE DRIVE_CDROM
  41.         PRINT "CD-ROM drive"
  42.     CASE DRIVE_RAMDISK
  43.         PRINT "RAM disk"
Title: Re: QB64 v1.5 reply to SpriggsySpriggs challenge answer (re bytes free)
Post by: Richard on January 09, 2021, 10:11:37 am
@SpriggsySpriggs

Thanks for challenge program answer.

Your program adjusted back down to bytes (rather than GB etc) does give the expected result. I try to do EVERYTHING referring to Bytes (rather than KB etc) to avoid confusion later on due to "rounding errors etc" eg if comparing file sizes. I have read (unofficially) that MS uses a complicated method to convert bytes to KB, some people on the internet report MS is inconsistent in this conversion.

Do you have a list of ALL Kernel32 Dynamic Library FUNCTIONS immediately available for use in QB64 programs - unless I was looking at the wrong link - I don't seem to see FUNCTION GetDiskFreeSpaceExA listed in your API collection (maybe I am misreading everything?)?
Title: Re: QB64 v1.5 reply to SpriggsySpriggs challenge answer (re bytes free)
Post by: SpriggsySpriggs on January 09, 2021, 11:47:13 pm
@Richard I probably don't have it in my API collection. I think I did that function just for your challenge. I can add it, though. I don't have every function from Kernel32 but I occasionally look and find more to add. If you can think of others that you want then let me know
Title: Re: QB64 v1.5 reply to SpriggsySpriggs challenge answer (re bytes free)
Post by: Richard on January 10, 2021, 01:50:41 am
@SpriggsySpriggs

Thanks for reply.

Is it even possible, via API's, to get TotalNumberOfBytes of a drive. I have been looking at the Windows API site and it does not seem to me to be listed as a API function (or equivalently TotalNumberOfUsedBytes, GetDiskTotalSpace, etc)? If so please add to your API collection.

As a special request, I am interested in the API CopyMemory funtion

WindowsAPI>SystemServices>MemoryManagementReference>MemoryManagementFunctions>GeneralMemoryFunctions>CopyMemory

which copies a block of memory from one location to another.

In a new project of mine I wish to copy 1 GByte (if possible) of memory - I do not know if qb64 program can get this copy for use (such as in _MEM) - so I will have to work with the copy via some means outside of QB64.  An API function from you would be nice.  If you can also arrange that this copy is saved to a disk file that would be a plus.

Title: Re: QB64 v1.5 reply to SpriggsySpriggs challenge answer (re bytes free)
Post by: SpriggsySpriggs on January 16, 2021, 05:58:47 pm
@Richard

I don't know if I'd recommend trying to move around gigabytes of data but here is something that should work. You can see that using CopyMemory I was able to copy the information stored in a string and copy it to a _MEM block and print the information stored to a file.

Code: QB64: [Select]
  1.  
  2. CONST GIGABYTE = 1024 ^ 3
  3.  
  4.     SUB CopyMemory ALIAS RtlCopyMemory (BYVAL Destination AS _OFFSET, BYVAL Source AS _OFFSET, BYVAL length AS _INTEGER64)
  5.  
  6. m = _MEMNEW(GIGABYTE)
  7.  
  8. DIM gig AS STRING * GIGABYTE
  9.  
  10. gig = "Hello, Richard"
  11.  
  12. CopyMemory m.OFFSET, _OFFSET(gig), LEN(gig)
  13.  
  14. OPEN "HelloRichardTest.txt" FOR OUTPUT AS #1
  15. PRINT #1, _MEMGET(m, m.OFFSET, STRING * GIGABYTE)

I don't know what sort of data you are wanting to store with this or whatever but that should at least get you on your way.
Title: Re: QB64 v1.5 reply to SpriggsySpriggs challenge answer (re bytes free)
Post by: Richard on January 16, 2021, 07:55:55 pm
@SpriggsySpriggs

Thanks for code - you even gave me an extra 2 bytes for the file! :)    (a semi-colon on PRINT #1 line fixed that)

I modified slightly your code, as below, to investigate why I got millions of "SPACEs" in my file - I thought that it would EITHER be millions of "NULLs" (i.e. CHR(&H00)) or "RANDOM GARBAGE" (if things were not initialized properly).

I used a simple free HEX editor to quickly view the file - have not yet analyzed what is in the MEM block.

Anyone like to comment???

Code: QB64: [Select]
  1. CONST GIGABYTE = 1024 ^ 3
  2.     SUB CopyMemory ALIAS RtlCopyMemory (BYVAL Destination AS _OFFSET, BYVAL Source AS _OFFSET, BYVAL length AS _INTEGER64)
  3. DIM m AS _MEM: DIM I AS INTEGER: DIM gig AS STRING * GIGABYTE
  4. m = _MEMNEW(GIGABYTE)
  5. gig = "Hello, Richard"
  6. FOR i% = 1 TO 32
  7.     IF MID$(gig$, i%, 1) = " " THEN MID$(gig$, i%, 1) = "_"
  8.     IF MID$(gig$, i%, 1) = CHR$(&H00) THEN MID$(gig$, i%, 1) = "-"
  9. CopyMemory m.OFFSET, _OFFSET(gig), LEN(gig)
  10.  
  11. OPEN "A:\HelloRichardTest.txt" FOR OUTPUT AS #1
  12. PRINT #1, _MEMGET(m, m.OFFSET, STRING * GIGABYTE);
Title: Re: QB64 v1.5 reply to SpriggsySpriggs challenge answer (re bytes free)
Post by: SpriggsySpriggs on January 16, 2021, 08:55:12 pm
It's just space. I mean, I made a fixed string the size of 1 gigabyte (which, to my knowledge, would be 1 gigabyte of spaces, then a CHR$(0)) and then stored it in the mem block. That's what's in the mem block. Since I printed the mem block's contents to the file you would get a gigabyte's worth of spaces in the file since the mem block only contains my gigabyte string. I have no use for moving data like this and have never used mem blocks so I probably won't pursue this any further.
Title: Re: QB64 v1.5 reply to SpriggsySpriggs challenge answer (re bytes free)
Post by: NOVARSEG on January 16, 2021, 09:55:16 pm
Richard

Quote
I had 3 different (non-interacting with each other) QB64 programs running and because of the the very slow performance I suspect that all 3 programs were running using the same physical (+logical) processor maybe???

If statements are not (or cannot be) available - would it help to have multiple QB64 x64 installations  eg on C:\ , A:\, D:\ etc and accordingly run each program from a different QB64 installation?

Similarly if I wish to force multiple programs to run on a particular physical/logical processor (where speed is not important) - is this possible to program?

Windows already allows multiple applications to run at the same time.

For a, say, 486 CPU with 4 GB ram, you can run 4095 simultaneous x86 programs at the same time. That is like 30 year old technology..

If you are worried about speed then try to incorporate all the features of those programs into a single one.

There are methods in which multiple CPUs can work on a single problem to increase speed. I imagine these systems to be  complex and expensive so you would need a good reason to do so.
Title: Re: QB64 v1.5 reply to SpriggsySpriggs challenge answer (re bytes free)
Post by: SMcNeill on January 17, 2021, 03:55:42 am
@SpriggsySpriggs

Thanks for code - you even gave me an extra 2 bytes for the file! :)    (a semi-colon on PRINT #1 line fixed that)

I modified slightly your code, as below, to investigate why I got millions of "SPACEs" in my file - I thought that it would EITHER be millions of "NULLs" (i.e. CHR(&H00)) or "RANDOM GARBAGE" (if things were not initialized properly).

I used a simple free HEX editor to quickly view the file - have not yet analyzed what is in the MEM block.

Anyone like to comment???

Code: QB64: [Select]
  1. CONST GIGABYTE = 1024 ^ 3
  2.     SUB CopyMemory ALIAS RtlCopyMemory (BYVAL Destination AS _OFFSET, BYVAL Source AS _OFFSET, BYVAL length AS _INTEGER64)
  3. DIM m AS _MEM: DIM I AS INTEGER: DIM gig AS STRING * GIGABYTE
  4. m = _MEMNEW(GIGABYTE)
  5. gig = "Hello, Richard"
  6. FOR i% = 1 TO 32
  7.     IF MID$(gig$, i%, 1) = " " THEN MID$(gig$, i%, 1) = "_"
  8.     IF MID$(gig$, i%, 1) = CHR$(&H00) THEN MID$(gig$, i%, 1) = "-"
  9. CopyMemory m.OFFSET, _OFFSET(gig), LEN(gig)
  10.  
  11. OPEN "A:\HelloRichardTest.txt" FOR OUTPUT AS #1
  12. PRINT #1, _MEMGET(m, m.OFFSET, STRING * GIGABYTE);

_MEMNEW doesn’t initialize a memblock, so it can contain all sorts of random information.  If you need it to be blank, be certain to set it that way manually.

DIM M AS _MEM
M = _MEMNEW(10000000000) ‘10 GB
_MEMFILL M, M.OFFSET, M.SIZE, 0 AS _UNSIGNED _BYTE ‘fill with CHR$(0)
_MEMFILL M, M.OFFSET, M.SIZE, 32 AS _UNSIGNED _BYTE ‘fill with blank spaces
Title: Re: QB64 v1.5 reply to SpriggsySpriggs challenge answer (re bytes free)
Post by: Richard on January 17, 2021, 07:03:35 am
@ SMcNeill

Thanks Steve - ACTUALLY I was hoping that for a special project I am playing around with (highly experimental - may not work at all) - to ATTEMPT to copy a contiguous bock of memory (1 GByte) (ideally I would choose by trial and error various locations) where only a very small part is changed (eg to less bytes (or zero preferably) than "Hello, Richard"). That is to say I don't want the MEM block to be "initialized" in any way (so I would "see" what the RANDOM GARBAGE was).

It appears that DIM gig as STRING  * GIGABYTE does an initialization for the whole string to be spaces.

Anyway to do  DIM gig so that "NO INITIALIZATION OCCURS" (I know that this is a strange request)?
Title: Re: QB64 v1.5 reply to SpriggsySpriggs challenge answer (re bytes free)
Post by: SMcNeill on January 17, 2021, 08:14:02 am
If you just want to view an uninitialized GB of memory, try this:

DIM M AS _MEM
M = _MEMNEW(1000000000) ‘1 GB
temp$ = SPACE$(1000000000) ‘1 GB string
_MEMGET M, M.OFFSET, temp$ ‘get the mem block into the string

‘DO whatever
Title: Re: QB64 v1.5 Auto update for compiling when include file changed
Post by: Richard on February 06, 2021, 07:27:08 pm
The preferred method for feature requests AND bugs etc is the link below

https://github.com/QB64Team/qb64/issues (https://github.com/QB64Team/qb64/issues)

Auto update for compiling when include file changed.


When editing an include file for use with the current QB64 program being edited in the IDE - the .exe file generated does not use the latest include file version (unless the programmer remembers to also "edit" the line (and immediately restores the line) where the include file is mentioned).

Feature request - option to auto update to latest versions of any include files referenced when compiling
Title: Re: QB64v1.5 multi instance launch problem https://github.com/QB64Team/qb64/issues
Post by: Richard on March 06, 2021, 09:30:20 pm
The preferred method for feature requests AND bugs etc is the link below

https://github.com/QB64Team/qb64/issues (https://github.com/QB64Team/qb64/issues)

This may be only related to Windows 10 x64 high DPI displays (eg my computer QB64 v1.5)...


If already have an instance of QB64 v1.5 Windows 10 x64 running - when attempting to launch a second instance of QB64 v1.5, the opening IDE screen does not appear on the display (it appears as a tiny "pop-up" when "hovering" mouse cursor over TaskBar ICON) - if now AGAIN attempt to launch QB64 v1.5, the IDE opening screen is now visible on main display as NORMAL. So now need to remove the "second" instance and so proceed with the third instance (which now becomes the intended second instance of QB64).
Title: Re: v1.5 multi instance launch problem https://github.com/QB64Team/qb64/issues #142
Post by: SpriggsySpriggs on March 06, 2021, 09:51:30 pm
I feel like this should have been just a new topic
Title: Re: v1.5 multi instance launch problem https://github.com/QB64Team/qb64/issues #142
Post by: FellippeHeitor on March 06, 2021, 10:50:59 pm
As proper as the repository is, I’ve already replied to you there.

Since it’s been replicated here, I’ll replicate the reply too:

Quote
For some reason improper coordinates got stored for the second instance. Go to internal/config.ini and delete the section for the second ide window. Please let me know if that fixes it.

And yes, this thread seems to have lasted too long already.
Title: Re: v1.5 128 bit (and beyond) math
Post by: Richard on April 02, 2021, 10:23:20 pm
Would be nice to have 128 bit (and beyond) math ability - for those who would use it.

Currently 8 byte (64 bit) is available and also with _FLOAT 10 byte used (80 bit).

Feature request initially is for the IDE to be able to handle the extra variable types - which would be a big task - and the number crunching parts (e.g. SQRT) would be via include files of various kinds (Basic, C++, etc) from users and outside sources.

So for instance, the IDE would recognize x&&& as a 16 byte (256 bit) variable type as a signed _INTEGER128 and be able to do the usual tasks such as PRINT x&&& etc.

It may  never eventuate that "everything" for larger bit work is provided, but at least if the IDE can recognize and handle the new variables - this would be a great start. Even if the functionality is limited only to HEX and BINARY formats (and the conversion to/from decimal is at user's responsibility) - this would also be quite useful.


I have read recently that apparently for more "serious" scientific work - calculations are done using "hundreds of decimal places" (and am not referring to those purely academic projects such as calculating Pi to 3.14 trillion decimal places and such.)

The manipulation of the larger math would be very suited for MEM and the user variables such as x&&& allow for easier code reading/writing.


Maybe I may be the only one to use this larger math - if so, then it may not be justified to invest into the required QB64 code development.. So much can be said relevant to this implementation.

Title: Re: v1.5 128 bit (and beyond) math
Post by: luke on April 02, 2021, 10:56:32 pm
There will not be any new first-class variable types added to QB64.

Consider producing a library to achieve such calculations, or wrapping something like GMP.
Title: Re: v1.5 128 bit (and beyond) math
Post by: bplus on April 02, 2021, 11:54:54 pm
Quote
Maybe I may be the only one to use this larger math - if so, then it may not be justified to invest into the required QB64 code development.. So much can be said relevant to this implementation.

Already doing arbitrary math with the oh interpreter, here is a pretty impressive example for the inverse of a giant number (23 - 9's an 8 and then 24 more 9's given by STx) to 4000 decimal places finding the first 115 terms of Fibonacci sequence in one number!
https://www.qb64.org/forum/index.php?topic=3723.msg131080#msg131080
Title: Re: v1.5 128 bit (and beyond) math
Post by: Richard on April 29, 2021, 09:27:19 pm
@luke quickly replied that there will not be any new first-class variable types added to QB64, which is a pity (for me). On internet research it seems that even with C++ language that 64 bits is the limit. So from the discontinuation of MS PDS7.1 (upgrade to QB45) some thirty years ago - there seems to be no expansion of bits.  I think that IBM for a number (if not most or all) of mainframes, the OS was highly scalable and already had 128 bits and this predates 30 years ago. It seems that since the Intel architecture is only 64bits, no one wants to have say a C++ written library to handle 128bit multiplication.

I started looking at @bplus OHI and am a bit lost at this stage to "extract" the least code required to incorporate in my programs. (To be able to do many digits of resolution for the basics - add, subtract, multiply and divide). Has anyone previously done this?
.
Even if BPlus code is used, I will be limited - eg doing SQR, TAN, <>, arrays, input # etc would be a pain!

Luke mentioned wrapping something like GMP. I read into this a bit, it was interesting that only some success was reported when using windows. I gather that GMP (and other similar versions) are written in maybe C++ (or some other language that I have no training, knowledge or experience with). My past experience with trying to use "packages" (like GMP etc) is that I end up downloading maybe Gigabytes, cannot get it to work with my present version of Windows (10 x64), found that the forums were not helpful in "getting started", and often very old ( eg a number of years) which does not interact with versions
 updates from Windows.


Title: Re: v1.5 128 bit (and beyond) math
Post by: SpriggsySpriggs on April 29, 2021, 09:51:41 pm
128 bit variable types do exist in C++
Title: Re: v1.5 128 bit (and beyond) math
Post by: NOVARSEG on April 29, 2021, 09:58:12 pm
Quote
It appears that DIM gig as STRING  * GIGABYTE does an initialization for the whole string to be spaces.

Anyway to do  DIM gig so that "NO INITIALIZATION OCCURS" (I know that this is a strange request)?

The essential action of DIM sets aside a memory block of bytes used for the variable that is DIMed. In QB45 you can see the memory allocation in the MAP file.

QB45 source code example.
DIM string1 AS STRING * 256

After compiling, the MAP file will show a length of 0100h in a memory segment called BC_DATA

I expect QB64 to be similar.   

128 bit variables are fast but not essential.  Try coding in 16 bit assembler and you will soon find out how wonderful and compact the code is.

Even with 16 bit assembler you are not limited to 16 bit variables. There is no limit to the number of digits after the decimal point.    128 bit math operations only do it faster.
Title: Re: v1.5 128 bit (and beyond) math
Post by: Richard on April 29, 2021, 10:02:56 pm
Thanks @SpriggsySpriggs

As I said I am not experienced with C++ (or C etc).

I looked at some "C" forums earlier regarding math beyond 64 bits - but it seems there were no libraries available (or in progress) to handle beyond 64 bits. I did come across something about 128 bit registers (NOT cpu registers) in C, but there was mention something about problems actually using these registers to actually do some thing with (would be nice to string together a number of C++ 128 registers to do math - don't know how to do unfortunately)

Maybe I should learn how to C++ code - hate to think how long it would take me?
Title: Re: v1.5 128 bit (and beyond) math
Post by: NOVARSEG on April 29, 2021, 10:09:58 pm
The latest Intel CPUs can do anything


Title: Re: v1.5 128 bit (and beyond) math
Post by: bplus on April 29, 2021, 10:12:42 pm
Quote
I started looking at @bplus OHI and am a bit lost at this stage to "extract" the least code required to incorporate in my programs. (To be able to do many digits of resolution for the basics - add, subtract, multiply and divide). Has anyone previously done this?
.
Even if BPlus code is used, I will be limited - eg doing SQR, TAN, <>, arrays, input # etc would be a pain!

Here is the meat (make sure you are at Best Answer):
https://www.qb64.org/forum/index.php?topic=2921.msg121886#msg121886

Copy paste into your app and use (don't need demo code in main loop) just:
myNum$ = Mr$(StringNumber1$, operator$ (+ - * or /), StringNumber2$)  'simple call


Quote
I will be limited - eg doing SQR, TAN, <>, arrays, input # etc would be a pain!

If writing your own code routines is a pain, then yeah you are right!

Do you know about Taylor series?
Yeah it would be slower too than using professional means but aren't we hobby programmers anyway?
100 digit decimals for division but can customize with the Inverse code to 1000's or more.

Even if it's all a hack job, you have pretty good idea how your code works. ;-))
Title: Re: v1.5 128 bit (and beyond) math
Post by: bplus on April 29, 2021, 10:16:55 pm
128 bit variable types do exist in C++

What kind of range does that give us for Integers and Floats?

And is there a way to run raw C++ code inside QB64? I think this was asked before for ASM or C but QB64 gets translated to C++ if I recall correctly?
Title: Re: v1.5 128 bit (and beyond) math
Post by: Richard on April 29, 2021, 11:04:12 pm
@NOVARSEG
@bplus

Thanks for replies.

I admit that a "well-written", "hand crafted" , "optimized" assembly code would be the most elegant, resource efficient, fastest and possibly the easiest to understand and debug. At this stage I am not quite ready to attempt assembly programming (Intel x86 syntax) and incorporate this seaminglessly into QB64 programs. At present I would have to have a "stand alone" assembly program and "cheat" by saving and writing to a disk temp file for (assembly <-> QB64) program interchange as I cannot correctly pass data and commands between the two. Hopefully one day I will sort this out for me.

Yes I have heard about Taylor Series (and even used same) - and there were other series too (McClarens ???, etc). The "fun" starts when the Mathematical Field of "Numerical Analysis" is used (where upon many other things - an analysis is done to see how many "additions", "subtractions", etc is performed to do a certain task (and with corresponding correlation to precision/accuracy of answer at each stage). And to top this, for "certain kinds" of tasks - to use methods where a "seed" is used to "kick-off" an iteration process to rapidly converge upon the answer (when eg a predetermined accuracy say 5 decimal places is only needed). A simple example is to estimated factorial N (N!) = 1 * 2 * 3 *... (n-1) * n  if precision required is only say the most significant digit (or two) then Sterlings Approximation for factorial may be sufficient.




Now I am at a "cross-roads" - having to spread my resources over

- assembly programming (long term)
- BPlus OHI approach (maybe up and going quickly)
- GMP and similar packages (probably get lost along the way)
- Learning C++ and to use 128bit registers (learning curve for C++ to overcome)
- my approach to use _MEM tools (just starting - however _MEM expertise already available with QB64 forum members (particularly @SMcNeill)

Just a side note - although many topics/replies have been made regarding FLOAT vs LONG (double precision) - in a nutshell you "always" need more bits (80 verses 64) to get a more accurate result - one thing I noticed "missing" from all the topics I have read is actual possible "problems" with 64bit math (as performed by the Intel x64 cpu) and am not referring to it being only 64 bits. Maybe I should reply on this if anyone is interested (my reply would rely on documentation from INTEL). 

Title: Re: v1.5 128 bit (and beyond) math
Post by: NOVARSEG on April 29, 2021, 11:40:47 pm
At 9:32 into video, there are 512 bit registers available.  Serious stuff.
Title: Re: v1.5 128 bit (and beyond) math
Post by: SMcNeill on April 30, 2021, 02:52:40 pm
At 9:32 into video, there are 512 bit registers available.  Serious stuff.

Use the boost library for 1024-bit math/variables.  https://www.boost.org/doc/libs/1_54_0/libs/multiprecision/doc/html/boost_multiprecision/tut/ints/cpp_int.html

https://www.boost.org/doc/libs/1_76_0/libs/multiprecision/doc/html/boost_multiprecision/tut/ints/cpp_int.html



Title: Re: v1.5 128 bit (and beyond) math
Post by: SpriggsySpriggs on April 30, 2021, 03:17:03 pm
What is the reason for needing such a large number right now?
Title: Re: v1.5 128 bit (and beyond) math
Post by: bplus on May 01, 2021, 10:12:49 am
What is the reason for needing such a large number right now?

What's 100! (exactly)

Public Key Cryptography comes to my mind first and playing with Number Theory.
Title: Re: v1.5 128 bit (and beyond) math
Post by: SpriggsySpriggs on May 01, 2021, 10:47:22 am
I highly doubt we're doing that in QB64, though. It's not really being used for any serious applications. Simple graphics demos and games.
Title: Re: v1.5 128 bit (and beyond) math
Post by: bplus on May 01, 2021, 11:00:16 am
And I am just talking about some of my interests (Prime Numbers included in Number Theory that lots of people like to dabble with)

Then there is also interest in precision beyond 16 decimal points and getting around Sci Notation.
Title: Re: v1.5 128 bit (and beyond) math
Post by: jack on May 01, 2021, 11:49:36 am
if you want to use a bignum library like GMP in BASIC then I suggest that you use another Basic compiler that supports operator overloading, it's the one that Pete hates :)
I mostly use that compiler and have written interface code that makes the use of the GMP library as easy to use as using built-in types like Integer or Double
Title: Re: v1.5 128 bit (and beyond) math
Post by: Richard on May 20, 2021, 11:01:24 pm
@SpriggsySpriggs

As to your question on the need of such large numbers?

Initially side-stepping ...


Many, if not all, experienced QB64 developers @SpriggsySpriggs , @luke, @FellippeHeitor  et al and QB64 users may well recall the "debacle" about the Pentium Bug. These developers etc may also have contributed at the time, to workarounds such as software patches etc. For those interested refer links below.

https://en.wikipedia.org/wiki/Pentium_FDIV_bug (https://en.wikipedia.org/wiki/Pentium_FDIV_bug)

https://www.techradar.com/au/news/computing-components/processors/pentium-fdiv-the-processor-bug-that-shook-the-world-1270773 (https://www.techradar.com/au/news/computing-components/processors/pentium-fdiv-the-processor-bug-that-shook-the-world-1270773)

The above links may be of a general reporting nature. However without reference to official INTEL publications/reports and better still with communication directly to the INTEL hardware/software engineers and contracted 3rd party research organizations involved directly at the time - the links highlight what I call as a potentially serious situation and also illustrates some commercial logistics problems (warranty, replacement, legal stuff etc).

Most people (including myself) fall into the trap of "ASSUME".

If you break up that word into ??? ? ?? (i.e. 3 words) you get the universally known phrase/sentence - "Never ASSUME because you make an ??? out of ? and ??"

Generally people assume that there are no bugs etc with computers and in particular the hardware (e.g. the processor chip itself) - although people generally accept and possibly expect bugs in software (take Windows 10 for instance).

So cutting a long story short - to check out a 64 bit division as reported by QB64 program and by which I gather that QB64 does not have original routine to perform the calculation - it just eventually relies on the say INTEL microprocessor calculating it - I will need more than 64 bits span for any technique I develop (if anything simply because of round-off errors). Similarly checking up on 80 bit division regarding FLOAT.

The above side-step (including links) is NOT my real concern - it goes deeper and more far reaching than this.

In my follow up of this reply to you I will relay to you my REAL concerns with 64 bit MATH  (actually I do not think QB64 is at fault - as it is, I gather only a messenger between the processor and the generated exe file when it comes to 64 bit math)

Title: Re: v1.5 128 bit (and beyond) math
Post by: George McGinn on May 30, 2021, 08:39:51 pm
I can tell you that when I code scientific research projects (ie: for astronomers and physicists), numbers used in calculations and even displaying can be very large, where I may need 23+ decimals or even significant digits (or both!) for use in calculations.

Anything that displays or uses a mantissa less than that is useless to me in those cases.

Which is why I use string math routines (many I've written myself or with a programmer friend of mine). However, these too can have limitations and performance issues.

It would be nice, as for anyone who has ever needed to do math (even in R) with large numbers, after about 7 to 13 numbers, you will get garbage data, leftover from memory, that can adversely affect calculations. I say nice to have because I don't always work on projects that large, and when I do I have routines (like bplus has) that are adequate to do the job. It would be nice to have a language other than C/C++ or assembler (like BASIC) where those who do not want to learn C/C++ or assembler to have this capability.

Just my two-cents!


What is the reason for needing such a large number right now?
Title: Re: v1.5 128 bit (and beyond) math
Post by: SpriggsySpriggs on May 30, 2021, 11:23:04 pm
The amount of use it will receive will be next to nil, I'm almost certain.
Title: Re: v1.5 128 bit (and beyond) math
Post by: bplus on May 31, 2021, 12:14:44 am
https://www.pcworld.com/article/155984/worst_tech_predictions.html
Title: Re: v1.5 128 bit (and beyond) math
Post by: SpriggsySpriggs on May 31, 2021, 12:30:16 am
@bplus I don't mean in general. I mean in QB64.
Title: Re: v1.5 128 bit (and beyond) math
Post by: STxAxTIC on May 31, 2021, 03:30:32 am
I would like to see Spriggs do something with regular numbers before he predicts the futility of really big ones.
Title: Re: v1.5 128 bit (and beyond) math
Post by: SpriggsySpriggs on May 31, 2021, 03:54:41 am
Alright well I sure do hope I see some 128 bit numbers being used in that NASA code and can't wait to see what colorful little demo we get next.
Title: Re: v1.5 128 bit (and beyond) math
Post by: bplus on May 31, 2021, 10:37:45 am
Alright well I sure do hope I see some 128 bit numbers being used in that NASA code and can't wait to see what colorful little demo we get next.

Well this thread has been all over the place, did we visit NASA too?
Title: Re: v1.5 128 bit (and beyond) math
Post by: George McGinn on May 31, 2021, 06:06:31 pm
I think he was talking about me.

I don't do work for NASA, but some of the grad students and research projects I code for, use data FROM NASA, observatories, and universities.

Unfortunately, none of those programs are in QB64 (yet), and I also sign a confidentiality (non-disclosure) agreement before working on projects.

I could work on some examples, like using the Planck Constant of 6.62607015×10^-34 ( or .0000000000000000000000000000000000662607015) or the Planck Unit (1.75 × 10^-63). The Planck Constant I've used in research on black-body radiation and the Planck Unit with the Hubble Constant for research into the expansion of the universe. (see image on how QB64 puts garbage in when printing the Planck Constant using the "PRINT USING" that goes past the 34th decimal place.

Anyway, I would like to use QB64, and that's where my (and bplus') string math routines come into play (until a language developer puts in 128bit math or functionality for large number math).

The functionality could be a special pre-compiler processing tag, so it does not effect the normal use of the language.

  [ This attachment cannot be displayed inline in 'Print Page' view ]  




Well this thread has been all over the place, did we visit NASA too?
Title: Re: v1.5 128 bit (and beyond) math
Post by: George McGinn on June 01, 2021, 12:38:29 am
@SpriggsySpriggs, @bplus

Here is an example of why it is important to increase the size of the accuracy or precision of numbers.

The program should produce a standard deviation of 10.34945. That's all.

However, when I extent the PRINT USING to accommodate the possibility of a number larger than this (say, 15 decimal places) you will see that I get garbage after the "945" using DOUBLE, SINGLE and _FLOAT.

This is an everyday example of the need for using large numbers, and QB64 fails at it. Which is why I and others have asked for changes to include large number math routines or the implementation of 128bit math processing.

It is not that it will not be used that often. In fact, it can be used for simple tasks that generally will produce numbers greater than the mantissa that restricts the precision of a result of a simple standard deviation. And if this is screwed up, even more uses will provide invalid results, and anyone looking for accuracy is just not going to get it.

It's not a matter of nice to have. It is something needed for many programming tasks.

Here is the code, followed by my results:

Code:
Code: QB64: [Select]
  1. REM Finding Standard Deviation
  2.  
  3. DIM SDEV_D AS DOUBLE
  4. DIM SDEV_S AS SINGLE
  5. DIM SDEV_F AS _FLOAT
  6.  
  7. SUM = 0
  8.  
  9. FOR K = 1 TO 10
  10.     READ N(K)
  11.     SUM = SUM + N(K)
  12.  
  13. AVE = SUM / 10
  14.  
  15. SUM = 0
  16. FOR K = 1 TO 10
  17.     SUM = SUM + (N(K) - AVE) ^ 2
  18.  
  19. SDEV = SQR(SUM / 9)
  20. SDEV_D = SQR(SUM / 9)
  21. SDEV_S = SQR(SUM / 9)
  22. SDEV_F = SQR(SUM / 9)
  23.  
  24. PRINT "The average is "; AVE: PRINT
  25. PRINT "The standard deviation for SDEV without 'PRINT USING' is "; SDEV
  26. PRINT USING "The standard deviation for SDEV is  ###.###############"; SDEV
  27. PRINT USING "The standard deviation for SDEV_D is ###.###############"; SDEV_D
  28. PRINT USING "The standard deviation for SDEV_S is ###.###############"; SDEV_S
  29. PRINT USING "The standard deviation for SDEV_F is ###.###############"; SDEV_F
  30.  
  31. REM DATA Statement
  32. DATA 72,84,96,88,91,75,79,100,76,99

Results:
  [ This attachment cannot be displayed inline in 'Print Page' view ]  
Title: Re: v1.5 128 bit (and beyond) math
Post by: SMcNeill on June 01, 2021, 01:02:32 am
There’s a lot of big num libraries out there for C.  If you guys really need such precision, you should look a few up and write wrappers and DECLARE LIBRARY them for use.  As I posted above, boost offers up to 1024-bit precision.
Title: Re: v1.5 128 bit (and beyond) math
Post by: jack on June 01, 2021, 07:54:49 am
@SpriggsySpriggs, @bplus

Here is an example of why it is important to increase the size of the accuracy or precision of numbers.

The program should produce a standard deviation of 10.34945. That's all.

However, when I extent the PRINT USING to accommodate the possibility of a number larger than this (say, 15 decimal places) you will see that I get garbage after the "945" using DOUBLE, SINGLE and _FLOAT.
after the second loop SUM = 964 so SQR(SUM / 9) is going to vary depending on the precision, it's not going to be exactly 10.34945 except perhaps for single
bplus or STxAxTIC could probably write a pre-parser that would convert a basic program's  math expressions into a program that would call string math functions
Title: Re: QB64 v1.5 Feature Request - Fellippe's interpreter option
Post by: madscijr on June 01, 2021, 08:41:26 am
Is that what you guys are looking for, an Immediate Window?
So you can test a snippet of code.

I'll just chime in and say, I would LOVE an immediate Window, that works like the one in Excel or Word VBA (even better would be one where you can scroll up and see the whole session).
It's just a great tool & option when developing.
I'll note that the immediate window in the old Visual Studio (say around 2008) was not as useful, as it didn't let you just click on it and start typing.
That behavior is specifically in MS Office VBA, and is what makes it so useful.
Title: Re: v1.5 128 bit (and beyond) math
Post by: SpriggsySpriggs on June 01, 2021, 12:17:44 pm
There’s a lot of big num libraries out there for C.  If you guys really need such precision, you should look a few up and write wrappers and DECLARE LIBRARY them for use.  As I posted above, boost offers up to 1024-bit precision.

Precisely. This can be easily sought out and a wrapper be made. This sort of reminds me of how WinAPI handles 64 bit numbers in compilers that don't support 64 bit natively. You just use a struct. Anyways, looking forward to seeing some wrapper made here.
Title: Re: v1.5 128 bit (and beyond) math
Post by: bplus on June 01, 2021, 12:22:53 pm
@SpriggsySpriggs, @bplus

Here is an example of why it is important to increase the size of the accuracy or precision of numbers.

The program should produce a standard deviation of 10.34945. That's all.

However, when I extent the PRINT USING to accommodate the possibility of a number larger than this (say, 15 decimal places) you will see that I get garbage after the "945" using DOUBLE, SINGLE and _FLOAT.

This is an everyday example of the need for using large numbers, and QB64 fails at it. Which is why I and others have asked for changes to include large number math routines or the implementation of 128bit math processing.

It is not that it will not be used that often. In fact, it can be used for simple tasks that generally will produce numbers greater than the mantissa that restricts the precision of a result of a simple standard deviation. And if this is screwed up, even more uses will provide invalid results, and anyone looking for accuracy is just not going to get it.

It's not a matter of nice to have. It is something needed for many programming tasks.

Here is the code, followed by my results:

Code:
Code: QB64: [Select]
  1. REM Finding Standard Deviation
  2.  
  3. DIM SDEV_D AS DOUBLE
  4. DIM SDEV_S AS SINGLE
  5. DIM SDEV_F AS _FLOAT
  6.  
  7. SUM = 0
  8.  
  9. FOR K = 1 TO 10
  10.     READ N(K)
  11.     SUM = SUM + N(K)
  12.  
  13. AVE = SUM / 10
  14.  
  15. SUM = 0
  16. FOR K = 1 TO 10
  17.     SUM = SUM + (N(K) - AVE) ^ 2
  18.  
  19. SDEV = SQR(SUM / 9)
  20. SDEV_D = SQR(SUM / 9)
  21. SDEV_S = SQR(SUM / 9)
  22. SDEV_F = SQR(SUM / 9)
  23.  
  24. PRINT "The average is "; AVE: PRINT
  25. PRINT "The standard deviation for SDEV without 'PRINT USING' is "; SDEV
  26. PRINT USING "The standard deviation for SDEV is  ###.###############"; SDEV
  27. PRINT USING "The standard deviation for SDEV_D is ###.###############"; SDEV_D
  28. PRINT USING "The standard deviation for SDEV_S is ###.###############"; SDEV_S
  29. PRINT USING "The standard deviation for SDEV_F is ###.###############"; SDEV_F
  30.  
  31. REM DATA Statement
  32. DATA 72,84,96,88,91,75,79,100,76,99

Results:
  [ This attachment cannot be displayed inline in 'Print Page' view ]

Well here is nice little test of String Math, guess I better get going with that SQR routine. I have to ask what precision answer you'd like or are expecting. The data suggests that it's all integers with precision of +-.5. Not being a statistician, I can only guess that double precision would be fine for Standard Deviation on Integer Data.
Title: Re: v1.5 128 bit (and beyond) math
Post by: George McGinn on June 01, 2021, 12:24:04 pm
You are correct, but there are two issues here -
1. If I have to print out the results and I have no idea how large or small the results will be, QB64 adds garbage at the end of the number AND
2. This is a simple standard deviation. We use this with numbers that are more than 25 significant digits, or have more than 25 decimal places (or both) and the results are just not there.

But QB64 has more problems than many interpreters that run on mobile devices, whose hardware isn't as robust as our desktops.

Here is part of a program I wrote many years ago after I had to appear before an inquiry board to explain why my results, or the system's results, were inaccurate. Here I just include the most simplistic tests of processor/language number accuracy tests, that use the most basic physics figures known to even layman. I also included a comparison to a run I did in TechBASIC on my iPad.

You'll see that the iPad, even though both contain garbage in their numbers that do affect the results of any calculation in it, gets closer to the right answer than QB64 does. In fact, I have no clue why !E+308 produces garbage results (not even close to the right result) and the iPad gets it 100% correct!

Note, the program is exactly the same on the iPad. The iPad's TechBASIC uses DOUBLE FLOAT for all the variables. In QB64, I use both DOUBLE and _FLOAT and get the same results. (TechBASIC is written in C, so there is no reason why QB64 can't get this simple math correct!)

Here is the program followed by screen shots of both a QB64 run (in 64bit) on a Linux, and the TechBASIC run. The code is 100 percent the same.

This is a problem that must be fixed on the compiler side.

Code: QB64: [Select]
  1. SCREEN _NEWIMAGE(1200, 800, 32)
  2.  
  3. X = 2 ^ 52 - 1
  4. Z = 2 ^ 53 - 1
  5. W = X + X
  6.  
  7. Y = 2 * 10 ^ 30
  8. Y1 = 2D * 10D ^ 30D
  9. B = 2D0 * 10 ^ 30D
  10. C = 2D0 * 10D ^ 30D
  11. D = 2D0 * EXP(30 * ln(10D0))
  12. E = 2D0 * EXP(30D * ln(10D0))
  13.  
  14. A = 1E+308
  15. A$ = "1E+308"
  16. LY = ((186000 * 60 ^ 2) * 24) * 365.25
  17.  
  18. Y$ = STR$(Y)
  19.  
  20. PRINT "The maximum absolute value 2^52     = ";: PRINT USING "#,###,###,###,###,###"; X
  21. PRINT USING "Add #,###,###,###,###,### to itself = #,###,###,###,###,###"; X, W
  22. PRINT "The maximum absolute value 2^53     = ";: PRINT USING "#,###,###,###,###,###"; Z
  23.  
  24. PRINT A$;: PRINT USING "   =   #######################"; A
  25. PRINT A$;: PRINT USING "   = ####,###,###,###,###,###"; A
  26.  
  27. PRINT "As an exponent, the Sun's Mass.        = "; Y$
  28. PRINT "The mass of the Sun 2*10^30 ";: PRINT USING "           = #.#####################^"; Y
  29. PRINT "The mass of the Sun 2d*10d^30d ";: PRINT USING "        = #.#####################^"; Y1
  30. PRINT USING "The answer of B using all _FLOAT = #.#####################^"; B
  31. PRINT USING "The answer of C using all _FLOAT = #.#####################^"; C
  32. PRINT USING "The answer of D using all _FLOAT = #.######################"; D
  33. PRINT USING "The answer of E using all _FLOAT = #.######################"; E
  34.  
  35. PRINT USING "Light Year = ###,###,###,###,###,### miles"; LY
  36.  

Here is the QB64 Run:
  [ This attachment cannot be displayed inline in 'Print Page' view ]  


Here is the TechBASIC run on the iPad:
  [ This attachment cannot be displayed inline in 'Print Page' view ]  



after the second loop SUM = 964 so SQR(SUM / 9) is going to vary depending on the precision, it's not going to be exactly 10.34945 except perhaps for single
bplus or STxAxTIC could probably write a pre-parser that would convert a basic program's  math expressions into a program that would call string math functions
Title: Re: v1.5 128 bit (and beyond) math
Post by: SpriggsySpriggs on June 01, 2021, 12:43:07 pm
One problem, George, is it looks like your program doesn't calculate standard deviation correctly. I checked against a standard deviation calculator and your numbers don't return 10.34945. I looked up a C++ example to calculate standard deviation and mine matches the online deviation calculator.

Code: QB64: [Select]
  1.  
  2. Print Using "#.#############"; calculateSD
  3.  
  4. Dats:
  5. Data 72,84,96,88,91,75,79,100,76,99
  6.  
  7.  
  8. Function calculateSD## ()
  9.     Dim As _Float sum, mean, standardDeviation
  10.     Dim As _Float dat
  11.     sum = 0.0: standardDeviation = 0.0
  12.     Dim As Long i
  13.     Restore Dats
  14.     For i = 1 To 10
  15.         Read dat
  16.         sum = sum + dat
  17.     Next
  18.     mean = sum / 10
  19.     Restore Dats
  20.     For i = 1 To 10
  21.         Read dat
  22.         standardDeviation = standardDeviation + ((dat - mean) ^ 2)
  23.     Next
  24.     calculateSD = Sqr(standardDeviation / 10)

You can check that code against this link:
https://www.calculator.net/standard-deviation-calculator.html?numberinputs=72%2C84%2C96%2C88%2C91%2C75%2C79%2C100%2C76%2C99&ctype=p&x=33&y=10 (https://www.calculator.net/standard-deviation-calculator.html?numberinputs=72%2C84%2C96%2C88%2C91%2C75%2C79%2C100%2C76%2C99&ctype=p&x=33&y=10)

My return:                              9.8183501669069
That online calculator's return: 9.8183501669069
Title: Re: v1.5 128 bit (and beyond) math
Post by: George McGinn on June 01, 2021, 01:00:35 pm
@SpriggsySpriggs - If you chose SAMPLE (which I thought I said it was in my post, but I used the word SIMPLE instead) your calculator produces the same results I get.

One problem, George, is it looks like your program doesn't calculate standard deviation correctly. I checked against a standard deviation calculator and your numbers don't return 10.34945. I looked up a C++ example to calculate standard deviation and mine matches the online deviation calculator.

Code: QB64: [Select]
  1.  
  2. Print Using "#.#############"; calculateSD
  3.  
  4. Dats:
  5. Data 72,84,96,88,91,75,79,100,76,99
  6.  
  7.  
  8. Function calculateSD## ()
  9.     Dim As _Float sum, mean, standardDeviation
  10.     Dim As _Float dat
  11.     sum = 0.0: standardDeviation = 0.0
  12.     Dim As Long i
  13.     Restore Dats
  14.     For i = 1 To 10
  15.         Read dat
  16.         sum = sum + dat
  17.     Next
  18.     mean = sum / 10
  19.     Restore Dats
  20.     For i = 1 To 10
  21.         Read dat
  22.         standardDeviation = standardDeviation + ((dat - mean) ^ 2)
  23.     Next
  24.     calculateSD = Sqr(standardDeviation / 10)

You can check that code against this link:
https://www.calculator.net/standard-deviation-calculator.html?numberinputs=72%2C84%2C96%2C88%2C91%2C75%2C79%2C100%2C76%2C99&ctype=p&x=33&y=10 (https://www.calculator.net/standard-deviation-calculator.html?numberinputs=72%2C84%2C96%2C88%2C91%2C75%2C79%2C100%2C76%2C99&ctype=p&x=33&y=10)

My return:                              9.8183501669069
That online calculator's return: 9.8183501669069
Title: Re: v1.5 128 bit (and beyond) math
Post by: OldMoses on June 01, 2021, 01:15:28 pm
I'm no computer scientist, nor an astrophysicist. I'm a farmer that flunked one algebra class and learned to use a little trig at my lathe and milling machine, and I like writing utility programs for an old role playing hobby. QB64 is excellent for what it does, namely rescuing Qbasic from obscurity.

That said, I agree with George. In working with my space flight utility, I learned early on that I would not put my own flesh in a ship running on QB64. Big numbers generated "issues" that necessitated the use of relative coordinate systems to keep the numbers as small and local as possible. Even so, Qbasic couldn't handle even the most rudimentary version of that program, so I'm still happy.

Title: Re: v1.5 128 bit (and beyond) math
Post by: bplus on June 01, 2021, 01:33:43 pm
One problem, George, is it looks like your program doesn't calculate standard deviation correctly. I checked against a standard deviation calculator and your numbers don't return 10.34945. I looked up a C++ example to calculate standard deviation and mine matches the online deviation calculator.

Code: QB64: [Select]
  1.  
  2. Print Using "#.#############"; calculateSD
  3.  
  4. Dats:
  5. Data 72,84,96,88,91,75,79,100,76,99
  6.  
  7.  
  8. Function calculateSD## ()
  9.     Dim As _Float sum, mean, standardDeviation
  10.     Dim As _Float dat
  11.     sum = 0.0: standardDeviation = 0.0
  12.     Dim As Long i
  13.     Restore Dats
  14.     For i = 1 To 10
  15.         Read dat
  16.         sum = sum + dat
  17.     Next
  18.     mean = sum / 10
  19.     Restore Dats
  20.     For i = 1 To 10
  21.         Read dat
  22.         standardDeviation = standardDeviation + ((dat - mean) ^ 2)
  23.     Next
  24.     calculateSD = Sqr(standardDeviation / 10)

You can check that code against this link:
https://www.calculator.net/standard-deviation-calculator.html?numberinputs=72%2C84%2C96%2C88%2C91%2C75%2C79%2C100%2C76%2C99&ctype=p&x=33&y=10 (https://www.calculator.net/standard-deviation-calculator.html?numberinputs=72%2C84%2C96%2C88%2C91%2C75%2C79%2C100%2C76%2C99&ctype=p&x=33&y=10)

My return:                              9.8183501669069
That online calculator's return: 9.8183501669069

I get a perfect match between his program and yours, just not at 10.... but at the 9.... that you show

PS I added the print of mean in function.
Title: Re: v1.5 128 bit (and beyond) math
Post by: SMcNeill on June 01, 2021, 02:11:44 pm
Why does the techbasic on the ipad print the wrong answer? 

((186000 * 60 ^ 2) * 24) * 365.25 = 5869713600000 (at least according to both google and my windows calculator, which is what I lazily used to check results), which is what QB64 gives us.  The screen shot of your ipad is showing the result as 5869713489920.

Quote
But QB64 has more problems than many interpreters that run on mobile devices, whose hardware isn't as robust as our desktops.

I must be missing something here, as it seems QB64 is giving us the correct answers while the mobile device screenshot you posted isn't.
Title: Re: v1.5 128 bit (and beyond) math
Post by: SMcNeill on June 01, 2021, 02:32:34 pm
Another question I have is one this line: E = 2D0 * EXP(30D * ln(10D0))

There’s no array called ln in your program, so ln(10) is going to be 0.  Is that what you expect here?  Or are you looking for LOG(10)?
Title: Re: v1.5 128 bit (and beyond) math
Post by: bplus on June 01, 2021, 02:35:03 pm
Oh the code in reply #127 is wrong, some fixes and it comes in on double and _Float because intermediary variables are _float:
Code: QB64: [Select]
  1. Rem Finding Standard Deviation
  2.  
  3. Dim SDEV_D As Double
  4. Dim SDEV_S As Single
  5. Dim SDEV_F As _Float
  6. Dim sum As _Float '<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< intermediaries have to be same or better precision
  7. Dim n(1 To 10) As _Float
  8. sum = 0
  9.  
  10. For K = 1 To 10
  11.     Read n(K)
  12.     sum = sum + n(K)
  13.  
  14. ave = sum / 10
  15.  
  16. sum = 0
  17. For K = 1 To 10
  18.     sum = sum + (n(K) - ave) ^ 2
  19.  
  20. SDEV = Sqr(sum / 10) ' divide by 10 not 9
  21. SDEV_D = Sqr(sum / 10)
  22. SDEV_S = Sqr(sum / 10)
  23. SDEV_F = Sqr(sum / 10)
  24.  
  25. Print "The average is "; ave: Print
  26. Print "The standard deviation for SDEV without 'PRINT USING' is "; SDEV
  27. Print Using "The standard deviation for SDEV is  ###.###############"; SDEV
  28. Print Using "The standard deviation for SDEV_D is ###.###############"; SDEV_D
  29. Print Using "The standard deviation for SDEV_S is ###.###############"; SDEV_S
  30. Print Using "The standard deviation for SDEV_F is ###.###############"; SDEV_F
  31.  
  32. Rem DATA Statement
  33. Data 72,84,96,88,91,75,79,100,76,99
  34.  
  35.  

Sorry I thought Spriggsy was quoting George code, guess that function was his own in QB64 that he was comparing to the Internet calc.
Title: Re: v1.5 128 bit (and beyond) math
Post by: George McGinn on June 01, 2021, 02:45:34 pm
I left the code exactly the same as it was in TechBASIC.

Without the ln it seems to not produce a result on the iPad. Since I am working on an iOS app right now, I will test what I just did in QB64 later. But with it, it corrects the issue of memory corruption and produces the right value. I haven't looked into why, but it just does.



Another question I have is one this line: E = 2D0 * EXP(30D * ln(10D0))

There’s no array called ln in your program, so ln(10) is going to be 0.  Is that what you expect here?  Or are you looking for LOG(10)?
Title: Re: v1.5 128 bit (and beyond) math
Post by: SpriggsySpriggs on June 01, 2021, 02:50:54 pm
Oh the code in reply #127 is wrong, some fixes and it comes in on double and _Float because intermediary variables are _float:
Sorry I thought Spriggsy was quoting George code, guess that function was his own in QB64 that he was comparing to the Internet calc.

@bplus Right, exactly. I was comparing the converted C++ code I found to the internet calculator
Title: Re: v1.5 128 bit (and beyond) math
Post by: George McGinn on June 01, 2021, 02:52:07 pm
I raised that very issue with TechBASIC's developer, Mike Westerfield.

I was told that the ARM processor on mobile devices wasn't as robust as those on desktops.

And since all math is done via registers on the CPU (in an area that is the math co-processor), it winds up being a hardware limitation that, unless you create your own bit-math (or string math) process, all hardware, from mainframes down to iPhones and iPads and even single board computers, have precision issues.

Saying that, with properly constructed code within compilers and interpreters, large number math can be precise.

Back in 1977 I worked on enhancing OS/HASP at Rockland Research Institute (now Nathan S. Kline Institute) so that the hardware limits for researchers and scientists were less of an issue.

The same can be put into QB64, with hardly any noticeable performance issues.


Why does the techbasic on the ipad print the wrong answer? 

((186000 * 60 ^ 2) * 24) * 365.25 = 5869713600000 (at least according to both google and my windows calculator, which is what I lazily used to check results), which is what QB64 gives us.  The screen shot of your ipad is showing the result as 5869713489920.

I must be missing something here, as it seems QB64 is giving us the correct answers while the mobile device screenshot you posted isn't.
Title: Re: v1.5 128 bit (and beyond) math
Post by: SMcNeill on June 01, 2021, 02:53:18 pm
I left the code exactly the same as it was in TechBASIC.

Without the ln it seems to not produce a result on the iPad. Since I am working on an iOS app right now, I will test what I just did in QB64 later. But with it, it corrects the issue of memory corruption and produces the right value. I haven't looked into why, but it just does.

Different languages, different commands.  Seems like TechBasic uses ln, while QB64 uses LOG.

Code won’t be the same unless you take the effort to convert to the proper language commands.  We use SQR, C uses sqrt...  You can’t just copy a formula directly from one into the other and expect it to always work.  You have to convert to proper syntax.
Title: Re: v1.5 128 bit (and beyond) math
Post by: George McGinn on June 01, 2021, 03:00:50 pm
Both my result and yours are correct. It is a matter of which Standard Deviation is being performed. I chose SAMPLE as it illustrated my example.

However, for those who do not understand the difference, I guess I need to clear up the difference between "POPULATION" vs "SAMPLE" in regards to Standard Deviation:

They are:

Quote
The population standard deviation is a parameter, which is a fixed value calculated from every individual in the population.

A sample standard deviation is a statistic. This means that it is calculated from only some of the individuals in a population. Since the sample standard deviation depends upon the sample, it has greater variability. Thus the standard deviation of the sample is greater than that of the population.

 The formulas to calculate both of these standard deviations are nearly identical:

    Calculate the mean.
    Subtract the mean from each value to obtain deviations from the mean.
    Square each of the deviations.
    Add together all of these squared deviations.

Now the calculation of these standard deviations differs:

    If we are calculating the population standard deviation, then we divide by n, the number of data values.
    If we are calculating the sample standard deviation, then we divide by n -1, one less than the number of data values.

The final step, in either of the two cases that we are considering, is to take the square root of the quotient from the previous step.

The larger the value of n is, the closer that the population and sample standard deviations will be.


One problem, George, is it looks like your program doesn't calculate standard deviation correctly. I checked against a standard deviation calculator and your numbers don't return 10.34945. I looked up a C++ example to calculate standard deviation and mine matches the online deviation calculator.

Code: QB64: [Select]
  1.  
  2. Print Using "#.#############"; calculateSD
  3.  
  4. Dats:
  5. Data 72,84,96,88,91,75,79,100,76,99
  6.  
  7.  
  8. Function calculateSD## ()
  9.     Dim As _Float sum, mean, standardDeviation
  10.     Dim As _Float dat
  11.     sum = 0.0: standardDeviation = 0.0
  12.     Dim As Long i
  13.     Restore Dats
  14.     For i = 1 To 10
  15.         Read dat
  16.         sum = sum + dat
  17.     Next
  18.     mean = sum / 10
  19.     Restore Dats
  20.     For i = 1 To 10
  21.         Read dat
  22.         standardDeviation = standardDeviation + ((dat - mean) ^ 2)
  23.     Next
  24.     calculateSD = Sqr(standardDeviation / 10)

You can check that code against this link:
https://www.calculator.net/standard-deviation-calculator.html?numberinputs=72%2C84%2C96%2C88%2C91%2C75%2C79%2C100%2C76%2C99&ctype=p&x=33&y=10 (https://www.calculator.net/standard-deviation-calculator.html?numberinputs=72%2C84%2C96%2C88%2C91%2C75%2C79%2C100%2C76%2C99&ctype=p&x=33&y=10)

My return:                              9.8183501669069
That online calculator's return: 9.8183501669069
Title: Re: v1.5 128 bit (and beyond) math
Post by: George McGinn on June 01, 2021, 03:05:08 pm
@SMcNeill

I tried LOG in both and it does not work.

It seems that TechBASIC assigns LONG to the array, based on the value that is in it. However, when I take it away, the calculation does not work due to the exponents. I don't know why.

But removing that in QB64 (ie: D = 2D0 * EXP(30 * 10D0) ) produces the same results, so it is mute. It works the same either way.

EDIT: I take that back - there is a difference, but which is correct? Also, what is the % in front of some of my numbers?

Different languages, different commands.  Seems like TechBasic uses ln, while QB64 uses LOG.

Code won’t be the same unless you take the effort to convert to the proper language commands.  We use SQR, C uses sqrt...  You can’t just copy a formula directly from one into the other and expect it to always work.  You have to convert to proper syntax.
Title: Re: v1.5 128 bit (and beyond) math
Post by: bplus on June 01, 2021, 03:17:17 pm
Both my result and yours are correct. It is a matter of which Standard Deviation is being performed. I chose SAMPLE as it illustrated my example.

However, for those who do not understand the difference, I guess I need to clear up the difference between "POPULATION" vs "SAMPLE" in regards to Standard Deviation:

They are:

 The formulas to calculate both of these standard deviations are nearly identical:

    Calculate the mean.
    Subtract the mean from each value to obtain deviations from the mean.
    Square each of the deviations.
    Add together all of these squared deviations.

Now the calculation of these standard deviations differs:

    If we are calculating the population standard deviation, then we divide by n, the number of data values.
    If we are calculating the sample standard deviation, then we divide by n -1, one less than the number of data values.

The final step, in either of the two cases that we are considering, is to take the square root of the quotient from the previous step.

The larger the value of n is, the closer that the population and sample standard deviations will be.

Ah something that has confused me since day one when trying to write a standard deviation code for data,
sometimes it's divide by n others by n-1 and also sometimes its with the SQR and sometimes without.

Never-the-less when making a point about precision calculations, make sure that intermediary variables hold same precision at least as you desire in the final result. Did you see difference that made? For me, I couldn't match Spriggsy's results until I changed the intermediary variables, the ones used to aid in finding the final results.
Title: Re: v1.5 128 bit (and beyond) math
Post by: bplus on June 01, 2021, 03:23:12 pm
QB64 uses base 10 for LOG, ln usually implies base e, there is a note how to convert QB64 base 10 LOG to ln in the Wiki under LOG.

Dang got it backwards, QB64 LOG is natural (base e) what most people call ln(x) and the conversion to base 10 is in the note.
http://qb64.org/wiki/LOG
Code: QB64: [Select]
  1. Print (Exp(1)) 'e
  2. Print Log(Exp(1)) '1
  3.  
Title: Re: v1.5 128 bit (and beyond) math
Post by: Richard on June 01, 2021, 10:21:10 pm
@madscijr

Regarding your reply #130 (this thread)

A number of forum members would welcome the feature of an immediate window, but despite request for same it would seem it is not going to happen with the developers.

If you refer to the following replies from me:-

https://www.qb64.org/forum/index.php?topic=3947.30 (https://www.qb64.org/forum/index.php?topic=3947.30)  see reply #34

https://www.qb64.org/forum/index.php?topic=1839.msg110823#msg110823 (https://www.qb64.org/forum/index.php?topic=1839.msg110823#msg110823) see reply #2

https://www.qb64.org/forum/index.php?topic=2276.msg116118#msg116118 (https://www.qb64.org/forum/index.php?topic=2276.msg116118#msg116118) see reply #8

I had experimented with dual instances of QB64 to simulate TRON-TROFF, breakpoints, watchpoints etc (from very old BASIC days) - and in principal an "immediate window" within the program (i.e. second instance BLOATED program) may, with care, give useful capability comparable to a true intermediate window. It is "messy" but with programming care it can be automated into programs (i.e. BLOAT original program (in instance #1), auto-insert TRON-TROFF flags, breakpoints, watchpoints, immediate window sort-of capability, logs, parsing original and replace with alternative code, etc. - and then UNBLOATING to recreate the original program after debugging/developing (in instance #2))

Of course, a cheap and nasty solution is to simply open up a "new instance" of QB64 to quickly test a snippet of code but of course it may not be so convenient in many cases because certain events/values may be required beforehand.

I have never used any version of MS Office or accessories etc but in MS PDS 7.1 (30 year old BASIC) it still has very important and useful features (such as immediate window, etc) which despite calls is still lacking in QB64.

For me, I may apply this technique (in the BLOATED program) to in  "parallel" with the math code of instance #1, simultaneously check all calculations etc with 128 bit computations and auto-insert relevant comments generated by instance #2 into the instance #1 (UNBLOATED) program.
Title: Re: v1.5 128 bit (and beyond) math
Post by: SpriggsySpriggs on June 01, 2021, 11:54:57 pm
@madscijr
A number of forum members would welcome the feature of an immediate window, but despite request for same it would seem it is not going to happen with the developers.
...
I have never used any version of MS Office or accessories etc but in MS PDS 7.1 (30 year old BASIC) it still has very important and useful features (such as immediate window, etc) which despite calls is still lacking in QB64.

@Richard I think people fail to see how absolute a nightmare this would be to code. However, if you feel up to the challenge, please feel free to visit the GitHub and contribute.
Title: Re: v1.5 128 bit (and beyond) math
Post by: Richard on June 02, 2021, 01:06:08 am
@SpriggsySpriggs

Thanks for your reply.

I appreciate how to have an immediate window can be a huge effort - it was done 30 years ago in BASIC (probably then a much huger problem to achieve because of hardware/software limitations - making the whole program fit and work within 640Kbytes memory in MS PDS 7.1). To the best of my knowledge, PDS 7.1 was written in assembler and not by a "high-level language such as C etc.

A prerequsite to contributing say via GitHub I gather would be a thorough understanding of C++ (because of the self-compiling nature of QB64). I am not familiar with C++ (or C - probably could not tell the difference between the two).

I gather that it would not be possible/practical to contribute using QB64 basic code (correct me if I am wrong) - so I am stuck learning C++. My knowledge of C (C++) is what @SMcNeill mentioned in some replies and essentially your replies to others regarding of meanings of syntax.  I suppose, since I have been programming in BASIC many years, my greatest problem is C++ Syntax (BASIC is so very easy to "read" and understand).

So to get me started off - would you be kind enough to enlighten me on the correct way to syntax a C++ code for the following fundamentals (if there is more than one way please advise also):-

How to "comment' an existing or new line (also for a contiguous block of comments)

How to "label" an existing line  (eg to have a "line number" and the characters allowed for label and total length permitted for label)

How to "GOTO" (linenumber or label)

How to "CALL"

What I initially had in mind was using the latest development build (and repository of stable version) to "Add comments and line labels quite extensively" with notes I make as I try to understand the methodology of QB64. Over time, as the notated code is updated, to auto-self-recompile QB64 (in theory QB64 should still work exactly as before (comments and line labels should not change anything). When I think I have some snippets ready to try or test - insert into code with new notes and recompile (this would only be for me personally - too much can go wrong (almost guaranteed) to risk putting into GitHub.

IF I can get something going or has potential and needs some help - contact the forum for advice. It may never be that I directly change the GitHub repository (since I do not have enough proven experience) - but IF I can get something to work on my code, then to forward ALL code changes (and comments etc) to the forum (or say you) - keeping in mind what I produce may well end up breaking something else in QB64.

For a long time I was thinking about "changing/improving" QB64 (for the benefit of all) - but the C++ part of it was "my excuse" for not going anywhere (because on my lack of knowledge of C++). I did try looking at some C forums but did not seem useful for a beginner like me. In contrast, there were many BASIC forums (going back way long ago) being more friendly for beginners.

If anyone knows if there is a C++64 forum or similar along the lines and helpfulness of QB64 - please advise.
Title: Re: v1.5 128 bit (and beyond) math
Post by: madscijr on June 02, 2021, 05:56:13 pm
@madscijr

Regarding your reply #130 (this thread)

A number of forum members would welcome the feature of an immediate window, but despite request for same it would seem it is not going to happen with the developers.

If you refer to the following replies from me:-

https://www.qb64.org/forum/index.php?topic=3947.30 (https://www.qb64.org/forum/index.php?topic=3947.30)  see reply #34

https://www.qb64.org/forum/index.php?topic=1839.msg110823#msg110823 (https://www.qb64.org/forum/index.php?topic=1839.msg110823#msg110823) see reply #2

https://www.qb64.org/forum/index.php?topic=2276.msg116118#msg116118 (https://www.qb64.org/forum/index.php?topic=2276.msg116118#msg116118) see reply #8

I had experimented with dual instances of QB64 to simulate TRON-TROFF, breakpoints, watchpoints etc (from very old BASIC days) - and in principal an "immediate window" within the program (i.e. second instance BLOATED program) may, with care, give useful capability comparable to a true intermediate window. It is "messy" but with programming care it can be automated into programs (i.e. BLOAT original program (in instance #1), auto-insert TRON-TROFF flags, breakpoints, watchpoints, immediate window sort-of capability, logs, parsing original and replace with alternative code, etc. - and then UNBLOATING to recreate the original program after debugging/developing (in instance #2))

Of course, a cheap and nasty solution is to simply open up a "new instance" of QB64 to quickly test a snippet of code but of course it may not be so convenient in many cases because certain events/values may be required beforehand.

I have never used any version of MS Office or accessories etc but in MS PDS 7.1 (30 year old BASIC) it still has very important and useful features (such as immediate window, etc) which despite calls is still lacking in QB64.

For me, I may apply this technique (in the BLOATED program) to in  "parallel" with the math code of instance #1, simultaneously check all calculations etc with 128 bit computations and auto-insert relevant comments generated by instance #2 into the instance #1 (UNBLOATED) program.

Thans for the thoughtful and detailed response. All that seems like going through a lot more trouble than it's worth, without really getting the benefits of the immediate window - the ability to run commands and print values in realtime, in the scope of the immediately running program's current breakpoint, with access to the current program state.

As is, if you want to see the values at a given point in your program, you can do something like

Code: QB64: [Select]
  1. ...your code...
  2. _ECHO "my value=" + _trim$(str$(myvalue))
  3. ...more code...
  4. input "press enter to continue";in$
  5.  

(thanks to @SpriggsySpriggs for the tip)
or you can just write values and debug info to a log file.

But a true immediate window would behave like MS Office where you can step through your program and run code against the current state, kind of like how the command prompt works in Python.

Maybe it could be accomplished as part of an alternative IDE? I know people have talked about making a GUI IDE, that behaves more like a standard Windows (or Mac, or whatever flavor of Linux) app, with the more modern GUI controls, behaviors, keyboard shortcuts, etc.
Title: Re: v1.5 128 bit (and beyond) math *** COMPILER ERROR ***
Post by: Richard on June 11, 2021, 07:04:30 am
I tested my test 128bit code in  both

v1.51 03bb0db    and      v1.51 2198409    dev builds and get the same message below for both:-

Compiler error (check for syntax errors) (Subscript out of range:9-12075)




Running the exact same test code in QB64 v1.5 (stable release) does not result in any error message (and the program runs as expected).

If the above message refers to line 9 this does not make sense as lines 8, 9, and 10 are either blank lines or a commented line.

The IDE for both dev builds does not indicate any errors.

Any suggestions on what is going on - my test code is using CONST, DIM SHARED and a lot of _MEM stuff (if that helps for suggestions)?

I repeat that no problems occur with the v1.5 stable release (Windows x64).

Title: Re: v1.5 128 bit (and beyond) math *** COMPILER ERROR ***
Post by: SpriggsySpriggs on June 11, 2021, 11:46:30 am
The compiler issue has been discussed in other threads. We've been looking into it.
Title: Re: v1.5 128 bit (and beyond) math *** COMPILER ERROR ***
Post by: Richard on June 11, 2021, 11:57:16 am
@SpriggsySpriggs

OK - will change my default QB64 back to stable build v1.5.
Title: Re: v1.5 128 bit (and beyond) math
Post by: George McGinn on June 11, 2021, 12:15:28 pm
@SMcNeill, Sorry, I missed this post and felt a response to clarify was in order:

First, I never said that the TechBASIC results were correct. That came from a program I use to test number inaccuracies. I have this code written in C, various BASIC dialects, R, Python, FORTRAN, COBOL, and Assembler (NASM). And the program tests more than what I showed (that is a small part of it).

EDIT: I was reminded that powerof in Python is ** and not ^ (I've been coding in BASIC for a while I forgot). Anyway, my results are now: 5869713600000.0, which matches QB64. However, it looks like the conversion out of exponential numbers is only providing 8 significant digits, and we are losing the rest.

QB64 also isn't giving the correct answer either, because of how it (and many other languages for that matter) handles exponents, mantissa's, etc. Most of this is a limitation of either the hardware or the underlying bytecode that is used to create QB64 (in this case, C++).

I ran the same equation in IPYTHON (screen print attached) just to show you how different the results are, depending on the language.

I get  97828577532.0 vs QB64's 5869713600000 vs TechBASIC's 5869713489920.

Even when I ask Python to calculate all FLOAT, I get the same results.

Quote
In [3]: print(float(((186000 * 60 ^ 2) * 24) * 365.25))                                               
97828577532.0

In fact, I get less significant digits using Python than any BASIC interpreter/compiler!

Here is the real speed of light (it is more than 186,000 mi/sec):

Quote
The speed of light in imperial units and US units is based on an inch of exactly 2.54 cm and is exactly

    299792458 m/s × 100 cm/m × 1/2.54 in/cm

which is approximately 186282 miles, 698 yards, 2 feet, and 5 inches per second (Or accepted as 186282.397).

The numbers used and the formulas used are just to test how accurate (precision) the mantissa and exponential calculations are.

  [ This attachment cannot be displayed inline in 'Print Page' view ]  

Why does the techbasic on the ipad print the wrong answer? 

((186000 * 60 ^ 2) * 24) * 365.25 = 5869713600000 (at least according to both google and my windows calculator, which is what I lazily used to check results), which is what QB64 gives us.  The screen shot of your ipad is showing the result as 5869713489920.

I must be missing something here, as it seems QB64 is giving us the correct answers while the mobile device screenshot you posted isn't.
Title: Re: v1.5 128 bit (and beyond) math *** COMPILER ERROR ***
Post by: Richard on June 12, 2021, 12:12:55 am
@GeorgeMcGinn

If I may further confuse the issue -  referring to

https://www.unitconverters.net/length/inches-to-mm.htm (https://www.unitconverters.net/length/inches-to-mm.htm)

  [ This attachment cannot be displayed inline in 'Print Page' view ]  

So in 2019 the metre has been re-defined based on changes made to the definition of a second - should I take it that the inch conversion, being defined by that 25.4 conversion factor, prior to 2019 is not the exact same quantity of physical length "distance" as to from 2019 onwards?

If this is so, calculations involved sending a probe to the planet Pluto (yes I still call it a planet) made prior to 2019 may be out by a few feet when the same calculations are done after 2019. Not that it really matters, since the mission success rate is questionable for such great distances :)
Title: Re: v1.5 128 bit (and beyond) math *** COMPILER ERROR ***
Post by: NOVARSEG on June 12, 2021, 12:56:18 am
from https://en.wikipedia.org/wiki/2019_redefinition_of_the_SI_base_units


Quote
Previous definition: The second is the duration of 9192631770 periods of the radiation corresponding to the transition between the two hyperfine levels of the ground state of the caesium-133 atom.
2019 definition: The second, symbol s, is the SI unit of time. It is defined by taking the fixed numerical value of the caesium frequency ΔνCs, the unperturbed ground-state hyperfine transition frequency of the caesium-133 atom,[40] to be 9192631770 when expressed in the unit Hz, which is equal to s−1.
The second may be expressed directly in terms of the defining constants:

1 s =
9192631770
/
ΔνCs
.
Title: Re: v1.5 128 bit (and beyond) math *** COMPILER ERROR ***
Post by: Richard on June 12, 2021, 02:24:00 am
@NOVARSEG

Yes, if you are equivalently rearranging an "equation" to derive a time standard, you can come up with a non-changed assignment to be used as a standard (and that in itself may never change).

I suppose the "real problem" is how to obtain reproducibility in practice.

Take for example the scientific experiment conducted many years ago (I think it was about something like does time change when traveling at different velocities, and for that matter is the speed of light an absolute constant or does it vary say when light is "launched" from a moving source). Briefly the experiment involved two sets of "portable atomic clocks" (they may have  been refrigerator sized units) and were probably "claimed to have been synchronized to each other". These were placed on to I think "domestic airlines" travelling in opposite directions with scientists accompanying - the objective I think was to see if there were any time differences... All that I ever heard further was that "it would take many months to analyze the results". (Never did find out what the "answer" was).

A more recent "interesting" experiment was to do with the detection of so-called gravity waves. Totally forgotten on the measuring methods used but what I vaguely recall afterwards was that the manufacturer of the components used for the experiment was changing the device specifications and effectively throwing in  "adjustment factors" to increase sensitivity. So by conveniently "ignoring noise and random events" one could conclude they have found gravity waves.

In general, to me it seems that when when the definitions change for a standard - there is no statement from those in the know  as to how a "before" and "after" definition change affects things - so if you had a "metre length" from "before" and placed beside from "after", can it be shown that both are the same length (to the best experimental accuracy techniques). Can an atomic clock be sure to always "tick" correctly - in particular never miss a beat or worse still, never have time phase changes for the transition "ticks".

So to summarize, with definition changes, an inch from a while ago may not be exactly the same as an inch from today (may be 99.9999% similar) and without ultra high certainty/precision, life becomes difficult because of propagation of errors.
Title: Re: v1.5 128 bit (and beyond) math *** COMPILER ERROR ***
Post by: luke on June 12, 2021, 02:33:24 am
There is no need to use floating point maths at all for the above calculation.

18600 * 60^2 * 24 * 365.25 = 18600 * 60^2 * 24 * (365 + 1/4) = 18600 * 60^2 * 24 * 365 + (18600 * 60^2 * 24) / 4.

The expression being divided by 4 is obviously a multiple of 4 (24 = 6 * 4), so the division is exact. You can now evaluate the entire thing with nay but integers in sight.

But in any case, I'm failing to detect any actual problem among your messages.
Title: Re: v1.5 128 bit (and beyond) math *** COMPILER ERROR ***
Post by: George McGinn on June 12, 2021, 10:35:28 am
@Richard, my post mentions CENTIMETERS where yours is in MILLIMETERS.

The results are the same (25.4mm = 2.54cm) when comparing distances.

EDIT: Converting distance by time is tricky due to time dilation, among other factors. It isn't as simple as made here. (See: https://opentextbc.ca/universityphysicsv3openstax/chapter/time-dilation/ (https://opentextbc.ca/universityphysicsv3openstax/chapter/time-dilation/))

@GeorgeMcGinn

If I may further confuse the issue -  referring to

https://www.unitconverters.net/length/inches-to-mm.htm (https://www.unitconverters.net/length/inches-to-mm.htm)

  [ This attachment cannot be displayed inline in 'Print Page' view ]  

So in 2019 the metre has been re-defined based on changes made to the definition of a second - should I take it that the inch conversion, being defined by that 25.4 conversion factor, prior to 2019 is not the exact same quantity of physical length "distance" as to from 2019 onwards?

If this is so, calculations involved sending a probe to the planet Pluto (yes I still call it a planet) made prior to 2019 may be out by a few feet when the same calculations are done after 2019. Not that it really matters, since the mission success rate is questionable for such great distances :)
Title: Re: v1.5 128 bit (and beyond) math *** COMPILER ERROR ***
Post by: bplus on June 12, 2021, 10:40:08 am
Quote
5,878,625,370,000 miles
In a vacuum, light travels at 670,616,629 mph (1,079,252,849 km/h). To find the distance of a light-year, you multiply this speed by the number of hours in a year (8,766). The result: One light-year equals 5,878,625,370,000 miles (9.5 trillion km).May 31, 2019

Code: QB64: [Select]
  1. Print "Light year miles:"; 670616629.0 * 8766
  2. Print "Light year miles:"; 670616629&& * 8766

Needs the && on the big number or .0
Title: Re: v1.5 128 bit (and beyond) math *** COMPILER ERROR ***
Post by: Richard on June 13, 2021, 02:10:50 pm
@SMcNeill

Regarding free memory available...

Quote

Is there a limit, if you compile with the 64-bit version of QB64?  I guess if you max out ram + hard drive usage, but that’s either one massive program or one helluva memory leak!


On my setup with 32 GByte memory (of which 10 GByte is configured as a RAM drive) with Windows 10 x64 - for my 128bit Math Code Project...

In my case it is critical that calculations are completed within a 3-day computer run session (it does not matter how many times I retry a 3-day session, just can not take longer than 3 days per run). So to this end I am evaluating various coding methods to be "time efficient" and so trying out _MEM type stuff ranging from BIT to INTEGER64 with associated timing comparisons. Because of the size of numbers and the method used to process same - I need to be mindful of how much memory is available, as my estimation for memory use is far from perfect (partly because I do not fully understand how Windows 10 allocates memory). So to avoid running into "Out of Memory" errors at run time - the reason for monitoring Free Memory Available.

As I wanted to investigate the practicality of using _UNSIGNED _BIT variables it was important to establish if a BIT array would always pack 8 bits per byte into memory (the ideal case) or if a byte was used for each bit. Below is my test program (based on @moises1953 code)


Code: QB64: [Select]
  1. TYPE MEMORYSTATUSEX 'MemStat
  2.     dwLength AS LONG: dwMemoryLoad AS LONG: ullTotalPhys AS _UNSIGNED _INTEGER64
  3.     ullAvailPhys AS _UNSIGNED _INTEGER64: ullTotalPageFile AS _UNSIGNED _INTEGER64
  4.     ullAvailPageFile AS _UNSIGNED _INTEGER64: ullTotalVirtual AS _UNSIGNED _INTEGER64
  5.     ullAvailVirtual AS _UNSIGNED _INTEGER64: ullAvailExtendedVirtual AS _UNSIGNED _INTEGER64
  6. DECLARE CUSTOMTYPE LIBRARY 'Memory Information using KERNEL32
  7.     FUNCTION GlobalMemoryStatusEx& (Mstat AS MEMORYSTATUSEX)
  8. DIM MemStat AS MEMORYSTATUSEX: DIM Result AS LONG: Result& = 0: PRINT: PRINT: COLOR 7
  9. MemStat.dwLength = LEN(MemStat)
  10. Result = GlobalMemoryStatusEx&(MemStat): before&& = MemStat.ullAvailPhys
  11. PRINT "Free phys mem"; USING "##,###,###,###"; before&&;: COLOR 14:
  12. h& = 799999999: DIM h~`(0 TO h&): PRINT " DIM h~`(0-"; LTRIM$(STR$(h&)); ")";: COLOR 7
  13. FOR hh& = 0 TO h&: h~`(hh&) = 1: NEXT
  14. Result = GlobalMemoryStatusEx&(MemStat): after&& = MemStat.ullAvailPhys
  15. PRINT USING "##,###,###,###"; after&&;: COLOR 10:
  16. PRINT " delta=";: PRINT USING "###,###,###"; before&& - after&&: END
  17.  

The results for various numbers of bits (as multiples of 8 bits) as in a BIT array versus free memory loss due to the creation of the BIT array is below


  [ This attachment cannot be displayed inline in 'Print Page' view ]  


So trying to appreciate how Windows 10 allocates memory, from the larger of sizes of the BIT array it would sort of suggest to me that 8bits (in a BIT array) are packed into a byte.  Of interest if I try to have a BIT array (0 TO 7999999999) i.e. 8 Giga bits I get an out of memory error at run time (even though I have (32 - 10) GBytes ram still available for system memory.
 




As a side note I have problems with trying to use BIT stuff, e.g. consider the statement


DIM m1 AS _UNSIGNED _BIT * 56: m1 = 0   ' this line is line... as below

looking at the number after "*" the results (IDE error)

'*  56  OK
'*  57  Compiler error (check for syntax errors) (Reference:9-21340) on line ...
'*  58  Cannot create a bit variable of sie >24 bits on line ...
'* 100  Too many characters in number after * on line ...

it would have been nice to have say DIM m1 as _UNSIGNED _BIT *1024 ' or much bigger - so I am confused with the results above.


Also, unless I am doing something wrong (quite possible), I cannot seem to be able to do something like

MEMGET m, m.offset, h~` ' i.e. any reference to a BIT variable


Similarly, trying to be fully versatile with _MEM stuff (experimental trials by me) I also have problems such as



z~%% = MEMNEW(1)::::::::: z~%% = 0 '                      1 bytes for ~%%

'In file included from qbx.cpp:2216:
'..\\temp\\main.txt: In function 'void SUB_L1_INITIALIZATION()':
'..\\temp\\main.txt:3112:59: error: cannot convert 'mem_block' to 'unsigned char' in assignment
' *_SUB_L1_INITIALIZATION_UBYTE_Z=(func156=func__memnew( 1 ));
'                                                           ^
'compilation terminated due to -Wfatal-errors.





z~% = MEMNEW(2)::::::::: z~% = 0 '                      2 bytes for ~%

'In file included from qbx.cpp:2216:
'..\\temp\\main.txt: In function 'void SUB_L1_INITIALIZATION()':
'..\\temp\\main.txt:3112:62: error: cannot convert 'mem_block' to 'short unsigned int' in assignment
' *_SUB_L1_INITIALIZATION_UINTEGER_Z=(func156=func__memnew( 2 ));
'                                                              ^
'compilation terminated due to -Wfatal-errors.


So far I think I am OK with the other variable types possibilities in the above scenarios.

Many thanks again for your informative tutorials (videos) on _MEM and my 128bit Math Code Project (NOT in competition with other forum members, or your C library link, etc) is my first application of _MEM with encouraging results (though slow at present).

Please supply any comments you may have  regarding above.

Title: Re: v1.5 128 bit (and beyond) math *** COMPILER ERROR ***
Post by: NOVARSEG on June 13, 2021, 06:33:54 pm
@Richard

Some basic MEM stuff

Should be able to do math calcs with 3 separate memory blocks.  The first 2 block can be the 2 variables to divide / multiply etc

The 3rd 2048 bit memory block is for final results .It can be made as large as you want etc.   The correct offsets need to used.

 MEM  does not support _UNSIGNED _BIT

Code: QB64: [Select]
  1.  
  2. DIM m1 AS STRING * 128 '1024 bits
  3. DIM m2 AS STRING * 128 '1024 bits
  4. DIM m3 AS STRING * 256 '2048 bits
  5.  
  6. DIM mm1 AS _MEM
  7. mm1 = _MEM(m1)
  8.  
  9. DIM mm2 AS _MEM
  10. mm2 = _MEM(m2)
  11.  
  12. DIM mm3 AS _MEM
  13. mm3 = _MEM(m3)
  14.  
  15. Byte1 = _MEMGET(mm1, mm1.OFFSET, _UNSIGNED _BYTE)
  16.  
  17. Byte2 = _MEMGET(mm2, mm2.OFFSET, _UNSIGNED _BYTE)
  18.  
  19. _MEMPUT mm3, mm3.OFFSET, Byte3    
Title: Re: v1.5 128 bit (and beyond) math *** COMPILER ERROR ***
Post by: NOVARSEG on June 13, 2021, 08:19:38 pm
example:   multiply the ASC value of 2 letters   A  *   B

The answer is 4,290

Code: QB64: [Select]
  1.  
  2. DIM m1 AS STRING * 128 '1024 bits
  3. DIM m2 AS STRING * 128 '1024 bits
  4. DIM m3 AS STRING * 256 '2048 bits
  5.  
  6. m1 = "A" + STRING$(127, CHR$(0))
  7. m2 = "B" + STRING$(127, CHR$(0))
  8.  
  9. DIM mm1 AS _MEM
  10. mm1 = _MEM(m1)
  11.  
  12. DIM mm2 AS _MEM
  13. mm2 = _MEM(m2)
  14.  
  15. DIM mm3 AS _MEM
  16. mm3 = _MEM(m3)
  17.  
  18. var1 = _MEMGET(mm1, mm1.OFFSET, _UNSIGNED _INTEGER64)
  19.  
  20. var2 = _MEMGET(mm2, mm2.OFFSET, _UNSIGNED _INTEGER64)
  21.  
  22. var3 = var2 * var1
  23.  
  24. _MEMPUT mm3, mm3.OFFSET, var3
  25.  
  26. var4 = _MEMGET(mm3, mm3.OFFSET, _UNSIGNED _INTEGER64)
  27.  
  28. PRINT var4

Seems like a complicated way to multiply numbers.   With this method it should be possible to multiply two  64 bit numbers or multiply  2  strings of 8 letters each.
Title: Re: v1.5 128 bit (and beyond) math *** COMPILER ERROR ***
Post by: Richard on July 01, 2021, 04:00:26 am
As many would know, bit flags are a powerful feature that allow for access to memory mapped operations.

In the application to say 128 bit (and beyond) math, bit patterns allow for specifically designed routines as an easy way for certain classes of operations in low-level programming. It would allow implementation of features for speed and memory optimization in addition to various programming interface protocols.

Referring to my reply #163 (this topic/thread), I was not able to use _UNSIGNED _BIT with MEM blocks.

Only one person ( @NOVARSEG ) replied that MEM does not support _UNSIGNED _BIT. I was hoping that some QB64 developers would comment on same.

Although a type such as _BIT is not mentioned for TYPE memory-type, I would think in my intended application for 128 bit (and beyond) math, if I worked with multiples of 64 bit fields - it would be possible to do MEM block <--> 64 bit array elements interactions (eg using DIM h~`(0 to 63)). Working with unsigned bit arrays would be a convenient mechanism for handling very large numbers, and has the advantage of easier program readability and debugging over packed bit methods such as byte, integer, long etc. QB64 appears to pack unsigned bits into bytes, so it is also memory efficient.

So suppose I had a bit array of size being a multiple of 64 bits - is there a programming mechanism to allow this to be a MEM block (which then can be accessed by the other variable types such as INTEGER64)? If not - then to have this special case of unsigned bit implementation as being compatible with the usual MEM block operations as a FEATURE REQUEST.  After all, if one sees that a MEM block is a contiguous set of bytes in memory, and a 64bit unsigned bit array is packed into 8 bytes in another contiguous set of 8 bytes of memory - then hopefully by virtue of handling contiguous sets of memory then MEM could work here.

To me, the fact that the very same MEM block can be "assigned" to many variable types including strings and vice versa (all of which effectively simultaneously) - makes it a very versatile feature of QB64 (together with potential speed gains and memory savings). Unsigned bit interaction capability would be a big plus especially in large number math (when compared to working with say integers, etc).
Title: Re: v1.5 128 bit (and beyond) math *** COMPILER ERROR ***
Post by: SpriggsySpriggs on July 01, 2021, 07:43:22 am
Unsigned bit, or just bit, has many issues. It's not recommended for use at all, actually. It half works and isn't actually a bit anyways. You could use an integer64 and use ReadBit and SetBit. That works well.
Title: Re: v1.5 128 bit (and beyond) math *** COMPILER ERROR ***
Post by: Richard on July 01, 2021, 01:16:11 pm
@SpriggsySpriggs

Thanks for your reply. I do not understand (at the moment) when the BIT stuff only half works (suppose will find out for myself soon enough).

Lets assume for the moment that BIT arrays fully work, and the one super large array h~`(0 to 1023) packs into 128 contiguous bytes in memory (which I think it does). Referring to your post

https://www.qb64.org/forum/index.php?topic=4023.0 (https://www.qb64.org/forum/index.php?topic=4023.0)   reply #6

Quote

@TempodiBasic

Don't forget; you can also use my new shared memory library in Windows!


Parent:
Code: QB64: [Select]
  1.  
  2.  
  3. 2.
  4.  
  5.  
  6. 3.Dim As _MEM pShare 'You need to use a _MEM block
  7.  
  8.  
  9. 4.Dim As Long longtoShare: longtoShare = 500 'declaring a long variable to store in the _MEM block
  10.  
  11.  
  12. 5.pShare = _Mem(longtoShare) 'storing the long variable in the _MEM block
  13.  
  14.  
  15. 6.
  16.  
  17.  
  18. 7.Print CommonShared("MySharedMem", pShare) 'initializing the shared memory object
  19.  
  20.  
  21. 8._MemFree pShare
  22.  
  23.  
  24. 9.
  25.  
  26.  
  27. 10.'$INCLUDE:'Win32 SharedMem.bas'
  28.  

Child:
Code: QB64: [Select]
  1.  
  2.  
  3. 2.
  4.  
  5.  
  6. 3.Dim As _MEM newMem: newMem = _MemNew(4) 'declaring the destination _MEM block
  7.  
  8.  
  9. 4.
  10.  
  11.  
  12. 5.Print ReadShared("MySharedMem", newMem) 'reading the shared memory object into the new _MEM block
  13.  
  14.  
  15. 6.
  16.  
  17.  
  18. 7.Dim As Long dest 'declaring a destination long variable
  19.  
  20.  
  21. 8._MemGet newMem, newMem.OFFSET, dest 'storing the contents of the _MEM block into a new long variable
  22.  
  23.  
  24. 9.Print dest
  25.  
  26.  
  27. 10._MemFree newMem
  28.  
  29.  
  30. 11.
  31.  
  32.  
  33. 12.'$INCLUDE:'Win32 SharedMem.bas'
  34.  

Full $INCLUDE, save as Win32 SharedMem.bas
Code: QB64: [Select]
  1.  
  2.  
  3. 2.    Function CreateFileMapping%& Alias "CreateFileMappingA" (ByVal hFile As _Offset, Byval lpFileMappingAttributes As _Offset, Byval flProtect As Long, Byval dwMaximumSizeHigh As Long, Byval dwMaximumSizeLow As Long, lpName As String)
  4.  
  5.  
  6. 3.    Function OpenFileMapping%& Alias "OpenFileMappingA" (ByVal dwDesiredAccess As Long, Byval bInheritHabndle As Long, lpName As String)
  7.  
  8.  
  9. 4.    Function MapViewOfFile%& (ByVal hFileMappingObject As _Offset, Byval dwDesiredAccess As Long, Byval dwFileOffsetHigh As Long, Byval dwFileOffsetLow As Long, Byval dwNumberOfBytesToMap As _Offset)
  10.  
  11.  
  12. 5.    Sub UnmapViewOfFile (ByVal lpBaseAddress As _Offset)
  13.  
  14.  
  15. 6.    Function GetLastError& ()
  16.  
  17.  
  18. 7.    Sub CloseHandle (ByVal hObject As _Offset)
  19.  
  20.  
  21.  
  22.  
  23. 9.
  24.  
  25.  
  26. 10.Function CommonShared%% (sharedName As String, pShared As _MEM)
  27.  
  28.  
  29. 11.    Const INVALID_HANDLE_VALUE = -1
  30.  
  31.  
  32. 12.    Const PAGE_READWRITE = &H04
  33.  
  34.  
  35. 13.    Const FILE_MAP_ALL_ACCESS = &HF001F
  36.  
  37.  
  38. 14.    Declare Dynamic Library "Kernel32"
  39.  
  40.  
  41. 15.        Sub CopyMemory Alias "RtlCopyMemory" (ByVal Destination As _Offset, Byval Source As _Offset, Byval Length As _Offset)
  42.  
  43.  
  44. 16.    End Declare
  45.  
  46.  
  47. 17.    Dim As _Offset hMapFile, pBuf
  48.  
  49.  
  50. 18.    Dim As Long sharedSize: sharedSize = Val(Str$(pShared.SIZE))
  51.  
  52.  
  53. 19.    hMapFile = CreateFileMapping(INVALID_HANDLE_VALUE, 0, PAGE_READWRITE, 0, sharedSize, sharedName)
  54.  
  55.  
  56. 20.    If hMapFile = 0 Then
  57.  
  58.  
  59. 21.        CommonShared = 0
  60.  
  61.  
  62. 22.        Exit Function
  63.  
  64.  
  65. 23.    End If
  66.  
  67.  
  68. 24.    pBuf = MapViewOfFile(hMapFile, FILE_MAP_ALL_ACCESS, 0, 0, sharedSize)
  69.  
  70.  
  71. 25.    If pBuf = 0 Then
  72.  
  73.  
  74. 26.        CloseHandle hMapFile
  75.  
  76.  
  77. 27.        CommonShared = 0
  78.  
  79.  
  80. 28.        Exit Function
  81.  
  82.  
  83. 29.    End If
  84.  
  85.  
  86. 30.    CopyMemory pBuf, pShared.OFFSET, sharedSize
  87.  
  88.  
  89. 31.    CommonShared = -1
  90.  
  91.  
  92. 32.    EndShare hMapFile, pBuf
  93.  
  94.  
  95.  
  96.  
  97. 34.
  98.  
  99.  
  100. 35.Function ReadShared%% (sharedName As String, destVar As _MEM)
  101.  
  102.  
  103. 36.    Const FILE_MAP_ALL_ACCESS = &HF001F
  104.  
  105.  
  106. 37.    Dim As _Offset hMapFile, pBuf
  107.  
  108.  
  109. 38.    Dim As Long sharedSize: sharedSize = Val(Str$(destVar.SIZE))
  110.  
  111.  
  112. 39.    hMapFile = OpenFileMapping(FILE_MAP_ALL_ACCESS, 0, sharedName)
  113.  
  114.  
  115. 40.    If hMapFile = 0 Then
  116.  
  117.  
  118. 41.        ReadShared = 0
  119.  
  120.  
  121. 42.        Exit Function
  122.  
  123.  
  124. 43.    End If
  125.  
  126.  
  127. 44.    pBuf = MapViewOfFile(hMapFile, FILE_MAP_ALL_ACCESS, 0, 0, sharedSize)
  128.  
  129.  
  130. 45.    If pBuf = 0 Then
  131.  
  132.  
  133. 46.        ReadShared = 0
  134.  
  135.  
  136. 47.        Exit Function
  137.  
  138.  
  139. 48.    End If
  140.  
  141.  
  142. 49.    destVar = _Mem(pBuf, sharedSize)
  143.  
  144.  
  145. 50.    ReadShared = -1
  146.  
  147.  
  148. 51.    EndShare hMapFile, pBuf
  149.  
  150.  
  151.  
  152.  
  153. 53.
  154.  
  155.  
  156. 54.Sub EndShare (hMap As _Offset, pMapBuf As _Offset)
  157.  
  158.  
  159. 55.    UnmapViewOfFile hMap
  160.  
  161.  
  162. 56.    CloseHandle pMapBuf
  163.  
  164.  
  165. 57.End Sub
  166.  


Using your shared memory routine of above - can I share the same contiguous memory used by h~`(0 to 1023) with a MEM block of size 128 bytes - in the one program (ideal case)? - over two programs (one program has h~`(0 to 1023) and the other a MEM block of size 128 bytes)?

If the above can be done, then maybe I would have BIT functionality (sort of) with MEM in my intended implementation of BIT in 128 bit (and beyond) math.

As it is critical for speed optimization in my case - I wish to persue using BIT with MEM (assuming it can be made to work in my case). Of course I will be doing numerous speed comparisons with other variables (not BIT) and MEM to determine which works best for me (there are many combinations of things to try out and compare in QB64 code alone, not to mention following up on the other suggestions by forum members such as C libraries etc).

Hope you understand my intentions of using your shared memory program to the case of BIT with MEM.
Title: Re: v1.5 128 bit (and beyond) math *** COMPILER ERROR ***
Post by: SpriggsySpriggs on July 01, 2021, 01:42:31 pm
@Richard To my knowledge, my Shared Memory Library should allow you to share a memory buffer up to the upper limit of a 64 bit integer. As long as your data matches on both sides then you can share whatever you want. Strings, numbers, arrays, etc.
Title: Re: v1.5 128 bit (and beyond) math *** COMPILER ERROR ***
Post by: Richard on July 01, 2021, 02:19:48 pm
@SpriggsySpriggs

Thanks.

Quote
To my knowledge, my Shared Memory Library should allow you to share a memory buffer up to the upper limit of a 64 bit integer. As long as your data matches on both sides then you can share whatever you want. Strings, numbers, arrays, etc.

If I understand you correctly - does that mean that I could have on one side a MEM block of size 18,446,744,073,709,551,615 unsigned integer64 elements (maximum limit size of unsigned integer64) (subject to available RAM memory of my computer)?

And also, in principle on the other side being of the same memory size, have a bit array of size h~`(0 to 18,446,744,073,709,551,615 * 64 -1) which I think is bigger than 128 bits span?

:)

Oops - h`() would have to be reduced down to only h`( 0 to 18,446,744,073,709,551,615 -1) because of indexing issues and correspondingly MEM block reduced to 18,446,744,073,709,551,615/64 unsigned integer64 elements to match in size to h~`().

 
Title: Re: v1.5 128 bit (and beyond) math *** COMPILER ERROR ***
Post by: SpriggsySpriggs on July 01, 2021, 02:33:05 pm
@Richard Not an unsigned integer64, just a regular integer64. From the documentation I see, the value for the buffer limit is created by two DWORDs, which are longs and not unsigned.
Title: Re: v1.5 128 bit (and beyond) math *** COMPILER ERROR ***
Post by: Richard on July 01, 2021, 02:52:38 pm
@SpriggsySpriggs

OK so signed integer64.

Now in theory I can ONLY work with 9,223,372,036,854,775,807 bits using h~`() array !

:)

Not that I will be using 128 bit (and beyond) math for this ...

Pi has been computed to 3.14 trillion digits (refer Google etc search) - I get bored reading Pi after 10 digits (so anything beyond that could be random numbers for all I care (who bothers to check the accuracy at say one millionth decimal place anyway)?

To calculate Pi to say 9,223,372,036,854,775,807/4 digits (rough estimate) may take longer than the known estimated existence of the universe on my computer!




Title: Re: v1.5 128 bit (and beyond) math *** COMPILER ERROR ***
Post by: Richard on July 19, 2021, 06:37:06 pm
@SpriggsySpriggs

Quote
To my knowledge, my Shared Memory Library should allow you to share a memory buffer up to the upper limit of a 64 bit integer. As long as your data matches on both sides then you can share whatever you want. Strings, numbers, arrays, etc.

For the "Parent" ...

Quote

3.Dim As _MEM pShare 'You need to use a _MEM block
 
 
4.Dim As Long longtoShare: longtoShare = 500 'declaring a long variable to store in the _MEM block
 
 
5.pShare = _Mem(longtoShare) 'storing the long variable in the _MEM block
 


Your program set is potentially very useful for me, and as per your example it worked. I was unsuccessful to apply it with variable types _BIT array and as  previously discovered _BIT types are not supported with _MEM blocks.


Is there any "programming trick" you know or heard of that I could try to "trick" the "child" program to link via a _BIT array h~`() in the child to a regular _MEM block in the "parent" program? In my case I would ensure that the _BIT array (which apparently is packed as contiguous bytes) is exactly the same number of bytes as the _MEM block in the parent program.


Title: Re: v1.5 128 bit (and beyond) math *** COMPILER ERROR ***
Post by: SpriggsySpriggs on July 19, 2021, 10:33:57 pm
@Richard Do not use BIT
Title: Re: v1.5 128 bit (and beyond) math *** COMPILER ERROR ***
Post by: Richard on August 09, 2021, 09:09:13 pm
@SpriggsySpriggs


Quote from @SpriggsySpriggs   (reply 113)
Quote
What is the reason for needing such a large number right now?


I omitted mentioning the following in my reply (118) ...



At about the same time of the "Pentium Bug", there was an interesting article. The article, as far as I could tell, did not mention specific names, companies, products and so - although "sketchy" here, the article relates to an investigation (in the USA) about that a certain (fairly complex) IC package (i.e. the silicon chip inside) was found in an "un-authorized" product on the commercial market. So apparently the silicon die chip was illegally copied and sold in a competitor's product. (Although the question maybe "Was this intelectural theft?" - or was this "A shenanigan (or something)" - the development that follows was that (at the time) an un-named US government agency was investigating the incident.)

Apparently, it turned out that the original manufacturer of the chip "on purpose" arranged by design a "deliberate error in the silicon die", an error (or design fault) so by its nature not to be noticed etc. and in the mainstream usage would not have typically any bearing on any outcomes. The shear probability of a competitor coming up with such a "extremely remote" design fault of this kind, and going further, that the whole silicon die itself was exactly identical including the physical location of the design fault on the silicon die itself - would suggest to readers of the article that corporate theft was involved. Further, due to lack of disclosure of specific names etc. and lack of follow-up press releases - the article left open to the readers that "Was there a National Security Risk (for USA) because of "corporate spying (or something)?". To sum this story up - I think the whole event was an investigative "STING" (I think the word is).


NOW, more recently (a few years ago, and I think maybe still continuing today) is the "Talent 1000" program - being run by the Chinese Government. Here the Chinese Government was actively encouraging its manufacturing infrastructure to improve its products to be competitive  with the rest of the world. Coincidently, there have been government investigations of "connections of various specialists" with the "Talent 1000" program - and especially of same (outside of China) not declaring such interests....(and I leave it to your imagination of all sorts of things that can be resulting because of this).


As far as this reply goes  ...


The Pentium Bug may not have been a "design mistake" (rather a test of security and integrity processes). As to the many thousands of computers which have had the particular "batch" of Pentium processors installed (apparently only a particular model/product number of the Pentium chip is affected) - and of which INTEL probably did not sell to computer makers - what happens to the owners of these affected computers today (and consider, following up on what was said above, on further INTEL products of the current "x86...x64" series)? At the time of the Pentium Bug, apparently software patches "popped up" but I seem to find same hard to find. For my INTEL processor I did run an INTEL program which did output a lot of information on my particular chip (like how much first, second and third level memory was present, etc.).



As far as QB64 goes, for the many potential "compromised" computers out there - maybe @SpriggsySpriggs (or someone) can come up with firstly a diagnostic program (Windows API or something) to exactly classify the processor installed. Secondly, based on this classification (and reference to any submitted list of "suspect processors") perform very specific program result tests (say along the line of advertised Pentium Bug tests). Finally to confirm if the bugs are present - and for say divides may need calculations beyond 64/80 bit using completely independent means (not intel divide/multiply operations).


Of course all of the above is an "isolated case" (Pentium Bug) and has not touched on a potentially more serious aspect of precision (which may be a matter of opinion depending on users expectations).
 
Title: Re: v1.5 128 bit (and beyond) math *** COMPILER ERROR ***
Post by: SpriggsySpriggs on August 10, 2021, 08:50:44 am
So we're building security programs in QB64 now?
Title: Re: v1.5 128 bit (and beyond) math *** COMPILER ERROR ***
Post by: SMcNeill on August 10, 2021, 12:21:08 pm
So we're building security programs in QB64 now?

You and Richard might be, but I’m not.  ;D

I’m happy to just build “Wello Horld” programs when I can, without messing them up…
Title: Re: v1.5 128 bit (and beyond) math *** COMPILER ERROR ***
Post by: SpriggsySpriggs on August 10, 2021, 12:22:42 pm
I sure as heck ain't building anything for security. Security doesn't even cross my mind when writing a QB64 program. Only thing I think is, "huh, neat. It worked. It's a miracle"
Title: Re: v1.5 128 bit (and beyond) math *** COMPILER ERROR ***
Post by: George McGinn on August 10, 2021, 09:13:19 pm
I guess I should say some prayers on my next QB64 compile --- I could use a miracle!

I sure as heck ain't building anything for security. Security doesn't even cross my mind when writing a QB64 program. Only thing I think is, "huh, neat. It worked. It's a miracle"
Title: Re: v1.5 128 bit (and beyond) math *** COMPILER ERROR ***
Post by: Richard on September 06, 2021, 12:44:25 am
In preparation for my QB64 coding for 128+bit math - I have run a number of modules, each being on purpose similar in coding style (essential difference between modules is the variable elements used and the memory allocated for same).

The objective was to simulate INC (increment, +1) but with the eventual aim of scalability (i.e. to go beyond 128 bits). The modules all were scaled down to 64 bits only (to allow in the near future easy cross-checking with INTEGER64 standard code) and as tested were not used for anything useful (i.e. an "empty" FOR NEXT loop would be the QB64 code equivalent). The test results (shown below) were for 16 INC's in succession and the "trial" was repeated 128 times.

The methodology used was purely bit-wise (i.e. base 2) - and consequently one bit only at a time was stored in the respective variable elements, for instance an INTEGER64 array stored only one bit value per array element (~2% memory efficient).

The overall aim was to determine which element variable and memory allocation combination would produce distinctive calculation time gains.


In the process of this development I gained some experience in using MEM blocks and UDT.



  [ This attachment cannot be displayed inline in 'Print Page' view ]  


Notes

In the tabulated values section, inc = 0 should read inc = 16
The horizontal axis is a linear time scale (0 to 3 seconds)
The vertical axis is a linear count (one count per pixel) for the respective modules.
Some modules are known to be in error
() designates QB64 arrays being used - one element per bit
memory and screen are the memory allocations as per using MEM coding
screen_0 and screen_2 are the old DOS memory allocations (&HB800 and &HA000 addresses) and NOT being used by MEM
udt as per user defined type
direct means that allocation unit is "hard-coded" (i.e. a03% variable used instead of a%(03) array element)
TIMER_empty_loops is actually a module without any code in the loop (here 16x) - to estimate overhead in timing of modules
TIMER_null is two time calls difference (i.e the resolution of the timing process for two successive enquiries)
The tabulated values represent minimum, average, maximum timings for the collection of 128 trials per module
The associated Histogram shows all data points above a line of half-intensity (line = span minimum to maximum)  - no data point is repeated on the exact same pixel (and always above the line).
The program was run without computer connection to internet, devices etc or essentially any other software running.
All modules are essentially the same coding style, only the variable elements used differ - the "heart" of each module - INC - was only 3 lines of functional QB64 code equivalent per iteration.
All modules were tested in "SLOW" mode, i.e. to roughly simulate in actual useage - so for instance at each iteration of INC, the binary string representation was displayed as text on a graphics screen, select case block used to redirect as necessary depending on a particular bit field value.
The timings (unit = second) do not include any setup overheads (zeroing etc) - and assumed the initial value (for the INC) was preloaded and valid.




Eventually it is planned to use resources as mentioned/written by @SMcNeill , @luke, @bplus  and @jack  as the program develops past INC to the more common modes. These other resources would be used to cross-check my results.



Title: Re: v1.5 128 bit (and beyond) math *** bumpy DETOUR via 80bit _FLOAT ***
Post by: Richard on October 03, 2021, 10:26:24 pm
This reply is really meant for any relatively new programmers.



QB64 Number Space


This is a first attempt to summarize the IDE_help/Wiki/internet/computer_science_math regarding the QB64 Number Space.

For the purpose of this reply - the QB64 Number Space are those numbers that can be explicitly entered and accurately retrieved by QB64. Examples of explicit values are   1000   0.5   0.333  1E3.  Examples of implicit numbers are   1/3    1.000000089E99    1.0000000000000000000001.

A simple (not complete) survey of explicit numbers (for QB64 x64) comparing _SINGLE _DOUBLE _FLOAT variables is tabulated in the screenshot. Also tabulated are elevated C floats (to 19 and 24 decimal places). For reference _INTEGER64 equivalents are included.

One intention of the survey was to exactly define what the contiguous range of integers are available for the various real variable types (i.e. to say e.g. going from    0 1 2 3 ...  ?      without missing any integers). Because of the way when having a small number of bits (32, 64, 80) the internal binary representation is governed by certain rules - simply put - when going to relatively high integer values - instead of the LSD for a contiguous series of numbers being   0   1   2   3   4   5  (LSD = Least Significant Digit) the resolution (granularity) is decreased to say  2   2   2   2   6   6  (for the LSD) for the exact same numbers originally desired.

An attempt was made to color code the LSD (least significant digits). Though not complete - think of RED digits (do not use), YELLOW (use with caution) and GREEN (probably >99.999% OK). Of course a word of caution is that when have a "string of trailing 0's or 9's - round off errors and rounding methods are to be considered.

So the output provided is not complete (and possibly some minor errors from my programming attempts exist).




 [ This attachment cannot be displayed inline in 'Print Page' view ]









Many thanks to @jack for his help in my starting to learn C (and to use C code within QB64 programs).




Edit: when have a Function of      1,000 + 1      say, it means that

c! = 1000! + 1!
c# = 1000# + 1#
c## = 1000## + 1##

etc - i.e. only consistent variable types is used (so no e.g.     c! = 1000# + 1##    )

Title: Re: v1.5 128 bit (and beyond) math *** COMPILER ERROR ***
Post by: SMcNeill on October 04, 2021, 09:58:56 am
I think you have a few typos in there Richard...  Or else math is broken bad.

9,999,969 + 1 = 9,999,997.....

Is that just a typo in the 9,999,996, or what’s going on there?  I can't tell from the screenshot alone.
Title: Re: v1.5 128 bit (and beyond) math QB64 Number Space (_DOUBLE)
Post by: Richard on October 28, 2021, 03:19:48 am
@SMcNeill

Thanks for pointing out the typo's.

Attached is the preliminary work in trying to establish the first transition point in going from Number Space Ordinary (NSO) where all positive integers are representable in _DOUBLE     TO      where the granularity is larger than 1 (i.e. resulting in "skipped" integers).   

 



  [ This attachment cannot be displayed inline in 'Print Page' view ]  
Title: Re: v1.5 128 bit (and beyond) math *** COMPILER ERROR ***
Post by: Richard on November 27, 2021, 07:36:13 am

(INC by bit enumeration)    versus    (&h...~&& + 1~&&)


 
Previously compared timings of various modules (differing essentially by variable_type/memory_allocation) by looping of same (about 100x) to obtain better timing results for comparison purposes (to establish which modules resulted in significant timing/resource gains). This effectively was a comparison of

(INC by bit enumeration) versus (FOR temp = 1 to #loops:...(no code here)...:NEXT)

This approach (i.e. having say 100x loops) was not technically correct approach as hardware caching would bias results towards measurements of loop times for code that eventually was stored in cache (in particular level 1 cache).

Current timings below are for once performed INC and measuring with 100 nano second resolution timer. Because QB64 code (&h...~&& + 1~&&) is very fast in comparison to highly scalable (i.e. many more) bit coding - resulting in the QB64 code not being measurable - 100 replications of (&hFFFFFFFFFFFFFF00~&& + 1~&&) were hard-coded (i.e. not in a FOR-NEXT LOOP). The result of this is the last module on the graph below had an apparent measurable result (all the other modules were in the sense only 1 replication and were somewhat measurable with 100 nano-second timer).

At this stage, without proper analysis etc, very roughly (&hFFFFFFFFFFFFFF00~&& + 1~&&) is about 100x FASTER than any (INC by bit enumeration) as used here. The requirement was set that all (INC by bit enumeration) methods were practically identical - i.e. the "heart" of each iteration was 3 lines of BASIC code and essentially the only difference between the various modules was the choice of variable_types/memory_used.


Regarding Cache memory.


My computer (roughly 8 years old) has the following Cache sizes:-
 
L1 cache size 32K  byte
L2 cache size 256  Kbyte
L3 cache size 6144 Kbyte

L1 is actually on the same silicon die as the processor itself and is the fastest of the three (it runs at the same speed as the microprocessor).

Though not specified, typically L2 cache runs at half the speed as L1 and typically is NOT located on the same die, but rather located on a separated die which may be INSIDE the CPU module or in another module (possibly "double-decking" the CPU Integrated circuit module i.e. in parallel and physically located underneath the main CPU chip - so no additional PCB space is being used). Apparently to manufacture L1 cache is very expensive, so the L2 running at half-speed (of L1) is an economic advantage.

L3 is located somewhat away from the CPU but closer than the standard RAM memory - it would run faster to some extent when comparing to accessing from RAM.


L4 might either be the RAM memory if PCIe hard drive M.2 is NOT present, or SATA SSD, or SATA HDD and may classified based on whether the performed .exe (and similarly .dll etc) are actually loaded entirely into memory (not all .exe's are fully loaded into memory when running). In either case L4 is slower than L3.


There is hardware and timing overheads to load up the cache - apparently to load up L1 cache seems to be about 5 clock cycles to pre-load cache with 16 bytes - and obviously only relatively small code blocks (<32 Kbytes) would ever, and after significant time delay, be pre-loaded into L1 cache. On the other hand, the much larger L3 cache may be constantly mirrored with all the program code (up to 6 Mbytes)  but at significant speed performance losses.

It is hard enough to model/understand how program execution speed increases as the various levels of cache are utilized - things become much more complicated when Windows takes priority over your desired running program .exe, resulting in cache (all levels) resources being spread over more than one application (i.e. your .exe and various Windows background processes).

On my computer (which has 4 physical processors i.e. 8 logical processors) even when overall system CPU useage is say 30% - ALL CPUs are simultaneously doing Windows background processes. There never seems to be any time when a CPU is "dedicated" to my program .exe.  @Pete sums it up as Window Priority.





The Graph below


In preparation for my QB64 coding for 128+bit math - I have run a number of modules, each being on purpose similar in coding style (essential difference between modules is the variable elements used and the memory allocated for same).

The objective was to simulate INC (increment, +1) but with the eventual aim of scalability (i.e. to go beyond 128 bits). The modules all were scaled down to 64 bits only (to allow in the near future easy cross-checking with INTEGER64 standard code) and as tested were not used for anything useful i.e. (INC by bit enumeration) versus (&h...~&& + 1~&&)(QB64 code equivalent). The test results (shown below) were for single iterations (i.e. a total of one replication) and the "trial" was repeated 128 times.

The methodology used was purely bit-wise (i.e. base 2) - and consequently one bit only at a time was stored in the respective variable elements, for instance an INTEGER64 array stored only one bit value per array element (~2% memory efficient), similarly using FLOAT (0.5% memory efficient).

The overall aim was to determine which element variable and memory allocation combination would produce distinctive calculation time gains.




Notes

Fundamental time unit = micro-seconds (resolution 100 nanoseconds, uncalibrated)
The horizontal axis is a linear time scale (0 to 64 micro-seconds),(i.e. in the zone immediately left of any printed text)
The vertical axis is a linear count (one count per pixel) for the respective modules.

() designates QB64 arrays being used - one element per bit
memory and screen are the memory allocations as per using MEM coding
screen_0 and screen_2 are the old DOS memory allocations (&HB800 and &HA000 addresses) and NOT being used by MEM
UDT as per user defined type
direct means that allocation unit is "hard-coded" (i.e. a03% variable used instead of a%(03) array element)
TIMER_empty_loops is actually a module without any code in the iteration (i.e. replication) - to estimate overhead in timing of modules
TIMER_null is two time calls difference (i.e. the resolution of the timing process for two successive enquiries)
The tabulated values represent minimum, average, maximum timings for the collection of 128 trials per module
The 1st, 2nd, 3rd, 4th, and 5th timing values are listed in the text on the RHS (right hand side).

The plotted 1st point is indicated with a  "+" (8-pixel branch length)
The plotted 2nd point is indicated with a  "+" (4-pixel branch length)
The plotted 3rd point is indicated with a  "+" (2-pixel branch length)
The plotted 4th point is indicated with a  "+" (1-pixel branch length)

The associated Histogram shows all data points above a line of half-intensity (line = span minimum to maximum)  - no data point is repeated on the exact same pixel (and always above the line).
The program was run without computer connection to internet, devices etc or essentially any other software running.
All modules are essentially the same coding style, only the variable elements used differ - the "heart" of each module - INC - was only 3 lines of functional QB64 code equivalent per iteration.

The timings (unit = micro-second) do not include any setup overheads (zeroing etc) - and assumed the initial value (for the INC) was preloaded and valid.

Since only 64 micro-seconds is spanning the un-texted portion of the display and since a timing resolution of 100 nanoseconds (uncalibrated) is in effect - the resulting "histogram" is distinctly "heavily quantized" (i.e. "gaps" = resolution steps in timings appear).


Cache memory effects

If Windows was not present then quite simply would expect:-

1st timing to be longest - MyProgram.exe running via L4 cache (in my case NVME PCIe M.2 SSD)
2nd timing to be shorter (and to the left) - MyProgram.exe running via L3 cache
3rd timing may be shorter still - MyProgram.exe POSSIBLY running via L2 cache
unknown - MyProgram.exe running via L1 cache


BUT Windows background processes (Window Priority) are continuously running over ALL CPU's simultaneously. Timing alterations are unpredictable (and would appear to be resulting in RANDOM timing elongations).

This is illustrated by the horizontal line (base line for histograms for each module of code) extending to the right of the 1st timing point and further illustrated by any change in Right-Left ordering of 1st, 2nd, 3rd, 4th and 5th points i.e. Windows "adds" to the timings. It is further illustrated by the lack of "bias skew" - when the L1 cache for the program code is envoked, the histogram points will disproportionally "clump" to the LHS (left-hand side) of the histogram (so NO "Bell-shaped" traditional statistical distribution curves).


Sadly, one might question (in general across all programs) whether there is any point in trying to achieve maximum speed performance increases since "Windows messes things up with timings" and is unpredictable and it seems cannot be switched off (at an individual CPU level).





  [ This attachment cannot be displayed inline in 'Print Page' view ]  
Title: Re: v1.5 128 bit (and beyond) math *** COMPILER ERROR ***
Post by: Richard on December 26, 2021, 08:34:59 am
Possible WIKI error (in Variable Type ranges) - case study unsigned integer components for

single 3.402823 e+38                     (2^128)      OK
double 1.797693134862310 e+308 (2^1024)     OK
float  1.18 e+4932                         (2^16384)   ???


The following code displays what I get when trying to access the range for FLOAT (for positive whole number component)

Code: QB64: [Select]
  1. a!=3.402823e+38 'single  
  2. print "single";a!
  3.  
  4. a# = 1.797693134862310e+308    
  5. print "double";a#
  6.  
  7. a## = 1.79769313486231580788856f308
  8. print "float ";a##
  9.  
  10. a## = 1.79769313486231580788857f308
  11. print "float ";a##
  12.  


Does anyone get a higher positive range value for FLOAT than illustrated above?






 
@SpriggsySpriggs

re your replies


Quote
« Reply #113 on: May 01, 2021, 05:17:03 am »

What is the reason for needing such a large number right now?



Quote
« Reply #115 on: May 02, 2021, 12:47:22 am »

I highly doubt we're doing that in QB64, though. It's not really being used for any serious applications. Simple graphics demos and games.



You question the reason for large numbers (128 bits) yet about 128 bits is needed to exactly represent the positive whole number component of QB64 single variables (refer table at start of this reply). SINGLE types are used commonly in programming tasks and because of limited range, QB64 has DOUBLE.

128 bit math would lessen the impact of the number space issues with the current variable types - it does not even begin to widen the range of the existing QB64 variable types.
Title: Re: v1.5 128 bit (and beyond) math *** COMPILER ERROR ***
Post by: jack on December 26, 2021, 11:54:26 am
Richard you keep forgetting that QB64's print statement converts the Float argument to double, the only thing that halfway works with Float is print using
Code: QB64: [Select]
  1. Dest Console
  2.  
  3. a## = 1.79769313486231580788857F308
  4. a## = a## * a##
  5. Print Using "##.##################^^^^"; a##
  6.  
output
Code: [Select]
% 3.231700607131100371F+616
except for the unneeded % the output is correct, if you want better output for the Float type then use the C runtime library as I have shown you in the past
Title: Re: v1.5 128 bit (and beyond) math *** COMPILER ERROR ***
Post by: jack on December 26, 2021, 12:54:57 pm
print using works ok with float that don't have a large exponent but in the following example the exponent is wrong
Code: QB64: [Select]
  1. Dest Console
  2. Option Explicit
  3.  
  4. Dim As Float i, f
  5.  
  6. f = 1##
  7. For i = 1## To 1750##
  8.     f = f * i
  9. Print Using "##.##################^^^^^"; f
  10.  
output
Code: [Select]
% 2.098318982648383492F+4969
correct value is
Code: [Select]
  2.098318982648383492F+4917
Title: Re: v1.5 128 bit (and beyond) math *** COMPILER ERROR ***
Post by: Richard on January 24, 2022, 09:59:23 am
This reply is really meant for any relatively new programmers.



QB64 comparison of output formatting



@jack earlier mentioned about how print and using formats may not give the same numerical results. To attempt to do "proper" comparisons of some of the variable types of QB64, I have now standardized on including:-

STR$()  (which is often used as in PRINT  i.e. a$=STR$(a%) gives identical output result as PRINT a%)

PRINT USING "######.######" (say) for fixed format printing

PRINT USING "##.######^^^^^" (say) for scientific notation

and Hexadecimal format.

By simultaneously displaying these four formats, it is easier to see when the various formats begin to break, in the study of the QB64 number space set.



Relatively new programmers might be tempted to "dial up maximum resolution" for the output streams (which on purpose I did below to highlight the problems associated) - however without due "care", this will typically result in numerical artifacts. Of course, it is up to the programmer/program_user/intended_program_market/standards/government_regulations (if applicable) which would be the deciding factor on how to handle this.


At present, the attachment below has not been edited for "errors" (as numerical artifacts) with say "red boxes" etc - so in the meantime consider it a QUIZ - to identify/confirm any errors (say pick one set (function) , and as far as you are comfortable to analyze - use any readily available techniques (your own QB64 program, other programming languages, calculators, wiki/google etc) to "support" your answer.

Because of obvious formatting problems - just "ignore" the last dozen or so lines in the attachment.


The attachment is a "practice run" in preparation for further QB64 number space study.








Title: Re: v1.5 128 bit (and beyond) math *** COMPILER ERROR ***
Post by: Richard on February 23, 2022, 08:56:09 am
Changed compiling options for enumeration of INC in QB64.


File -O2.png is for gcc compiler flag settings.

File Standard.png is the default QB64 compiler settings.


QB64 INC is now for only one iteration (in line with all other modules).



Title: Re: v1.5 128 bit (and beyond) math *** COMPILER ERROR ***
Post by: Richard on March 22, 2022, 11:46:31 am
             256 bit INC                      


Using techniques developed for 64 bit INC  (i.e. +1), tests performed on various variable/memory combinations for 256 bit INC.

Updated to include a large "X" to clearly show where the timings end for a particular module.

Also, on LHS, shows a linear-linear graph TIME vs TRIAL#. Because of Windows background tasks - there is a wide spread of timings per module.

Included are QB64 code results, using INTEGER64 unsigned variables, for timing comparisons.