Converting from PowerBasic

General FreeBASIC programming questions.
Mike Trader
Posts: 25
Joined: Feb 02, 2008 22:10

Converting from PowerBasic

Postby Mike Trader » Feb 03, 2008 2:28

Hello All,

I like PB for a number of reasons, but after numerous run ins with the owner for daring posts like this:
http://www.powerbasic.com/support/pbfor ... 934&page=4
or perhaps this:
http://www.powerbasic.com/support/pbfor ... fc&t=35768


Coupled with things like this:
http://www.powerbasic.com/support/pbfor ... hp?t=35253
and comments like this
http://www.jose.it-berater.org/smfforum ... pic=1558.0
http://www.jose.it-berater.org/smfforum ... pic=1562.0

All of a sudden my nick has "come to their attention" as not being my actual name, despite the fact that I hashed this out on the phone with the owner three years ago when he agreed to let me continue using my nick after I bought more product.

The Forum used to be a great resource, but after years of heavy handed culling, all the good developers have left. I have had it too. Apart from that, who knows where this language is going. At least here you say you intend to implement OOP and so forth. We can at least have some hope things are going in a direction consitent with our needs.

I have got to find an alternative language and begin porting 10 years development soon.

I have read a lot here and it seems that V1ctor has been doing amazing things. I like the concept of implementing OOP. I have worked with that a little in Java and I would like to bridge into it.

I am expecting a little bit of a learning curve, but first a few funadamental questions.
Does FB support Mac platforms and is there an intention to develop it out that far?
Can FB support inline ASM?
I was reading about calling a .dll which is made easy by the PB compiler. Dll such as zlib.dll. How hard is that going to be for dll libraries with many procedures.
I also read that FB can support procedural codeing and oop at the same time. Will that be true going foreward?
And finally, is DWORD an integer for all operationsie compatible with a C Double int?


I am also hoping that in this forum nicks are allowed and that there is tolerant admin that welcomes active discussion and perhaps even a little constructive criticism with appropriate courtesy of course
Kind Regards
Mike
Last edited by Mike Trader on Feb 03, 2008 22:14, edited 2 times in total.
DrV
Site Admin
Posts: 2116
Joined: May 27, 2005 18:39
Location: Midwestern USA
Contact:

Re: Converting from PowerBasic

Postby DrV » Feb 03, 2008 2:55

Mike Trader wrote:Does FB support Mac platforms and is there an intention to develop it out that far?
Not yet, but it's possible that it will in the future (none of the current developers have access to a Mac as far as I know).

Can FB support inline ASM?
Yes, see the documentation: here

I was reading about calling a .dll which is made easy by the PB compiler. Dll such as zlib.dll. How hard is that going to be for dll libraries with many procedures.
You need to write a Declare Function/Sub for each procedure and translate structs into FreeBASIC Types, but it is straightforward and there is an automated tool to help (search the forum for 'swig').

I also read that FB can support procedural codeing and oop at the same time. Will that be true going foreward?
Yes, traditional procedural programming will always be supported (you don't have to use OOP if you don't want to).

And finally, is DWORD an integer for all operationsie compatible with a C Double int?
There is no built-in DWORD type, but in the Windows headers, DWORD is the same as DWORD in the C Windows headers (32-bit unsigned integer on Win32).

I am also hoping that in this forum nicks are allowed and that there is tolerant admin that welcomes active discussion and perhaps even a little constructive criticism with appropriate courtesy of course
Nicknames are fine, and most members use them.
notthecheatr
Posts: 1759
Joined: May 23, 2007 21:52
Location: Cut Bank, MT
Contact:

Re: Converting from PowerBasic

Postby notthecheatr » Feb 03, 2008 3:07

DrV wrote:
And finally, is DWORD an integer for all operationsie compatible with a C Double int?
There is no built-in DWORD type, but in the Windows headers, DWORD is the same as DWORD in the C Windows headers (32-bit unsigned integer on Win32).


DWORD is basically uInteger, right? The only thing is that if we ever change to 64-bit then uInteger will probably be a QWORD. But that's probably not in the near future, so no worries there.
MichaelW
Posts: 3500
Joined: May 16, 2006 22:34
Location: USA

