Oxygen Basic

Information => Introducing Oxygen => Topic started by: John on January 26, 2017, 10:04:00 AM

Title: Re: PowerBasic equivalents and conversions
Post by: John on January 26, 2017, 10:04:00 AM
Welcome aboard ChrisC,

It would be great if you could convince some of your other Power(less)BASIC friends to join you on your OxygenBasic adventures.
Title: Re: Re: PowerBasic equivalents and conversions
Post by: Charles Pegge on January 28, 2017, 04:39:52 AM

Hi Chris,

I have not used PowerBasic in the last ten years, so I am a little rusty, but Oxygen Basic has the core essential subset of PB functions from which all others can be derived.

If you post some key pieces of PowerBasic source code, we could show how it can be translated into O2.  This could form the basis for a PBtoO2 transitional manual.
Title: Re: Re: PowerBasic equivalents and conversions
Post by: chrisc on January 29, 2017, 03:31:31 PM
Thanks Charles and John

I have attached a powerbasic  ListView with Statusbar example for you to convert to O2.

In regards to getting people to change over to O2, I will writing to those PB forum members who are
interested to change over. They are some who live by self denial and heads in the sand ones, which
I would just ignore.

Appreciate your help.

Title: Re: Re: PowerBasic equivalents and conversions
Post by: chrisc on January 29, 2017, 03:46:55 PM
A simple Menu bar program in PowerBasic

Title: Re: Re: PowerBasic equivalents and conversions
Post by: chrisc on January 29, 2017, 03:55:23 PM
THis is a PowerBasic program which build up a number array and to use PowerBasic Array scan
command to search for the array index matching a given number 15
Title: Re: Re: PowerBasic equivalents and conversions
Post by: chrisc on January 29, 2017, 04:00:54 PM
This is a Powerbasic Function to Split a given string  to form  an array

Title: Re: Re: PowerBasic equivalents and conversions
Post by: John on January 29, 2017, 07:46:47 PM
Array Split

Code: [Select]
'  Array split
'  https://www.powerbasic.com/support/pbforums/showthread.php?t=17642
 '  Function to Split a given string  to form  an array

#COMPILE EXE

GLOBAL Tmp() AS  STRING

FUNCTION PBMAIN() AS LONG
   DIM Kount AS LONG
   DIM jj AS LONG
   DIM Ast AS STRING

  ' When there are inbetween blank spaces in a string which
  ' are unwanted, we use a SHRINK statement
   Ast = "Hello, world, What, a,  Nice, day, outside,  My,  Window "

   ArSplit( Ast, ",",Kount )

  ' prints out the array contents
   OPEN "arOut.txt" FOR OUTPUT  AS #3
    FOR  jj = 1 TO Kount
        PRINT #3, jj, Tmp(jj)
    NEXT jj
    CLOSE #3

    MSGBOX "done"

END FUNCTION

'=====================================
 '  Split a given string to form an array
SUB ArSplit( GivenSt AS STRING, Delimit$ ,Cnt AS LONG )
   LOCAL  Strt, i AS LONG
   'get rid of inbetween blanks first
    GivenSt = TRIM$(GivenSt)
    GivenSt = SHRINK$(GivenSt)
    Cnt = PARSECOUNT(GivenSt, Delimit$)
    REDIM Tmp(1 TO Cnt&)

    Strt& = 1
    FOR i& = 1 TO Cnt&
        Tmp(I&) = TRIM$(EXTRACT$(Strt&, GivenSt, Delimit$))
        Strt& = INSTR(Strt&, GivenSt, Delimit$) + 1
    NEXT
END SUB

Here is my attempt at your function in Script BASIC.

Code: Script BASIC
  1. Ast = "Hello, world, What, a,  Nice, day, outside,  My,  Window "
  2.  
  3. SPLITA Ast BY "," TO AstArray
  4.  
  5. OPEN "ArraySplitOut.txt" FOR OUTPUT  AS #1
  6. FOR x = 0 to UBOUND(AstArray)
  7.   PRINT #1, x, "\t",TRIM(AstArray[x]),"\n"
  8. NEXT
  9. CLOSEALL
  10.  


jrs@jrs-laptop:~/PB/Ar split$ time scriba ArraySplit.sb

real   0m0.025s
user   0m0.004s
sys   0m0.000s
jrs@jrs-laptop:~/PB/Ar split$ cat ArraySplitOut.txt
0   Hello
1   world
2   What
3   a
4   Nice
5   day
6   outside
7   My
8   Window
jrs@jrs-laptop:~/PB/Ar split$


I'm looking forward to seeing the OxygenBasic version posted.


Title: Re: Re: PowerBasic equivalents and conversions
Post by: chrisc on January 29, 2017, 10:18:08 PM
I have attached  2 files describing how to convert from PowerBasic to PureBasic.
Perhaps these documents can form the basis of converting from PowerBasic to O2

Note that syntax of PureBasic is awkward like they DO NOT have a For Loop and things like

DIM  jkount as long    becomes   Dim jkount.l

These are the syntax, we found difficult to convert to PureBasic,  it is a put off for us Basic programmers
Title: Re: Re: PowerBasic equivalents and conversions
Post by: chrisc on January 29, 2017, 10:19:12 PM
This is the pdf file
Title: Re: Re: PowerBasic equivalents and conversions
Post by: Aurel on January 29, 2017, 11:21:15 PM
Interesting examples for me
and i like to try convert to o2 using awinh, purebasic is not so problematic
because i have some experience with that basic,, ;D
well i forget add ListView control into my include file so i need to do
first something like this :/first i must translate this code to o2/
dLib code:

Code: [Select]
Declare _lvleft,_lvinit,LV_ITEM,LV_COLUMN

Structure Listviewcolumn
    cmask.l
    cfmt.l
    ccx.l
    cpszText.l
    ccchTextMax.l
    ciSubItem.l
EndStructure

Structure Listviewitem
    mask.l
    iItem.l
    iSubItem.l
    state.l
    stateMask.l
    pszText.l
    cchTextMax.l
    iImage.l
    lParam.l
EndStructure

Procedure FirstListViewInit()
  StructMemory LV_ITEM.Listviewitem
  StructMemory LV_COLUMN.Listviewcolumn
  _lvinit=1
EndProcedure

