Recent Posts

Pages: [1] 2 3 ... 10
1
Example Code / O2 Example
« Last post by John on June 24, 2018, 07:42:35 PM »
What type of application could we assemble that would best show the features and use of Oxygen Basic?

If the example was documented in code well, it could serve a dual purpose.

My vote would be to port ThinBasic to O2 as a community effort with Eros managing the project. Maybe a thinBasic to O2 native translator would be a better use of everyones time. This direction would allow Eros to keep his source code private.

I've have always wanted to run a few benchmarks between thinBasic and Script BASIC to see which is more efficient executing its scripts. This would also compare PB and C as the interpreters engines.

2
DLLC / Re: ScriptO2
« Last post by John on June 24, 2018, 01:59:34 PM »
My next O2 related task is to clean up DLLC removing the the threaded IUP functionality. The main features of DLLC is the dynamic FFI, bstr / wide strings, C structures create / access and low level COM support.

I already have a cross platform threading extension module (SBT) and my IUP extension module allows multiple instances of the message loop to run in threads. COM/OLE automation is provided in a CallByName wrapper.

As much as I like O2 and Charles, I have a working BASIC project to facilitate and without others interest in contributing external solutions to O2, It seems to be a waste of my time. At my age, time utilization is at the top of my list.

O2 may run code faster but when the difference is under a second, I'm not willing to give up the ease of use and the unlimited functionality SB gives me.

3
DLLC / Re: ScriptO2
« Last post by Laurent on June 24, 2018, 12:14:12 PM »
I don't see EZGUI, Brian's BASIC or the external debugger project making any headway either.

Although o2debugger is functional I need some feedback to make it evolve or at least fix bugs.
So I'm waiting you John .... The others too ;-)
4
DLLC / Re: ScriptO2
« Last post by John on June 23, 2018, 07:16:43 PM »
I'm not seeing much interest in a scripting front end for O2. I don't see EZGUI, Brian's BASIC or the external debugger project making any headway either.

At this point in the O2 development cycle, I'm just going to be happy with DLLC as a Windows only extension module.

I'm going to create a thread on AllBASIC showing the evolution of  BASIC from Dartmoth to VB6 using Script BASIC code examples.
5
General / Re: Using OxygenBasic with Unicode
« Last post by Arnold on June 23, 2018, 09:06:34 AM »
This is another interesting experiment with unicode. I put together two alphabets which I can input with my keyboard (English, German), and three alphabets which I can only create fully by using keycodes (French, Grecian, Russian). I do not know if the used keycodes are always correct.

I also tried to use the WinApi functions CharLower and CharUpper, but these functions seem not always work correctly. (if my keycodes were correct).

If I understand this correctly then it should be possible to fill the wstrings MyAlphabet_U /_L  with the characters of the language which is supported by the keyboard. Unfortunately I cannot test these cases.

