Recent posts

#1

  $ Title "Phi Scaling. Left button move. Right button rotate"
  uses consoleG
  BeginScript

  procedure main()
  ================
  if opening
  end if
  cls .2,.3,.5
  move 20,-25
  UserMovement m1,100
  '
  '
  shading
  color 1,1,.5,1
  int i
  float phi=1.618033988
  float phm=phi-1
  phi*=3.5 'base scaling factor
  '
  for i=1 to 10
    pushstate
    scale phi
    go sphere
    popstate
    move 0,phi,0
    phi*=phm
    move 0,phi,0
  next
  '
  end procedure 'main

  EndScript
#2
OxygenBasic / Re: Extended Macro Syntax
Last post by Frank Brübach - Yesterday at 07:06:50 PM
Hi Charles thx for Updates and new macro Features I have tested all examples  with last
Updated version ... Now all examples running fine ;)

Function ff (int a,b,c) AS Long 'OK

Function ff AS Long (int a,b,c) '  OK

Regards frank
#3
OxygenBasic / Re: Extended Macro Syntax / Fu...
Last post by Charles Pegge - Yesterday at 06:24:33 PM
I've also extended function syntax slightly:

The as specifier can go to the left of the prototype as well as to the right:

Standard function:
function ff a(int a,b,c) as long
return a+b+c
end function
print ff(1,2,3)

New alternative:
function ff as long (int a,b,c)
return a+b+c
end function
print ff(1,2,3)


https://github.com/Charles-Pegge/OxygenBasic/blob/master/OxygenBasic.zip

#4
OxygenBasic / Extended Macro Syntax
Last post by Charles Pegge - Yesterday at 07:50:55 AM
Using 'procedure' 'sub' 'function' 'as' to improve readability of macros: (The original syntax is still valid)

macro procedure
macro procedure mm (a,b,c)
print a+b+c
end macro
'
mm(1,2,3)

macro function
macro function mm as int (retv,a,b,c)
retv=a+b+c
end macro
'
print mm(1,2,3)


https://github.com/Charles-Pegge/OxygenBasic/blob/master/OxygenBasic.zip


o2 Macros also support default values:

macro function mm as int (retv,a=1,b=10,c=100)
retv=a+b+c
end macro

print mm(2) 'result 112
#5
OxygenBasic Examples / Re: String to array byte
Last post by Frank Brübach - February 23, 2024, 07:40:48 PM
I have the solution :)

'
'nearly 99% good
'
Dim strsrc As String
strsrc = "Hello, Animal World!"

Dim byteArray() As Byte at strptr(strsrc)

  dim i,j as long
  dim s,t as string
  j=1
  s=space 600
  for i=1 to 20
    't=str(i) chr(9)+chr(i+64) +chr(13) +chr(10)+str(byteArray[i]) ":  " + chr(byteArray[i])
    't=chr(9)+chr(i+64) +chr(13)+chr(10)+str(byteArray[i]) ":  " + chr(byteArray[i])
    t=chr(9)+str(byteArray[i]) ":  " + chr(byteArray[i])
    mid (s,j)=t
    j+=len t
  next

  print left s,j

2) Same example runs with ubound()

Dim strsrc As String
strsrc = "Hello, Animal World!"

Dim byteArray() as byte at strptr(strsrc)

'-----> go 2) with ubound() ------------- //
'
  dim i,j,k as long
  k=ubound(byteArray)*20
  dim s,t,st as string
  j=1
  s=space 500
  for i=1 to k 'ubound(byteArray) '20
    't=str(i) chr(9)+chr(i+64) +chr(13) +chr(10)+str(byteArray[i]) ":  " + chr(byteArray[i])
    't=chr(9)+chr(i+64) +chr(13)+chr(10)+str(byteArray[i]) ":  " + chr(byteArray[i])
    t=chr(9)+str(byteArray[i]) ":  " + chr(byteArray[i])
    mid (s,j)=t
    j+=len t
  next

  print left s,str(j-1)

