Welcome, Guest |
You have to register before you can post on our site.
|
Latest Threads |
The Crucial Role of Getti...
Forum: Utilities
Last Post: Martinstobe
Yesterday, 04:41 PM
» Replies: 0
» Views: 15
|
The Essential Role of See...
Forum: Utilities
Last Post: Martinstobe
Yesterday, 12:32 PM
» Replies: 0
» Views: 14
|
astuce pour survivre fina...
Forum: Utilities
Last Post: coletteleger
05-14-2025, 04:47 AM
» Replies: 0
» Views: 54
|
trouver permis de conduir...
Forum: Utilities
Last Post: nicolasrene
05-05-2025, 05:24 AM
» Replies: 0
» Views: 57
|
LIGHTBAR Menu
Forum: Programs
Last Post: nicolasrene
05-05-2025, 05:08 AM
» Replies: 15
» Views: 1,070
|
Learning Pallet Rack Safe...
Forum: Utilities
Last Post: Sandrapew
04-03-2025, 09:36 AM
» Replies: 0
» Views: 62
|
Choosing New Versus or Pr...
Forum: Utilities
Last Post: Sandrapew
03-18-2025, 01:11 AM
» Replies: 0
» Views: 64
|
The QB64 IDE shell
Forum: Utilities
Last Post: JasonPag
09-16-2024, 05:37 PM
» Replies: 9
» Views: 1,160
|
Importance regarding Ches...
Forum: Utilities
Last Post: JasonPag
09-01-2024, 06:34 PM
» Replies: 0
» Views: 91
|
Chess and Analysis and En...
Forum: Utilities
Last Post: JasonPag
08-28-2024, 02:37 PM
» Replies: 0
» Views: 94
|
|
|
C file functions in QB64 ??? |
Posted by: Jack - 04-26-2023, 11:00 AM - Forum: Help Me!
- Replies (11)
|
 |
I wonder if it's possible to get the C file functions working in QB64, specifically fopen, fprintf and fclose
I tried the following but it won't compile
Code: (Select All) Type iobuf
ptr As _Offset 'zstring ptr
cnt As Long
bas As _Offset 'zstring ptr
flag As Long
file As Long
charbuf As Long
bufsiz As Long
tmpfname As _Offset 'zstring ptr
End Type
Declare Library
Function fopen%& (file_name As String, mode As String)
Function fclose& (file_ptr As _Offset)
Function fprintf& (file_ptr As _Offset, frmt As String, st As String)
End Declare
Dim As _Offset fp
Dim As String fln, md, frmt, text
Dim As Long status
fln = "fopen-test.txt" + Chr$(0)
md = "w" + Chr$(0)
frmt = "%s\n" + Chr$(0)
text = "hello world" + Chr$(0)
fp = fopen(fln, md)
status = fprintf(fp, frmt, text)
Print "status = fprintf(fp, frmt, text) = "; status
status = fclose(fp)
the compiler log follows
Quote:internal\c\c_compiler\bin\c++.exe -O2 -w -std=gnu++11 -DGLEW_STATIC -DFREEGLUT_STATIC -Iinternal\c\libqb/include -Iinternal\c/parts/core/src/ -Iinternal\c/parts/core/glew/include/ -DDEPENDENCY_NO_SOCKETS -DDEPENDENCY_NO_PRINTER -DDEPENDENCY_NO_ICON -DDEPENDENCY_NO_SCREENIMAGE internal\c/qbx.cpp -c -o internal\c/qbx.o
In file included from internal\c/qbx.cpp:2333:
internal\c/../temp/main.txt: In function 'void QBMAIN(void*)':
internal\c/../temp/main.txt:29:35: error: cannot convert 'intptr_t*' {aka 'long long int*'} to 'FILE*' {aka '_iobuf*'}
29 | *__LONG_STATUS=( int32 )fprintf(__OFFSET_FP,(char*)(__STRING_FRMT)->chr,(char*)(__STRING_TEXT)->chr);
| ^~~~~~~~~~~
| |
| intptr_t* {aka long long int*}
In file included from internal\c\libqb/include/audio.h:21,
from internal\c/qbx.cpp:1:
D:/QB64pe-3.6.0+/internal/c/c_compiler/x86_64-w64-mingw32/include/stdio.h:357:20: note: initializing argument 1 of 'int fprintf(FILE*, const char*, ...)'
357 | int fprintf (FILE *__stream, const char *__format, ...)
| ~~~~~~^~~~~~~~
internal\c/../temp/main.txt:48:34: error: cannot convert 'intptr_t*' {aka 'long long int*'} to 'FILE*' {aka '_iobuf*'}
48 | *__LONG_STATUS=( int32 )fclose(__OFFSET_FP);
| ^~~~~~~~~~~
| |
| intptr_t* {aka long long int*}
D:/QB64pe-3.6.0+/internal/c/c_compiler/x86_64-w64-mingw32/include/stdio.h:615:28: note: initializing argument 1 of 'int fclose(FILE*)'
615 | int __cdecl fclose(FILE *_File);
| ~~~~~~^~~~~
mingw32-make: *** [Makefile:410: internal\c/qbx.o] Error 1
I know that QB64 has file functions but I have a reason to want the C file functions
<edit>
fopen works, it's the other two functions that fail
|
|
|
Can't start QB64PE 3.6.0 more than once. |
Posted by: Fifi - 04-25-2023, 11:50 PM - Forum: General Discussion
- Replies (4)
|
 |
