Author Topic: Late binding to DLL / Call DWORD equiv / (for Ray)  (Read 2213 times)

0 Members and 1 Guest are viewing this topic.

Mike Lobanovsky

  • Admin Support Member
  • *****
  • Posts: 1857
Re: Late binding to DLL / Call DWORD equiv / (for Charles)
« Reply #30 on: March 12, 2018, 07:19:36 PM »
... dreadfully mangled names in MSVCRT, they are clearly not intended for public use ...

Actually those are the C++ public exports I was referring to in my earlier messages here. :D

Quote
... they are an improvement on declare function, and pass through the compiler pronto ...

That's it!

Should you also agree to use type identifier prefixes rather than classic BASIC postfixes, OxygenBasic's parser may become the prontoest parser around. (after FBSL of course) :D
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, 2 x nVidia GTX 650Ti w/ 2GB VRAM, Windows 7 Ultimate Sp1)

Aurel

  • Sr. Member
  • ****
  • Posts: 277
Re: Late binding to DLL / Call DWORD equiv / (for Ray)
« Reply #31 on: March 12, 2018, 10:07:06 PM »
I don't know for you but I know what work for me and work fine
it is as I said VB way of declares .Also there are plenty of them on net.
Another thing ..i don't need unicode because o2 is ansi..
..all this talks reminds me that i must remove instruction bind from my include.

Arnold

  • Hero Member
  • *****
  • Posts: 677
Re: Late binding to DLL / Call DWORD equiv / (for Ray)
« Reply #32 on: March 13, 2018, 10:54:36 AM »
After searching in Internet for unicode I found a lot of explanations, definitions, tables and discussions, but no real working sample with exception of MASM32. Here I found the only examples which made sense to me. I took one of them and ported it to OxygenBasic.

To use unicode text I can use stringtables in a resource file, compile the .rc file with GoRC and link the .res file with LinkRes2Exe.exe to the executable. The resource file must be created as a unicode text file, which can be edited e.g. with WordPad.

And yes, to display the unicode text of the application I must use the "W" functions. I now know it is possible to use unicode with Oxygenbasic, but as I am not able to speak any of these languages, or can use the necessary keyboards, I will stay with Ansi and be happy.

I attached the necessary files to build the application. If the path of OxygenBasic is different, then in BuildMulti.bat o2dir must be adjusted, and in multi.rc (using at least Wordpad) the path for oxicon.ico must be corrected too.

Roland