Postby MichaelW » Feb 03, 2008 10:42

Hi Mike,

For 32-bit integers FB supports Integer, Uinteger, Long, and Ulong, which AFAIK are handled as integers for all calculations/operations except division (other than integer division) and where there is a floating-point value involved.

For 64-bit integers FB supports LongInt and ULongInt, which AFAIK are handled as integers for all calculations/operations except division (other than integer division) and where there is a floating-point value involved.

Working on the timing macros with you I saw multiple examples of PB using the FPU for what should have been integer operations IMO. To borrow some code from the timing macros, this is what PB does with a conditional assignment involving only Quad Integers (the only 64-bit integer type supported, AFAIK):

Code: Select all

GLOBAL CounterTSC1, CounterTSC2, CounterOverhead AS QUAD

IF (CounterTSC2 - CounterTSC1) < CounterOverhead THEN CounterOverhead = CounterTSC2 - CounterTSC1

00401ECC DF2D40454000           fild    qword ptr [404540h]
00401ED2 DF2D30454000           fild    qword ptr [404530h]
00401ED8 DF2D38454000           fild    qword ptr [404538h]
00401EDE DEE1                   fsubp   st(1),st
00401EE0 DED9                   fcompp
00401EE2 DFE0                   fstsw
00401EE4 9E                     sahf
00401EE5 7314                   jnb     loc_00401EFB
00401EE7 DF2D30454000           fild    qword ptr [404530h]
00401EED DF2D38454000           fild    qword ptr [404538h]
00401EF3 DEE1                   fsubp   st(1),st
00401EF5 DF3D40454000           fistp   qword ptr [404540h]
00401EFB                    loc_00401EFB:

And this is what FB does with similar code:

Code: Select all

dim as ulongint CounterTSC1, CounterTSC2, CounterOverhead

IF (CounterTSC2 - CounterTSC1) < CounterOverhead THEN CounterOverhead = CounterTSC2 - CounterTSC1

mov ebx, dword ptr [ebp-20]
mov eax, dword ptr [ebp-16]
sub ebx, dword ptr [ebp-12]
sbb eax, dword ptr [ebp-8]
mov esi, dword ptr [ebp-28]
mov ecx, dword ptr [ebp-24]
cmp eax, ecx
ja .Lt_0004

I have no way to compare the timing on this, but the PB code will obviously be much slower.

FB supports inline assembly, using a more powerful assembler than the PB inline assembler. Since the compiler currently outputs assembly code this same assembler (GAS) is used to assemble the compiler output. And with a simple command-line switch you can have the assembly code available for analysis.

FB comes with header files and import libraries for the Windows system DLLs, as well as ~60 external libraries. I don’t do much with the external libraries, but I do know that the Windows header files are very well worked out, and that problems with them are rare. And you can forget the CALL keyword. With FB the function calls are like a BASIC version of the C code that you see in the Microsoft references.

One downside is that FB does not support anything like DDT, so coding a Windows GUI is more difficult, requiring that the programmer have a reasonable working knowledge of the Windows API.

Edit: Since someone might take exception to my statement regarding FB using a more powerful assembler, I should add that in FB inline assembly you can use, among other things, alignment directives, macros such as repeat blocks, and SSE instructions.
Mike Trader
Posts: 25
Joined: Feb 02, 2008 22:10

Postby Mike Trader » Feb 03, 2008 22:10

Hello Michael!
What a refreshing surprise to find you here.

I have made some very good friends on the PB Forum and I will be very sad to leave them, but dealing with a rageaholic that refers to the Forums as "his private property" constantly and illegally sends your personal information (gather during a business transaction) to third parties, is just unacceptable.

It has never been my intention to bash PB, and my posts have always been truthful. I don't take anything a face value and as I dig down I ask quetions. If that is going to make anyone here super uncomfortable and get me banned, please say so now!

One downside is that FB does not support anything like DDT, so coding a Windows GUI is more difficult, requiring that the programmer have a reasonable working knowledge of the Windows API.


