Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - SMcNeill

Pages: 1 ... 263 264 [265]
3961
Programs / Steve's Poker Playhouse
« on: July 27, 2017, 09:45:51 am »
It's a solo game of poker.  What more could you want?

Extract, compile, run.  ;)

3962
Programs / File Listing
« on: July 27, 2017, 09:00:57 am »
Lots of folks like to ask for a way to easily grab the contents of a directory and import a list of the contents of that directory into their programs, so for them, I introduce my little File Grab Library.

Code: QB64: [Select]
  1. '$INCLUDE:'Filegrab.BI'
  2.  
  3. REDIM Results(0) AS STRING
  4. SCREEN _NEWIMAGE(1280, 720, 32)
  5.  
  6. SelectFile _CWD$, "*.*", Results()
  7. FOR i = 1 TO UBOUND(results)
  8.     PRINT Results(i)
  9.  
  10.  
  11. '$INCLUDE:'Filegrab.BM'

As you can see, usage is fairly straight forward.   
Extract to your QB64 folder. 
Include the header. 
Include the footer. 
REDIM an array to hold the results.
Call the routine with SelectFile _CWD$, "*.*", Results(),

SelectFile is the name of the routine. 
First Parameter _CWD$ can be replaced with whatever directory you want the contents of.
Second Parameter "*.*" is the filter of whatever you want for that directory.  Use "*.txt" for a listing of all text files, for example.
Third Parameter Results() is the REDIM array which you use to store the results of the file listing.

Works on Windows, Linux, and Mac.

3963
Programs / SaveImage
« on: July 27, 2017, 08:43:57 am »
Since [abandoned, outdated and now likely malicious qb64 dot net website - don’t go there] is down, and nobody knows when it might be back up, I thought I'd take time to post some useful little routines on the forums here so people can find and make use of them. 

First up is my SaveImage library.

Inside is a couple of quick demos which illustrate how to save a QB64 screen image in either BMP or PNG format, how one can easily turn a text screen into a 256 color graphic screen with one simple command, and how to compress and inflate strings or programs quickly and easily. 

Commands should be simple enough that everyone can figure them out without any real effort involved.

To Deflate/Inflate a string/file:
Code: QB64: [Select]
  1. '$include:'saveimage.bi'
  2. text$ = "Whatever the heck it is that we might want to compress, be that a long string of input, a binary file (just load the whole file into a single string and then deflate it), or whatever else is wanted)."
  3. de$ = Deflate(text$) ' <-- This is how simple it is to deflate the string
  4. t$ = Inflate(de$) '  <-- This is how simple it is to inflate that deflated string
  5. '$include:'saveimage.bm'

To turn a text screen into a graphic screen:
Code: QB64: [Select]
  1. '$include:'saveimage.bi'
  2. PRINT "Hello World.  This is a SCREEN 0 screen which I'm printing on."
  3. x = TextScreenToImage256(0) 'And a quick example of how to turn a text screen into a 256 color image screen
  4. SCREEN x 'swap screens
  5. CIRCLE (320, 240), 100, 40 'And draw a circle on it
  6. LOCATE 2,1: PRINT "And now it's been converted to a 256 color graphical screen.  See the circle on it??"
  7. '$include:'saveimage.bm'
  8.  

To save an image (from any QB64 screen mode -- even SCREEN 0 text screens work!):
Code: QB64: [Select]
  1. '$Include:'SaveImage.BI'
  2. SCREEN _NEWIMAGE(1280, 720, 32)
  3. InitialImage$ = "Volcano Logo.jpg"
  4. exportimage1$ = "testimage.png"
  5. exportimage2$ = "testimage.bmp"
  6.  
  7.  
  8. l& = _LOADIMAGE(InitialImage$)
  9. _PUTIMAGE , l& 'And this line
  10.  
  11. Result = SaveImage(exportimage1$, 0, 0, 0, _WIDTH, _HEIGHT)
  12. IF Result = 1 THEN 'file already found on drive
  13.     KILL exportimage1$ 'delete the old file
  14.     Result = SaveImage(exportimage1$, 0, 0, 0, _WIDTH, _HEIGHT) 'save the new one again
  15. PRINT Result
  16. PRINT "Our initial Image"
  17. IF Result < 0 THEN PRINT "Successful PNG export" ELSE PRINT "PNG Export failed.": ' END
  18.  
  19.  
  20.  
  21. Result = SaveImage(exportimage2$, 0, 0, 0, _WIDTH, _HEIGHT)
  22. IF Result = 1 THEN 'file already found on drive
  23.     KILL exportimage2$ 'delete the old file
  24.     Result = SaveImage(exportimage2$, 0, 0, 0, _WIDTH, _HEIGHT) 'save the new one again
  25. PRINT Result
  26. PRINT "Our initial Image"
  27. IF Result < 0 THEN PRINT "Successful BMP export" ELSE PRINT "BMP Export failed.": END
  28.  
  29.  
  30.  
  31.  
  32.  
  33. zz& = _LOADIMAGE(exportimage1$, 32) 'Even though we saved them in 256 color mode, we currently have to force load them as 32 bit images as _LOADIMAGE doesn't support 256 color pictures yet
  34. IF zz& <> -1 THEN
  35.     SCREEN zz&
  36.     PRINT "Image Handle: "; zz&, exportimage1$
  37.     PRINT "Successful Import using _LOADIMAGE"
  38.     PRINT "ERROR - Not Loading the new image with _LOADIMAGE."
  39.  
  40.  
  41.  
  42. zz& = _LOADIMAGE(exportimage1$, 32) 'Even though we saved them in 256 color mode, we currently have to force load them as 32 bit images as _LOADIMAGE doesn't support 256 color pictures yet
  43. IF zz& <> -1 THEN
  44.     SCREEN zz&
  45.     PRINT "Image Handle: "; zz&, exportimage2$
  46.     PRINT "Successful Import using _LOADIMAGE"
  47.     PRINT "ERROR - Not Loading the new image with _LOADIMAGE."
  48.  
  49.  
  50.  
  51.  
  52. '$INCLUDE:'SaveImage.BM'