Code: OxygenBasic
  1. '====================================================================
  2. ' Multi-lingual example, simple modal dialog as main.
  3. '====================================================================
  4. ' ported from MASM32 example to OxygenBasic
  5.  
  6. $ filename "Multi_lingual.exe"
  7.  
  8. 'use rtl32
  9. use rtl64
  10.  
  11. '% review
  12.  
  13. use corewin
  14.  
  15. uses dialogs
  16. 'namespace
  17.  
  18. % DS_CENTER=0x0800
  19. % WM_SETICON=128
  20.  
  21. ==============================================
  22.  
  23. 'MAIN CODE
  24. =============================================
  25.  
  26. 'dim nCmdline as asciiz ptr, hInstance as sys
  27. '&nCmdline = GetCommandLine
  28. hInstance = GetModuleHandle(NULL)
  29.  
  30. Init_common_controls()
  31.  
  32. function DialogProc( sys hDlg, uint uMsg, sys wParam, lParam ) as int callback
  33.  
  34.   wstring pbuf = space 260
  35.  
  36.   select case uMsg
  37.  
  38.     case WM_INITDIALOG
  39.        hStat0 = GetDlgItem(hDlg,1250)
  40.        hStat1 = GetDlgItem(hDlg,1251)
  41.        hStat2 = GetDlgItem(hDlg,1252)
  42.        hStat3 = GetDlgItem(hDlg,1253)
  43.        hStat4 = GetDlgItem(hDlg,1254)
  44.        hStat5 = GetDlgItem(hDlg,1255)
  45.        hStat6 = GetDlgItem(hDlg,1256)
  46.        hStat7 = GetDlgItem(hDlg,1257)
  47.        hStat8 = GetDlgItem(hDlg,1258)
  48.        hStat9 = GetDlgItem(hDlg,1259)
  49.        hStat10 =GetDlgItem(hDlg,1260)      
  50.  
  51.        SendMessage (hDlg, WM_SETICON,1, LoadIcon(hInstance,500))
  52.        
  53.        LoadStringW (hInstance,250,pbuf,260)
  54.        SetWindowTextW (hStat0,pbuf)
  55.  
  56.        LoadStringW (hInstance,251,pbuf,260)
  57.        SetWindowTextW (hStat1,pbuf)
  58.  
  59.        LoadStringW (hInstance,252,pbuf,260)
  60.        SetWindowTextW (hStat2,pbuf)
  61.  
  62.        LoadStringW (hInstance,253,pbuf,260)
  63.        SetWindowTextW (hStat3,pbuf)
  64.  
  65.        LoadStringW (hInstance,254,pbuf,260)
  66.        SetWindowTextW (hStat4,pbuf)
  67.  
  68.        LoadStringW (hInstance,255,pbuf,260)
  69.        SetWindowTextW (hStat5,pbuf)
  70.  
  71.        LoadStringW (hInstance,256,pbuf,260)
  72.        SetWindowTextW (hStat6,pbuf)
  73.  
  74.        LoadStringW (hInstance,257,pbuf,260)
  75.        SetWindowTextW (hStat7,pbuf)
  76.  
  77.        LoadStringW (hInstance,258,pbuf,260)
  78.        SetWindowTextW (hStat8,pbuf)
  79.  
  80.        LoadStringW (hInstance,259,pbuf,260)
  81.        SetWindowTextW (hStat9,pbuf)
  82.  
  83.        LoadStringW (hInstance,260,pbuf,260)
  84.        SetWindowTextW (hStat10,pbuf)
  85.        
  86.  
  87.     case WM_COMMAND
  88.       select case loword(wParam)
  89.         case IDCANCEL, IDOK
  90.            EndDialog( hDlg, null )
  91.       end select
  92.      
  93.     case WM_CLOSE
  94.       EndDialog( hDlg, null )
  95.                
  96.   end select
  97.  
  98.   return 0
  99. end function
  100.  
  101. sub winmain()
  102.  
  103.   sys lpdt
  104.  
  105.   'provide memory for DLGTEMPLATE structure etc    
  106. '  dyn::init(lpdt,nBytes)
  107.  dyn::init(lpdt,5000) '1024
  108.  
  109.   Dialog( 23,  10,10,360,183, "Multi-Lingual Support", lpdt,
  110.           WS_VISIBLE|WS_CAPTION|WS_SYSMENU|DS_CENTER or DS_SETFONT,
  111.           8,"MS Sans Serif" )
  112.   CONTROL "Chinese : ",1000,"Static",WS_CHILDWINDOW|WS_VISIBLE|SS_RIGHT,18,14,56,10
  113.   CONTROL "Japanese : ",1001,"Static",WS_CHILDWINDOW|WS_VISIBLE|SS_RIGHT,18,26,56,10
  114.   CONTROL "Russian : ",1002,"Static",WS_CHILDWINDOW|WS_VISIBLE|SS_RIGHT,18,38,56,10
  115.   CONTROL "Greek : ",1003,"Static",WS_CHILDWINDOW|WS_VISIBLE|SS_RIGHT,18,50,56,10
  116.   CONTROL "Hindi : ",1004,"Static",WS_CHILDWINDOW|WS_VISIBLE|SS_RIGHT,18,62,56,10
  117.   CONTROL "Vietnamese : ",1005,"Static",WS_CHILDWINDOW|WS_VISIBLE|SS_RIGHT,18,74,56,10
  118.   CONTROL "Georgian : ",1006,"Static",WS_CHILDWINDOW|WS_VISIBLE|SS_RIGHT,18,86,56,10
  119.   CONTROL "Serbian : ",1007,"Static",WS_CHILDWINDOW|WS_VISIBLE|SS_RIGHT,18,98,56,10
  120.   CONTROL "Armenian : ",1008,"Static",WS_CHILDWINDOW|WS_VISIBLE|SS_RIGHT,18,110,56,10
  121.   CONTROL "Korean : ",1009,"Static",WS_CHILDWINDOW|WS_VISIBLE|SS_RIGHT,21,123,56,10
  122.   CONTROL "English:",1010,"Static",WS_CHILDWINDOW|WS_VISIBLE|SS_RIGHT,18,136,56,10
  123.   CONTROL "Chinese",1250,"Static",WS_CHILDWINDOW|WS_VISIBLE,76,14,268,10
  124.   CONTROL "Japanese",1251,"Static",WS_CHILDWINDOW|WS_VISIBLE,76,26,268,10
  125.   CONTROL "Russian",1252,"Static",WS_CHILDWINDOW|WS_VISIBLE,76,38,268,10
  126.   CONTROL "Greek",1253,"Static",WS_CHILDWINDOW|WS_VISIBLE,76,50,268,10
  127.   CONTROL "Hindi",1254,"Static",WS_CHILDWINDOW|WS_VISIBLE,76,62,268,10
  128.   CONTROL "Vietnamese",1255,"Static",WS_CHILDWINDOW|WS_VISIBLE,76,74,268,10
  129.   CONTROL "Georgian",1256,"Static",WS_CHILDWINDOW|WS_VISIBLE,76,86,268,10
  130.   CONTROL "Serbian",1257,"Static",WS_CHILDWINDOW|WS_VISIBLE,76,98,268,10
  131.   CONTROL "Armenian",1258,"Static",WS_CHILDWINDOW|WS_VISIBLE,76,110,268,10
  132.   CONTROL "Korean",1259,"Static",WS_CHILDWINDOW|WS_VISIBLE,78,123,268,10
  133.   CONTROL "English",1260,"Static",WS_CHILDWINDOW|WS_VISIBLE,78,136,268,10
  134.   CONTROL "OK",IDOK,"Button",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP,288,156,56,14
  135.  
  136.   CreateModalDialog( null, @DialogProc, 0, lpdt )
  137. end sub
  138.  
  139. winmain()
  140.  