Code: OxygenBasic
  1. $ filename "Alphabets.exe"
  2. 'use rtl32
  3. 'use rtl64
  4.  
  5. extern lib "User32.dll"
  6. ! CharUpper "CharUpperW"                        '1
  7. ! CharLower "CharLowerW"                        '1
  8. ! MessageBox            "MessageBoxW"           '1
  9. end extern
  10.  
  11. wstring tab=wchr(9)
  12. wstring sep
  13.  
  14. function setup_alphabet(int length_U, wstring lang_U, lang_L) as wstring
  15.    int n=0, x
  16.    int le=length_U
  17.    wstring lang
  18.    wstring capital, small
  19.  
  20.    for x=1 to le
  21.       n+=1
  22.       sep=") " : if n<10 then sep=")  "
  23.       lang &= n & sep & mid(lang_U,n,1) & tab & mid(lang_L,n,1) & tab
  24.  
  25.       'Only for testing - does not always work?
  26. '      capital=mid(lang_L,n,1) : CharUpper(capital)
  27. '      small=mid(lang_U,n,1) : CharLower(small)
  28. '      lang &= n & sep & capital & tab & small & tab      
  29.   next
  30.    return lang
  31. end function
  32.  
  33. wstring English_U="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
  34. wstring English_L="abcdefghijklmnopqrstuvwxyz"
  35.  
  36. wstring English=setup_alphabet(len(English_U), English_U, English_L)
  37. MessageBox 0, English ,wstring("English Alphabet"),0
  38.  
  39.  
  40. wstring French_U=
  41. wchr(65)+wchr(192)+wchr(194)+wchr(198)+wchr(66)+wchr(67)+wchr(199)+
  42. wchr(68)+wchr(69)+wchr(200)+wchr(201)+wchr(202)+wchr(203)+wchr(70)+wchr(71)+wchr(72)+
  43. wchr(73)+wchr(206)+wchr(207)+wchr(74)+wchr(75)+wchr(76)+wchr(77)+wchr(78)+wchr(79)+
  44. wchr(212)+wchr(338)+wchr(80)+wchr(81)+wchr(82)+wchr(83)+wchr(84)+wchr(85)+wchr(217)+
  45. wchr(219)+wchr(220)+wchr(86)+wchr(87)+wchr(88)+wchr(89)+wchr(376)+wchr(90)
  46. wstring French_L=  
  47. wchr(97)+wchr(224)+wchr(226)+wchr(230)+wchr(98)+wchr(99)+wchr(231)+
  48. wchr(100)+wchr(101)+wchr(232)+wchr(233)+wchr(234)+wchr(235)+wchr(102)+wchr(103)+wchr(104)+
  49. wchr(105)+wchr(238)+wchr(239)+wchr(106)+wchr(107)+wchr(108)+wchr(109)+wchr(110)+wchr(111)+
  50. wchr(244)+wchr(339)+wchr(112)+wchr(113)+wchr(114)+wchr(115)+wchr(116)+wchr(117)+wchr(249)+
  51. wchr(251)+wchr(252)+wchr(118)+wchr(119)+wchr(120)+wchr(121)+wchr(255)+wchr(122)
  52.  
  53. wstring French=setup_alphabet(len(French_U), French_U, French_L)
  54. MessageBox 0, French ,wstring("French Alphabet"),0
  55.  
  56.  
  57. wstring Grecian_U=
  58. wchr(913)+wchr(914)+wchr(915)+wchr(916)+wchr(917)+wchr(918)+wchr(919)+wchr(920)+
  59. wchr(921)+wchr(922)+wchr(923)+wchr(924)+wchr(925)+wchr(926)+wchr(927)+wchr(928)+
  60. wchr(929)+wchr(931)+wchr(932)+wchr(933)+wchr(934)+wchr(935)+wchr(936)+wchr(937) '8486)
  61. wstring Grecian_L=
  62. wchr(945)+wchr(946)+wchr(947)+wchr(948)+wchr(949)+wchr(950)+wchr(951)+wchr(952)+
  63. wchr(953)+wchr(954)+wchr(955)+wchr(956)+wchr(957)+wchr(958)+wchr(959)+wchr(960)+
  64. wchr(961)+wchr(963)+wchr(964)+wchr(965)+wchr(966)+wchr(967)+wchr(968)+wchr(969)
  65.  
  66. wstring Grecian=setup_alphabet(len(Grecian_U), Grecian_U, Grecian_L)
  67. MessageBox 0, Grecian ,wstring("Grecian Alphabet"),0
  68.  
  69.  
  70. wstring Russian_U=
  71. wchr(1040)+wchr(1041)+wchr(1042)+wchr(1043)+wchr(1044)+wchr(1045)+wchr(1025)+wchr(1046)+
  72. wchr(1047)+wchr(1048)+wchr(1049)+wchr(1050)+wchr(1051)+wchr(1052)+wchr(1053)+wchr(1054)+
  73. wchr(1055)+wchr(1056)+wchr(1057)+wchr(1058)+wchr(1059)+wchr(1060)+wchr(1061)+wchr(1062)+
  74. wchr(1063)+wchr(1064)+wchr(1065)+wchr(1066)+wchr(1067)+wchr(1068)+wchr(1069)+wchr(1070)+wchr(1071)
  75. wstring Russian_L=
  76. wchr(1072)+wchr(1073)+wchr(1074)+wchr(1075)+wchr(1076)+wchr(1077)+wchr(1105)+wchr(1078)+
  77. wchr(1079)+wchr(1080)+wchr(1081)+wchr(1082)+wchr(1083)+wchr(1084)+wchr(1085)+wchr(1086)+
  78. wchr(1087)+wchr(1088)+wchr(1089)+wchr(1090)+wchr(1091)+wchr(1092)+wchr(1093)+wchr(1094)+
  79. wchr(1095)+wchr(1096)+wchr(1097)+wchr(1098)+wchr(1099)+wchr(1100)+wchr(1101)+wchr(1102)+wchr(1103)
  80.  
  81. wstring Russian=setup_alphabet(len(Russian_U), Russian_U, Russian_L)
  82. MessageBox 0, Russian ,wstring("Russian Alphabet"),0
  83.  
  84. ==============================================================
  85.  
  86. 'This is for testing the own keyboard
  87. wstring MyAlphabet_U="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
  88. wstring MyAlphabet_L="abcdefghijklmnopqrstuvwxyz"
  89.  
  90. wstring MyAlphabet=setup_alphabet(len(MyAlphabet_U), MyAlphabet_U, MyAlphabet_L)
  91. MessageBox 0, MyAlphabet ,wstring("My Alphabet - Testing the own keyboard"),0
  92.  