3964
QB45 used CHAIN as a way to modularize programs and get around memory limits.  QB64 doesn't have those issues as it'll use several GB of memory if necessary, so nobody is doing any real work trying to implement/expand/support the command.  Unless it's completely necessary for your programs, I'd suggest not to bother using it.

3965
QB64 Discussion / Re: Is rolling your own really that important?
« on: July 25, 2017, 09:09:37 am »
E.  If it's your own work, it's easier to troubleshoot, edit, and customize.

3966
QB64 Discussion / Re: Compound assignments
« on: July 24, 2017, 04:26:00 pm »
May I ask how a change is made and who goes about doing it?

I mean we may be just wasting our time with all these opinions.

I really doubt it is a democratic process. And those who have technical knowledge of what an actual change involves certainly carry more weight with their opinions (hopefully). But then there is the Tradition thing which is all opinion and there a community may have more equal input.

All this supposes the changer listens and weighs-in all these factors.

Anyone Galleon has approved write-permission to the repo, can make changes.  AFAIK, that's basically me, Fellippe, and Luke -- unless somebody else was added which I didn't notice.

As for WHAT changes are pushed, Galleon is a very free spirited guy with the source code.  Just about anything goes, but you have to figure out how to do it yourself.  (With a few exceptions which he's ruled out for the language, such as inline streaming of other languages.)

Generally, we listen to all suggestions, and we're generally nice enough guys to say, "Let me look into that.", or, "Not me, maybe one of the others will"...  Some suggestions we can help work into the language, some we can't, but we tend to try and keep a two-way line of communication open as much as possible to not leave anyone in the dark.  ;)

Only 100% guaranteed way to get changes to the language: 
1) Get write permission to the github repo from Galleon.
2) Make the changes yourself.
3) Push those changes into the repo. 

3967
QB64 Discussion / Re: Compound assignments
« on: July 23, 2017, 05:03:22 pm »
Honestly, I think if somebody is writing such long variable names that it's a hindrance to use them in their program, then they need to rethink those names.

MyLongArseVariableType.SubType.Identifier = MyLongArseVariableType.SubType.Identifier + 1 isn't much more to type than ++MyLongArseVariableType.SubType.Identifier...

Here's how you do it:

1) Type in "MyLongArseVariableType.SubType.Identifier"
2) Hold down mouse button, highlight that name.
3) Press "Ctrl + C"
4) Type in "="
5) Press "Ctrl + V"
6) Type in " + 1"
7) Hit ENTER

If you're typing in that long name over and over, you're just working yourself to death.  An even easier trick:  Use "LAVN1" for the "Long Arse Variable Number 1" when writing your program.  Then, before publishing or sharing the code, Edit and Replace All "LAVN1" instances with the actual name, to make the source more readable for others.

X += Y is moving away from BASIC and onwards towards C.  It's not something I'd ever add into the code personally, and, like Stx, I don't think anyone else is working towards pushing those changes into the language.

3968
QB64 Discussion / Re: Proposed Enhancements To QB64
« on: July 22, 2017, 04:12:16 pm »
I have no more than 1 monitor for test for more monitors with 1 graphic card, but i thing, if is resolution 1280 x 1050 on monitor 0 and _PUTIMAGE insert image to 1300, 50 , its then displayed on second monitor at (1300 - 1280), 50. This i think only, i have it not tested. If anyone test this, i like result to know.

