Recent posts

#11
OxygenBasic / Re: demo issues
Last post by Charles Pegge - May 09, 2024, 04:02:52 PM
Thanks Roland,

This is a case-sensitivity issue affecting the iif macro in the program

Here is a quick fix:

macro iif int(r, a,b,c)
'if A then R=B else R=C
if a
  r=b
else
  r=c
endif
end macro

I will fix this compiler problem properly in the next update.
#12
OxygenBasic / Re: demo issues
Last post by Roland Stowasser - May 09, 2024, 02:40:00 PM
Hi Charles,

there is a small problem with /demos/Sound/KeyBoardMidi.o2bas. This app runs fine with oxygen.dll 07P10 (version 0.7.0 2024-01-01T14:45:45 32bit), but with the oxygen.dll in progress (version 0.70 2024-03-19T 10:02:07 32bit) I get this error message:

ERROR : not found
WORD:  r
PROC:    createThemenu
COL:      1
LINE:      422
FILE:      main source

This is a strange error message. If I comment out the createThemenu procedure the message happens in a different place. So I think there is something missing with oxygen.dll? Maybe I am using a version that is not up to date?
#13
AI Reset: "Life As We Know It Will Be Gone In 5 Years" - Upcoming Utopia vs Dystopia | Salim Ismail

Tom Bilyeu
7 may 2024


3hrs15
#15

Rhetorical strategies.

World of Antiquity
1 may 2024

#16
General Discussion / NASA named an asteroid after m...
Last post by Charles Pegge - May 07, 2024, 10:01:15 PM

Sabine Hossenfelder
7 may 2024


Hossi
#17
OxygenBasic Examples / Re: Input Box help
Last post by Charles Pegge - May 07, 2024, 05:55:29 PM
inc\console.inc provides the low-level stuff. You can deconstruct or override it if necessary:

uses console
print "Enter your name: "
string name=ltrim(rtrim(input()))
if name
  print cr
  print "Hello, " + name + "!" + cr
  wait
endif
#18
OxygenBasic Examples / Input Box help
Last post by Frank Brübach - May 07, 2024, 04:12:26 PM
Hello Charles again thx First for Help with both msgbox asm examples

Next for the road tried to Convert an old freebasic example Code only Line 38 is Here a Problem readConsoleA() function or it's more?

Thx in advance, Frank

' frebasic
'#include "crt.bi"
'#include "windows.bi"

' oxygen basic
'
uses corewin
uses console

' Declare external functions
declare function GetStdHandle( byval nStdHandle as ulong ) as long
declare function ReadConsoleA( byval hConsoleInput as long, byval lpBuffer as integer, byval nNumberOfCharsToRead as long, byref lpNumberOfCharsRead as long, byval lpReserved as integer ptr ) as long

' Define constants
% STD_INPUT_HANDLE = -10
% STD_OUTPUT_HANDLE = -11
% STD_ERROR_HANDLE = -12
% BUFSIZE = 128

' Define input function
function InputBox( prompt as string ) as string
    dim as long bytes_read
    dim as any ptr input_handle
    dim as integer ptr buffer ' integer 'any
    dim as string input_text
    ' Get handle to console input
    input_handle = GetStdHandle( STD_INPUT_HANDLE )
   
    ' Allocate memory for input buffer
    'buffer = allocate( BUFSIZE )
    buffer = sysallocStringLen( BUFSIZE )

    ' Print prompt
    print prompt
   
    ' Read input from console
    ' problem zone ---------------------------------------------- //
    ReadConsoleA( input_handle, buffer, BUFSIZE, bytes_read, 0 )
    ' problem zone ---------------------------------------------- //

    ' Convert buffer to string
    input_text = Str(buffer) '*buffer
   
    ' Free memory
    free( buffer )
   
    ' Return input text
    return input_text
end function

' Main program
dim as string names

' Get user input
names = InputBox( "Enter your name: " )

' Print input
print "Hello, " + names + "!"

wait
'sleep
#19
General Discussion / Survival Rations Inspired by H...
Last post by Charles Pegge - May 06, 2024, 08:51:24 PM
Survival Rations Inspired by History - Just 3 a day will keep you full of energy!

Fandabi Dozi
29 aug 2023

#20
OxygenBasic Examples / Re: Msgbox asm
Last post by Charles Pegge - May 06, 2024, 08:14:01 PM
Needs to use 32bit asm with the 32bit default oxygen.dll

Declare Function MessageBox Lib "user32.dll" alias "MessageBoxA" (ByVal hwnd As Long, ByVal lpText As String, ByVal lpCaption As String, ByVal wType As Long) As Long

zstring tit[] ="The great world of OxygenBasic..."
zstring msg[] ="Happy Easter"

'32bit asm
'=========
push 0 '1
addr eax,tit
push eax
addr eax,msg
push eax
push 0
call MessageBox

But you can create a 64bit binary instead of a JIT:

$filename "t.exe"
uses rtl64
'msgbox 64 bit
'
Declare Function MessageBox Lib "user32.dll" alias "MessageBoxA" (ByVal hwnd As sys, ByVal lpText As String, ByVal lpCaption As String, ByVal wType As Long) As Long

zstring tit[] ="The great world of OxygenBasic..."
zstring msg[] ="Happy Easter"

sub  rsp,32
mov  r9d, 0     
lea  r8,  tit   
lea  rdx, msg   
mov  rcx, 0       
call MessageBox
add  rsp,32