ProcedureLib CreateListView(_lvhwnd,_lvx,_lvy,_lvw,_lvh,_lvstring.s,_lvcwidth,_lvflag,_ex)
  Declare _lvhandle
  If _lvinit=0
    FirstListViewInit()
  EndIf
  _lvhandle = CreateWindowEx(_ex,"SysListView32","",_lvflag,_lvx,_lvy,_lvw,_lvh,_lvhwnd,0,0,0)
  LV_COLUMN\cmask=#LVCF_FMT|#LVCF_TEXT|#LVCF_WIDTH
  LV_COLUMN\cfmt=#LVCFMT_LEFT
  LV_COLUMN\ccx=_lvcwidth
  LV_COLUMN\cpszText=_lvstring
  SendMessage(_lvhandle,#LVM_INSERTCOLUMN,0,LV_COLUMN)
  GetAsyncKeyState(#VK_LBUTTON)
  ProcedureReturn _lvhandle
EndProcedure

..one thing i am not sure is do i must use typedef struct in listviewInit like :
'init ListView....
Function FirstListViewInit()
  typedef struct LV_ITEM.Listviewitem
  typedef struct LV_COLUMN.Listviewcolumn
  _lvinit=1
End Function

hmm ..i must check VB version  ;D
Title: Re: Re: PowerBasic equivalents and conversions
Post by: Aurel on January 31, 2017, 05:33:23 AM
ok like this for start,,,
next few more functions to work with ListView and add checkboxes or icons into columns
Code: [Select]
  $ Filename "skeleton.exe" ' o2
include "RTL32.inc"
include "awinh.inc"
INT win,wx=0,wy=0,ww=600,wh=400,wstyle = WS_MINMAXSIZE
INT button0,b0ID=100, lvControl,lvID=1000
win=SetWindow("GUI-PB->o2::ListView",wx,wy,ww,wh,0,wstyle)
'create button----------------------------------------------------------
button0 = SetButton(win,180,4,80,26,"Close (X)",0x50001000,0x200,b0ID)
'create List view------------------------------------------------------
lvControl = SetListView(win, 20, 40, 300, 220, "ListView Control", 200,1417740297 ,0x200)
'----------------------------------------------------------------------
Wait()  'message loop
'----------------------------------------------------------------------
'func main
Function WndProc (sys hwnd,wmsg,wparam,lparam) as sys callback
SELECT hwnd
CASE win
Select wmsg
CASE WM_CLOSE
CloseWindow(win)
EndProgram
End Select
END SELECT
RETURN Default
END FUNCTION
Title: Re: Re: PowerBasic equivalents and conversions
Post by: Charles Pegge on February 01, 2017, 03:16:49 AM
Thanks Chris.

Here is a light-touch translation of your first example Array Scan

I have commented out incompatible PB lines with 2 quote marks

For JIT execution you can omit the 3 lines used for creating the 64 bit exe file.

ArrayScan64.exe survives all but one of the VirusTotal.com scans. (Invincea)

Code: [Select]
''#COMPILE EXE
''#DIM ALL

'
% filename    "ArrayScan64.exe"
includepath "$\inc\"
include "RTL64.inc"

#lookahead
indexbase 1

''GLOBAL Arr() AS LONG
GLOBAL Arr(100) AS LONG


FUNCTION PBMAIN () AS LONG
    LOCAL AnyElem AS LONG

        ''REDIM Arr(1 TO 100)
       
        Arr(1) = 5
        Arr(2) = 15
        Arr(3) = 25
        Arr(4) = 35
        Arr(5) = 45
        Arr(6) = 55
        Arr(12) = 105
        Arr(16) = 155
        Arr(26) = 515

       AnyElem = FindElemArray(15)

       ''MSGBOX " AnyElem " + STR$(AnyElem)
       MBOX " AnyElem " + STR(AnyElem)

END FUNCTION

'===========================
' Find an element in array
' matching the wanted number wnum
FUNCTION FindElemArray(wnum AS LONG) AS LONG
   LOCAL I&
   I& = 0
   ''ARRAY SCAN Arr(),= wnum , TO I&
   ArrayScan(wnum,I)
   FUNCTION = I&
END FUNCTION

'''Extra Functions

sub ArrayScan(n as long, r as long)
  'Assumes Arr is a static array
  for i=1 to spanof Arr
    if Arr(i)=n then r=i : return
  next
end sub

'''Main Call
PBMAIN()
Title: Re: Re: PowerBasic equivalents and conversions
Post by: Aurel on February 02, 2017, 04:13:42 AM
...new functions added
so far seems that all work solid..even i have few o2 quirks  :D

Code: [Select]
  $ Filename "ListView.exe" ' o2
include "RTL32.inc"
include "awinh.inc"
INT win,wx=0,wy=0,ww=600,wh=400,wstyle = WS_MINMAXSIZE
INT button0, b0ID=100, lvControl, lvID = 1000 , static1, st1ID = 500
'create window =======================================================
win = SetWindow("GUI-PB->o2::ListView",wx,wy,ww,wh,0,wstyle)
'=====================================================================
'create static control -----------------------------------------------
static1 = SetStatic(win,20,10,240,13,"ListView Control in Oxygen Basic - by Aurel",0,0,st1ID)
'crete button---------------------------------------------------------
button0 = SetButton(win,300,4,80,26,"Close (X)",0x50001000,0x200,b0ID)

'create List view----------------------------------------------------------------
lvControl = SetListView (win, 20, 40, 400, 220, "Column_1", 200, 1417740297 ,0x200,lvID)

'add new column to listView -> {AddLVC hwnd, pos, width , text, flag}-----------
AddListViewColumn (lvControl, 2, 200,"Column_2",0 )

'add listview item {AddLVI hwnd, pos, text, icon} -> column 0 - zero based ----
AddListViewItem (lvControl, 0, "Text 1- Oxygen Basic", 0)
AddListViewItem (lvControl, 1, "Text 2- Oxygen Basic", 0)
AddListViewItem (lvControl, 2, "Text 3- Oxygen Basic", 0)
AddListViewItem (lvControl, 3, "Text 4- Oxygen Basic", 0)
AddListViewItem (lvControl, 4, "Text 5- Oxygen Basic", 0)
AddListViewItem (lvControl, 5, "Text 6- Oxygen Basic", 0)
'add second column item -  AddLVSI{hwnd,pos,sub,text) -> column 1 -second column

AddListViewSubItem (lvControl,0, 1, "Text 0 - Power Basic")
AddListViewSubItem (lvControl,1, 1, "Text 1 - Power Basic")
AddListViewSubItem (lvControl,2, 1, "Text 2 - Power Basic")
AddListViewSubItem (lvControl,3, 1, "Text 3 - Power Basic")
AddListViewSubItem (lvControl,4, 1, "Text 4 - Power Basic")
AddListViewSubItem (lvControl,5, 1, "Text 5 - Power Basic")


'----------------------------------------------------------------------
Wait()  'message loop
'----------------------------------------------------------------------
'func main
Function WndProc (sys hwnd,wmsg,wparam,lparam) as sys callback
SELECT hwnd
CASE win
Select wmsg
CASE WM_CLOSE
CloseWindow(win)
EndProgram
End Select
END SELECT
RETURN Default
END FUNCTION
Title: Re: Re: PowerBasic equivalents and conversions
Post by: John on February 02, 2017, 09:17:44 AM
For those interested, PowerBASIC (https://forum.powerbasic.com/forum/announcements-articles-and-support-faqs/product-announcements/757277-powerbasic-has-a-new-home#post757277) has been sold.

Title: Re: Re: PowerBasic equivalents and conversions
Post by: Aurel on February 02, 2017, 09:42:22 AM
Point of this topic is conversion from pb to o2 ...right?
Second i don't believe in bright future of powerBasic simply
because there is no users or customers for such a thing .
Title: Re: Re: PowerBasic equivalents and conversions
Post by: Charles Pegge on February 03, 2017, 03:46:49 AM
Good decision for Drake Software - adopting PowerBasic on which it critically depends.

Quote
Drake Software: Established 1977; Employees – 325+; Each year, Drake processes more than 26 million federal and state accepted returns.

Quote
Future Path - We use PB in our own product that we distribute to over 50,000 tax offices in the USA. So we intent for PB to be around for a long time. (And that will include new features and new releases - but that will come in time).
Title: Re: Re: PowerBasic equivalents and conversions
Post by: Charles Pegge on February 03, 2017, 04:06:35 AM

Array Split

I've rewritten the array splitting function, and cheated by using a static array.

Code: [Select]
'  Array split
'  https://www.powerbasic.com/support/pbforums/showthread.php?t=17642
'  Function to Split a given string  to form  an array

''#COMPILE EXE
''#DIM ALL

'
'% filename    "ArraySplit64.exe"
'includepath "$\inc\"
'include "RTL64.inc"

#lookahead
indexbase 1

% msgbox mbox

''GLOBAL Tmp() AS  STRING
GLOBAL Tmp(16000) AS  STRING

FUNCTION PBMAIN() AS LONG
   DIM Kount AS LONG
   DIM jj AS LONG
   DIM Ast AS STRING

  ' When there are inbetween blank spaces in a string which
  ' are unwanted, we use a SHRINK statement
   Ast = "Hello, world, What, a,  Nice, day, outside,  My,  Window "

   ArSplit( Ast, ",",Kount )


  ' prints out the array contents
   ''OPEN "arOut.txt" FOR OUTPUT  AS #3
    local output as string
    FOR  jj = 1 TO Kount
        ''PRINT #3, jj, Tmp(jj)
        output += str(jj)+chr(9)+tmp(jj)+chr(13,10)
    NEXT jj
    ''CLOSE #3
    putfile("ArOut.txt",output)

    MSGBOX "done"
END FUNCTION

sub ArSplit( GivenSt AS STRING, Delimit$ AS STRING ,Cnt AS LONG)
  local byref b as byte
  @b=strptr(GivenSt)
  local d as byte
  d=asc(Delimit$)
  local i,j,e,bg,as long
  bg=1
  for i=1 to len(GivenSt)+1
    select b(i)
    case 0,d
      j+=1
      tmp(j)=ltrim(rtrim(mid(GivenSt,bg,i-bg)))
      bg=i+1
      Cnt+=1
    end select
  next
end sub


'=====================================
 '  Split a given string to form an array
''SUB ArSplit( GivenSt AS STRING, Delimit$ ,Cnt AS LONG )
''   LOCAL  Strt, i AS LONG
''   'get rid of inbetween blanks first
''    GivenSt = TRIM$(GivenSt)
''    GivenSt = SHRINK$(GivenSt)
''    Cnt = PARSECOUNT(GivenSt, Delimit$)
''    REDIM Tmp(1 TO Cnt&)
''
''    Strt& = 1
''    FOR i& = 1 TO Cnt&
''        Tmp(I&) = TRIM$(EXTRACT$(Strt&, GivenSt, Delimit$))
''        Strt& = INSTR(Strt&, GivenSt, Delimit$) + 1
''    NEXT
''END SUB

PBMAIN()
Title: Re: Re: PowerBasic equivalents and conversions
Post by: Arnold on February 03, 2017, 04:25:35 AM
Hi Chris,

attached are the project files for my solution of LV Statusbar and an executable + dll for Win 64-bit. The included batch file will create a dll for 32-bit, to create a 32bit executable of LV StatusBar the line:
' executable("LV_StatusBar.exe",32)
must be uncommented in LV StatusBar.o2bas.

I do not know Powerbasic and I am not used to the syntax. But it seems that your program uses memory based dialog templates. This could be done with Oxygen too, but will need a lot of work - see e.g. CreateDialogInderect macro in Win32 Help File. Instead I created resources in a .rc file with help of Resed.exe.

Do you recognize how I tried to implement Powerbasic statements? The app does not achieve all the things your program does, but at some stage a function library would be necessary for this kind of program. This is without doubt the strength of languages like C, Powerbasic or Purebasic which already include such libraries. But I think this was not the main purpose for Charles when he developed OxygenBasic.

I found if I minimize your program and restore it again the listview has disappeared. Also the listview is not adjusted when changing the size of the window.

Charles@ - I noticed that I must use:
int LVN_ITEMCHANGED = -101  ' % does not work in Win64
int NM_CLICK = -2  ' % does not work in Win64
for Win32 I can use % instead of int.

I also noticed that for Win64 I must use:
      sys l=loword(lParam), h=hiword(lParam)-20
      MoveWindow(hListview,0, 0, l, h, true)
'      MoveWindow(hListview,0, 0, loword(lParam), hiword(lParam)-20, true)
For Win32 I can use the commented statement.

Roland
Title: Re: Re: PowerBasic equivalents and conversions
Post by: Aurel on February 03, 2017, 05:06:01 AM
Arnold or Roland
You must know one important thing that you cannot replace
include file - you called libraries with resources.
resources are resources and include files or headers are different thing.
ListView as any other native windows common controls can be used
in a way I present here in my example ..
of course you or anyone else can tweak this functions to your needs if you have
enough knowlege or experience.
So i don't see any problem with that ..
and why complicate things using statusbar.dll + mainwin.inc   :o
Just look at a joseRoca huge windows headers which cover most of windows
centric programming with Power Basic.
Title: Re: Re: PowerBasic equivalents and conversions
Post by: Arnold on February 03, 2017, 08:10:03 AM
Hi Aurel,

I am not sure if I understood everything you mentioned. But maybe you read this link about the purpose of resource files:
https://msdn.microsoft.com/de-de/library/windows/desktop/aa380599(v=vs.85).aspx (https://msdn.microsoft.com/de-de/library/windows/desktop/aa380599(v=vs.85).aspx)

What I have seen from the Powerbasic code I assume that the app uses resources which are created in memory during execution and need some more work to implement the necessary functions / structures. I use resources which are created with a resource file script which can be compiled and linked to a dll or exe file.
You create controls/resources via CreateWindow(ex) which is perfectly ok. So I look forward to your solution.

Roland
Title: Re: Re: PowerBasic equivalents and conversions
Post by: Aurel on February 03, 2017, 08:37:24 AM
And again...
I REPEAT :
Windows API functions are NOT resources and include files are NOT resources.
Using header or include files are most common or usual way to create wrapper
functions in many languages and also in Oxygen Basic too.
Resources are :
bitmaps
icons
strings
manifest
etc..etc..
My way is not unusual than standard way to do this things .
So really dont se reason to use .rc files for that .
Title: Re: Re: PowerBasic equivalents and conversions
Post by: John on February 03, 2017, 12:08:50 PM
Charles,

Your O2 array split required few changes. Motivation that you're not locked into PowerBASIC.

FYI - If you didn't get your free legacy version of PowerBASIC, it sounds like the new owners are terminating that offer. Everything should have a price tag is what I'm hearing.


Title: Re: Re: PowerBasic equivalents and conversions
Post by: Charles Pegge on February 04, 2017, 03:40:38 AM

Hi Roland,

Thanks for your listview demo. Negative number  % definitions appear to encode correctly in 64 bit, so I will need to run some more tests.

Hi John,

I have PBWin 9. I assume functions like SHRINK$ and PARSECOUNT$ are in version 10.


My array splitter works in a per-byte single pass, could be adapted quite easily for ascii-delimited splitting.

Code: [Select]
sub ArSplit( GivenSt AS STRING, Delimit$ AS STRING ,Cnt AS LONG)
  local byref b as byte
  @b=strptr(GivenSt)
  local d as byte
  d=asc(Delimit$)
  local i,j,bd,be as long
  for i=1 to len(GivenSt)+1
    select b(i)
    case 0,d
      j+=1
      if bd then tmp(j)=mid(GivenSt,bd,be-bd+1) else tmp(j)=""
      bd=0
      Cnt+=1
    case 1 to 32
      'ignore white space
    case else
      if bd=0 then bd=i 'ltrim position
      be=i 'rtrim position
    end select
  next
end sub
Title: Re: Re: PowerBasic equivalents and conversions
Post by: John on February 04, 2017, 11:40:43 AM
Quote from: Charles
I have PBWin 9. I assume functions like SHRINK$ and PARSECOUNT$ are in version 10.

Do you think it would be worth while to create a PowerBASIC .inc for OxygenBasic of functions, workarounds, fixes, ... specific to PowerBASIC? (all versions PBWin / PBCC)

Quote from: Steve Hutchesson
I chuckle at the range of suggestions, porting an existing compiler written in assembler to 64 bit is a pipe dream from folks who don't write assembler. I would bet good money that a 64 bit version of PB will be an entirely new tool. I would wish Adam and Co the best in the direction they end up going in allowing that we have already been told that they will proceed carefully to make sure they get the results right.

I think it would take less time to make O2 PB compatible and 64 bits before PowerBASIC Inc. gets around to 64 bits.
Title: Re: Re: PowerBasic equivalents and conversions
Post by: Charles Pegge on February 05, 2017, 02:07:28 AM

Yes John, PowerBasic.inc could include both macros and functions specific to PB. But we still have the problem of PB specifics like Dialog Create, and Menu Add, not to mention the COM system in PB 10.


re PB 64 bit versions: From my own experience with OxygenBasic. About 15% of the codebase would have to be rewritten, mainly the run-time libraries. So the task is not overwhelming. Adam Drake mentioned that the PB source is about 100,000 lines of Asm in all.

Title: Re: Re: PowerBasic equivalents and conversions
Post by: John on February 05, 2017, 08:54:16 AM
Quote
But we still have the problem of PB specifics like Dialog Create, and Menu Add, not to mention the COM system in PB 10.

I'm not suggesting that DDT be ported to O2. Most PowerBASIC programmers prefer to call the Windows API rather than Zale's wrapper for it. You already have a start with COM with the work you put into DLLC. There may be something usable from Dave's Script BASIC COM efforts that might make the iDispatch side easier for BASIC users to work with.

José Roca has provided a wealth of functionality to PowerBASIC and would be a big plus if his includes could be used by OxygenBasic.
Title: Re: Re: PowerBasic equivalents and conversions
Post by: Aurel on February 05, 2017, 01:39:37 PM
Jose Roca includes cannot be used with Oxygen Basic without modification of such a large files.
Title: Re: Re: PowerBasic equivalents and conversions
Post by: jcfuller on February 05, 2017, 02:34:28 PM
Jose Roca includes cannot be used with Oxygen Basic without modification of such a large files.
Plus you would need his permission to port them.

James
Title: Re: Re: PowerBasic equivalents and conversions
Post by: John on February 05, 2017, 05:05:48 PM
Quote from: James
Plus you would need his permission to port them.

Does that also hold true for his FreeBASIC include files?
Title: Re: Re: PowerBasic equivalents and conversions
Post by: Mike Lobanovsky on February 05, 2017, 06:09:55 PM
Don't really see what the problem is. Why not use C headers directly without conversion? Why trash what's already been done to implement this functionality in O2? What's so peculiar about PowerBASIC's SDK programming that would be worth porting to yet another BASIC language, especially now that PB seems to be moving off the dead point its own self? SDK is not PB's programming style, it's Win32's programming style, after all, and Win32 has been designed to be programmed in C and not in PB. Let's not put the cart before the horse.
Title: Re: Re: PowerBasic equivalents and conversions
Post by: chrisc on February 05, 2017, 08:35:08 PM
Thank XXX you all

Mike is right, make use of C headers rather than converting the PB proprietary DDT or SDK. I don't think
Drake Software can launch its 64bit compiler anytime this year.  As they were only taken hold of the
source code on Jan 31 2017 and they were laden with many other loads from their own Taxation system (their main app)

One question is that does O2 compile to native machine code ?  Not sure, I heard that  compiled XOJO is actually in
p-code and only have a partial native code in its compiled exe files.
Title: Re: Re: PowerBasic equivalents and conversions
Post by: John on February 05, 2017, 11:06:21 PM
Quote
Why not use C headers directly without conversion?

That makes the most sense to me as well.

The fastest way to a native Windows GUI is with IUP. These GUI toolkits exist for a reason.
Title: Re: Re: PowerBasic equivalents and conversions
Post by: Mike Lobanovsky on February 06, 2017, 02:27:11 AM
Yes Chris,

O2 is a 100% native code compiler. BASIC source is transparently translated to equivalent assembly and then compiled by Charles' core x86/x64 assembler either statically to an on-disk EXE file or dynamically into the process memory. The former mode is primarily used to deploy the solution while the latter one is more handy at the project development and debugging stage. Otherwise the resultant executable machine code is absolutely identical.
Title: Re: Re: PowerBasic equivalents and conversions
Post by: John on February 06, 2017, 09:58:36 PM
Mike,

Would FBSL be a closer match to PowerBASIC than O2?

Title: Re: Re: PowerBasic equivalents and conversions
Post by: Charles Pegge on February 07, 2017, 02:45:26 AM
Hi Roland,

Re: LV_StatusBar: negative equates / 64 bit compiling

The problem traces down to NMLV.hdr.code being defined as a 32 bit UINT. So you are effectively CASE testing 64bit integer numbers against a 32bit uint.

The solution is to cast the select as int, to enforce  64bit sign-extension

SELECT CASE (int) NMLV.hdr.code

Code: [Select]
        SELECT CASE (int) NMLV.hdr.code

          CASE LVN_ITEMCHANGED
              ' when a check box is checked or unchecked it displays
...





Title: Re: Re: PowerBasic equivalents and conversions
Post by: Charles Pegge on February 07, 2017, 03:41:35 AM

Hi Chris,

To follow on from Mike: OxygenBasic was built from machine code - the ultimate bottom-up. The original o and o2 were opcode languages, and became embedded in built-in linker. Assembly code came next, then a macro layer for high level assembler. Then the macro layer was extended to create BASIC.

But I seriously underestimated the complexity of high level languages. It has taken much longer to get there than I originally anticipated,  back in 2008 :)
Title: Re: Re: PowerBasic equivalents and conversions
Post by: Mike Lobanovsky on February 07, 2017, 11:03:36 AM
John,

No, FBSL's BASIC is an interpreter and as such takes much more after VB than PB not only in terms of speed but also in terms of vocabulary and built-in functionality. FBSL's two integral machine code jitters expect their source code to be written in plain ANSI C and Intel style assembly and there's no automatic BASIC-to-C or BASIC-to-Asm translation possible in the current version of FBSL. The three languages can however co-operate at the function level within the same multi-lingual FBSL script passing objects and values to and fro via function arguments and returns and/or sharing them in the same process memory via their pointers.
Title: Re: Re: PowerBasic equivalents and conversions
Post by: John on February 07, 2017, 11:25:53 AM
I don't see interpreters being second class citizens when they can easily switch to C or ASM for critical sections of code. 90% of most applications are running idle. Script BASIC for example did the PB array split in .02 seconds including load, tokenizing, and writing out a file. How fast does it have to be?
Title: Re: Re: PowerBasic equivalents and conversions
Post by: Mike Lobanovsky on February 07, 2017, 01:46:35 PM
"The faster the better" and "Small is beautiful" are my mottos. :)
Title: Re: Re: PowerBasic equivalents and conversions
Post by: John on February 07, 2017, 07:47:41 PM
"The faster the better" and "Small is beautiful" are my mottos. :)

