Oxygen Basic

Information => Introducing Oxygen => Topic started by: Arnold on February 05, 2019, 03:43:59 AM

Title: Testing new OxygenBasicProgress of 4th Feb 2019
Post by: Arnold on February 05, 2019, 03:43:59 AM
Hi Charles,

I installed the OxygenBasicProgress.zip and have started to test the demos in examples\WinDynDialogs (in 32-bit). A few small modifications were needed.

in \inc\Dialogs.inc I made a small typo in line 373, this should be:
sub AutoCheckBox
instead of sub AutoCCheckBox

Small modifications are necessary to run these apps with the latest oxygen.dll

DlgFromWin.o2bas line 144:
    do while (bRet := GetMessage(&Msg, NULL, 0, 0)) '!= 0
and:
SimpleModeLess.o2bas line 58:
   while (bRet := GetMessage(&Msg, NULL, 0, 0)) '!= 0
(The part !=0 is not needed and superfluous)

ListView.o2bas line 201
              Dialog( 0,0,144,77, "About Listview Sample",
instead of
              Dialog( 4,0,0,144,77, "About Listview Sample",
(4 is the count of controls in dialog and is not needed any more)

Apart from these small issues the demos run very nice in WinDynDialogs. Will you note the changes for the next release?

Roland

Title: Re: Testing new OxygenBasicProgress of 4th Feb 2019
Post by: Arnold on February 05, 2019, 07:53:49 AM
Hi Charles,

to run the demos of WinDynDialogs in 64-bit I only found this demo of interest:
In FullScreen.o2bas SetWindowPos does not fire. Reading the docu of Win32Help SetWindowPos is declared as:

BOOL SetWindowPos(HWND hWnd,HWND hWndInsertAfter,int X,int Y,int cx,int cy,UINT uFlags)

So I applied in line 56:
             SetWindowPos(hDlg, (sys) HWND_TOPMOST,
...

This looks logical to me, at least the app now works in 64-bit correctly too. What do you think?

I also modified Set/GetWindowlong to Set/GetWindowLongPtr (though Oxygen can handle this without these changes). Thus the adapted code for FullScreen.o2bas would look like this:

Code: OxygenBasic
  1. '====================================================================
  2. ' Fullscreen dialog demo, switch between normal and fullscreen mode
  3. ' modeless dialog as main.
  4. '====================================================================
  5.  
  6. $ filename "FullScreen.exe"
  7. 'uses rtl32
  8. 'uses rtl64
  9.  
  10. '% review
  11.  
  12. uses dialogs
  13.  
  14.  
  15. int ID_TestBtn=100
  16.  
  17. bool FullScreen=False
  18. int oldx, oldy, oldwidth, oldheight
  19.  
  20. '====================================================================
  21.  
  22. function DialogProc(sys hDlg, uint uMsg, sys wParam, lParam ) as int callback
  23.  
  24.    RECT rcDlg
  25.  
  26.    select case uMsg
  27.  
  28.      case WM_INITDIALOG
  29.        ShowWindow(hDlg,SW_SHOW)
  30.        
  31.      case WM_COMMAND
  32.  
  33.         select case loword(wParam)
  34.  
  35.         case ID_TestBtn      
  36.            FullScreen = not FullScreen
  37.        
  38.            if FullScreen then
  39.              GetWindowRect( hDlg, @rcDlg )
  40.              oldx=rcDlg.left : oldy=rcDlg.top
  41.              oldwidth=rcDlg.right-oldx : oldheight=rcDlg.bottom-oldy
  42.  
  43.              int cx, cy
  44.              sys hdc = GetDC(NULL)
  45.              cx = GetDeviceCaps(hdc,HORZRES) +
  46.              GetSystemMetrics(SM_CXBORDER)
  47.              cy = GetDeviceCaps(hdc,VERTRES) +
  48.              GetSystemMetrics(SM_CYBORDER)
  49.              ReleaseDC(null,hdc)
  50.        
  51.              SetWindowLongPtr(hDlg,GWL_STYLE,
  52.                            GetWindowLongPtr(hDlg, GWL_STYLE) and
  53.                            (not (WS_CAPTION or WS_THICKFRAME or WS_BORDER)))
  54.  
  55.              ' Put window on top and expand it to fill screen
  56.             SetWindowPos(hDlg, (sys) HWND_TOPMOST,
  57.              -(GetSystemMetrics(SM_CXBORDER)+1),
  58.              -(GetSystemMetrics(SM_CYBORDER)+1),
  59.              cx+1, cy+1, SWP_NOZORDER)
  60.  
  61.            else
  62.              SetWindowLongPtr(hDlg,GWL_STYLE,
  63.                            GetWindowLongPtr(hDlg, GWL_STYLE) or
  64.                                          WS_THICKFRAME or WS_BORDER or WS_CAPTION)
  65.  
  66.              MoveWindow( hDlg, oldx, oldy, oldwidth, oldheight, true )
  67.            end if
  68.  
  69.         case IDCANCEL
  70.            DestroyWindow( hDlg )
  71.  
  72.         end select
  73.        
  74.      case WM_CLOSE
  75.         DestroyWindow( hDlg )
  76.  
  77.      case WM_DESTROY
  78.         PostQuitMessage( null )
  79.  
  80.   end select
  81.  
  82.   return 0
  83. end function
  84.  
  85. '====================================================================
  86.  
  87. sub WinMain()
  88.  
  89.    sys hDlg
  90.    MSG wMsg
  91.  
  92.    Dialog( 0, 0, 200, 100, "Switch between FullScreen and Normal",
  93.                 WS_OVERLAPPEDWINDOW or DS_CENTER )
  94.    DefPushButton( "&Test", ID_TestBtn, 10, 20, 40, 20 )
  95.  
  96.    hDlg = CreateModelessDialog( null, @DialogProc, 0 )
  97.  
  98.    while GetMessage( @wMsg, null, 0, 0 ) != 0
  99.      if IsDialogMessage( hDlg,  @wMsg ) = 0 then
  100.        TranslateMessage( @wMsg )
  101.        DispatchMessage( @wMsg )
  102.      end if
  103.    wend
  104.  
  105. end sub
  106.  
  107. WinMain()
  108.  
Title: Re: Testing new OxygenBasicProgress of 4th Feb 2019
Post by: Arnold on February 07, 2019, 12:51:05 AM
Hi Charles,

while working through the demos of \examples\basics, I realized with horror that I asked many questions that were actually already answered in the examples. But your answers also helped me to better understand the code in other programming languages.

I noticed that in SizeofSpanof.o2bas the statement: dim s as asciiz*256 will not work any more. Is sizing for this case deprecated? I found two alternatives, are there still more?

Roland

Code: OxygenBasic
  1.  
  2. 'dim s as asciiz*256    'ERROR: *sizing not supported here
  3.  
  4. 'dim s as asciiz*        'will crash without message
  5. 'dim s as asciiz[256]    'will crash without message
  6.  
  7. 'dim s[256] as asciiz     'ok
  8. asciiz s[256]             'ok
  9.  
  10. print sizeof s
  11. print spanof s
  12. print countof s
  13. print bytesof s
  14. print "len of s = " len(s)
  15.  
  16. s="hello"
  17. print s
  18. print "len of s =" len(s)
  19.  
  20. dim st as asciiz*
  21. st="hello"
  22. print st
  23. print "len of st =" len(st)
  24.  
Title: Re: Testing new OxygenBasicProgress of 4th Feb 2019
Post by: Arnold on March 01, 2019, 03:01:55 AM
Hi Charles,

I noticed that in projectsB/Iup four apps do not work as expected:

jfdemo1H.o2bas needs a modification in line 25:
sub AddChild(sys parent, child)
otherwise the form will not be shown
(in jfdemo1.o2bas both versions of AddChild do work)

tabs.o2bas, line 17 must be deleted or commented out:
'typedef sys Ihandle
otherwise  the example6 will not create a new tab

zbox.o2bas, line 12 must be deleted or commented out:
'typedef sys Ihandle
otherwise changing the Layout will not work.

in gldemo3.o2bas line 111 should be modified too:
sub AddChild(sys parent, child)

In the other Iup examples, I found no problems.

Roland



Title: Re: Testing new OxygenBasicProgress of 4th Feb 2019
Post by: John on March 01, 2019, 09:41:06 PM
Thanks Roland for being the guiding angel for the O2 IUP effort.
Title: Re: Testing new OxygenBasicProgress of 4th Feb 2019
Post by: Arnold on April 12, 2019, 03:23:52 AM
Hi Charles,

I hope you are well and you still have some time to work on the further development of OxygenBasic? Now and then I compare the behavior of the current version with version B0 of July 2018 and in this case I checked the examples of the folder WideChars.

In HelloUnicode.o2bas there is an error message in line 158 (function WndProc, missing sys hWnd). That is logical for me, O2 is a bit stricter now with type checking?

In ReadUnicode.o2bas an error is displayed in line 34 (missing right bracket). If I change to:   print "ALPHA: " wchr (0x3b1) then everything works fine.

I am a bit unsure about the behaviour of print in UnicodeConsoleIO.o2bas. Line 86:
print  "Ansi:    " name
does not work correctly any more. It should have not worked with B0 neither as there is missing a cr or printl, so I commented it out. Line 96:
SetConsoleTitleW title
does also not work, the title of the console and the print statement should display unicode. Perhaps the logic of UnicodeConsoleIO.o2bas must be revised a bit. You introduced L".." with the new version:

https://www.oxygenbasic.org/forum/index.php?topic=1775.msg19328#msg19328

Can this have some impact now with using unicode in a console window?

Roland
Title: Re: Testing new OxygenBasicProgress of 4th Feb 2019
Post by: Charles Pegge on April 15, 2019, 07:54:50 AM
Hi Roland,

I've been catching up on sleep, and neural regeneration :) Intensive programming takes its toll but I hope to resume my normal level of activity soon.

Thanks for reporting the wide-Char problems. I have fixed wchr(n1,n2,...), which would not work with literal numbers. I still need to look at the console.
Title: Re: Testing new OxygenBasicProgress of 4th Feb 2019
Post by: Arnold on April 23, 2019, 01:19:10 AM
Hi Charles,

as is, this little code will crash:

Code: [Select]
$ filename "Here.exe"
'uses rtl32
'uses rtl64

uses console

dim a$ as string

a$="abcdefg"

goto here              'here will crash?
a$ = "1234567890"       'this does not get executed

here:
a$ = right$(a$,5)

print a$

printl "Enter..."
waitkey

If I replace "here" with "there" everything will work fine. You applied here in some cases too like:
    call fwd here : .here : pop eax : sub eax,here : add eax,bssdata

but this is labelled as .here, perhaps this does conflict with here:  It is not a major problem, I only wanted to notify you about the behaviour.

Roland
Title: Re: Testing new OxygenBasicProgress of 4th Feb 2019
Post by: Charles Pegge on April 23, 2019, 02:46:25 AM
Hi Roland,

.here is used internally. I will change this internal label to something decorated with underscores.
Title: Re: Testing new OxygenBasicProgress of 4th Feb 2019
Post by: Arnold on April 24, 2019, 02:50:16 AM
Hi Charles,

this is stated in Oxygen Helpfile:

#autodim
ACTION: enable variables to be created without a Dim statement
 
USE: switch off this mode for stricter compiling!
 
EXAMPLE: #autodim off

REMARKS: this mode is normally active.
 
In older versions of Oxygenbasic #autodim was the default, since version B0 the default is: #autodim off. From my experience, I can confirm that this behaviour is much less error-prone. Could 'active' be changed to 'disabled' in the next Oxygen Helpfile? I suppose the option now is #autodim on?

Roland
Title: Re: Testing new OxygenBasicProgress of 4th Feb 2019
Post by: Charles Pegge on April 24, 2019, 06:39:08 AM
Thanks, Roland.

I'll update the manual:

Code: [Select]
data       "#autodim 13 44"
'action:   enable variables to be created without a Dim statement
'use:      for mall, informal programs.
'example:  #autodim on
'related: 
'group:    directives
'updated:  24/04/2019
Title: Re: Testing new OxygenBasicProgress of 4th Feb 2019
Post by: John on April 24, 2019, 07:47:34 AM
It would nice if Mr. Roca would join us again and pickup where he left off with his documention effort.

Title: Re: Testing new OxygenBasicProgress of 4th Feb 2019
Post by: Aurel on April 24, 2019, 09:57:39 AM
It would be BUT better not
I like very much his aproach to things but in some cases HE is not very much oriented
according to problems with his own (theo) forum our John is a master 8)
which lead us to ..he don't feel the charm of o2  :D

so ...is autodim oFF or is ON by default?
Title: Re: Testing new OxygenBasicProgress of 4th Feb 2019
Post by: John on April 24, 2019, 04:42:44 PM
Aurel,

If my plate wasn't already full with the ScriptBasic project, I would find a way that I could contribute more. I do what I can to keep the project promoted and provide resources to share O2 with others.
Title: Re: Testing new OxygenBasicProgress of 4th Feb 2019
Post by: John on April 24, 2019, 07:48:09 PM
Theo isn't a very good hosting provider. No https, errors on the forum and off topic posts you wonder what planet he is from.
Title: Re: Testing new OxygenBasicProgress of 4th Feb 2019
Post by: Aurel on April 24, 2019, 10:30:22 PM
John ..
sorry my bad english..
not you....    mr.Roca
..he don't feel the charm of o2

anyway Jose is nice guy but he prefer other things  :)
Title: Re: Testing new OxygenBasicProgress of 4th Feb 2019
Post by: Charles Pegge on April 25, 2019, 04:42:54 PM
The default is now #autodim off (20-05-2018). This is the safer option for programs of any significant size.
Title: Re: Testing new OxygenBasicProgress of 4th Feb 2019
Post by: Alex_Longard on April 26, 2019, 11:15:14 PM
Hello Charles!
Help me please, i not know how to translate this codes in O2:

ps: C++ code
Code: [Select]
rtclass *runtime = (rtclass*)(basicstruct->instance);

basicstruct *b = (basicstruct*) malloc(sizeof(basicstruct));
memset(&b, 0, sizeof(basicstruct));

int** arrayptr;

Title: Re: Testing new OxygenBasicProgress of 4th Feb 2019
Post by: Charles Pegge on April 27, 2019, 02:32:49 AM
Hi Alex,

I can't make sense of the first line without seeing definitions for rtclass and basicstruct, and how runtime is used.

but the others are:

Code: [Select]
'basicstruct *b = (basicstruct*) malloc(sizeof(basicstruct));
'memset(&b, 0, sizeof(basicstruct));
basicstruct *b : @b=getmemory(sizeof(basicstruct))

'int** arrayptr;
int** arrayptr
Title: Re: Testing new OxygenBasicProgress of 4th Feb 2019
Post by: Alex_Longard on April 27, 2019, 04:04:35 AM
Hi Charles!
Thank you!

rtclass used as type for *runtime, which use in programm instance:

I upload all C++ code for Mingw compiler, i cand not translate some strange code, which i not seed in O2 examples(((

This basic code which i rewrite.
Code: [Select]
#include "pluginterfaces\vst2.x\aeffect.h"
#include "pluginterfaces\vst2.x\aeffectx.h"
#include <stdio.h>

typedef audioMasterCallback VSTHostCallback;
typedef AEffect VSTPlugin;

extern "C" {
extern AEffect *VSTPluginMain(audioMasterCallback audioMaster); }

const VstInt32 PLUGIN_VERSION = 1000;

class VSTPluginWrapper
{
public:
VSTPluginWrapper(VSTHostCallback vstHostCallback, VstInt32 vendorUniqueID, VstInt32 vendorVersion, VstInt32 numParams, VstInt32 numPrograms, VstInt32 numInputs, VstInt32 numOutputs);
~VSTPluginWrapper();

inline VSTPlugin *getVSTPlugin()
{
return &_vstPlugin;
}

inline VstInt32 getNumInputs() const
{
return _vstPlugin.numInputs;
}

inline VstInt32 getNumOutputs() const
{
return _vstPlugin.numOutputs;
}

private:
VSTHostCallback _vstHostCallback;
VSTPlugin _vstPlugin;
};

void VSTPluginProcessSamplesFloat32(VSTPlugin *vstPlugin, float **inputs, float **outputs, VstInt32 sampleFrames)
{
VSTPluginWrapper *wrapper = (VSTPluginWrapper*)(vstPlugin->object);
for(int i = 0; i < wrapper->getNumInputs(); i++)
{
auto inputSamples = inputs[i];
auto outputSamples = outputs[i];
for(int j = 0; j < sampleFrames; j++)
{
outputSamples[j] = inputSamples[j] * 0.5f;
} } }

void VSTPluginProcessSamplesFloat64(VSTPlugin *vstPlugin, double **inputs, double **outputs, VstInt32 sampleFrames)
{
VSTPluginWrapper *wrapper = (VSTPluginWrapper*)(vstPlugin->object);
for(int i = 0; i < wrapper->getNumInputs(); i++)
{
auto inputSamples = inputs[i];
auto outputSamples = outputs[i];
for(int j = 0; j < sampleFrames; j++)
{
outputSamples[j] = inputSamples[j] * 0.5;
} } }

VstIntPtr VSTPluginDispatcher(VSTPlugin *vstPlugin, VstInt32 opCode, VstInt32 index, VstIntPtr value, void *ptr, float opt)
{
VstIntPtr v = 0;
VSTPluginWrapper *wrapper = (VSTPluginWrapper*)(vstPlugin->object);
switch(opCode)
{
case effGetPlugCategory:
return kPlugCategSynth;
break;
case effClose:
delete wrapper;
break;

case effGetVendorString:
strncpy((char*)(ptr), "Alex Longard", kVstMaxVendorStrLen);
v = 1;
break;

case effGetVendorVersion:
return PLUGIN_VERSION;
break;
default:
// printf("Unknown opCode %d [ignored] \n", opCode);
break;
}
return v;
}

void VSTPluginSetParameter(VSTPlugin *vstPlugin, VstInt32 index, float parameter)
{
VSTPluginWrapper *wrapper = (VSTPluginWrapper*)(vstPlugin->object);
}

float VSTPluginGetParameter(VSTPlugin *vstPlugin, VstInt32 index)
{
VSTPluginWrapper *wrapper = (VSTPluginWrapper*)(vstPlugin->object);
return 0;
}

VSTPluginWrapper::VSTPluginWrapper(audioMasterCallback vstHostCallback, VstInt32 vendorUniqueID, VstInt32 vendorVersion, VstInt32 numParams, VstInt32 numPrograms, VstInt32 numInputs, VstInt32 numOutputs) : _vstHostCallback(vstHostCallback)
{
memset(&_vstPlugin, 0, sizeof(_vstPlugin));
_vstPlugin.magic = kEffectMagic;
_vstPlugin.object = this;
_vstPlugin.flags = effFlagsCanReplacing | effFlagsCanDoubleReplacing;
_vstPlugin.uniqueID = vendorUniqueID;
_vstPlugin.version = vendorVersion;
_vstPlugin.numParams = numParams;
_vstPlugin.numPrograms = numPrograms;
_vstPlugin.numInputs = numInputs;
_vstPlugin.numOutputs = numOutputs;
_vstPlugin.dispatcher = VSTPluginDispatcher;
_vstPlugin.getParameter = VSTPluginGetParameter;
_vstPlugin.setParameter = VSTPluginSetParameter;
_vstPlugin.processReplacing = VSTPluginProcessSamplesFloat32;
_vstPlugin.processDoubleReplacing = VSTPluginProcessSamplesFloat64;
}

VSTPluginWrapper::~VSTPluginWrapper()
{
}

VSTPlugin *VSTPluginMain(VSTHostCallback vstHostCallback)
{
VSTPluginWrapper *plugin = new VSTPluginWrapper(vstHostCallback, CCONST('u', 's', 'a', 'n'), PLUGIN_VERSION, 1111, 0, 2, 2);
return plugin->getVSTPlugin();
}
Title: Re: Testing new OxygenBasicProgress of 4th Feb 2019
Post by: Charles Pegge on April 27, 2019, 04:31:05 AM
Code: [Select]
rtclass *runtime = (rtclass*)(basicstruct->instance);

This line does not make sense since (rtclass*)(basicstruct->instance) cannot produce a value. Perhaps it is a dim statement with strong typing, in which case the pointer value for runtime is assigned later:

rtclass*runtime
...
@runtime = @b.instance
Title: Re: Testing new OxygenBasicProgress of 4th Feb 2019
Post by: Alex_Longard on April 27, 2019, 04:39:39 AM
I showed above all the code, so you will understand where I stumble for translation.
Title: Re: Testing new OxygenBasicProgress of 4th Feb 2019
Post by: Charles Pegge on April 27, 2019, 04:43:32 AM
What is the structure of BasicStruct ?
Title: Re: Testing new OxygenBasicProgress of 4th Feb 2019
Post by: Alex_Longard on April 27, 2019, 04:54:18 AM
basicstruct as AEffect structure in aeffect.h include file.

I rewrite all code for self.
Title: Re: Testing new OxygenBasicProgress of 4th Feb 2019
Post by: Charles Pegge on April 27, 2019, 04:56:15 AM
How have you defined basicstruct->instance?
Title: Re: Testing new OxygenBasicProgress of 4th Feb 2019
Post by: Alex_Longard on April 27, 2019, 05:02:43 AM
The first code that I showed was my mistake when I rewrote the code for myself which is now fully shown above. Instead of basicstruct, the code contains _vstplugin->object
Code: [Select]
VSTPluginWrapper *wrapper = (VSTPluginWrapper*)(vstPlugin->object);

I attached to the post an archive with full working code that is only for C++. This is a scary code that I rewrote to understand some things, but more confused.