I Like oxygen :) nice Weekend
#6
OxygenBasic Examples / Re: String to array
Last post by Frank Brübach - February 23, 2024, 01:25:22 PM
Many thanks Charles :)

How I can make a String Buffer list with IT? Left two columns?

'uses corewin

'----- 1) ok
'
Dim strsrc As String
strsrc = "Hello, Animal World!"
Dim byteArray() As Byte at strptr(strsrc)
dim i,v as integer

do
  i++
  if byteArray[i]=0 then
  'exit
  end if
'print str(byteArray[8]) ":  " chr(byteArray[8]) '65 A
print str(byteArray[i]) ":  " + chr(byteArray[i])
loop until i=20


'----- 2) how to make a buffer string list with this array?
'
  dim i,j as long
  dim s,t as string
  j=1
  s=space 500
  for i=1 to 20
    t=str(i) chr(9) chr(i+64) chr(13) chr(10)
    mid (s,j)=t
    j+=len t
  next

  print left s,j-1
#7
OxygenBasic Examples / Re: String to array
Last post by Charles Pegge - February 23, 2024, 12:08:11 PM
Hi Frank,

Using a DO loop to iterate over the string:

uses console
Dim strsrc As String
strsrc = "Hello, Animal World!"
Dim byteArray() As Byte at strptr(strsrc)
dim i,v as integer
'print str(byteArray[8]) ":  " chr(byteArray[8]) '65 A
do
  i++
  if byteArray[i]=0
    exit do
  endif
  print str(byteArray[i]) ":" tab chr(byteArray[i]) cr
loop
wait
#8
OxygenBasic Examples / String to array byte
Last post by Frank Brübach - February 23, 2024, 06:41:33 AM
Good morning

How I can Convert in my example each Charakter of the String to its Byte value?

Dim strsrc As String
strsrc = "Hello, Animal World!"
Dim byteArray() As Byte at strptr(strsrc)
dim i,v as integer
print str(byteArray[8]) ":  " chr(byteArray[8]) '65 A

'How I can Convert each character of the string to its corresponding byte value
#9
OxygenBasic Examples / Re: Rnd command
Last post by Frank Brübach - February 21, 2024, 06:35:41 PM
I understand No Problem Charles thx I will try to make an alternative way and try to implement a rnd2() or irnd2() and rgb() fixed command in oxygen I dont give Up ;)
I am studying also the freebasic source Code of oxygen 2016 and try to learn more about this topic

Nice wednesday
#10
Advanced Datatypes / Re: Technique with a FASTPROC ...
Last post by Charles Pegge - February 21, 2024, 03:56:43 PM
Those macro were used to implement 'operator overloading', which does not seem to be possible in PowerBasic.

In general o2 macros are quite similar to those in PowerBasic. Instead of MacroTemp, the private macro symbols are listed after the parameters, and in macro functions, the return symbol is the first parameter.

PowerBasic:
    MACRO loadsd(sse2reg,immval)    ' load a 64 bit immediate into an SSE register
    MACROTEMP valdbl
      LOCAL valdbl as DOUBLE
      valdbl = immval
      ! movsd sse2reg, valdbl
    END MACRO

translates to: o2
    MACRO loadsd(sse2reg,immval,  valdbl )    ' load a 64 bit immediate into an SSE register
      LOCAL valdbl as DOUBLE
      valdbl = immval
      movsd sse2reg, valdbl
    END MACRO

and PowerBasic:
MACRO FUNCTION SseRtn           ' load an SSE register into a DOUBLE value
    MACROTEMP valdbl
      LOCAL valdbl as DOUBLE
      ! movsd valdbl, xmm0
    END MACRO = valdbl

becomes o2:
MACRO SseRtn double(valdbl)  ' load an SSE register into a DOUBLE value
      movsd valdbl, xmm0
    END MACRO