6
General / Core Primitive Types in O2
« Last post by Charles Pegge on June 22, 2018, 06:11:51 AM »

This is a list of core types and their typecodes used internally:

Code: [Select]
void      0x00 '* -1, Used by reference only
sbyte     0x01
byte      0x21
ubyte     0x21
string    0xe1
string2   0xe2
wstring   0xe2
bstring   0xc1
gstr_     0xc1 '* Accept any Bstring width. for core functions only
bstr      0xc1
bstring2  0xc2
char      0xa1
wchar     0xa2
cstr_     0xa1 '* Accept any char width. for core functions only
asciiz    0xa1
zstring   0xa1
zstring2  15 0xa2
asciiz2   15 0xa2
short     15 0x02
long      0x04
wide      0xa2
int       0x04
integer   0x04
float     0x64
single    0x64
double    0x68
extended  0x6A
quad      0x48 '* using FPU on 32 bit systems (was 08), returns data on edx:eax
word      0x22
dword     0x24
ulong     0x24
uint      0x24
any       0x08 '* to be used by reference only
sys       0x08 '* 4/8 depending on 32/64 bit system
bool      0x04 '* MS
boolean   0x01 '* MS
fpu       0x40 '* fast call using fpu registers (not exportable)
signed    0x04
unsigned  0x24
qword     0x28 '* Assembler only
7
General / Re: Using OxygenBasic with Unicode
« Last post by Charles Pegge on June 22, 2018, 06:02:02 AM »
Thank you, Roland.

I will include this demo in examples\WideChars (formerly WideStrings)

asciiz2, zstring2 and wchar are the same type, and the o2 core string functions are aware of character width.

There are schemes for 32bit characters. It would be quite easy to support them, should they ever come into common use.
8
General / Using OxygenBasic with Unicode
« Last post by Arnold on June 22, 2018, 05:12:32 AM »
Hi Charles,

unicode strings seem to be a complicated subject. In the meantime I understand that MS Windows OS supports UTF-16 LE, that I can display all kind of characters in some text editors like Notepad or Wordpad, but that my possibilities for input via keyboard are limited and so I need other tricks to achieve this.

As Oxygen supports unicode strings I would like to investigate this feature a bit more and started some tests. I adapted examples\WinGui\HelloWin1.o2bas (without minwin) and it works quite nice:

Code: OxygenBasic
  1.   $ filename "HelloUnicode.exe"
  2.   'uses RTL32
  3.  'uses RTL64
  4.  
  5.   % CS_VREDRAW      1
  6.   % CS_HREDRAW      2
  7.   % IDI_APPLICATION 32512
  8.   % IDC_ARROW       32512
  9.   % WHITE_BRUSH      0
  10.   % SM_CXSCREEN      0
  11.   % SM_CYSCREEN      1
  12.   % WS_OVERLAPPEDWINDOW 0x00cf0000
  13.   % SW_SHOW             5
  14.   % WM_CLOSE            16
  15.   % WM_KEYDOWN          0x100
  16.   % WM_DESTROY          2
  17.   % SW_NORMAL           1
  18.   % WS_VISIBLE          0x10000000
  19.   % WS_CHILD            0x40000000
  20.   % WS_CHILDWINDOW      WS_CHILD
  21.    
  22.  
  23.   type POINT
  24.   long x
  25.   long y
  26.   end type
  27.  
  28.   '28 bytes
  29.  type MSG
  30.   sys   hwnd
  31.   int   message
  32.   sys   wParam
  33.   sys   lParam
  34.   dword time
  35.   POINT pt
  36.   end type
  37.  
  38.   '40 bytes
  39.  type WNDCLASS
  40.   int style
  41.   sys lpfnwndproc
  42.   int cbClsextra
  43.   int  cbWndExtra
  44.   sys hInstance
  45.   sys hIcon
  46.   sys hCursor
  47.   sys hbrBackground
  48.   sys lpszMenuName
  49.   sys lpszClassName
  50.   end type
  51.  
  52.   extern lib "Kernel32.dll"
  53.   ! GetCommandLine         "GetCommandLineW"      '0
  54.  ! GetModuleHandle        "GetModuleHandleW"     '1
  55.  end extern
  56.  
  57.   extern lib "User32.dll"
  58.   ! CreateWindowEx        "CreateWindowExW"       '12
  59.  ! DefWindowProc         "DefWindowProcW"        '4
  60.  ! DispatchMessage       "DispatchMessageW"      '1
  61.  ! GetClientRect                                 '2
  62.  ! GetMessage            "GetMessageW"           '4
  63.  ! GetSystemMetrics                              '1
  64.  ! LoadIcon              "LoadIconW"             '2
  65.  ! LoadCursor            "LoadCursorW"           '2
  66.  ! PostQuitMessage                               '1
  67.  ! RegisterClass         "RegisterClassW"        '1
  68.  ! SendMessage           "SendMessageW"          '4
  69.  ! SetWindowText         "SetWindowTextW"        '2  
  70.  ! ShowWindow                                    '2
  71.  ! TranslateMessage                              '1
  72.  ! UpdateWindow                                  '1
  73.  end extern
  74.  
  75.   extern lib "GDI32.dll"
  76.   ! GetStockObject                                '1
  77.  end extern
  78.  
  79.   declare function WinMain(sys inst, prevInst, asciiz2*cmdline, sys show) as sys
  80.   declare sub getwstrings()
  81.  
  82.   '=========
  83.  'MAIN CODE
  84.  '=========
  85.  
  86.   dim cmdline as asciiz2 ptr, hInstance as sys
  87.   @cmdline=GetCommandLine
  88.   hInstance=GetModuleHandle 0
  89.  
  90.   sys lbl[5]
  91.   wstring hellos[5]
  92.  
  93.   '
  94.  'WINDOWS START
  95.  '=============
  96.  '
  97.  WinMain hInstance,0,cmdline,SW_NORMAL
  98.   end
  99.  
  100.  
  101. function WinMain(sys inst, prevInst, asciiz2*cmdline, sys show) as sys
  102.  
  103.    WndClass wc
  104.    MSG      wm
  105.  
  106.    sys hwnd, Wwd, Wht, Wtx, Wty, Tax
  107. wstring classname="Demo"
  108.  
  109.    wc.style = CS_HREDRAW or CS_VREDRAW
  110.    wc.lpfnWndProc = @WndProc
  111.    wc.cbClsExtra =0
  112.    wc.cbWndExtra =0
  113.    wc.hInstance =inst
  114.    wc.hIcon=LoadIcon 0, IDI_APPLICATION
  115.    wc.hCursor=LoadCursor 0,IDC_ARROW
  116.    wc.hbrBackground = GetStockObject WHITE_BRUSH
  117.    wc.lpszMenuName =null
  118.    wc.lpszClassName = strptr classname
  119.  
  120.    RegisterClass (@wc)
  121.  
  122.    Wwd = 320 : Wht = 200
  123.    Tax = GetSystemMetrics SM_CXSCREEN
  124.    Wtx = (Tax - Wwd) /2
  125.    Tax = GetSystemMetrics SM_CYSCREEN
  126.    Wty = (Tax - Wht) /2
  127.  
  128.    hwnd = CreateWindowEx 0,wc.lpszClassName,  wstring("OXYGEN BASIC"),WS_OVERLAPPEDWINDOW,Wtx,Wty,Wwd,Wht,0,0,inst,0
  129.    lbl[1]=CreateWindowEx(0, wstring("static"), wstring("Hello World"),WS_CHILDWINDOW|WS_VISIBLE, 20, 10,200,25, hwnd,0,inst,0)
  130.    lbl[2]=CreateWindowEx(0, wstring("static"), "",WS_CHILDWINDOW|WS_VISIBLE, 20, 35,200,25, hwnd,0,inst,0)
  131.    lbl[3]=CreateWindowEx(0, wstring("static"), "",WS_CHILDWINDOW|WS_VISIBLE, 20, 60,200,25, hwnd,0,inst,0)
  132.    lbl[4]=CreateWindowEx(0, wstring("static"), "",WS_CHILDWINDOW|WS_VISIBLE, 20, 85,200,25, hwnd,0,inst,0)
  133.    lbl[5]=CreateWindowEx(0, wstring("static"), "",WS_CHILDWINDOW|WS_VISIBLE, 20,110,200,25, hwnd,0,inst,0)
  134.  
  135.    getwstrings()
  136.  
  137.    SetWindowText(lbl[2], hellos[4])   'Grecian      
  138.   SetWindowText(lbl[3], hellos[3])   'Japanese    
  139.   SetWindowText(lbl[4], hellos[2])   'Korean    
  140.   SetWindowText(lbl[5], hellos[1])   'Armenian          
  141.  
  142.    ShowWindow hwnd,SW_SHOW
  143.    UpdateWindow hwnd
  144.  
  145.    sys bRet
  146.    do while bRet := GetMessage (@wm, 0, 0, 0)
  147.      if bRet = -1 then
  148.        'show an error message
  149.     else
  150.        TranslateMessage @wm
  151.        DispatchMessage @wm
  152.      end if
  153.    wend
  154.  
  155. end function
  156.  
  157.  
  158. function WndProc ( hWnd, wMsg, wParam, lparam ) as sys callback
  159.  
  160.    select wMsg
  161.            
  162.       case WM_DESTROY
  163.          PostQuitMessage 0
  164.  
  165.       case WM_KEYDOWN
  166.          Select wParam
  167.             Case 27 : SendMessage hwnd, WM_CLOSE, 0, 0      'ESCAPE
  168.         End Select
  169.  
  170.       case else
  171.          function=DefWindowProc hWnd,wMsg,wParam,lParam
  172.  
  173.    end select
  174.  
  175. end function ' WndProc
  176.  
  177. sub getwstrings()
  178.    'very simple
  179.   int n=0
  180.    int p1=1, p2, le
  181.    wstring wcrlf=wchr(13)+wchr(10)
  182.  
  183.    wstring txt=(wstring) getfile "multi.txt"
  184.    if len(txt)=0 then mbox "Cannot load multi.txt"
  185.  
  186.    while 1
  187.      p2=instr(p1,txt, wcrlf)
  188.      if p2=0 then exit while
  189.      le=p2-p1+1
  190.      n+=1
  191.      hellos[n]=mid(txt,p1,le)
  192.      p1=p2+2     'wcrlf'
  193.   wend
  194. end sub
  195.  

There are two items where I am not sure:

In function WinMain I used: asciiz2* cmdline. Is this logic correct?
I had to use: wstring classname="Demo" in order to succeed with strptr classname. Does Oxygen support something similiar like wstrptr "Demo"?

My first impression is that functions like len, instr, mid work very well with wstrings.

Roland
9
Development / Re: Where is O2?
« Last post by John on June 21, 2018, 05:48:57 PM »
I think Charles made a good point when he said O2 will be what he wants it to be, nothing more or less.

I don't think O2 should try to be another PowerBASIC or any other past BASIC flavor. You best know the Windows API if you plan to use it in it's current form.

How do others feel about O2 offering compatibility with macros?
10
General / Re: The Redim Macro
« Last post by Arnold on June 21, 2018, 03:50:55 AM »
Thank you, Charles. I was confused because of s(101) which shows a curious output when using wstring. But s(101) is out of range and should not be used anyway.

Edit: I was totally wrong. I overlooked n=1000
Pages: [1] 2 3 ... 10