Author Topic: PureBasic vs. PowerBasic (Bob's Opinion)  (Read 28235 times)

0 Members and 1 Guest are viewing this topic.

Offline Bob Houle

  • Newbie
  • *
  • Posts: 41
  • User-Rate: +3/-3
  • "It was too lonely at the top."
Re: PureBasic vs. PowerBasic (Bob's Opinion)
« Reply #15 on: March 07, 2016, 03:49:06 PM »
Look... you said you thought you had found some buggy code and I said:
"Post it on the forum"

You then asked for a way to create a Main() program like PowerBASIC,
and I provided an answer.
--------------
Quote
Don't turn my words around, Bob.


Where is this coming from?  ???

It's obvious you don't like PureBasic. Or PBDev.

That's O.K.

Just move on.  :)

If you like things as they are with PowerBASIC... that's fine.

Just move on.  :)

But please stop bashing something you "think" you know (but don't)

Offline Theo Gottwald

  • Administrator
  • Hero Member
  • *****
  • Posts: 935
  • User-Rate: +30/-4
    • it-berater
Re: PureBasic vs. PowerBasic (Bob's Opinion)
« Reply #16 on: March 09, 2016, 08:11:32 AM »
Sometimes i believe i have violett glases on, or the other person has green.
But thats the world.

Code: [Select]
You then asked for a way to create a Main() program like PowerBASIC,
Can you show me where i asked that?
So i can find out who has the glases on :-)

I have clearly stated where i see the shortcomings.
Point - by point.

That does not mean i don't like PureBasic. Thats just your opinion.
Why is it not OK, to clearly tell the shortcomings of a computer-program?

There should not be any reason to take thios personal.
As i see it, there is a difference between somebody writing

Quote
XY is just bad

and somebody writing

Quote
XY missing some features that i am used to, and the person working on XY doesn't like to add these features

Where do you see the "bashing"?
So please stop insulting my clear criticism of openly visible facts as bashing.

I will still use PureBasic and also closely watch its developement.


Offline Bob Houle

  • Newbie
  • *
  • Posts: 41
  • User-Rate: +3/-3
  • "It was too lonely at the top."
Re: PureBasic vs. PowerBasic (Bob's Opinion)
« Reply #17 on: March 09, 2016, 02:52:30 PM »
Quote
Can you show me where i asked that?
So i can find out who has the glases on :-)


Here...

PS:Do you know a trick how i can make PureBasic to compile a "Main File" like it can be set in the PowerBasic IDE?



Offline Patrice Terrier

  • ROMs
  • Hero Member
  • *****
  • Posts: 934
  • User-Rate: +62/-1
    • www.zapsolution.com
Re: PureBasic vs. PowerBasic (Bob's Opinion)
« Reply #18 on: March 09, 2016, 03:28:22 PM »
He he.

This is like when Theo, spoke of Windows 10, compared to Windows 2000  ;D

...
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Offline Theo Gottwald

  • Administrator
  • Hero Member
  • *****
  • Posts: 935
  • User-Rate: +30/-4
    • it-berater
Re: PureBasic vs. PowerBasic (Bob's Opinion)
« Reply #19 on: March 09, 2016, 07:19:07 PM »
Hahaha ... i guess we run from Missunderstanding to missunderstanding.
Have to say that the PureBasic IDE is very good even compared to any PowerBasic IDE.
(Other the Firefly or Phoenix because of the VD :-).

There is just one thing that i did not yet find out - but i think its in there.
In PureBasic I must currently first switch to the "main file" before i can press "Compile".
I believe this is my mistake - that was my question about "Main File".

You know i don't like Win 10 at all Patrice :-).

But i never said that i would not like PureBasic.

What do you think, do i  have "glasses on"?

It was in the year 2000 when i bought myself this so called C-Meter i guess it was about $400 or more.
In fact its some sort of "Lie detector".

It was the time when my last gf left me. When i got it, she was already gone.
Since then i had it in my cupboard.

This week i took it out and realized that it needs a "COM-Port" which no modern PC has.
And the Software was on a "Disk". But my Computer has no Disk drive.

Ok, so i got an RS232 to USB Adapter and also an old computer with Disc-Drive.
And funny enough - the thing still works. Even under Win 10.

And from what it shows, i would say that i speak the truth.
« Last Edit: March 09, 2016, 07:40:13 PM by Theo Gottwald »

Offline David Roberts

  • Newbie
  • *
  • Posts: 29
  • User-Rate: +0/-0
Re: PureBasic vs. PowerBasic (Bob's Opinion)
« Reply #20 on: November 02, 2016, 02:13:50 AM »
I've had PureBasic for quite a while but I did not take to it. After reading through this thread I decided to have another go. There have been quite a few updates since my last look and was surprised to see a SHA3 plugin. What I embarked on stretched me no end but I got there in the end. Purists will no doubt frown at what I'm doing here but I am not a purist.
 
PureBasic dll saved to SHA3Hash.dll
 
Code: [Select]
UseSHA3Fingerprint()
 
ProcedureDLL.s SHA3_256( text$ )
 
  *Buffer = AllocateMemory( Len( text$ ) )
  If *Buffer
    PokeS(*Buffer, text$, -1, #PB_Ascii)
    SHA3$ = Fingerprint(*Buffer, MemoryStringLength(*Buffer, #PB_Ascii), #PB_Cipher_SHA3, 256)
    FreeMemory(*Buffer)
    ProcedureReturn SHA3$
  EndIf
 
EndProcedure
 
ProcedureDLL.s SHA3_512( text$ )
 
  *Buffer = AllocateMemory( Len( text$ ) )
  If *Buffer
    PokeS(*Buffer, text$, -1, #PB_Ascii)
    SHA3$ = Fingerprint(*Buffer, MemoryStringLength(*Buffer, #PB_Ascii), #PB_Cipher_SHA3, 512)
    FreeMemory(*Buffer)
    ProcedureReturn SHA3$
  EndIf
 
EndProcedure

PureBasic test
 
Code: [Select]
If OpenLibrary(0, "SHA3Hash.dll")
  Test$ = "Houses Of Parliament"
  MessageRequester("SHA3_256", PeekS(CallFunction(0, "SHA3_256", @Test$) ))
  MessageRequester("SHA3_512", PeekS(CallFunction(0, "SHA3_512", @Test$) ))
EndIf

PowerBASIC
 
Code: [Select]
#Compile Exe
#Dim All
 
Declare Function SHA3_256 Lib "SHA3Hash.dll" ( ByVal strText As WString ) As WString
Declare Function SHA3_512 Lib "SHA3Hash.dll" ( ByVal strText As WString ) As WString
 
Function PBMain
Local sText As WString
 
  sText = "Houses Of Parliament"
  MsgBox SHA3_256( sText )
  MsgBox SHA3_512( sText )
 
End Function

The PureBasic test and the PowerBASIC exe gave the same results. Just to be sure all was well I went to https://emn178.github.io/online-tools/ and got a confirmation on both SHA3-256 and SHA3-512.
 
So, PowerBASIC now has SHA3 without getting my hands dirty building a SHA3 engine.
 
Having got that working the next step will be a PureBasic library to create a hash, hash one or more blocks in and then finalize the hash. PureBASIC has the procedures to do that.
 
I then wrote a simple PowerBASIC dll with a view to using it in PureBasic. However, I am getting an 'Invalid memory access. (read error at address 0).
 
Would you look at it, Bob?
 
If I can get it to work there are a few other procedures that could be added to PB_String_Crunches.dll to give PureBasic a bit more 'oomph' in the string department.
 
PowerBASIC
 
Code: [Select]
#Compile DLL "PB_String_Crunches.dll"
#Dim All
 
Function PB_Remove_Any( ByVal MainString As String, ByVal MatchString As String ) Export As String
 
  Function = Remove$( MainString, Any MatchString )
 
End Function

PureBasic
 
Code: [Select]
Prototype.s ProtoPB_Remove_Any( param1$, param2$ )
If OpenLibrary( 0, "PB_String_Crunches.dll" )
  PB_Remove_Any.ProtoPB_Remove_Any = GetFunction( 0, "PB_Remove_Any" )
  s1$ = "Lo38ok2 Ma, n6o nu1mbe78rs!"
  s2$ = "0123456789"
  s3$ = PB_Remove_Any( s1$, s2$ )
  CloseLibrary(0)
EndIf

 
« Last Edit: November 03, 2016, 01:03:32 AM by David Roberts »

Offline David Roberts

  • Newbie
  • *
  • Posts: 29
  • User-Rate: +0/-0
Re: PureBasic vs. PowerBasic (Bob's Opinion)
« Reply #21 on: November 02, 2016, 03:00:16 AM »
'Dependency Walker' says I should have used PB_REMOVE_ANY but I'm still getting a memory access violation.

Offline David Roberts

  • Newbie
  • *
  • Posts: 29
  • User-Rate: +0/-0
Re: PureBasic vs. PowerBasic (Bob's Opinion)
« Reply #22 on: November 03, 2016, 12:18:10 AM »
OK, I managed PowerBASIC to PureBasic

I have managed it.
 
PowerBASIC code
 
Code: [Select]
#Compile DLL "PB_String_Crunches.dll"
#Dim All
 
Function RemoveAny( ByVal MainString As String, ByVal MatchString As String ) Export As WString
Local sText As WString
 
  sText = Remove$( MainString, Any MatchString )
  Function = sText
 
End Function

PureBasic code
 
Code: [Select]
Prototype.l ProtoRemoveAny( param1.p-bstr, param2.p-bstr )
If OpenLibrary( 0, "PB_String_Crunches.dll" )
  RemoveAny.ProtoRemoveAny = GetFunction( 0, "REMOVEANY" )
  s1$ = "Lo38ok2 Ma, n6o nu1mbe78rs!"
  s2$ = "0123456789"
  MessageRequester("", PeekS(RemoveAny( s1$, s2$ ) ))
  CloseLibrary(0)
EndIf

Resulting in: "Look Ma, no numbers!"
 
 

Offline José Roca

  • Administrator
  • Hero Member
  • *****
  • Posts: 2485
  • User-Rate: +204/-0
Re: PureBasic vs. PowerBasic (Bob's Opinion)
« Reply #23 on: November 03, 2016, 01:44:41 AM »
> PeekS(RemoveAny( s1$, s2$ )

I smell memory leaks. When are the temporary BSTRings freed?

Offline David Roberts

  • Newbie
  • *
  • Posts: 29
  • User-Rate: +0/-0
Re: PureBasic vs. PowerBasic (Bob's Opinion)
« Reply #24 on: November 03, 2016, 02:12:22 AM »
I certainly cannot answer that.
« Last Edit: November 03, 2016, 02:23:23 AM by David Roberts »

Offline José Roca

  • Administrator
  • Hero Member
  • *****
  • Posts: 2485
  • User-Rate: +204/-0
Re: PureBasic vs. PowerBasic (Bob's Opinion)
« Reply #25 on: November 03, 2016, 02:18:37 AM »
> There are no BSTRings in PeekS(RemoveAny( s1$, s2$ )

Yes, there are. THREE!

> RemoveAny( s1$, s2$ ) is a pointer to the PowerBASIC's Wstring export and PeekS simply reads it.

...and does not free it.

Offline David Roberts

  • Newbie
  • *
  • Posts: 29
  • User-Rate: +0/-0
Re: PureBasic vs. PowerBasic (Bob's Opinion)
« Reply #26 on: November 03, 2016, 02:51:04 AM »
I gave it further thought and edited my last post before your last post.  :)

The PowerBASIC export is unicode to unicode so we only have two string format conversions; the parameters.

The ideal time to free up the bstr's is on receipt of the export as they are no longer needed then but how PureBasic does that I have no idea.

 

Offline José Roca

  • Administrator
  • Hero Member
  • *****
  • Posts: 2485
  • User-Rate: +204/-0
Re: PureBasic vs. PowerBasic (Bob's Opinion)
« Reply #27 on: November 03, 2016, 03:14:51 AM »
In the code that you have posted it is not freed.

Rules for allocating and releasing memory allocated for BSTRs.

- When you call into a function that expects a BSTR argument, you must allocate the memory for the BSTR before the call and release it afterwards.

- When you call into a function that returns a BSTR, you must free the string yourself.

- When you implement a function that returns a BSTR, allocate the string but do not free it. The receiving the function releases the memory.

See: https://msdn.microsoft.com/en-us/library/xda6xzx7.aspx

Offline José Roca

  • Administrator
  • Hero Member
  • *****
  • Posts: 2485
  • User-Rate: +204/-0
Re: PureBasic vs. PowerBasic (Bob's Opinion)
« Reply #28 on: November 03, 2016, 03:22:25 AM »
Don't know what kind of code will generate that compiler, but I don't think that PeekS will release the BSTR. If I were you, I would ask it in the Pure Basic forum.

Offline David Roberts

  • Newbie
  • *
  • Posts: 29
  • User-Rate: +0/-0
Re: PureBasic vs. PowerBasic (Bob's Opinion)
« Reply #29 on: November 03, 2016, 03:47:01 AM »
Quote
In the code that you have posted it is not freed.

It certainly isn't freed by me. I have no idea what PureBasic does but I should imagine that rule #1 applies.

I got the tip on 'p-bstr' from the PureBasic forums and I have seen the main coder, Fred as Theo refers to him, recommend it. It was my idea to use 'Export As WString'

Quote
I don't think that PeekS will release the BSTR

No, that is simply a reading function.

It seems to me that RemoveAny( s1$, s2$ ) by virtue of being prototyped is probably 'bracketed' by a conversion to bstr before and then a freeing up after as opposed to no 'bracketing' with no prototyping; but I am only guessing.