I don't know if that motto would fly with your wife.  :-*
Title: Re: Re: PowerBasic equivalents and conversions
Post by: Arnold on February 08, 2017, 12:19:18 AM
Thank you Charles. Small cause great effect.

Quote
SELECT CASE (int) NMLV.hdr.code

I use some more code of this kind which select negative constants and which must be adapted for 64bit compatibility.

Roland
Title: Re: Re: PowerBasic equivalents and conversions
Post by: Arnold on February 08, 2017, 01:37:45 AM
Hi Chris,

as there are some demos with menus provided with Oxygenbasic there should be no problem. My interest here was to create menus within dialogs (like in the powerbasic code) using a resource file which I created with Resed.exe.

I did not implement the back colors of the menu which seem to need the MENUITEMINFO structure and SetMenuItemInfo function. But I was interested in the MessageBoxIndirect function. Also in accelerators (like F1, Ctrl-O, Ctrl-S) which cannot be used with DialogBox, so I used the CreateDialog macro instead.

Attached are the project files and a 64bit executable as a zip file. There is also a batch file which builds the exe file. (OxygenBasic is expected in c:\). Simp_menu.o2bas will create a 32bit exe, for a 64bit exe these lines must be changed to:

Code: [Select]
'Create Exe File: uncomment executable
'32 for Win32, 64 for Win64
' executable("Simp_menu.exe",32)
 executable("Simp_menu.exe",64)