Hello all,
Sorry but I've been away for a while and I'm locked with an old problem with QBPE64 3.6.0 that I just installed on a baremetal Acer Notebook.
After the installation, QB64PE starts normally and I can change the size of the IDE.
However, if I quit QB64PE then restart it later, I always get the following error message box:
Internal IDE Error
(module: ide_methods, on line: 18218)
< OK>
However, I can't even click on the OK button and I've only to quit QB64PE and I can't use it anymore.
I know this is an old problem and that it was solved when removing a configuration file but I can't remember what file it is and where it's located.
TIA for your help.
Cheers
Fifi
|
|
|
big factorial |
Posted by: Jack - 04-25-2023, 01:46 AM - Forum: Programs
- Replies (2)
|
 |
just for fun
Code: (Select All) $Console:Only
_Dest _Console
Option _Explicit
Dim As Long d, i, n, dm
Dim As Double t
Const big_base = 1000000000~&&
n = 1
While n > 0
Input "n "; n
If n = 0 Then End
' calculate the number of decimal digits of the factorial using the Strling approximation
d = (.2171472409516259# + .4342944819032518 * n) * Log(n) + .3990899341790576# - .4342944819032518# * n
dm = d \ 9 'divide the number of digits by 9 to get the maximum array dimension
ReDim As _Unsigned Long fac(dm)
Dim As String s, sf
t = Timer(.0001)
fac(0) = 1 ' start with 1
For i = 2 To n
a_mul fac(), i
Next
t = Timer(.0001) - t
' convert the array to string
sf = ""
For i = 0 To dm
s = _Trim$(Str$(fac(i)))
If Len(s) < 9 Then
s = String$(9 - Len(s), "0") + s
End If
sf = s + sf
Next
'strip leading 0's
While Left$(sf, 1) = "0"
sf = Mid$(sf, 2)
Wend
Print sf
Print "elapsed time "; t; " seconds"
Wend
Sub a_mul (arr1() As _Unsigned Long, m As _Unsigned _Integer64)
Static As Long nlimbs ' start with 1 number of elements (nlimbs = 0)
Dim As Long carry, i
Dim As _Unsigned _Integer64 tmp
carry = 0
For i = 0 To nlimbs
tmp = m * arr1(i) + carry
carry = tmp \ big_base
arr1(i) = tmp Mod big_base
Next
If carry > 0 Then
nlimbs = nlimbs + 1 ' increment the number of elements
arr1(nlimbs) = carry
End If
End Sub
|
|
|
MemSound has a deficiency :) |
Posted by: Petr - 04-24-2023, 06:37 PM - Forum: Help Me!
- Replies (9)
|
 |
Hello,
I just released a new version of SaveSound in my thread. It can also do something that hasn't been here before - save sound in 24 bit Wav format. On that occasion, I discovered that both SndOpen and SndPlay can play the created 24-bit WAV file, but unfortunately, MemSound cannot handle it. This also follows from the help for MemSound, where only 8, 16, 32 bit formats are written about. I recently found out how to create a 24 bit format very easily and I'm assuming you didn't know about this option and that's why it wasn't known.
|
|
|
_LOADFONT example omission |
Posted by: mnrvovrfc - 04-24-2023, 02:46 PM - Forum: Wiki Discussion
- Replies (1)
|
 |
From this page:
https://qb64phoenix.com/qb64wiki/index.php/LOADFONT
The second example has "_FONT" statement missing. If the font doesn't exist, largely due to mistyping (which was driving me crazy just now trying to load "cyberbit.ttf" in current directory), then the example as it's presented right now isn't going to do anything about it.
The code example should read like the following:
Code: (Select All) i& = _NEWIMAGE(800, 600, 32)
SCREEN i&
COLOR &HC0FFFF00, &H200000FF
f& =_LOADFONT("C:\Windows\Fonts\times.ttf", 25) 'normal style
_FONT f&
PRINT "Hello!"
TIP: If you have Wine in your Linux installation and have run "winetricks corefonts", or any other way to populate the "Windows/Fonts" directory, then this statement could be used to load Times New Roman:
Code: (Select All) f& = _LOADFONT("/home/user/.wine/drive_c/windows/Fonts/times.ttf", 25) 'normal style
(replace "user" without double-quotation marks with the name of the user that is linked with the password for your regular account.)
|
|
|
BAM feature in the works: two voices for SOUND |
Posted by: CharlieJV - 04-24-2023, 04:44 AM - Forum: QBJS, BAM, and Other BASICs
- Replies (2)
|
 |
Although the WebAudio API is a tough thing to figure out, I've managed to get two voices (oscillators) working without too much clicking between sounds.
Loads to do (like figuring out how to adjust volume, and getting more voices working without buzzing sounds), but this will have to do for a near-future release of BAM.
If you have a moment to give the following a try on your device with your particular browser, please let me know how it goes:
(EDIT: ARG! I forgot to mention: turn down your volume!!!)
|
|
|
Why element size is not 2? |
Posted by: Petr - 04-23-2023, 11:57 AM - Forum: Help Me!
- Replies (9)
|
 |
Code: (Select All) Type snd1
l As Integer
r As Integer
End Type
Type snd2
l As _Unsigned _Byte
r As _Unsigned _Byte
End Type
ReDim s(0) As snd2 '1
ReDim s(0) As snd1 '2
Print Len(s(0).l) 'expected is 2
Is there any way to fix this, or does that mean I have to completely rewrite 90 percent of the program that relied on this?
|
|
|
|