Mike Lobanovsky

  • Admin Support Member
  • *****
  • Posts: 1857
Re: Late binding to DLL / Call DWORD equiv / (for Arnold)
« Reply #33 on: March 13, 2018, 12:04:30 PM »
Roland,

Your Russian translation reads literally "The programmer is best in the morning" but I got the idea. Good morning to you too, colleague! :D

Thanks for sharing this working example and walking an extra mile to prove once again OxygenBasic is alive and kicking! :)
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, 2 x nVidia GTX 650Ti w/ 2GB VRAM, Windows 7 Ultimate Sp1)

Charles Pegge

  • Admin Support Member
  • *****
  • Posts: 3751
    • Oxygen Basic
Re: Late binding to DLL / Unicode min demo
« Reply #34 on: March 13, 2018, 09:04:39 PM »
Many thanks, Roland. I would like to include your demo in WinDynDialogs.

Here is a minimal demo:

note the casting on Getfile. It is only byte-aware.

Code: [Select]
'2018-03-14 T 04:10:15
'UNICODE LOADING AND DISPLAY
% filename "t.exe"
'use rtl64
use corewin
wstring ws
ws=(wstring) getfile "t.txt"
messageboxW 0,ws,"",0
'
'EXAMINE UNICODING
word ww at strptr ws
string t
for i=1 to 512
  t+=hex(ww[i],4)+"  "
next
print t

Mike Lobanovsky

  • Admin Support Member
  • *****
  • Posts: 1857
Re: Late binding to DLL / Unicode min demo
« Reply #35 on: March 14, 2018, 01:25:04 AM »
I would like to include your demo in WinDynDialogs.

Good morning, computer programmers!

If you decide to add the demo to the distro, please use the following Russian demo string:

Доброе утро, программист!  (and note the punctuation)

It says exactly what its English equivalent does.
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, 2 x nVidia GTX 650Ti w/ 2GB VRAM, Windows 7 Ultimate Sp1)

Arnold

  • Hero Member
  • *****
  • Posts: 677
Re: Late binding to DLL / Call DWORD equiv / (for Ray)
« Reply #36 on: March 14, 2018, 02:03:46 AM »
Hi Mike,

I only copied the text to Google translator and checked if the characters looked similar and I have no idea if the translation was correct in each case. I always was jealous of the people in my neighborhood who grew up multilingual. For me it is already difficult to learn only the alphabet of these languages. Maybe I will try Esperanto.

Roland

Mike Lobanovsky

  • Admin Support Member
  • *****
  • Posts: 1857
Re: Late binding to DLL / Call DWORD equiv / (for Arnold and Jose)
« Reply #37 on: March 14, 2018, 03:55:39 AM »
Hi Roland,

I wasn't trolling. I was rather encouraging you to continue your explorations. I like to watch, and I appreciate, your unfailing perseverance in attaining your goals. :)