This depends on how you have your desktop configured.  Does it clone the screens?  (A lot of times you see this option when a laptop might be hooked up to a TV to stream a movie or such.)  Does it extend the screen?  Which monitor is marked the primary screen and which is the secondary?

QB64 will handle larger screens just like any other windows program.  It might truncate the display at the edge of the visible screen.  It might wrap it over to the next display screen.  It all depends on your OS settings and which monitor you open the program up in to begin with.

3969
QB64 Discussion / Re: CatChum for CP/M
« on: July 21, 2017, 11:08:47 am »
If you're looking to reproduce authentic style Pacman gameplay, you might want to take a look at this link: http://gameinternals.com/post/2072558330/understanding-pac-man-ghost-behavior

That does the best job of any write up which I've ever seen, explaining how the Ghost AI behaves and operates in Pacman.  It might be of some use to you.  ;)

3970
From the N54 Qbasic forum:

Quote
Don't panic!    by Galleon (no login)
The server ran out of space and I've been to busy to fix it. It will be back soon enough.
Posted on Jul 17, 2017, 12:46 AM

3971
QB64 Discussion / Re: How do you make the 64 bit Version of QB64?
« on: July 16, 2017, 06:35:44 am »
It's not too hard a process, but it does take some manual troubleshooting to get it to work -- and even then I don't guarantee that 100% of the commands will work exactly as they do in the 32-bit version.

1) First, download a fresh version of QB64.

2) Download a fresh version of mingw -- the 64-bit compiler which you want to use.  (Some of the older versions work perfectly well, but I don't know which one.  If you have time, patience, and bandwidth, you might download archived versions and find one that plugs in perfectly well and which won't need any modification.  I'd start by looking for a copy 2-3 years old, if I wanted to go that route.)

3) Go into your QB64 folder and remove the old version of the c-compiler.  Paste the new version in and extract it into that folder.  Look for the file called "INSTALL_MINGW_HERE.txt".  When you see it, you're in the proper folder.

Quote
Only Windows users need these files.

This is a copy of the "Mingw-w32 (i686) ToolChain" from "http://www.drangon.org/mingw/"

After extraction, the 7 (or so) folders should be manually placed directly into this folder named
"internal\c\c_compiler\"

If you don't have a folder called "internal\c\c_compiler\bin" after extraction you have
done something wrong. There should be about 6 other folders here too.

Due to the large size of the Windows C++ compiler it was not practical to distribute it uncompressed,
expecially under a source revision system.

4) Run the "setup_win.bat" in the main QB64 folder.  If all works well, CONGRATULATIONS!!  You now have a 64-bit version of QB64.  You downloaded an older version of mingw x64 which is error free and works as it should with QB64.  Sing a happy song, try everything out, and you shouldn't have any issues.

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

IF, however, the setup batch file fails to work properly, you'll have to look close at the error messages and go in and do some manual editing of a few lines inside the CPP files which mingw uses...

From what I remember, it's a simple patch, with only a few lines needing to be altered for variable declarations.  lotr and rotr are the two variables which aren't declared in scope, (if I remember correctly), and the setup script will point you towards the file which contains the error.   

All you need to do is go in, remark out a few lines. It has a few #ifdef blocks which sets different values for those commands, and whatever the heck they're doing, they're doing it wrong.  Inside the file, you should be able to see that alternative definition -- just remark those lines out or remove them and save that file.

Run setup.bat a second time and you should get a 64-bit version of QB64.exe this time around -- with one cavet:  I don't guarantee that every command will work as they should.  _MEM commands, in particular, seem completely screwy in the 64-bit version which needs modification...  So does a few more things, but I don't remember what they were.  99% of all commands work perfectly fine.  1% work, but work WRONG.  As long as you stay away from those particular commands (once you sort out what they are), you can write 64-bit programs in basic for windows.

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

Honestly, the BEST solution (since no one is supporting 64-bit windows versions), is to download an archived version of the x64 mingw compiler and use it.  Up until 2 or 3 years ago, all you had to do is plug it in, rebuild QB64, and things worked just fine.   Then mingw did several updates and it no longer worked as advertised for QB64...

The 32-bit compiler that comes packaged with QB64 is the same one that's been with it for years.  I don't even know if someone could just swap in the newest version of the 32-bit mingw and have it work, without needing to modify and tweak things first.  Who knows which commands were obsoleted, altered, removed, or replaced with newer functions??

Find the older version of the 64-bit compiler and you're golden.  Get a newer version and you'll have to manually troubleshoot things yourself to make certain they all work properly.

I'm sorry I don't remember what the last plug-in-and-go version was, which worked without needing any alterations.  If anyone takes time to test them out and finds out for us, let us know.  Maybe somebody here will host the proper version and then there'll never be any issues for anybody who wants a 64-bit version from now on.

Pages: 1 ... 263 264 [265]