Recent posts

#91
OxygenBasic Examples / Re: Class question
Last post by Charles Pegge - June 19, 2024, 03:22:40 AM
You can also use new and del for dynamic objects
new myTestdummy ki
...
del ki

NOTE
When translating from PB, and you want 64bit compatibility, use sys instead of long or dword for all handles like hWnd and hInst.
#92
Freebasic / Paul Squire's WinFBE
Last post by José Roca - June 19, 2024, 01:21:42 AM
Paul Squires has taken a break for programming for a while.

However, his latest versión of the editor (3.1.0) is available at:

https://github.com/PaulSquires/WinFBE/releases

The package contains all you need to start working with FreeBasic: editor, compilers, headers, examples, templates, and my WinFBX framework.

All you need is to download WinFBE_Suite.zip and unzip it in any folder of your choice, e.g. WinFBE_Suite.

#93
OxygenBasic Examples / Class question
Last post by Frank Brübach - June 18, 2024, 05:29:32 PM
i wanted translate a Powerbasic Code and I am Not quite Sure how to translate 'INSTANCE' to oxygen My Idea was dim and it Works See my simple Code example .. Rest I know already

' only a dummy class test, oxygen
'
class myTestdummy
  long a,b,c,my_hInstance

  ' how to translate INSTANCE ? with dim ?
  ' INSTANCE my_hwnd as long
  '
    dim my_hwnd as long ' it's ok here

  method abc(int prox) as long
  return prox*prox
  end method

  method create() as long
  @a=getmemory 100*sizeof long
  end method

  '' PROPERTY GET hInstance () AS DWORD
  ''   PROPERTY = m_hInstance
  '' END PROPERTY
   
  method hInstance() as dword
   return my_hInstance
  end method

end class

'print "ok"

dim myTestdummy ki
print ki.abc 2 ' result 4 it's ok
#94
OxygenBasic Examples / Re: Parse example o2
Last post by Frank Brübach - June 18, 2024, 05:26:01 PM
Hey Charles sorry No Go with your Index=2 Idea but its Not so important for me at this Moment thx
#95
OxygenBasic Examples / Re: Parse example o2
Last post by Charles Pegge - June 18, 2024, 10:32:34 AM
Hi Frank,

O2 does not support empty parameters (,,) yet,  but I am working on it.

However, to take advantage of defaults in any order, you can do this:
s=myParse(expression="one,two,three", index=2)
#96
OxygenBasic / Re: ternary operator equivalen...
Last post by Frank Brübach - June 17, 2024, 12:13:03 PM
Hi Charles your Code is working Well..  Made an Update of oxygen Basic dont know what was the Problem Here
#97
OxygenBasic Examples / Parse example o2
Last post by Frank Brübach - June 17, 2024, 12:10:46 PM
Hello need a little Help,

Translated this Code of freebasic only one Line doesn't Work properly

' parse example test oxygen
' only one line doesn't work properly
' a=myparse(("one,two,three", ,2)
'
uses console

'indexbase 0

function myParse(string expression, delimiter = ",", int index ) as string
    int count = 1
    string temp = ""
    int d = 1
    int f = 0
    int i = 0
    int z = 1
    do
        i = instr(d, expression, delimiter)
        if i > 0 then
            f = i
            if count = index then
                exit do
            end if
            count += 1
            f += Len(delimiter)
            d = f
        elseif count = index then
            f = Len(expression) + 1
        end if
    loop until i = 0

    return MID(expression,d, f-d)
    'function = mid(expression,d, f-d)
         
end function

string a,b,c

a = myparse("one,two,three", ,2)   ' not ok -> should returns "two"
b = myparse("xyz", , 1)            ' ok -> returns "xyz"
c = myparse("xx1x","x", 3)         ' ok -> returns "1"

Printl "'" + a + "'"
Printl "'" + b + "'"
Printl "'" + c + "'"

wait
#98
OxygenBasic / Re: ternary operator equivalen...
Last post by Charles Pegge - June 17, 2024, 08:43:06 AM
It works here. I also tested it with a console:

uses console

macro iif int(r,e,a,b)
========================
if e
  r=a
else
  r=b
endif
end macro
'
int a = 10, b = 20

print iif(a < b , a , b) cr
wait
#99
OxygenBasic / Re: ternary operator equivalen...
Last post by Frank Brübach - June 17, 2024, 07:25:43 AM
Good morning,

Charles you example doesn't Work Here Got an Error message in
Print iif(a<b,a,b) ' Not found [a

Here's another example

' o2-tenary-frank c to oxygen
uses console

''
'' int a=10, b=20,c;
'' if(a<b){c=a}
'' else{c=b}
'' printf("%d",c)


Dim a As Integer = 10
Dim b As Integer = 20
Dim c As Integer

If a < b Then
    c = a
Else
    c = b
End If

Print c 'result 10

wait
#100
OxygenBasic / Re: ternary operator equivalen...
Last post by Charles Pegge - June 17, 2024, 02:59:20 AM
Hi James,

It can be done with macro functions (the C ternary syntax proved to be too messy)

macro iif int(r,  e,a,b)
========================
if e
  r=a
else
  r=b
endif
end macro
'
int a = 10, b = 20

print iif(a < b , a , b)