Recent posts

OxygenBasic Examples / Re: CByte
Last post by Charles Pegge - Yesterday at 05:44:54 PM
some signed byte values:

0x7f -->  127
0x80 --> -128
0x81 --> -127
0xfe --> -2
0xff --> -1

0x104 modulo 0xff --> 4
The entire food pyramid on planet Earth is cruel, unfortunately.

Some more stories:

strange Humanoids Around the World: Ten Eyewitness Accounts

Preston Dennett
20 apr 2024

Twelve Amazing Humanoid Encounters

Preston Dennett
18 may 2024

Code to share / Re: halProment 64 Bit Test
Last post by Frank Brübach - Yesterday at 02:19:29 PM
Finally the big step to 64 Bit architecture
Thanks Charles for His great and Files :-)

All examples you can find in *.rar folder below
If you have any questions please ask thx, frank

'' -- halProment Basic 64 bit test, 26-5-24, 29-05-24, by frank bruebch
'' -- you must compile this example with menu compile/quickrun produces an exe file

$ FileName "test64-2.exe"
#include "$\inc\" ''

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 Sys

byte val1
byte val2
int result 
    val2=6 '

    'mov eax,val1 
    mov eax,val2  ''multiply (or add) eax by ebx  "
    'mul val1 'ebx
    add eax,5  '' here add 5
    mov result,eax

zstring tit[]="HalProment Basic 64 bit"
zstring msg[]="Hello dear Animal World! " + str(result)

'' halProment Basic 64 bit

sub  rsp,40h
mov  r9,  0     
lea  r8,  tit 
lea  rdx, msg 
mov  rcx, 0
call messagebox     
add  rsp, 40h
'' output: Hello dear Animal World! 11 (add) ' 24 (multiply)

#ifdef mode64bit
#print "Producing 64-bit code output"
print "Producing 64-bit code output"
#print "Producing 32-bit code output"

'' result: "Producing 64-bit code output" ' all ok :-)

PS you can Download the latest Update under GitHub too
Code to share / Re: Window GUI (SDK) hello ani...
Last post by Frank Brübach - Yesterday at 02:14:12 PM
Window winapi GUI (SDK)

  ' -- windows gui test, halProment, 19-05-2024 --
  take diverprom
  Function WinMain(sys inst, prevInst, asciiz*cmdline, sys show) as pro

  WndClass wc
  MSG      wm

  sys hwnd, wwd, wht, wtx, wty, tax
  with wc
  .lpfnWndProc = @WndProc
  .cbClsExtra =0
  .cbWndExtra =0   
  .hInstance =inst
  .hIcon=LoadIcon 0, IDI_APPLICATION
  .hCursor=LoadCursor 0,IDC_ARROW
  .hbrBackground = GetStockObject WHITE_BRUSH
  .lpszMenuName = null
  .lpszClassName = strptr "Demo"
  end with
  sys r=RegisterClass (@wc)
  Wwd = 520 : Wht = 400
  Tax = GetSystemMetrics SM_CXSCREEN
  Wtx = (Tax - Wwd) /2
  Tax = GetSystemMetrics SM_CYSCREEN
  Wty = (Tax - Wht) /2
  hwnd = CreateWindowEx 0,wc.lpszClassName,"HalProment Basic",WS_OVERLAPPEDWINDOW,Wtx,Wty,Wwd,Wht,0,0,inst,0
  if not hwnd
    mbox "Unable to create window"
    exit function
  end if
  ShowWindow hwnd,SW_SHOW
  UpdateWindow hwnd
  sys bRet
  do while bRet := GetMessage (@wm, 0, 0, 0)
    if bRet = -1 then
      'show an error message
      TranslateMessage @wm
      DispatchMessage @wm
    end if
  end Function

  dim as rect crect

  function WndProc (pro hWnd, wMsg, wParam, lparam ) as pro callback

    static as pro hdc
    static as pstring txt
    static as PaintStruct Paintst
    select wMsg
      case WM_CREATE
      GetClientRect hWnd,cRect

      case WM_DESTROY
      PostQuitMessage 0
      case WM_PAINT

      GetClientRect  hWnd, cRect
      hDC=BeginPaint hWnd, Paintst
      SetBkColor  hdc,black 'yellow
      SetTextColor hdc,green 'red
      DrawText hDC,"Hello Animal World!",-1,cRect,%DT_SINGLELINE or %DT_CENTER or %DT_VCENTER
      EndPaint hWnd,Paintst
      function = 1
      case WM_KEYDOWN

      Select wParam

    Case 27 : SendMessage hwnd, WM_CLOSE, 0, 0      'ESCAPE

      End Select

      case else
        function=DefWindowProc hWnd,wMsg,wParam,lParam
    end select

  end function