I developed the project creating a dll like I did with LV_StatusBar. To create a standalone executable I used this trick:

Code: [Select]
...
/*
sys hResources = loadlibrary "Simp_menu.dll"
if not hResources then
  mbox "Error: Simp_menu.dll not found"
  ExitProcess(1)
end if
*/

hResources = hInstance
...

In this way I can create and modify the resources in a dll, can develop and debug the main code and later put everything together in a single file. But of course this is only one way to achieve this goal, many roads lead to Rome.

Roland
Title: Re: Re: PowerBasic equivalents and conversions
Post by: Charles Pegge on February 08, 2017, 02:49:32 AM
Thanks Roland,

I hope that unsigned integers being evaluated for negative values are rare!

I have also resolved the hiword(lparam)-20,  parameter problem, which turned out to be a missing cr in Oxygen's 64 bit parameter Asm encoder. I will post a new OxygenBasic update soonest.
Title: Re: Re: PowerBasic equivalents and conversions
Post by: Mike Lobanovsky on February 08, 2017, 10:28:28 AM
I don't know if that motto would fly with your wife.  :-*

Which one of them? I've had a few. ;)
Title: Re: PowerBasic equivalents and conversions
Post by: chrisc on February 08, 2017, 10:39:57 AM
ThanX sirs for your code and info on O2