I learned the windows API kicking and screaming over the last 8 years. DDT is PBs solution to that problem but has limitations, so I began to use the full Win API for dialogs. It wont be too hard to convert everything to the full CreateWindowEx() and messge pump GetMessage(). Most of the good PB guys recommend this anyway.

In reading on this forum I noticed someone using the gtk library. Now is this a self contained cross platform Grafical user interface?

Also I use Paul Squires Jellyfish code editor. I am very encouraged by his support of this language.
Some also mentioned wxWidgets. What this?

Also I forgot to ask about pointers explicitly. I use pointers heavily in my coding these days and along with WinAPI IsBadWritePtr() seem to have no trouble with memory leaks. I know VB did not support pointers but does FB have any limitations?

When OOP is implemented a lot of problems can be eliminated with the Constructor and Destructor methods as I understand it?

Finally is anyone building CGI.exe with FB? In PB STDOUT is available in the console version and in the windows version it is done using a Pipe with GetStdHandle() and ReadFile(). How is this done in FB?
sir_mud
Posts: 1401
Joined: Jul 29, 2006 3:00
Location: US
Contact:

Postby sir_mud » Feb 04, 2008 1:21

In reading on this forum I noticed someone using the gtk library. Now is this a self contained cross platform Grafical user interface?

Its not really self-contained, but many open source programs use it, like Inkscape and The Gimp. It is almost garunteed to be installed or easily installable for linux and is smaller to download than .NET for windows. WxWidgets is another cross-platform gui toolkit, but it is geared towards C++ development and the C interface is out-dated and not updated at this time.

Also I forgot to ask about pointers explicitly. I use pointers heavily in my coding these days and along with WinAPI IsBadWritePtr() seem to have no trouble with memory leaks. I know VB did not support pointers but does FB have any limitations?

FB is pretty much a safer/easier C, you are able to use pointers for what ever you need. The only limitations are those of the OS/platform.

When OOP is implemented a lot of problems can be eliminated with the Constructor and Destructor methods as I understand it?

Basic OOP is already implemented, we are still lacking inheritance and polymorphism though.

Code: Select all

type UDT
   declare constructor () 'default constructor
   declare constructor ( byref as UDT ) 'copy constructor
   declare constructor ( byval x as integer )

   declare sub SubMethod ( byval x as integer )
   declare function FuncMethod ( ) as integer

   private:
   x as integer
end type

constructor UDT ()
end constructor 'etc

sub UDT.SubMethod 'etc
end sub

function UDT.FuncMethod 'etc
end function



Finally is anyone building CGI.exe with FB? In PB STDOUT is available in the console version and in the windows version it is done using a Pipe with GetStdHandle() and ReadFile(). How is this done in FB?

You should have no problem with this either.

Code: Select all

'Works from console or inside a GUI application
var FF = freefile()
var stdin_result = open cons( for input, as FF )
var FF2 = freefile()
var stdout_result = open cons( for output, as FF2 )
'now you can write with any of the input/output commands:
print #2, "This rocks!"
input #1, mystring


Hope you have fun learning more about FB :D
cevpegge
Posts: 74
Joined: Feb 12, 2007 10:19
Location: Wales
Contact:

Postby cevpegge » Feb 07, 2008 19:09

Using FB is a really good experience, the syntax is great and I am now using it for all new projects. Like Mike, I come from a PB background.

A couple of questions:

in FB inline assembly you can use, among other things, alignment directives, macros such as repeat blocks, and SSE instructions.


I've used the FB assembler a lot but without specific documentation on the assembler. The directives would be very useful to know about, also how to do blocks of Inline data. Can you point me in the right direction?


Another question: FB decorates its STDcall export function names, @4 @8 etc. Is it possible to suppress this feature. Some compilers like PB do not understand this decoration implicitly so the DLL calls it makes have to be adapted. This compatibility problem arises when replacing PB compiled DLLs with FB compiled DLLs. It would be nice to maintain compatibility if possible.

Thanks.
Charles
stylin
Posts: 1253
Joined: Nov 06, 2005 5:19

Postby stylin » Feb 07, 2008 19:13

cevpegge, declarations in EXTERN "Windows-MS" blocks do not append that info:

