Welcome, Guest |
You have to register before you can post on our site.
|
|
|
question or suggestion - save drafts? |
Posted by: madscijr - 10-23-2024, 04:30 PM - Forum: Site Suggestions
- Replies (9)
|
|
First, I was editing a rather long post, and then something happened and everything reset to the blank editor - I don't know what I did, hit the wrong key on the keyboard or clicked the wrong thing on the browser. Anyway, everything I typed was gone - POOF!
So my question is, is my draft saved somewhere, and if so, how do I get it back to continue editing?
And if not, my suggestion is, can we configure the site to auto-save drafts, and if a user exits without posting it, they can go to some page that lists their unfinished posts, where they can continue editing or delete them?
I have seen that kind of feature on other Web sites so I know it can be done, not sure if it can be done here, but I figure it's worth asking, after losing all that content!
|
|
|
Pete's Dumb Idea of the Day! |
Posted by: Pete - 10-21-2024, 07:53 PM - Forum: General Discussion
- Replies (18)
|
|
Wouldn't it be nice to have this feature for Data Restore?
On x Restore data1, data2, data3
instead of needing to code...
Select Case x
Case 1: Restore data1
Case 2: Restore data2
Case 3: Restore data3
End Select
data1:
data eof
data2:
data eof
data3:
data eof
Be sure to post your hate comments in a respectful, non-micro-aggressive and culturally appropriate manner. Oh who am I kidding? Comment however the hell you want!
Pete
|
|
|
Making files more portable |
Posted by: JRace - 10-21-2024, 12:40 AM - Forum: Programs
- Replies (9)
|
|
Steve's $Embed thread (https://qb64phoenix.com/forum/showthread.php?tid=3142) got my curiosity going.
But first, an FYI:
For several years now I've been using the 7Zip self-extractor to compress software packages, such as editors or compiler suites, into single-file EXEs for easy transport on a thumbdrive.
7Zip's cleverly designed self-extractor stub (which I will call the .SFX) can extract these files into a temporary folder, and then execute a file of my choice. Normally the executed file would be a script to copy files into a more permanent installation folder, but I instead run that now unpacked editor or a batch file to perform compilation steps. The .SFX waits patiently and when all programs in the temp folder have ended, the .SFX conscientiously deletes that temp folder. No muss, no fuss.
This saves a lot of space on a thumbdrive, compressing a 512 megabyte (after the deletion of some non-essential MinGW files) QB64PE suite down to just 53.48 megs.
It also saves a LOT! of time. I don't know how long it would take to copy all 6350 (again, fat-trimmed) files of QB64PE to a thumbdrive, but copying MinGW alone can take several HOURS. (At least, it took that long on the thumbdrives I was using. I will never buy another SanDisk flash drive. I own several and those turkeys are all SLOW.)
(If anyone is thinking of trying the .SFX stunt described above I have to warn you that it's not for the faint-of-heart. It's a manual process that cannot be done from the 7Zip GUI. It took much time, trial, and error to get it all working the way I envisioned.)
Anyway, I created a small executable ("Hello, World", written in C) and embedded it into a QB64PE test program which would extract HELLO.EXE to disk and run it. The tester compiled and ran as it should.
Ohhhkay, now a slightly bigger test. For this one I chose CharlieJV's Basic Anywhere Machine and modded the test program to fit:
Code: (Select All) _Title "ExtractRun"
$Embed:'./BAM.html','embhandle'
o$ = _Embedded$("embhandle")
_WriteFile "./BAM_extracted.html", o$
If _FileExists("./BAM_extracted.html") Then Shell "start BAM_extracted.html"
End
(the filenames in ExtractRun can be changed as needed)
The compiled ExtractRun with a small executable is 1.95 megs. Let's consider that the baseline, minimal ExtractRun size.
Uncompressed Basic Anywhere Machine weighs in at 4.54 megabytes.
The compiled ExtractRun with BAM is 2.81 megs (UPX can compress that down to about 1.5 megs.)
That means PE's $EMBED squeezes BAM down to just 0.86 megs.
Just posting this in case anyone wants to tinker or build with it.
|
|
|
Expanding SELECT CASE |
Posted by: NakedApe - 10-20-2024, 06:08 PM - Forum: GitHub Discussion
- Replies (5)
|
|
I've been trying to clean up IF statements in the game I'm working on. Would it be hard to have SELECT CASE work not just with variables but also with arrays and UDTs?
Imagine:
SELECT CASE flag ' (booleans)
CASE .drawShip: .........
CASE .explode: .........
CASE .endRound: .........
END SELECT
Or:
SELECT CASE fatArray()
CASE 0 TO 50: ..............
CASE 51 TO UBOUND(fatArray): ..........
END SELECT
Would this be cool / useful?
|
|
|
Problem with _Resize |
Posted by: dano - 10-20-2024, 01:15 PM - Forum: General Discussion
- Replies (7)
|
|
Code: (Select All)
$Resize:On
'_Resize Off
MenuScreen& = _NewImage(1000, 500, 32)
MainScreen& = _NewImage(1400, 965, 32)
start:
Screen MenuScreen&
_ScreenMove 200, 50
_ScreenMove 175, 10
Cls
Print "smaller screen"
wfk
'_Resize On , _Stretch ' causes screen to be shrunken down in size
'_Resize On , _Smooth ' causes screen to be shrunken down in size
'_Resize On ' works correctly
Screen MainScreen&
w# = _Width
h# = _Height
Cls
Print "larger screen as "; w#; " x "; h#
wfk
GoTo start
Sub wfk ' wfk=wait for key
i$ = ""
While i$ = ""
i$ = InKey$
Wend
If i$ = Chr$(27) Then System
End Sub
When you run this program as is, everything works fine. The screen sizes are correct and they go back and forth as expected.
BUT...
un-REM '_Resize On
>everything still works correctly.
un-REM '_Resize On , _Stretch -or- '_Resize On , _Smooth
>the second screen size has shrunk - the resolution is still correct, just the default size has been shrunk down. Why? How can I avoid this?
It does not matter if the $Resize is On or Smooth or Stretch, you get the same behavior.
>>>>> ALSO <<<<<
In this program if you try to Ctrl-Break to break out of this program (in the wfk Sub), it seems to lock up and you can never exit and you have to kill it with Task Manager. BUT if you take the wfk subroutine and use it with a program that does not do anything with the screens (basically only printing...try it!), it will exit with Ctrl-Break every time. Why? Is this a bug?
|
|
|
Embed Source Code in EXE |
Posted by: SMcNeill - 10-20-2024, 09:58 AM - Forum: Learning Resources and Archives
- Replies (7)
|
|
On Discord, we were talking about various things (as usual -- all you guys are invited to join us there!), and the topic came up about how to retrieve the source code from the EXE. With the new embedding commands, it's simple as heck to embed the BAS source into your program and then retrieve it and restore it later.
For example, something as simple as this works for us:
Code: (Select All)
'Step One: Embed the source code into your EXE
$Embed:'MyProgramName.Bas','sourcehandle'
'Step Two: Assign a variable to represent the source code
source_code$ = _Embedded$("sourcehandle")
'Step Three: Write a simple routine to retrieve the source
c$ = UCase$(Command$)
If c$ = "-SOURCE" Then
Open "MyProgramName.tmp" For Output As #1 'so you don't overwrite the original source while testing
Print #1, source_code$
Close #1
System
End If
We have now added a command line paramater to the EXE which is trigged by "-SOURCE", and which dumps the source file to the drive for us.
It doesn't get much simpler than this.
Feel free to make use of this style code for any/all of your own progams where you might want to store the source with the EXE for future reference/retrieval.
|
|
|
LOG helps find a power |
Posted by: bplus - 10-19-2024, 03:30 PM - Forum: Keyword of the Day!
- Replies (2)
|
|
LOG came in handy for me recently when I was reducing LOC (Lines Of Code) for Classic 2048 Game from Dav's version.
He had all these lines to create a shaded Backcolor for a tile, to get darker as value gets higher:
Code: (Select All) Select Case board(x, y)
Case 2: bg& = _RGB(239, 229, 218)
Case 4: bg& = _RGB(236, 224, 198)
Case 8: bg& = _RGB(241, 177, 121)
Case 16: bg& = _RGB(236, 141, 84)
Case 32: bg& = _RGB(247, 124, 95)
Case 64: bg& = _RGB(233, 89, 55)
Case 128: bg& = _RGB(242, 217, 107)
Case 256: bg& = _RGB(238, 205, 96)
Case 512: bg& = _RGB(238, 205, 96)
Case 1024: bg& = _RGB(238, 205, 96)
Case 2048: bg& = _RGB(238, 205, 96)
Case 4096: bg& = _RGB(121, 184, 226)
Case 8192: bg& = _RGB(121, 184, 226)
Case 16384: bg& = _RGB(121, 184, 226)
Case 32768: bg& = _RGB(60, 64, 64)
Case Else: bg& = _RGB(204, 192, 180)
End Select
I said to myself if I didn't mind going color blind a bit, I could shade tiles darker by finding the power of 2 that the Board(x, y) value and do bg& in shades of grey: _RGB32(OneValue0to255) = shade of grey
Code: (Select All) If Board(x, y) Then power = Log(Board(x, y)) / Log(2) Else power = 0
bg& = _RGB32(255 - 17 * power) ' =set to shade of grey, the higher the value the darker
Mission accomplished!
Here is a little formula for getting Power in X of Y. In example above, what power of 2 is Board(x, y) value?
PowerX = Log(Y)/Log(X)
Check if Y is 0 first though to avoid error.
|
|
|
PictureButton Rollover effect |
Posted by: TempodiBasic - 10-19-2024, 12:00 AM - Forum: Programs
- Replies (4)
|
|
Hi friends
here a simple demo to get a picturebutton with rollover effect
Code: (Select All)
Rem demo of a pictureButton with rollover effect
Rem here we use one image to load and we create the rollover image on fly
DefLng L
Lscreen = _NewImage(800, 600, 32)
Screen Lscreen
_Title "Rollover PictureButton example"
Cls , _RGBA(127, 28, 211, 255)
If _FileExists("QB64bee.jpeg") Then LBee1 = _LoadImage("QB64bee.jpeg") Else _PrintString (10, 200), "Not found QB64bee"
' here we create the second image used for rollover effect
Lbee2 = _NewImage(50, 50, 32)
_Dest Lbee2
Line (0, 0)-(50, 50), _RGBA(227, 72, 17, 255), BF
_PutImage (3, 3)-(45, 45), LBee1, Lbee2
_Dest 0
_PrintString (10, 140), " move mouse over and out of button, press leftclick on the button, press rightclick to quit"
_PutImage (30, 50)-(80, 100), LBee1, Lscreen ' show picturebutton
Do
If _MouseInput Then
If InTheMiddle(30, 80, _MouseX) Then
If InTheMiddle(50, 100, _MouseY) Then
lbee = Lbee2
Else
lbee = LBee1
End If
Else
lbee = LBee1
End If
_PutImage (30, 50)-(80, 100), lbee, Lscreen
End If
If _MouseButton(1) And lbee = Lbee2 Then Msg$ = " You have clicked on the button" Else Msg$ = Space$(40)
_PrintString (10, 200), Msg$
Loop Until _MouseButton(2) = -1
End
Function InTheMiddle (min As Integer, max As Integer, value As Integer)
If min > max Then Swap min, max
If min < value And value < max Then
InTheMiddle = -1
Else
InTheMiddle = 0
End If
End Function
please download the attached image or use another of your choice. In this second case, please change the name and path of the image to load with _LOADIMAGE.
then
copy and paste this code into QB64IDE and save it in the same folder of the image downloaded or choosen by you.
At the end press F5 and see the result.
|
|
|
Compile error when .bas name is same as a directory (linux) |
Posted by: Dav - 10-18-2024, 11:44 AM - Forum: General Discussion
- Replies (3)
|
|
Can't recall if this is a known thing, but I came across this today trying to compile my 2048.bas game in the qb64pe directory. I had previously made a /2048 directory in that same place of Fellippe's game version. With the 2048 folder there, my original 2048.bas wouldn't compile anymore. I renamed Fell's folder to 2048fell and then my 2048.bas would compile. So to prove it was a name conflict issue, I made a folder named /compile, and tried to compile a file named compile.bas, and it would not compile either until I removed the directory. So, looks like a filename can't be the same as a directory name (Using Linux here).
I did the same test using the Windows QB64-PE version (under wine in Linux) and it would compile. So maybe this is just a Linux issue?
- Dav
|
|
|
|