Be forewarned however that, despite Jose's reasoning, there are two inarguable facts (sorta natural phenomena) that should be taken into account:
  • Below is a snapshot of what similar exercises in Unicode by Johen (MasmBasic author) would look like under a typical "clean" American installation of Windows 7+ (no localization packs; LCID=1033 only). There are only too many US residents who aren't really aware that there is no such thing as a globe of the United States. And I am not sure either if chrisc, so far apparently the only owner of a Canadian geotag on this site, realizes he might well be living on a territory that formerly used to be part of the Russian Empire. :)

  • Those people who are still using Win2K through WinXP Sp3 coding environments for whatever reason (nostalgia, backward compatibility verification (FBSL v3.5 binaries run on anything from W'95 OSR2 up to Win 10), greedy employer, etc.) should avoid naming their files in their national Unicode char sets. Unicode support under those OSes is partial, and failure to do so may cause harm to their NTFS disk partitions.
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, 2 x nVidia GTX 650Ti w/ 2GB VRAM, Windows 7 Ultimate Sp1)

Charles Pegge

  • Admin Support Member
  • *****
  • Posts: 3751
    • Oxygen Basic
Re: Late binding to DLL / Unicode source code
« Reply #38 on: March 14, 2018, 09:43:13 AM »
I'll investigate the feasability of using unicode source code in o2. You could have variable names in greek, or even  Cyrillic :).  It opens up new possibilities

John

  • Hero Member
  • *****
  • Posts: 3280
Re: Late binding to DLL / Call DWORD equiv / (for Ray)
« Reply #39 on: March 14, 2018, 11:23:43 AM »
Languages of the internet

English  (27.3%)
Chinese (22.6%)
Spanish (7.8%)
Japanese (5.3%)
Portuguese (4.3%)
German (4.0%)
Arabic   (3.3%)
French  (3.2%)
Russian (2.5%)
Korean (2.1%)


Mike Lobanovsky

  • Admin Support Member
  • *****
  • Posts: 1857
Re: Late binding to DLL / Call DWORD equiv / (for John and Charles)
« Reply #40 on: March 14, 2018, 12:40:42 PM »
John,

If we however re-evaluate this list from the business perspective of a commercial project and customer solvency, we may as well forget anything that comes below Item #1. So no wonder PB Inc. couldn't care less for Unicode. ;)

You could have variable names in ... Cyrillic :).  It opens up new possibilities

Oh no, not again! There's the so called 1C:Enterprise business management software package on the Russian market that's in fact their own "strategic" alternative to such US packages as SAP or Sage. Its client side scripting is implemented as a Russian-only "visual basic". I used to do a lot of that stuff in my greener years, and frankly, I've never seen more weird and cryptic code ever since.

Matter is, a non-native English programmer (including me) never perceives an ordinary programming language's vocab as anything humanly meaningful. That's just a set of conventional cryptic symbols or tokens one has to learn by heart to denote certain actions the computer is supposed to perform. The same regards var names, equates, common abbreviations, metadata etc.

But when I see code written totally in Russian, first I'd shake my head to drive away the delusion, then I'd wipe my glasses, and then I'd burst with laughter at Russian imperative Do/Loop's, While/Wend's, IIf's and End If's. ;D

My deepest condolences and sympathy to my English speaking friends being forced to do this every single day of their lives. ;D
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, 2 x nVidia GTX 650Ti w/ 2GB VRAM, Windows 7 Ultimate Sp1)

Charles Pegge

  • Admin Support Member
  • *****
  • Posts: 3751
    • Oxygen Basic
Re: Late binding to DLL / Unicode source code
« Reply #41 on: March 14, 2018, 02:30:36 PM »
Perhaps extending the repertoire of symbols available for use. After all, Physicists and Mathematicians, like to use their own special symbols. Another advantage would be to express unicode string literals directly in the source code.

Creating a few mockups would help to explore the idea.

Arnold

  • Hero Member
  • *****
  • Posts: 677
Re: Late binding to DLL / Call DWORD equiv / (for Ray)
« Reply #42 on: March 15, 2018, 02:31:28 AM »
Hi Charles,

I agree with Mike. There should be no special need for coding in unicode. I always used ascii or ansi but was never aware of this. With my code editor (PSPad) I can save the code in several formats and I tried this with a small c program:
Compiling using gcc 4.8.1 / tcc 0.9.27 worked with ansi, oem, iso 8859-2, utf-8, it failed with utf-16 LE, utf-16 BE. I get the same results when running .o2bas files. Therefore I think Oxygen is compliant with other programming languages. And your Unicode min demo and examples\WideStrings\ReadUnicode.o2bas is already very helpful to see the principles of using unicode. And I noticed there are several libraries available if there would be full unicode support required. (I suppose I will never need them)

Roland

Charles Pegge

  • Admin Support Member
  • *****
  • Posts: 3751
    • Oxygen Basic
Re: Late binding to DLL / Unicode source code
« Reply #43 on: March 15, 2018, 04:38:47 AM »
Thank you both.

From my insider point of view, converting to direct unicode source compiling would be quite disruptive. The best way of dealing with unicode source would be to create a front-end counterpart of co2, a uco2.

This would be the most efficient way to implement other dialects of Basic, and other experimental languages.