Class question

Started by Frank Brübach, June 18, 2024, 05:29:32 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Frank Brübach

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

Charles Pegge

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.