I need to know where can I find documentation like  user guide for O2 for beginners like myself.
I'm doubtful that  PB will ever take off again under the new management.  They haven't even responded
to my emails for more than a week. 
Title: Re: Re: PowerBasic equivalents and conversions
Post by: Mike Lobanovsky on February 08, 2017, 12:44:08 PM
I hope that unsigned integers being evaluated for negative values are rare!

Actually there seems to be 288 of them all in all per approx. 7,000 #defines in the WINDOWS_LEAN_AND_MEAN  and Windows Common Controls set of C headers. :)
Title: Re: PowerBasic equivalents and conversions
Post by: Charles Pegge on February 09, 2017, 02:03:54 AM
Hi Chris,

re: user guides

The Oxygen_help manual, which is rather skeletal, can be found in inf/, along with a few technical docs.

This is all we have for users at present.

OxygenBasic has a minimal set of core functions and macros (around 200), but with a highly flexible syntax, which has stretched considerably since its inception, including OOP and C-notation. So creating the definitive manual is going to be quite a task.
Title: Re: PowerBasic equivalents and conversions
Post by: Aurel on February 09, 2017, 03:54:52 PM
chris
do you mean on something like this..
it is just old chm i have found
Title: Re: PowerBasic equivalents and conversions
Post by: chrisc on February 10, 2017, 10:36:58 AM
ThanX ,  but I need more documentation on O2, are there any links on the Internet where
I can search for them ? 
Title: Re: PowerBasic equivalents and conversions
Post by: Aurel on February 10, 2017, 11:08:41 AM
I think not...
One of option will be go trough examples
then explain in short what is what ...
my english is not very good but i can add few more things to this help.
I know some things about o2 but i am not sure that I will explain it very good  ::)

for example :
byte c at strptr(s)

but this one is clear :

string s="Oxygen"
p = cast (string) s
p = p + " Basic"
print p ' -> 'Oxygen Basic'
In this case p becomes string pointer of s and can be used like this
Title: Re: PowerBasic equivalents and conversions
Post by: Arnold on February 10, 2017, 03:49:33 PM
Quote
p = cast (string) s

Interesting aspect. Does PowerBasic work this way?

I searched in \inf\oxygen_help.chm for "string" and there are many topics listed which indicate what is possible. There are many demos in examples\Basics\ e.g. Cast.o2bas or Strptr.o2bas which show the use of cast. I have just finished browsing all the demos of the OxygenBasic subfolders but I did not find the combination above which I think is simply not necessary for this example. But maybe this is new territory.

Which reminds me that I am still looking forward to the standard way of a LV statusbar example.
Title: Re: PowerBasic equivalents and conversions
Post by: Aurel on February 10, 2017, 11:46:28 PM
Quote
I have just finished browsing all the demos of the OxygenBasic subfolders but I did not find the combination above which I think is simply not necessary for this example

Yeah casting is funny things  :)
BUT when string casting work on this way it looks like in Cast.o2bas  example it
looks that not work ?
So is this a bug or something else ?

float f= 0.56
p = cast (int) f
print p ' ->  must be 1 but o2 throw - > #qNAN ..heh well known garbage


Quote
Which reminds me that I am still looking forward to the standard way of a LV statusbar
example

Arnold ..i dont get it what you mean when you say standard way.  ???
Title: Re: PowerBasic equivalents and conversions
Post by: Arnold on February 11, 2017, 02:36:21 AM
Hi Aurel,

what is wrong with this:

float f= 3.9
int p = f

print p   '4 which is expected

Quote
what you mean when you say standard way. 

I refer to your message (http://www.oxygenbasic.org/forum/index.php?topic=1480.msg16067#msg16067)

Roland
Title: Re: PowerBasic equivalents and conversions
Post by: Aurel on February 11, 2017, 02:52:43 AM
Hi Arnold
what you present is not casting float as int then
usual internal transformation.
so ...do you try my example?
and what result you get ?

unfortunately i get this ..look in screenshot
so..something is wrong?
Title: Re: PowerBasic equivalents and conversions
Post by: Arnold on February 11, 2017, 03:17:16 AM
I think Charles explained this here:
http://www.oxygenbasic.org/forum/index.php?topic=982.msg8265#msg8265 (http://www.oxygenbasic.org/forum/index.php?topic=982.msg8265#msg8265)
Title: Re: PowerBasic equivalents and conversions
Post by: Aurel on February 11, 2017, 03:39:12 AM
Aha ..i see
then that is ok for me ...
but good thing is that string casting work on a simple way . :)
by the way do you translate pb listview to oxygen ?
Title: Re: PowerBasic equivalents and conversions
Post by: Arnold on February 11, 2017, 10:29:24 AM
This is a LV Statusbar completely without any .rc file (though James will recognize his code). Attached is the source file and a 64bit executable. It works like the dll version. The style of the code is sometimes a bit alike Freebasic (I think).

