Author Topic: Re: PowerBasic equivalents and conversions  (Read 12703 times)

0 Members and 1 Guest are viewing this topic.

Charles Pegge

  • Guest
Re: Re: PowerBasic equivalents and conversions
« Reply #15 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).
« Last Edit: February 03, 2017, 03:53:39 AM by Charles Pegge »

Charles Pegge

  • Guest
Re: Re: PowerBasic equivalents and conversions
« Reply #16 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()

Arnold

  • Guest
Re: Re: PowerBasic equivalents and conversions
« Reply #17 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


.
« Last Edit: February 03, 2017, 04:33:19 AM by Arnold »

Aurel

  • Guest
Re: Re: PowerBasic equivalents and conversions
« Reply #18 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.
« Last Edit: February 03, 2017, 05:20:25 AM by Aurel »

Arnold

  • Guest
Re: Re: PowerBasic equivalents and conversions
« Reply #19 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

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
« Last Edit: February 08, 2017, 01:28:48 AM by Arnold »

Aurel

  • Guest
Re: Re: PowerBasic equivalents and conversions
« Reply #20 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 .

JRS

  • Guest
Re: Re: PowerBasic equivalents and conversions
« Reply #21 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.


« Last Edit: February 03, 2017, 01:23:38 PM by John »

Charles Pegge

  • Guest
Re: Re: PowerBasic equivalents and conversions
« Reply #22 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

JRS

  • Guest
Re: Re: PowerBasic equivalents and conversions
« Reply #23 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.
« Last Edit: February 04, 2017, 09:38:49 PM by John »

Charles Pegge

  • Guest
Re: Re: PowerBasic equivalents and conversions
« Reply #24 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.


JRS

  • Guest
Re: Re: PowerBasic equivalents and conversions
« Reply #25 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.
« Last Edit: February 05, 2017, 11:29:15 AM by John »

Aurel

  • Guest
Re: Re: PowerBasic equivalents and conversions
« Reply #26 on: February 05, 2017, 01:39:37 PM »
Jose Roca includes cannot be used with Oxygen Basic without modification of such a large files.

jcfuller

  • Guest
Re: Re: PowerBasic equivalents and conversions
« Reply #27 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

JRS

  • Guest
Re: Re: PowerBasic equivalents and conversions
« Reply #28 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?

Mike Lobanovsky

  • Guest
Re: Re: PowerBasic equivalents and conversions
« Reply #29 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.