'  WinMain inst,0,cmdline,SW_NORMAL  '' both lines are working
  WinMain 1,0,1,SW_NORMAL
Code to share / Re: Array examples reducing St...
Last post by Frank Brübach - Yesterday at 02:11:02 PM
Array examples how to reduce a String Text

' array reducing for a string
pindex 0

Dim txt() as zstring = "Hello World " + Chr(0)
dim i as integer
For i = 0 to Len(txt)-2 ''Len(txt)-1 if pindex is not active
    p? txt(i) + Chr(txt(i))

' output: hello world ello world llo world lo world o world
' output: world orld rld ld d 
Code to share / Update4 halProment 32/64 bit
Last post by Frank Brübach - Yesterday at 02:07:34 PM
Byte Array example

' -- byte array example
pim strsrc as pstring
strsrc = "Hello, Animal World!"

Dim byteArray() as byte at strptr(strsrc)

  pim i,j as pro
  pim s,t as pstring
  s=space 600
  for i=1 to 20
    t=chr(9)+str(byteArray[i]) ":  " + chr(byteArray[i])
    mid (s,j)=t
    j+=len t

  p? left s,j
OxygenBasic Examples / Re: CByte
Last post by Frank Brübach - May 28, 2024, 08:03:31 PM
Oh good didn't know yet thx Charles

Found an old freebasic examples with cByte(260)=4 and I didnt understand the result but now... ;)

sbyte sb 'signed byte
print sb
print sb 'rounds to 33
print sb 'auto-convert string -32
print sb 'wrap overflow -1
' if that's -1 then 260 it's 4 ?
' why it's 4 as result? => 5 - 1 ? = 4
print sb ' 4
OxygenBasic Examples / Re: CByte
Last post by Charles Pegge - May 28, 2024, 06:01:03 PM
Hi Frank,

string-to-number conversion etc is built into Oxygen:

sbyte sb 'signed byte
print sb
print sb 'rounds to 33
print sb 'auto-convert string -32
print sb 'wrap overflow -1
OxygenBasic Examples / CByte
Last post by Frank Brübach - May 28, 2024, 01:19:19 PM
Hello Charles, do you know cByte?
Its interesting datatype for oxygen too? Its existing in freebasic as converting Data Type

Converts numeric or string expression to Byte.

declare function Cbyte ( byval expression as datatype ) as byte

Type typename
declare operator cast ( ) as byte
End Type

result = Cbyte( numeric expression )
result = Cbyte( string expression )
result = Cbyte( user defined type )

A numeric, string, or pointer expression to cast to a Byte value.
Any numeric, string, or pointer data type.
A user defined type.

Return Value:
A Byte value.

The Cbyte function rounds off the decimal part and returns a 8-bit Byte value. The function does not check for an overflow, and results are undefined for values which are less than -128 or larger than 127.

The name can be explained as 'Convert to Byte'.

If the argument is a string expression, it is converted to numeric by using Valint.

' Using the CBYTE function to convert a numeric value

'Create an BYTE variable
Dim numeric_value As Byte

'Convert a numeric value
numeric_value = CByte(-66.30)

'Print the result, should return -66
Print numeric_value
News and Announcements / 🚀 New update from 27.05.2024
Last post by Theo Gottwald - May 28, 2024, 08:06:16 AM
📢🤖🆕 Yesterday, I released a new update for the smart package robot! 🚀 This update includes important changes for parallel running robots. 💡 Check out the sample code to see how to use parallel running robots as a watchdog to prevent a main program from hanging. 🕵��♀️ And don't forget to try out the newest version of the social media assistant button bar that is in the Sample Scripts Folder!

📲 #smartpackagerobot #update #parallelrunning #watchdog #socialmediaassistant #code #innovation 💡🤖🚀🕵��♀️📲

Gestern habe ich ein neues Update für den smarten Paketroboter veröffentlicht! 🤖✨ Dieses Update beinhaltet wichtige Änderungen für parallel laufende Roboter. 🚀💡 Schaut euch den Beispielcode an, um zu sehen, wie ihr parallel laufende Roboter als Wachhund nutzen könnt, um ein Hauptprogramm vor dem Einfrieren zu bewahren. 🛡�🖥� Vergesst nicht, die neueste Version der Social Media Assistant Button-Leiste auszuprobieren! 🌐🔍

#smartpackagerobot #update #parallelrunning #watchdog #socialmediaassistant #code #innovation 🤖💻📦