http://www.freebasic.net/wiki/wikka.php ... xternBlock
cevpegge
Posts: 74
Joined: Feb 12, 2007 10:19
Location: Wales
Contact:

Postby cevpegge » Feb 07, 2008 20:36

The example given in the Wicci (and manual) does not seem to work:
.18.3

fbc -dylib t.bas

gives:

Illegal parameter specification in 'Function YetAnotherFunction ...

Code: Select all

Extern "Windows-MS"
    Declare Function YetAnotherProcedure ( ByVal As Integer ) As Integer
End Extern

Function YetAnotherProcedure ( ByVal i As Integer ) As Integer
 Function=i+1
End function



Any clues?
stylin
Posts: 1253
Joined: Nov 06, 2005 5:19

Postby stylin » Feb 07, 2008 20:49

cevpegge, you have to both declare and define the procedure in matching extern blocks.
cevpegge
Posts: 74
Joined: Feb 12, 2007 10:19
Location: Wales
Contact:

Postby cevpegge » Feb 07, 2008 21:04

Okay but this tine the error is:

... dlltools.exe: Syntax error in def file t.def:0

but if I add "export" to the defintion or both declaration and definition then the compile works.

Got there in the end. Thanks!

Code: Select all

Extern "Windows-MS"
    'Declare Function YetAnotherProcedure ( ByVal i As Integer ) As Integer
End Extern

Extern "Windows-MS"
    Function YetAnotherProcedure ( ByVal i As Integer ) As Integer export
        Function=i+1
    End function
End Extern
John Spikowski
Posts: 453
Joined: Dec 24, 2005 2:32
Location: WA - USA
Contact:

GTK

Postby John Spikowski » Feb 08, 2008 0:12

Hi Mike,

