Find attached the file FormatX5.zip which contains FormatX.bas and is a library of format functions.
They are not a Print Using replicants but contain certain FormatX$ functions similar to the ones in QB 7.1
The functions allow for parsing formatted strings and unique to QB64 which has no Format$ functions.
Year between 1753 and 2078 increased to 0001 and 9999.
NOT backwards compatible with QB 4.5 because format date/time is stored in float Now## precision.
Read on! ejo
Code: (Select All)
Format library v5.0a in BASIC for QB64 similar to BC7/VBDOS1 is PD 2024.
Version v1.0a:
Initial creation 09/30/2024.
Version v2.0a:
Adds StoreColor for Colorf function.
Adds KeyBoardLine$ function.
Adds Debug to StatusLine.
Adds some constants.
Version v3.0a:
Adds Control-Break trapping.
Adds statusline format strinng.
Adds titlebar timer trap.
Version v4.0a:
Adds extended LineInput$ function.
Version v5.0a:
Fixes date/time display in:
DateTimeClock$ and DateTimeClockSerial$ (serial##)
When using the Shell command I can redirect STDOUT with the standard command line syntax. I have used the technique to use write files then open them in my code.
However Is there a way to have the program output to a pipe and have my program read from the pipe without using an intermediate file ?
okay so i been experimenting with 8088 machine via PCem, i used the hercules video card with amber color, i love it
so i'll make a text adventure game but for the 80s era baby like dont you love opening your pc just to play a text adventure game
for grammar i use chatgpt cause robots has good grammar i dont DD
I was thinking of making an rpg similiar to Elder Scrolls daggerfall but scratch that i'll make my own rpg
with
stats
equipments
spells
golds
love (lust is okay too LOL)
a mid size world wish me luck guys wohoooo
I got this from Steve at old forum and tested it today on problem encountered by Cortez at another forum.
It does not work:
Code: (Select All)
' !!!! 2024-09-27 this does not work
' test
Print N2S$("1E6")
Print N2S$("10E6")
Print N2S$("100E6")
Print N2S$("1E-6")
Print N2S$("10E-6")
Print N2S$("100E-6")
Function N2S$ (EXP$) 'remove scientific Notation to String (~40 LOC)
'SMcNeill Jan 7, 2020 ref: https://www.qb64.org/forum/index.php?topic=1555.msg112989#msg112989
'Last Function in code marked Best Answer (removed debug comments and blank lines added these 2 lines.)
ReDim t$, sign$, l$, r$, r&&
ReDim dp As Long, dm As Long, ep As Long, em As Long, check1 As Long, l As Long, i As Long
t$ = LTrim$(RTrim$(EXP$))
If Left$(t$, 1) = "-" Or Left$(t$, 1) = "N" Then sign$ = "-": t$ = Mid$(t$, 2)
dp = InStr(t$, "D+"): dm = InStr(t$, "D-")
ep = InStr(t$, "E+"): em = InStr(t$, "E-")
check1 = Sgn(dp) + Sgn(dm) + Sgn(ep) + Sgn(em)
If check1 < 1 Or check1 > 1 Then N2S = _Trim$(EXP$): Exit Function 'If no scientic notation is found, or if we find more than 1 type, it's not SN!
Select Case l 'l now tells us where the SN starts at.
Case Is < dp: l = dp
Case Is < dm: l = dm
Case Is < ep: l = ep
Case Is < em: l = em
End Select
l$ = Left$(t$, l - 1) 'The left of the SN
r$ = Mid$(t$, l + 1): r&& = Val(r$) 'The right of the SN, turned into a workable long
If InStr(l$, ".") Then 'Location of the decimal, if any
If r&& > 0 Then
r&& = r&& - Len(l$) + 2
Else
r&& = r&& + 1
End If
l$ = Left$(l$, 1) + Mid$(l$, 3)
End If
Select Case r&&
Case 0 'what the heck? We solved it already?
'l$ = l$
Case Is < 0
For i = 1 To -r&&
l$ = "0" + l$
Next
l$ = "." + l$
Case Else
For i = 1 To r&&
l$ = l$ + "0"
Next
l$ = l$
End Select
N2S$ = sign$ + l$
End Function
Anyone have a better way of doing this?
Cortez was testing Val() instead of N2S$() which didn't work either. Val has a bug also.
Something kind of silly but was fun to make. I started playing with some plasma code and it morphed into a lava lamp somehow. Never had one in real life.
This runs slow on my older laptop - commenting out the _LIMIT 30 didn't speed it up at all for me. So if the blobs and plasma go too fast for you on your modern PC, play with the t = TIMER * .7 line to adjust speed.
- Dav
Code: (Select All)
'============
'LAVALAMP.BAS
'============
'By Dav, SEP/2024 for QB64PE
Screen _NewImage(1000, 700, 32)
Do
Cls
t = Timer * .7 'control speed here
'plasma background
For y = 0 To _Height Step 2
For x = 0 To _Width Step 2
r = Int(128 + 127 * Sin((x * .01) + t))
g = Int(128 + 127 * Sin((y * .01) + t * 1.2))
b = Int(128 + 127 * Sin((x * .01) + (y * 0.01) + t * .8))
Line (x, y)-Step(1, 1), _RGBA(r, g, b, 50), BF
Next
Next
'oily plasma blobs
For y = 50 To _Height - 51
For x = 325 To 675
disx = x - _Width \ 2
dixy = y - _Height \ 2
wav = Sin(t + dixy * .05 + disx * .05) * 35
rad = 150 + 50 * Sin(t * 1.5 + dixy * .1) + wav
pulse = 1 + .5 * Sin(t + dixy * .1)
If Sqr(disx ^ 2 / (85 * pulse) ^ 2 + dixy ^ 2 / (rad * pulse) ^ 2) < 1 Then
clr = Int(255 - Sqr(disx ^ 2 + dixy ^ 2) / 2)
Line (x, y)-Step(1, 1), _RGBA(255, clr, clr / 3, 150), BF
End If
Next
Next
'draw top half of lamp
For y = 50 To 350
wfix = (350 - y) / 3
Line (325 + wfix, y)-(675 - wfix, y), _RGBA(255, 255, 100, 50), BF
Next
'draw bottom half of lamp
For y = 351 To 650
wfix = (y - 351) / 3
Line (325 + wfix, y)-(675 - wfix, y), _RGBA(255, 255, 100, 50), BF
Next
'lamp top
Line (425, 20)-(575, 50), _RGB(150, 100, 0), BF
Line (425, 20)-(575, 50), _RGBA(255, 255, 100, 75), B
'lamp base
Line (375, 650)-(625, 700), _RGB(150, 100, 0), BF
Line (375, 650)-(625, 700), _RGBA(255, 255, 100, 75), B
Posted by: Petr - 09-25-2024, 07:10 PM - Forum: Petr
- Replies (2)
Small utility for calculating points in line.
Code: (Select All)
Type LinePoints
X As Integer
Y As Integer
End Type
ReDim Shared LP(0) As LinePoints
Screen _NewImage(800, 600, 32)
Line (40, 399)-(100, 199)
GETPOINTS 40, 399, 100, 199, LP()
Sleep
'if all points in array are calctulated correctly, all points in LINE are draw yellow
For D = 0 To UBound(LP)
PSet (LP(D).X, LP(D).Y), &HFFFFFF00
Next D
Sub GETPOINTS (x1, y1, x2, y2, A() As LinePoints)
Dim lenght As Integer
lenght = _Hypot(x1 - x2, y1 - y2) 'Fellippe Heitor show me using this great function.
ReDim A(lenght) As LinePoints
For fill = 0 To lenght
If x1 > x2 Then A(fill).X = x1 - fill * ((x1 - x2) / lenght)
If x1 < x2 Then A(fill).X = x1 + fill * ((x2 - x1) / lenght)
If x1 = x2 Then A(fill).X = x1
If y1 > y2 Then A(fill).Y = y1 - fill * ((y1 - y2) / lenght)
If y1 < y2 Then A(fill).Y = y1 + fill * ((y2 - y1) / lenght)
If y1 = y2 Then A(fill).Y = y1
Next
End Sub
Dim As Integer ER, EL
Error1:
ER = Err: EL = _ErrorLine
Resume Quit
Quit:
Print "?Error"; ER; " on line"; EL; "described as "
Print _ErrorMessage$(ER)
End
Data 6
Data 7 ' the number
It will trap with an error 2 on line 5. I discovered something today:
You can't put a comment on a data statement.
Without the comment it works just fine.
Has anyone made a routine to copy a paste a non-rectangular area of the screen? Or does QB64PE have a built-in way? I'm working on a new drawing program and trying to add a feature where you can draw an enclosed area with the mouse, copy it, and paste it. Making a circle area routine was easy, but having some difficulty with the any shape one. I'm doing a polygon approach for the any shaped one, capture all the pixels inside the drawn polygon. Wondered if someone here has already made such a routine that is working.
Here's the circle copy/paste that is working ok.
- Dav
Code: (Select All)
Screen _NewImage(1000, 700, 32)
For t = 1 To 7000
Color _RGB(Rnd * 255, Rnd * 255, Rnd * 255)
Print _Trim$(Str$(Int(Rnd * 10)));
Next
Locate 2, 24:: Color _RGB(255, 255, 255)
Print " Copied this area of the screen "
_Delay 2
Cls
Do
PutCircle Rnd * _Width, Rnd * _Height, x&, Rnd * 255
_Limit 30
Loop Until InKey$ <> ""
Function GetCircle& (cx, cy, radius)
If circleimg& <> 0 Then _FreeImage circleimg&
circleimg& = _NewImage(radius * 2, radius * 2) '
_Dest circleimg&
For x = 0 To radius * 2
For y = 0 To radius * 2
If Sqr((x - radius) ^ 2 + (y - radius) ^ 2) <= radius Then
clr& = Point(cx - radius + x, cy - radius + y)
PSet (x, y), clr&
End If
Next
Next
For x = 0 To radius * 2
For y = 0 To radius * 2
If Sqr((x - radius) ^ 2 + (y - radius) ^ 2) <= radius Then
clr~& = Point(x, y)
r = _Red32(clr~&)
g = _Green32(clr~&)
b = _Blue32(clr~&)
PSet (cx + x, cy + y), _RGBA(r, g, b, alpha)
End If
Next
Next