Code: OxygenBasic
  1. '=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
  2. '                   This source created by dlg2src
  3. '                      Target: Oxygen Basic
  4. 'Modified a little bit
  5. '=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
  6. $ filename "LV_StatBar.exe"
  7. includepath "$/inc/"
  8. '#include "RTL32.inc"
  9. '#include "RTL64.inc"
  10. #include "MinWin.inc"
  11. ! SetRect lib "user32.dll" alias "SetRect" (lpRect as RECT, byVal X1 as long, byVal Y1 as long, byVal X2 as long, byVal Y2 as long) as long
  12. ! MulDiv lib "kernel32.dll" alias "MulDiv" (byVal nNumber as long, byVal nNumerator as long, byVal nDenominator as long) as long
  13. ! IsDialogMessage Lib "user32.dll" (sys hDlg,lpMsg) as sys    
  14. ! GetDeviceCaps lib "gdi32.dll" alias "GetDeviceCaps" (byVal hDc as sys, byVal nIndex as long) as long
  15. ! GetDlgItem lib "user32.dll" (sys hWnd, int nIDDlgItem) as sys
  16. ! CreateStatusWindow lib "comctl32" alias"CreateStatusWindowA" (LONG style, char* lpszText, sys hwndParent, UINT wID) as sys
  17.  
  18. '------------------------------------------------------------------------------
  19. % COLOR_BTNFACE 15
  20. % HWND_DESKTOP 0
  21. % SM_CYCAPTION 4
  22. % SM_CYHSCROLL 3
  23. % SM_CXVSCROLL 2
  24. % SWP_NOACTIVATE 0X10
  25. % SWP_NOMOVE 0X2
  26. % SWP_NOZORDER 0X4
  27. % WM_NCCALCSIZE 0X83
  28. % SWP_NOSIZE 0X1
  29. % LOGPIXELSY 90
  30. % LVS_SINGLESEL 4
  31. % LVS_REPORT 1
  32. % LVS_EX_CHECKBOXES 4
  33. % LVS_EX_FULLROWSELECT 0x20
  34. % LVIS_STATEIMAGEMASK 0xF000
  35. % SB_SETPARTS 0x404
  36. % SB_SETTEXT 0x401
  37. % SBS_SIZEGRIP 16
  38. % CCS_BOTTOM 3
  39. % LVCF_TEXT 4
  40. % LVIF_TEXT 1
  41. % LVM_INSERTCOLUMN 0x101B
  42. % LVM_INSERTITEM 0x1007
  43. % LVM_SETCOLUMNWIDTH 0x101E
  44. % LVM_SETBKCOLOR 0x1001
  45. % LVM_SETITEM 0x1006
  46. % LVM_SETEXTENDEDLISTVIEWSTYLE 0x1036
  47. % LVM_GETITEMSTATE 0x102C
  48. % LVN_ITEMCHANGED  -101
  49. % NM_CLICK -2
  50. % IMAGE_ICON 1
  51. % LR_LOADFROMFILE 16
  52. % ICON_SMALL 0
  53. % ICON_BIG 1
  54. % WM_SETICON 0x80
  55.  
  56.  
  57. 'structures
  58. 'commctrl.h
  59. type LVCOLUMN
  60.   uint  mask
  61.   int   fmt
  62.   int   cx
  63.   char* pszText
  64.   int   cchTextMax
  65.   int   iSubItem
  66.   int   iImage
  67.   int   iOrder
  68.   int   cxMin
  69.   int   cxDefault
  70.   int   cxIdeal
  71. end type
  72. typedef LVCOLUMN LV_COLUMN
  73.  
  74. type LVITEM
  75.   uint   mask
  76.   int    iItem
  77.   int    iSubItem
  78.   uint   state
  79.   uint   stateMask
  80.   char*  pszText
  81.   int    cchTextMax
  82.   int    iImage       // index of the list view item's icon
  83.  sys    lParam       // 32-bit value to associate with item
  84.   int    iIndent
  85.   int    iGroupId
  86.   uint   cColumns
  87.   UINT   *puColumns
  88.   int    *piColFmt
  89.   int    iGroup
  90. end type
  91. typedef LVITEM LV_ITEM
  92.  
  93. type NMLISTVIEW
  94.   NMHDR hdr
  95.   int   iItem
  96.   int   iSubItem
  97.   uint  uNewState
  98.   uint  uOldState
  99.   uint  uChanged
  100.   POINT ptAction
  101.   sys   lParam
  102. end type
  103. typedef NMLISTVIEW NM_LISTVIEW
  104.  
  105.  
  106. macro ListView_InsertColumn(hwnd,iCol,pcol) (SendMessage(hwnd, LVM_INSERTCOLUMN, iCol, pcol))
  107. macro ListView_InsertItem(hwnd,pitem) (SendMessage(hwnd, LVM_INSERTITEM,0, pitem))
  108. macro ListView_SetColumnWidth(hwnd,iCol,cx) (SendMessage(hwnd, LVM_SETCOLUMNWIDTH, iCol, cx))
  109. macro ListView_SetItem(hwnd,pitem) (SendMessage(hwnd, LVM_SETITEM,0, pitem))
  110. macro ListView_GetCheckState(hwnd,i) ((SendMessage(hwnd, LVM_GETITEMSTATE, i, LVIS_STATEIMAGEMASK))>>12)-1
  111.  
  112. '------------------------------------------------------------------------------
  113. Declare Function WinMain ( Byval hInstance AS sys, _
  114.                            Byval hPrevInstance AS sys, _
  115.                            Byval szCmdLine AS ZSTRING PTR, _
  116.                            Byval nCmdShow AS LONG) AS LONG
  117. declare SUB UpdateStatusBar(sys hWnd)
  118. declare sub DispListView(BYVAL hListview AS DWORD,  BYVAL lColCnt AS LONG, BYVAL lRowCnt AS LONG) AS LONG                          
  119.  
  120. '==============================================================================
  121.    Dim cmdline As asciiz ptr, inst as sys
  122.     &cmdline=GetCommandLine
  123.     inst=GetModuleHandle 0
  124.     WinMain(inst, NULL, cmdline, SW_NORMAL)
  125.     END
  126. '==============================================================================
  127.  
  128. % ICC_LISTVIEW_CLASSES    &h1
  129. % ICC_TREEVIEW_CLASSES    &h2
  130. % ICC_BAR_CLASSES         &h4
  131. % ICC_TAB_CLASSES         &h8
  132. % ICC_UPDOWN_CLASS        &h10
  133. % ICC_PROGRESS_CLASS      &h20
  134. % ICC_HOTKEY_CLASS        &h40
  135. % ICC_ANIMATE_CLASS       &h80
  136. % ICC_WIN95_CLASSES       &hff
  137. % ICC_DATE_CLASSES        &h100
  138. % ICC_USEREX_CLASSES      &h200
  139. % ICC_COOL_CLASSES        &h400
  140. % ICC_INTERNET_CLASSES    &h800
  141. % ICC_PAGESCROLLER_CLASS  &h1000
  142. % ICC_NATIVEFNTCTL_CLASS  &h2000
  143. % ICC_STANDARD_CLASSES    &h4000
  144. % ICC_LINK_CLASS          &h8000
  145. '==============================================================================
  146. Function O2CreateFont(szFaceName As Zstring,Byval lPointSize As long) As sys
  147.     Dim tlf As LOGFONT
  148.     Dim hdc As sys
  149.     Dim nNum As long
  150.     hdc = GetDc(%HWND_DESKTOP)
  151.     nNum = GetDeviceCaps(hdc, %LOGPIXELSY)
  152.     tlf.lfHeight         = -MulDiv(lPointSize,nNum , 72)
  153.     tlf.lfWidth          =  0
  154.     tlf.lfEscapement     =  0
  155.     tlf.lfOrientation    =  0
  156.     tlf.lfWeight         =  0
  157.     tlf.lfItalic         =  0
  158.     tlf.lfUnderline      =  0
  159.     tlf.lfStrikeOut      =  0
  160.     tlf.lfCharSet        =  %ANSI_CHARSET
  161.     tlf.lfOutPrecision   =  %OUT_TT_PRECIS
  162.     tlf.lfClipPrecision  =  %CLIP_DEFAULT_PRECIS
  163.     tlf.lfQuality        =  %DEFAULT_QUALITY
  164.     tlf.lfPitchAndFamily =  %FF_DONTCARE
  165.     tlf.lfFaceName       =  szFaceName
  166.     ReleaseDC(%HWND_DESKTOP, hdc)
  167. Function = CreateFontIndirect(@tlf)
  168. End Function
  169. '==============================================================================
  170. Sub O2Center(sys hwnd)
  171.     Dim As RECT WndRect
  172.     Dim As sys x,y
  173.     GetWindowRect(hwnd,&WndRect)
  174.     x = (GETSYSTEMMETRICS(%SM_CXSCREEN) - (WndRect.Right-WndRect.Left))/2
  175.     y = (GETSYSTEMMETRICS(%SM_CYSCREEN) - (WndRect.Bottom-WndRect.Top+GETSYSTEMMETRICS(%SM_CYCAPTION)))/2
  176.     SetWindowPos (hWnd, NULL, x, y, 0, 0, SWP_NOSIZE OR SWP_NOZORDER)
  177. End Sub
  178. '==============================================================================
  179. Sub O2SetWindowClientSize(sys hwnd,W,H)
  180.     Dim As RECT rc,rcTemp
  181.     Dim As sys hMenu,swStyle,exStyle
  182.     SetRect(rc,0,0,W,H)
  183.     hMenu = GetMenu(hwnd)
  184.     dwStyle = GetWindowLong(hwnd,%GWL_STYLE)
  185.     AdjustWindowRectEx(rc, dwStyle, hMenu<>NULL , GetWindowLong(hwnd, GWL_EXSTYLE))
  186.     If hMenu <> NULL Then
  187.         @rcTemp = @rc
  188.         rcTemp.Bottom = &H7FFF
  189.         SendMessage(hwnd, WM_NCCALCSIZE, 0,  &rcTemp)
  190.         rc.Bottom = rc.Bottom + rcTemp.Top
  191.     End If
  192.     If (dwStyle AND WS_HSCROLL) = WS_HSCROLL Then
  193.         rc.Bottom = rc.Bottom + GetSystemMetrics(SM_CYHSCROLL)
  194.     End If
  195.     If (dwStyle AND WS_VSCROLL) = WS_VSCROLL Then
  196.         rc.Right = rc.Right + GetSystemMetrics(SM_CXVSCROLL)
  197.     End If
  198.     sys cx,cy
  199.     cx = rc.Right - rc.Left
  200.     cy = rc.Bottom - rc.Top
  201.     SetWindowPos(hwnd, NULL, 0, 0, cx, cy, SWP_NOZORDER OR SWP_NOMOVE OR SWP_NOACTIVATE)
  202. End Sub
  203. '==============================================================================
  204. % IDD_Main 1000
  205. % IDC_Statusbar 1060
  206. % IDC_ListView 1001
  207.  
  208. int CurrentRow, CurrentCol
  209. sys hStatus
  210.  
  211. '==============================================================================
  212. Function WinMain(Byval hInstance as sys, _
  213.                  Byval hPrevInstance As sys, _
  214.                  Byval szCmdLine As ZSTRING PTR, _
  215.                  Byval nCmdShow As LONG ) As sys
  216.     Dim wMsg As MSG
  217.     Dim wcls As WNDCLASS
  218.     Dim As sys hWin,hCtl,hFont
  219.  
  220.     With wcls
  221.        .style         = CS_HREDRAW OR CS_VREDRAW
  222.        .lpfnWndProc   = @WndProc
  223.        .cbClsExtra    = 0
  224.        .cbWndExtra    = 0
  225.        .hInstance     = hInstance
  226.        .hbrBackground = COLOR_BTNFACE+1
  227.        .hIcon         = LoadIcon(0, IDI_APPLICATION)
  228.        .hCursor       = LoadCursor( NULL, IDC_ARROW )
  229.        .lpszMenuName  = NULL
  230.        .lpszClassName = strptr"O2SdkWindow"
  231.     End With
  232.     If RegisterClass (@wcls) = FALSE Then
  233.         MessageBox( NULL, "Failed to register wcls", "Error", MB_ICONERROR )
  234.          Exit Function
  235.     End If
  236.     Dim As INITCOMMONCONTROLSEXt icc
  237.     icc.dwSize = SIZEOF(icc)
  238.     icc.dwICC = ICC_NATIVEFNTCTL_CLASS OR ICC_COOL_CLASSES OR ICC_BAR_CLASSES OR  _
  239.                 ICC_TAB_CLASSES OR ICC_USEREX_CLASSES OR ICC_WIN95_CLASSES OR  _
  240.                 ICC_STANDARD_CLASSES OR ICC_ANIMATE_CLASS OR ICC_DATE_CLASSES OR  _
  241.                 ICC_HOTKEY_CLASS OR ICC_INTERNET_CLASSES OR ICC_LISTVIEW_CLASSES OR  _
  242.                 ICC_PAGESCROLLER_CLASS OR ICC_PROGRESS_CLASS OR ICC_TREEVIEW_CLASSES OR  _
  243.                 ICC_UPDOWN_CLASS
  244.     InitCommonControlsEx(@icc)
  245.     hFont = O2CreateFont("Arial",9)
  246.  
  247.     hWin = CreateWindowEx(WS_EX_TRANSPARENT|WS_EX_TOPMOST,"O2SdkWindow","ListView - check",WS_VISIBLE|WS_CLIPCHILDREN|WS_OVERLAPPEDWINDOW,0,0,234,132,0,0,hInstance,NULL)
  248.     O2SetWindowClientSize(hWin,410,248)
  249.  
  250.     hStatus = CreateStatusWindow(WS_CHILD | WS_BORDER | WS_VISIBLE | SBS_SIZEGRIP | CCS_BOTTOM, "", hWin, IDC_Statusbar)
  251.     'Statusbar set parts
  252.    int statwidths[] = {100, -1}
  253.     SendMessage(hStatus, SB_SETPARTS, 2, &statwidths)
  254.     SendMessage(hStatus, SB_SETTEXT, 0, "Row : Col")
  255.     UpdateStatusBar(hWin)
  256.  
  257.     hListview = CreateWindowEx(WS_EX_CLIENTEDGE, "SysListView32",NULL,WS_CHILD | WS_TABSTOP | WS_VISIBLE | WS_BORDER|LVS_SINGLESEL|LVS_REPORT,5,0,389,225,hWin,%IDC_ListView,hInstance,BYVAL %NULL)
  258.     SendMessage(hListview,%WM_SETFONT,hFont,0)
  259.     'Listview setup
  260.    int lColCnt=3, lRowCnt=300
  261.     DispListView(hListview, lColCnt,lRowCnt)
  262.  
  263.     O2Center(hWin)
  264.     ShowWindow(hWin,nCmdShow)
  265.  
  266.     While(GetMessage(@wMsg,NULL,0,0) <> 0)
  267.         If IsDialogMessage (hWin,@wMsg) = 0 Then
  268.             TranslateMessage(@wMsg)
  269.             DispatchMessage(@wMsg)
  270.         End If
  271.     Wend
  272.     DeleteObject(hFont)
  273.     Function = wMsg.wParam
  274. End Function
  275. '==============================================================================
  276.  
  277. Function WndProc ( hWnd, wMsg, wParam, lparam ) as sys callback
  278.    Select Case wMsg
  279.    case WM_CREATE
  280.             hIcon = LoadImage(NULL, "ibeam blue.ico", IMAGE_ICON, 32, 32, LR_LOADFROMFILE)
  281.             if hIcon then            
  282.                 SendMessage(hwnd, WM_SETICON, ICON_BIG, hIcon)            
  283.             else            
  284.                 MessageBox(hwnd, "Could not load large icon! Is it in the current working directory?", "Error", MB_OK or MB_ICONERROR)
  285.             end if
  286.  
  287.             hIconSm = LoadImage(NULL, "ibeam blue.ico", IMAGE_ICON, 16, 16, LR_LOADFROMFILE)
  288.             if hIconSm then            
  289.                 SendMessage(hwnd, WM_SETICON, ICON_SMALL, hIconSm)            
  290.             else            
  291.                 MessageBox(hwnd, "Could not load small icon! Is it in the current working directory?", "Error", MB_OK or MB_ICONERROR)
  292.             end if
  293.        
  294.    case WM_SIZE
  295.       RECT rcStatus
  296.       int iStatusHeight
  297.  
  298.       // Size Status bar and ListView
  299.       hListview = GetDlgItem(hWnd, IDC_LISTVIEW)
  300.       MoveWindow(hListview,0, 0, loword(lParam), hiword(lParam)-20, true)
  301.       hStatus = GetDlgItem(hWnd, IDC_Statusbar)
  302.       SendMessage(hStatus, WM_SIZE, 0, 0)
  303.  
  304.       GetWindowRect(hStatus, &rcStatus)
  305.       iStatusHeight = rcStatus.bottom - rcStatus.top
  306.  
  307.    case WM_NOTIFY
  308.       'address of pnmh=lParam (keeps the notification message header )
  309.      NMHDR pnmh at lParam
  310.       if pnmh.idFrom = IDC_LISTVIEW then
  311.         NM_LISTVIEW NMLV at lParam  'address
  312.  
  313.         SELECT CASE (int) NMLV.hdr.code
  314.  
  315.           CASE LVN_ITEMCHANGED
  316.               ' when a check box is checked or unchecked it displays
  317.              ' its status at the caption
  318.              hListView=GetDlgItem(hWnd, IDC_LISTVIEW)
  319.               Checked = ListView_GetCheckState(hListView, NMLV.iItem)
  320.  
  321.               IF Checked = TRUE THEN
  322.                   SendMessage(hWnd, WM_SETTEXT, 0, "Row " + STR(NMLV.iItem+1) +" Checked: " + str(Checked))
  323.               ELSE
  324.                 ' when unchecked
  325.                  SendMessage(hWnd, WM_SETTEXT, 0, "Row " + STR$(NMLV.iItem+1) +" Checked: " + STR(Checked))
  326.               END IF
  327.  
  328.           CASE NM_CLICK     ' click on a cell
  329.                 NM_LISTVIEW lPlvNm at lParam  'address
  330.                 CurrentRow = LpLvNm.iiTem + 1
  331.                  CurrentCol = LpLvNm.iSubItem + 1
  332.                  UpdateStatusBar(hWnd)
  333.  
  334.         END SELECT
  335.       end if
  336.  
  337.  
  338.    Case WM_COMMAND
  339.       Select Case LOWORD(wParam)
  340.           Case IDCANCEL
  341.              If HIWORD(wParam) = BN_CLICKED Then
  342.                SendMessage(hWnd,WM_CLOSE,0,0)
  343.              Exit Function
  344.           End If
  345.       End Select
  346.    Case WM_DESTROY
  347.       PostQuitMessage(0)
  348.       Exit Function
  349.    End Select
  350.    Function = DefWindowProc(hWnd, wMsg, wParam, lParam)
  351. End Function
  352.  
  353.  
  354. '=====================
  355. ' The status bar displaying the current position of cursor
  356. ' and help text for each column
  357. SUB UpdateStatusBar(sys hWnd)
  358.  
  359.    hStatus=GetDlgItem(hWnd, IDC_Statusbar)
  360.    SendMessage(hStatus, SB_SETTEXT, 0, "Row " & str(CurrentRow) & ":" & "Col " & str(CurrentCol))
  361.  
  362.  ' Help text for each column when a particular column is clicked
  363.   SELECT CASE CurrentCol
  364.        CASE 1
  365.             SendMessage(hStatus, SB_SETTEXT, 1, "Enter characters only")
  366.        CASE 2
  367.             SendMessage(hStatus, SB_SETTEXT, 1, "Enter numbers only")
  368.        CASE 3
  369.             SendMessage(hStatus, SB_SETTEXT, 1, "Enter Alphanumeric here")
  370.    END SELECT
  371. END SUB
  372.  
  373. '===============================
  374. ' Display and load in the data for the ListView
  375. sub DispListView(BYVAL hListview AS DWORD,  BYVAL lColCnt AS LONG, _
  376.         BYVAL lRowCnt AS LONG) AS LONG
  377.    LOCAL lCol   AS LONG
  378.    LOCAL lRow   AS LONG
  379.  
  380.    SendMessage(hListView, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_CHECKBOXES OR LVS_EX_FULLROWSELECT )
  381.  
  382.    #indexbase 0
  383.  
  384.   ' Load column headers.
  385.   LV_COLUMN lvc
  386.    lvc.mask = LVCF_TEXT
  387.  
  388.    dim as string Column$[3]
  389.  
  390.    Column$[0] = "Column 1"
  391.    Column$[1] = "Column 2"
  392.    Column$[2] = "Column 3"
  393.  
  394.    FOR i = 0 TO 2
  395.       lvc.mask = LVCF_TEXT
  396.       lvc.pszText = Column$[i]
  397.       ListView_InsertColumn(hListview, i, lvc)
  398.    NEXT
  399.  
  400.    for i=0 to 2
  401.       ListView_SetColumnWidth(hListview, i, 65)
  402.    next
  403.  
  404.  
  405. ' Load sample data.
  406. '==========================
  407.  LV_ITEM lvItem
  408. '==========================
  409.  
  410.   lvItem.mask      =  LVIF_TEXT
  411.   string text
  412.  
  413.   for r = lRowCnt to 1 step -1
  414.     text="Column 1 " & "Row " & r
  415.     lvItem.pszText   = text
  416.     lvItem.iSubItem  =  0
  417.     ListView_InsertItem(hListview, &lvItem)
  418.  
  419.     text="Column 1 " & "Row " & r
  420.     lvItem.pszText   = text
  421.     lvItem.iSubItem  =  1
  422.     ListView_SetItem(hListview, &lvItem)
  423.  
  424.     text="Column 1 " & "Row " & r
  425.     lvItem.pszText   = text
  426.     lvItem.iSubItem  =  2
  427.     ListView_SetItem(hListview, &lvItem)
  428.  
  429.   next r
  430.  
  431.   ' Auto size columns.
  432.  for i=0 to 2
  433.      ListView_SetColumnWidth(hListview, i, -2)
  434.   next
  435.  
  436. end sub
  437.  
  438.  
Title: Re: PowerBasic equivalents and conversions
Post by: Aurel on February 11, 2017, 12:01:53 PM
Ok Arnold
and fine with small changes with includes i compile this program on win32.
It seems that app work properly , just a small thing main window
flickering like hell when we move or resize but this is problem because
is not added WS_CLIPCHILDREN into window style.
By the way i have similar problem with TAB control even is this contant added ..hmmm.
Title: Re: PowerBasic equivalents and conversions
Post by: Emil_halim on February 16, 2017, 06:48:32 AM
Hi Aurel,

from where can i get your Editor please?
Title: Re: PowerBasic equivalents and conversions
Post by: John on February 16, 2017, 03:40:32 PM
(http://windowsitpro.com/site-files/windowsitpro.com/files/uploads/2017/02/drkonstantinmalkov.jpg)

Believe it or not this is not Bob Zale but Dr. Konstantin Malkov (http://windowsitpro.com/virtualization/managing-switch-vmware-hyper-v).