Glad to see you here on the FreeBASIC forum. I use the GTK-Server (http://www.gtk-server.org) interface to GTK with Basic interpreters but go direct to the GTK libraries with FreeBASIC.

Looking forward to your input once your up to speed.

John
Frank Cox
Posts: 58
Joined: Nov 16, 2005 21:20

Postby Frank Cox » Feb 08, 2008 6:49

The Forum used to be a great resource, but after years of heavy handed culling, all the good developers have left. I have had it too. Apart from that, who knows where this language is going. At least here you say you intend to implement OOP and so forth. We can at least have some hope things are going in a direction consitent with our needs.


You know what, Mike.. I'm coming in the door here right behind you.

It's not particularly on-topic, but PowerBASIC users might find this thread interesting:

http://groups.google.ca/group/comp.lang ... f42c32df73

Anyway, the short form of this situation is that I too am looking for a new basic compiler that will meet my needs, and I'm thinking that FreeBASIC is quite likely it.

I have already posted a question regarding the possibility of making FreeBASIC run on native 64-bit Linux, and am prepared to assist with making that happen if possible. (I don't yet have any clue whatsoever about what would be involved -- I'm hoping someone more knowledgeable about FreeBASIC than me can tell me.) I actually used FreeBASIC a while back to write the "glue code" to make a fancy voice mail/fax machine setup that I created on Centos 4/i386, and was extremely impressed at that time -- it looks like FreeBASIC has done nothing but improve ever since.

Things look interesting.
cevpegge
Posts: 74
Joined: Feb 12, 2007 10:19
Location: Wales
Contact:

Postby cevpegge » Feb 08, 2008 8:02

Mike and myself both use inline assembler for critical operations so being able to have a more advanced assembler than what we have been using is excellent news.

The assembler documentation provided in the manual is necessarily limited and it links to pages from the NASM manual, which is fine for x86 reference. But FreeBasic's Assembler is actually AS (or GAS), whose assembler directives are not compatible with NASM.

Anyway, I found a very helpful article on the subject here:

Linux assemblers: A comparison of GAS and NASM
http://www.ibm.com/developerworks/libra ... -nasm.html

And the AS manual here:

http://sourceware.org/binutils/docs-2.17/as/index.html

Testing some of the 'AS; statements, I found some incompatibilities relating to quote marks (ascii 39) and very long number literals. But nothing to worry about.
Mike Trader
Posts: 25
Joined: Feb 02, 2008 22:10

Postby Mike Trader » Feb 08, 2008 8:56

Well I am not surprised at that thread at all.
What does surprise me is that he thinks he can fool all the people all the time.


We'll reconsider that temporary block whenever you're ready to treat
your hosts and your peers with normal business respect. I'm afraid we
can't let one person with a temper make it uncomfortable for everyone else. Please let us know when you're ready.
Best regards,
Tim Robbins



http://forum.magicball.net/showthread.php?t=13108
Hi,
I am just a little confused and maybe you can help me. You firstregistered with the name of Otringal on Novemember 4th and then registered again using the name Quetch Twinsen, which is the name of a fictional video game character. I know you are aware of this character as it appeared in Little Big Adventure 1 and 2 and you are working on your own version of this game. Also your email has the name of Marcia Razvan. Please help me understand how your real name is also the name of character in a video game produced by the French company, Adeline Software?
Sincerely,
Steve Rossell
PowerBASIC Staff



http://www.powerbasic.com/support/pbfor ... hp?t=35375
I assure you that PowerBASIC is more accurate than these other compilers you are comparing it too. Consider the following expression, (3 billion * 3) / 3. PowerBASIC correctly computes this expression to 3 billion. Try this expression in your other compilers and tell me if they have the same level of accuracy.
If you need a lower level of accuracy in your programs then either write your own routines or use a less accurate compiler.
Sincerely,
Jeff Daniels
PowerBASIC Staff



Why is it all these people sound like the same person? Hmmmmm

Statements like
PowerBASIC maintains a short list of folks with whom we will not do business.

and emails like:
I think it would be best if you find another supplier of programming
tools. It's clear we can't communicate. Pleas don't order again.
Best regards,
Bob Zale
PowerBASIC Inc.

make me wonder what reality he inhabits. If I had know this when I started I would never have chosen PB. This is hard enough. Who wants to deal with that!

As for the "support" mentioned in that thread
Anyway, the real truth is that PowerBASIC free support is extensive and well known. We invite all of our friends to use it to their best advantage.
Bob Zale
PowerBASIC Inc.


The forums are defined as "User to User" for good reason. The last time I received any support in those forums was somewhere around 2002 when Lance was active. Unfortunatly, he too disappeared without a trace... He was the reason I chose PowerBasic in the first place.

Since then, "support" has been characterized by posts like this:
http://www.powerbasic.com/support/forum ... 12827.html
Well, Mike, at PowerBASIC, we create and sell programming tools. It's not possible to include a free lifetime consulting service. That's economically impossible unless we start charging $3000 to $5000 for compilers like MS and Borland. If you go to Sears and buy a hammer, they don't take the hammer and build you a house. They couldn't afford to do that, either, at the prices they charge for a hammer.
When you ask "Please write this code for me..." or "Please make my code faster..." or "Please help me find my coding bug..." or "Please translate this code from SNOBOL for me...", that's consulting work, not technical support. That's the very reason we created these forums many years ago, and that's why they're called "Peer Support Forums". This is simply not something we can do free of charge based upon upgrade prices under $100.
We'd like you to get the assistance as inexpensively as possible, and I really hope you can make a connection here. However, if all else fails, we have always offered paid technical assistance for "in-depth" problems of this nature. Feel free to contact us at your convenience if that is of interest to you.
Thanks!
Bob Zale
PowerBASIC Inc.

Either I misunderstood the concept of support or I am just not a friend.

There seems to be plenty of time to investigate a kid gamer, yet there is no time to spend expanding upon the choice of using the FPU for a DWORD operation... and I was actually hoping to learn something...

The product enjoys the support of some really talented developers. THEY are PB support. I guess they don't realize that without these contributions, there is no support. Providing a forum in which "support happens" is not quite the same thing as providing support. Even I have contributed to this body of knowledge in my attempts to give back, by exploring new areas and posting source code. No more.

I wish I had the skills to actually contribute to this project, because I can think of no finer way to say I am not willing to get drawn into that kind of nonsense, that I have tolerated for so long, than to create a better alternative.
My hat is off to all of you working on this project.

Return to “General”

Who is online

Users browsing this forum: No registered users and 1 guest