Is there any real Basic implementation for GTK+ ?

New to FreeBASIC? Post your questions here.
hedergabor
Posts: 23
Joined: Feb 15, 2013 10:13
Location: Europe
Contact:

Is there any real Basic implementation for GTK+ ?

Post by hedergabor »

Good day !

I have a question about GUI tools, but specially about file browsers and more (the reader can find it out below).
Recently I really do not need this thing and will not need for my first real GUI project, but I also see things from other view points.

I think it is better to add my opinion because it is a fundamental problem as I can see.

I dislike visual GUI builders and do not like the concepts of VB and VB-like tools such as KBasic, XOJO (REAL Basic), Gambas, etc. That is not structured Basic, therefore is not real Basic. I did not understand them even when I already wrote my self developed Javascript animations for my web pages. I am still ready to drop the towel because of Gambas. (I visited some webpages of Gambas today and lost all my good mood for that.)

The official FreeBASIC distrubtions are not real multipurpose Basic distributions, probably because they had no such purpose. I can understand the situation, all QBasic game developers who were continued with FreeBASIC feel like in haven because FreeBASIC became a super tool for their neends. But for a kid or a hobby programmer or even for a college/university student the official FreeBASIC dictributions are not real 21th century BASIC, like PureBasic or Ionic Wind's Basics (Creative Basic, IBasic, Emergence Basic, IWBasic) or Liberty Basic (and JustBasic). I always compare to Emergence Basic (against the fact that I have never read any whole Basic tutoral yet, I just simply wrote some - even highly efficient - Basic codes in FreeBASIC plus some more little codes in EBasic and Python for testing the language). I have a rule that I only have my own 'certificate' for those languages I learnt a whole tutorial, so those are PHP, Javascript, HTML and Pascal now. Anyway I also tested more than 20 languages and dialects a little bit and finally found out that FreeBASIC is about a superior tool compared to them (easy to type, easy to read, the debugger, program efficiency+power, loveable syntax and freedom). I became curious about GUI programming last year and wrote a little program in Creative Basic (after I became disappointed again with Python). Then I thought that maybe it is not much more difficult in FreeBASIC, so I wrote a simple window test prg in native FreeBASIC then I played with the FLTK wrapper and with GTK2+ a little bit, just to defeat my complex I think. But I still think that for GUI programming Simple GUI or (Flatland) _RB_LIB/GUI are the real authentic Basic tools, although have lack of fundamental features. (I think it is also necessary to write help files for them.) Gui_chung is also a good example for an authentic Basic concept.
At this time I already have many tools for file browsers for console FreeBASIC programs. (with file I/O plus temporary file : EBasic filebrowser for XP, PureBasic filebrowser for XP and Linux ; as library tool by object files : FLTK) All are very good just for me, but none of them for any shared GUI app. (Partly because Basic is Basic. There is one very tough rule : never do anything wich needs too much effort or an expert to have advise or 'scientific' tutorials, because that is not Basic. And never shall be Basic.) Actually FreeBASIC already needed too much effort (just from me ?), but this is love(?). I have called for myself this 'Python syndrome'.

Now about my question. When I did some trials with Cairo fonts I found out that many tools can be implemented into FreeBASIC as real native Basic.

Some lines from my test program :

#include once "modules/cairotext.bas"

..

cairocontext ablakszelesseg_ , ablakmagassag_

..

cairofont 45 , "Verdana" , normal , bold , 0 , 0 , 255 , 255
cairoprint 50 , 40 , "ez a Cairo text"

..

#include once "modules/fltkfilebrowser.bas"

..

if FBfilebrowsergomb_ then
directoryname_ = ""
filename_ = ""
fltkfilebrowser
endif

..

cairodestroy


This is not a real development yet, just for playing about GUI and to figure out concepts.
But as I already can see, it is hard to avoid GTK+ implementation for multiplatform GUI programming. GTK+ is not Basic and is too sophisticated and difficult for being native Basic. Therefore some implementations must be done if there is no such tool already.

For example file browser, like this :

dim shared as string filename_

filename_ = gtkfilebrowser / .. parapeters here /

And even this case, the name 'gtkfilebrowser' is good enough for PHP taste, but already is too complicated for real native Basic. 'Filebrowser' is OK, but than there is not too much options for name spaces. (fileopen, filesave, filechooser, filedialog, etc.) I personally do not like such funcion names as file_open_dialog, etc. - C library function name like sentence for a function name. I was sick of C for years and could not imagine that people changed Pascal onto C in universities just because C is simpler(?). No, at least three times more difficult. (I sudied Pascal in the late 80s and felt myself stupid for even that.)

Is there any such implementation already for GTK+ in FreeBASIC ? I really do not want to invent the `soap`.

Thank you anyway for reading this.
Kwabbernoot
Posts: 80
Joined: Apr 19, 2010 18:23
Location: NL

Re: Is there any real Basic implementation for GTK+ ?

Post by Kwabbernoot »

There is a FreeBASIC GTK+ tutorial.
http://zetcode.com/gui/fbgtk/
caseih
Posts: 2157
Joined: Feb 26, 2007 5:32

Re: Is there any real Basic implementation for GTK+ ?

Post by caseih »

I find your statements contradictory. You eschew things like VB that make simple GUIs extremely easy to develop, yet you do not want to use a real, full GUI toolkit such as GTK+. And you keep using nonsensical phrases like "Basic is Basic," which is clearly false (what is BASIC anyway? never been standardized). What makes FB not a multipurpose distribution? And why is something like FLTK good for you but not for a shared GUI app? You say GTK+ is not BASIC. What does that even mean? GTK+ isn't C either. It's just a library with its own powerful architecture and API. I guess I don't understand your points at all.

Some of your rant seems to involve personal preference. CamelCase vs snake_case. And when you're accessing an external library, you typically have to access it using the names provided by the library, unless the FB wrapper renames things (GTK+ does not, for ease of wrapper generation). Hey at least you don't have to use Java where classes and methods are both in CamelCase and still complete, verbose, sentences!

To answer what I think is your question, no there is no such implementation as you seek already for GTK+ in FB. You are always free to write one and post it here.

I'm not really sure what you want at all (doesn't seem like you know either), but I've seen a couple of different native FB GUI libraries created by forum members that might interest you. They are not very complicated, but handle basic (as in simple) needs.

Full blown GUI toolkits like GTK+, or even FLTK, are complex beasts. There will be a learning curve. You can't avoid that. In any language.
caseih
Posts: 2157
Joined: Feb 26, 2007 5:32

Re: Is there any real Basic implementation for GTK+ ?

Post by caseih »

Thinking on it, what you are asking for is a procedural library that lets you display message boxes and get input such as file selection. Is that right? Something like this perhaps?

Code: Select all

myfile = guichoosefile()
do_something_with(myfile)
print "All is well?"
No one has made such procedural wrappers for GTK+ but it wouldn't be too hard to make something like that. Of course before too long you'll need a full GUI app, and they are by their very nature event-driven, not procedural.
hedergabor
Posts: 23
Joined: Feb 15, 2013 10:13
Location: Europe
Contact:

Re: Is there any real Basic implementation for GTK+ ?

Post by hedergabor »

@Kwabbernoot

Thank you the link dear (Mr.) Kwabbernoot. I already read that tutorial last year when I played around GTK+ 2 a little bit (with FB 0.23 I think but I am not sure). (I also translated for myself some example codes from a Free Pascal tutorial.)

@caseih

Dear (Mr.) caseih !
I thank your opinion. (I am absolutely right whatever I wrote above.) I explain it, but firstly, I thank you your theoretical code example.

You understood what I need, and you are right, I have to learn GTK+ to get that. Obviously I did not want to do any such job before I find out that there is no such work. Because I am not an expert. Language development is not my business. It is not a joke, anyone can understand this if read these things bellow.

To get a file browser in a few lines is not an extra stuff in a real 21st century structured language.

For example, I wrote two codes for file I/O and temporary file writing in Emergergence Basic and PureBasic for testing this feature. I do not want to develop any new codes, because I am not so good, so I upload these codes. (Maybe they have somewhat faults, but worked perfectly for me. I think they are good enough to represent concepts.)

This is the PureBasic code :

Code: Select all


; ANSI CP 1250 , CR+LF

filename_.s = ""
openfilename_.s = "openfilename.tmp"

pattern_.s = "All files (*.*)|*.*|PureBasic (*.pb)|*.pb|Basic (*.bas)|*.bas|Text (*.txt)|*.txt|PNG (*.png)|*.png|GIF (*.gif)|*.gif"

#file = 1
#tmpfile = 2

filename_ = openfilerequester("open file" , "" , pattern_ , 0)

if filename_
createfile(#tmpfile , openfilename_)
writestring(#tmpfile , filename_ , #PB_Ascii)
endif

end

This is the Emergence Basic code :

Code: Select all


' ANSI CP 1250 , CR+LF

def tempfile_ : file
def tempfilename_ , filter_ : string
def filename_[1000] : istring

filename_ = ""
tempfilename_ = getstartpath + "/openfilename.tmp"

filter_ = "All files (*.*)|*.*|PureBasic (*.pb)|*.pb|Basic (*.bas)|*.bas|Text (*.txt)|*.txt|PNG (*.png)|*.png|GIF (*.gif)|*.gif"

filename_ = filerequest("select file" , 0 , 1 , filter_)

if ( not(filename_ = "") and not(openfile(tempfile_ , tempfilename_ , "w")) )
write tempfile_ , filename_
closefile tempfile_
endif

end

As anyone can see, these are single source files. To write whatever simple GUI even one source file is enough in such programming languages. No project files, no classes, no objects, no graphical editor. (Although for example for IWBasic there is graphical GUI editor. I think it is a usual feature for such IDEs.)

I stated as you later agreed dear (Mr.) caseih that it can be even more simple in FreeBASIC.
Only three lines of codes in a code of a native FB window (which created with screen or with screenres) :

Code: Select all


#include once "modules/gtkwidgets.bas"

dim shared as string filename_
filename_ = filebrowser .. parapeters here ..

As I showed my code samples before, I already did it for the filechooser of the FLTK C wrapper, although not with a function but with a SUB.

But this is not a built-in feature in all (or at least most) official distributions of FB yet.
(There is a distribution at http://free-basic.ru/download.html for FB 0.24 with window9 , but I did not download and tested it yet, so I do not know whether that is an absolutely automated installation or not.)
I cannot remember any tool that can give me for Linux such thing as filerequest() of EBasic (Windows) or openfilerequester() of PureBasic (multiplatform).

Emergence Basic and IWBasic have amazing chm help files. (The only one confusing part is those '@class = @idcontrol' like things in GUI codes which need some extra effort to understand and use. I think Emergence Basic GUI is not as simple as it has to be.)
I could agree that PureBasic GUI is not simple enough, I found it too difficult for my taste when I tested it.

About VB :

It is not a hard thing to write objects and to use some `callback mechanism` in HTML DOM. Anyone can do that, although it can be very confusing for a beginner, because it is a good question why a beginner have to learn at least two different languages to do that.

Once again, I only upload real code, it is from the index page of my professional site. (Only three lines from the HTML code.)

Code: Select all


<body onload='kikapcsolo()'><!-- onload : javascript animacio -->

<!-- szkript elsewhere in the code !! -->
<script language="javascript" type="text/javascript" src="javascript/kismotor_index_electro.js"></script>

I guess VB and VB-like tools do something similar. Such technique is not simple to develop web pages for a totally beginner like I was. There are two different source files, top of all in two different languages. (It is much harder obviously than only using one Basic dialect for codes.) For body onload the browser starts the Javascript function kikapcsolo().

Plus, Emergence Basic and Creative Basic do the same, but luckily it can be in one source file.

Once again, I upload my very simple first test GUI program for Creative Basic. This was the program which bringed me for the idea that a FreeBASIC GUI app can be as simple as this.

Code: Select all


' ANSI CP 1250 , CR+LF

'---------------------------------
'		Declarations
'---------------------------------

const cp1250 = 0x00EE0000
const red = rgb(255,0,0)
const blue = rgb(0,0,255)

def ablak1 as window

'---------------------------------
'		Main
'---------------------------------

window ablak1 , 10 , 100 , 500 , 400 , @size|@minbox|@maxbox , 0 , "Ablakom már" , &ablak1

control ablak1 , "B , BE , 50 , 140 ,100 , 40 , 0 , 1"
control ablak1 , "B , KI , 250 , 140 , 100 , 40 , 0 , 2"

setfont ablak1 , "Ariel" , 35 , 700 , cp1250
frontpen ablak1 , red
print ablak1 , "Áll már a fűnyíró őrláng !"

kep_ = loadimage("27.gif" , @imgscalable)
showimage ablak1 , kep_ , @imgscalable , 50 , 100

move ablak1 , 10 , 350
setfont ablak1 , "Ariel" , 20 , 0 , cp1250
frontpen ablak1 , blue

waituntil ablak1 = 0

end

'---------------------------------
'		Procedures
'---------------------------------

sub &ablak1

if @class = @idclosewindow then closewindow ablak1

if @class <> @idmousemove 
if ( 0 < @mousex ) & ( @mousex < 400 )  & ( 0 < @mousey ) & ( @mousey < 400 )
print ablak1 , "OK !" 
print ablak1 , @mousex , @mousey
endif
endif

if @class = @idcontrol
if @controlid = 1 then print ablak1 , "BE "
if @controlid = 2 then print ablak1 , "KI "
endif

return


(if @class <> @idmousemove) is an example for the confusing part of the language.
I can add, that Creative Basic reminds me to Pascal. I found Creative Basic is a very strict language compared to FreeBASIC. Maybe I am wrong with this opinion, but when I tried to define functions before the Main code I got errors.

You can see what happens with the (sub &ablak1) which is the main procedure here.
I guess Gambas do the same, but in a different source file. The project files include at least two files instead of one. As you can see, the structured programming of Creative Basic lets the programmer to do the whole thing without knowing anything about such things as callback or pointer or main event loop or classes or objects. That is the great part of the whole structured programming style. The stone aged minded simplicity. This is the goal of such programming method. When a language learner is able to write simple console programs with loops and functions/procedures, he can write immediately simple GUIs too. He do not need to understand any additional concepts, specially not the concepts of object oriented programming or pointers.

And this is the next part, GTK+. The GTK+ examples in the tutorials for beginners are not too difficult for college students, but obviously are more complicated than to write only three simple lines for a file browser. For example, FB could have some simple bult-in functions for GTK+ like filebrowser(), and the programmer could have his options do it other way with GTK+, for example he could write his own file browser which fits to his needs.
Structured programming in native GTK+ maybe is a very hard thing. I read an opinion about it, he said that structured programming in native GTK+ is absolutely impossible. When I tested GTK+ 2 with FreeBASIC, the GTK+ main event loop really looked untouchable for me. But maybe not for an expert (I hope so).

If someone can implement GTK+ into FreeBASIC for structured programming, so that is really simple Basic and everybody can use it as simple way as programming in Creative Basic - he does something very important.
But even in that case a simple native main event loop is the better. (Like in AutoIt 3.) I wrong know whether anybody could write such thing for FreeBASIC for GTK+. Therefore I am ready to compromise with a native main window (created with screen or screenres) plus additional FLTK and GTK+ GUIs, which appear in another windows, like file browser, colour chooser, input text editor, etc. It could be programmed with a simple DO loop, which makes GUI programming very easy.

But I hope no one want to torture simple folks who only need Basic.

From en.wikipedia.org/wiki/BASIC the BASIC is :

Beginner's All-purpose Symbolic Instruction Code

- for Beginners
- All-purpose
- Symbolic Instruction (I agree that - philosophically - it can be graphical symbol too, but originally it was always typed code, as I remember to all Basic codes I saw in the 80s.)
Plus, Basic was already more than 20 years old in 1986.

Some introductions for Basic says about this : Basic is simple, because it simply comes from the English language.

if I like it then the machine prints "You like it."
if iliketit_ then print "You like it."

Plus some more thing :

1.
My freedom is a real freedom.
ilikeit_ from the above example can be ILikeIt_ or I_Like_It_ , but I can not be forced to follow any conventions. I love codes in lower case.

2.
When a computer language only uses simple statements, such as 'printline' it is unnecessary to use some capitalized letters in the code or using underlines in the code. In real everyday texts people do not write such things as EveryDay or every_day. The word 'everyday' is well known, so it is easy to read. The built-in words of a Basic language are the same. It is not necessary to write 'ConsolePrint' or to define the word 'console_print' instead of using 'consoleprint', because the programmer read and write this word dozens or hundreds of times. Anyway, I agree that I am not the person who wants to show much respect for readability by others. I do not like indentation and some other conventions, in old Basic codes I did not see such things as indentation or combinations of upper case letters and lower case letters. Like If Then, Do While, etc. (Plus heavy indentation makes difficult to read codes for me.)

If someone respects the original meaning of the word 'Basic', he has to respect the freedom of the code writer. I think this is why people can write such codes in many Basic dialects as
IF THEN
If Then
if then

Because this freedom makes easier to use a programming language which produced for beginners. Nowadays a beginner Basic programmer can be only 9-10 years old. Or even younger ?
For indentation it is the same.



Why the official FreeBASIC distributions are not real multipurpose tools.
All real 21st century Basic have many built-in tools to provide multipurpose programming. The programmer do not has to install many other tools to get this. (Only a few.) For example the documentation of PureBasic DEMO version mention some libraries for installation in Linux as necessary packages, but as I remember almost all packages were already installed in OpenSUSE in my PC when I tested PureBasic for Linux. Emergence Basic provide all libraries in its own installation, which are needed beside the system libraries of XP. Even a schoolboy can install such Basic. Plus the programmer usually can use external libraries for his needs. (In Emergence Basic he even can use built-in C or assembly codes.) FreeBASIC lacks many such built-in tools. This made an interesting thread in a forum years ago.

FreeBASIC even worst then C for this aim : A C programmer can choose a library and simply use it - I meant only compatible libaries of course. He can already get the header files of the library with the library package.
The FreeBASIC programmer can not use C libraries directly. He needs traslated header files from C header files and he needs compiled C libraries which are static or shared libraries and content object files.
It is a great plus that the official FreeBASIC distributions have code examples and bi header files for C libraries, but that is all.
These FreeBASIC distributions do not content those C libraries (except the Standard C library, or maybe some others - I do not know about such other libraries but who knows). Now this is the hardest part : A beginner downloads a C library package for Windows, which is - in the luckiest case - already compiled library with static and shared libraries. But the programmer wanted a Basic like Liberty Basic and had no idea about C, maybe even have no idea about libraries (because he can be even 10 years old !), and he has no idea about that his downloaded library is another version than his header file. Top of all, sometimes it is not easy to find a repository which contents the proper old library. No problem, he simply makes his new header files ? Maybe yes, but maybe not. He is not a C programmer, he wants only Basic. Compatibility troubles are also exist, for example the FLTK C wrapper needs FreeBASIC 0.24 or later versions. I also read thread for IUP, it looks like that the FreeBASIC 0.24 is not really good version for a certain IUP library package, but an earlier is OK. (I do not want to look after for that thread.)
Always running forward with the latest distributions can result much more troubles. For example I wrote some PHP codes for MySQL 5.1
MySQL 5.1 has different syntax for that aim than some earlier versions which widely used for PHP4. Than MySQL 5.5 came out, with some new different syntax. I am not in the mood to rewrite codes and install always the latest stuff. I use OpenSUSE 11.2, Debian Lenny, SUSE Professional 9.0 and XP (recently SP3), all in the same PC. It took many time and effort to figure out how to install and configure things. I have a complete written know-how for that. Obviously because it could not be so funny to do the whole thing again and again. For FreeBASIC GTK+ 2 apps there shall be many Linux ISO distributions for a while (For example for Puppy and Debian) in repositories. (At least I hope so.)


Python has site-packages for libraries for Windows. The programmer simply chooses the suitable site-packe from a repository. (For example for Python 2.6 there is a version of PyFLTK as site-package for Windows.) There are other techniques, for example LuaAIO, which is a complete distribution which contents all built-in libraries for that Lua version. Script Basic applies similar technique for built-in libraries. It looks like FreeBASIC had no such support from developers and users than Python. But I am almost sure that LuaAIO was distributed by only one developer. (I do not check it now.)

Final note :

But look at these Creative Basic codes please.

setfont ablak1 , "Ariel" , 35 , 700 , cp1250
frontpen ablak1 , red
print ablak1 , "Áll már a fűnyíró őrláng !"

Nice feature anyway. Poor FB 0.24 programmer only get the 8/16 fonts as best font by default, for print or for draw, to print texts simple way in screen.
Any other bigger/different font needs some extra work to look after libraries or making self-made tiny BMP or PNG images for letters, etc. I applied some Cairo font codes into a self-made Basic implementation, but that only looks usable with Courier fonts in the main event loop in my program. (With about 4-5 acceptable sizes.) Before the main event loop Cairo did good job for me.

I still not have tested FB 1.03, but for FB 0.24 and for FB 0.23 I had no any problems for GTK+ 2 on XP when I tested it, so I stay with FB 0.24 (this version also supports the FLTK C wrapper).

I almost forgot the FLTK filechooser. FLTK filechooser made the same bug for me in my PC with FLTK C wrapper for FreeBASIC and with Python 2.6 PyFLTK. Maybe it was because of only my machine or system, but maybe it can happen in some other machines too. GTK+ has nicer file browsers. But only for me on my machine, FLTK filechooser is OK. I know what to do with it. I also thought about a troubleshoot button.
Last edited by hedergabor on Nov 19, 2015 8:10, edited 2 times in total.
caseih
Posts: 2157
Joined: Feb 26, 2007 5:32

Re: Is there any real Basic implementation for GTK+ ?

Post by caseih »

I think I understand what you're saying. When you say you a language is multipurpose you mean that the language (and the runtime; the distinction is blurry in your mind) has all batteries of any kind included. External libraries should not be needed. This is not how I use the term, though. So I think we just aren't agreeing on our definitions.

You are correct, though: FB certainly isn't a competitor to any of the BASIC variants you list here. FB is much more general. More like C, or Pascal.

FB scratches an itch that many users like; you're free to take it or leave it, or contribute to it. I would argue that the other BASICs you refer to here (including some you have code examples for) are less multipurpose than FB because you're locked into whatever user interface constructs the language provides. FB, on the other hand, allows access to any external, native libraries. In other words, a program in your CreativeBasic (sp?) with it's custom GUI constructs may or may not look like a native app, may not be portable between platforms. Whereas FB allows creation of full-blown apps using whatever GUI toolkit is appropriate for the platforms you are targeting. I am a firm believer that the language itself should be as minimal as possible (FB is rather bloated, but all BASICs have a lot of baggage), with rich runtime libraries, and access to good external GUI libraries. I understand that QBasic compatibility brings a lot of baggage to both the language and the runtime, but I think that in the FB dialect, graphics commands should removed from the language specification and made to be called like any other sub or function in the runtime. Same for the Draw command that people having so much fun with on this forum.

Your wanted procedural user interface constructs really aren't appropriate for being in the language itself, but be made an external, optional, callable library. I suspect most of the users of FB who aren't using Fb for it's QBasic compatibility would have no need of such procedural wrappers, though.
marcov
Posts: 3462
Joined: Jun 16, 2005 9:45
Location: Netherlands
Contact:

Re: Is there any real Basic implementation for GTK+ ?

Post by marcov »

caseih wrote:(what is BASIC anyway? never been standardized).
https://en.wikipedia.org/wiki/BASIC#Standards
hedergabor
Posts: 23
Joined: Feb 15, 2013 10:13
Location: Europe
Contact:

Re: Is there any real Basic implementation for GTK+ ?

Post by hedergabor »

@caseih

Dear (Mr.) caseih !

I agree what you wrote. You and I absolutely say about the same thing but from two different view points. As Basic is originally - or better to say traditionally - created for beginners. An authentic Basic is always limited for its built-in feauters. (Using external libraries can be optional.) But obviously this is what I want from a real Basic. Simpliticy, wich only can be done when developers compromise because of the simple syntax. PureBasic became too difficult for me in this way in this manner, beacuse the developer firstly simlified mechanisms, then produced lot of features for productivity to avoid the lack of efficiency. The result is a confusing GUI which brings almost as much troubles for me, than GTK+ could do.

What you wrote about FB is rather a sweet dream for beginners - because of the additional work for libraries compared to C. For example if I really wanted to try CGUI, I would start to do it in C, not in FreeBASIC, because of the less work with the library.

But you are right, really, FreeBASIC is propagated as a combination of Basic and C, so almost officially FreeBASIC is not a real Basic for beginners(?). This is my point. With external libraries - as you said dear (Mr.) caseih - FreeBASIC can be an authentic limited tool for beginners and for old-fashioned Basic lovers. What I stated that FreeBASIC has no such official distributions, but obviously - theoretically - anyone could made such distributions for FreeBASIC, packing external libraries into the distribution, plus additional help files, etc. Because this is the need of native Basic programmers. Simlicity in syntax, in installation, etc.
Plus, this should be required in schools to apply FreeBASIC as teaching tool.

Plus some notes :

1.
The PureBasic DEMO from 2014 still needed GTK+ 2 packages for Linux.

2.
I agree that such function names like 'allocate_memory_block' etc. can appear in any language, but I mostly saw such function names in libraries developed in C. (And I hope that when I publish a self made little module developed in FreeBASIC, no one will claim that my functions are not FreeBASIC.)
marcov
Posts: 3462
Joined: Jun 16, 2005 9:45
Location: Netherlands
Contact:

Re: Is there any real Basic implementation for GTK+ ?

Post by marcov »

hedergabor wrote:From en.wikipedia.org/wiki/BASIC the BASIC is :

Beginner's All-purpose Symbolic Instruction Code

- for Beginners
- All-purpose
- Symbolic Instruction (I agree that - philosophically - it can be graphical symbol too, but originally it was always typed code, as I remember to all Basic codes I saw in the 80s.)
Plus, Basic was already more than 20 years old in 1986.
Be very careful to interpret historical acronyms by today's standards. I know this about Pascal, but since Basic is even older that is even more dangerous.

In the case of Pascal (that is commonly refered to as teaching language), it is a gross oversimplification since many people will have first year students, or even younger in mind. While it was actually meant to teach master level math students about algorithms AND THEIR EFFICIENT IMPLEMENTATION.

I wouldn't be surprised if Basic had similar issues. If you want to derive meaning from the acronym, you need to study it in the original, not current context.
hedergabor
Posts: 23
Joined: Feb 15, 2013 10:13
Location: Europe
Contact:

Re: Is there any real Basic implementation for GTK+ ?

Post by hedergabor »

@marcov

Thank you your advise dear (Mr.) marcov.

The quotation "Beginner's All-purpose Symbolic Instruction Code" is appeared for example in the webpage of KBasic, as I remember. This is a simple way to make sense for visitors what is that Basic. But for example I am not totally beginner but have still programmed in Basic, therefore "Beginner's All-purpose Symbolic Instruction Code" is only expresses the main features. I agree that many methods can be simple enough for certain tastes to call them "real Basic", but structured Basic languages still are an authentical way derived from the early time console programming. This is what I tried to explain.
They try to provide mechanisms for the programmer to write any programmes in about the same manner as writing simple console programs, and this is a feature which did not changed to many Basic IDE till now from the 80s. There are many Basic interpreters and compilers which try to follow this tradition. So this what can be called commonly Basic.

In the simplest case, an authentical Basic - and there are many - provides such features like this, because it is a straight derivation from simple console programming :

Code: Select all


dim mywindow_ as window
dim mybutton_ as button
dim myfilename_ as string

mywindow_ = window .. parameters here ..
mybutton_ = button .. parameters here ..

'main event loop

do

if mybutton_ then
myfilename_ = filebrowser .. parameters here ..
endif

.. other codes here ..

loop until ..conditons here .. ' it can use constants

end

Any other features can be added, but the lack of such features as represented above is very critical to find out whether is that language really Basic or not. Because the opposite corner, when a tool propagated as "Basic" and only can provide very sophisticated mechanisms as 'simple tool' for beginner, is even more dangerous in 2015.* I agree that maybe it shall be changed to 2040.

* : Please think of a graphical editor for GUI, with 10 or more options for any widgets.
"Ó, No, I only wanted to write this for my 'lovingly prepared' image button :
FBbegomb_ = button(270 , 40 , 50 , 50 , "widgetgraphics/begomb1.bmp" , _
"widgetgraphics/begomb2.bmp" , "widgetgraphics/begomb3.bmp" , RED)
"

But it already happened that some people tried to find out what tool can be called "modern Basic" for such fundamental taste - for example PHP or Javascript were mentioned.

What is a related fact, a really simple language for console scripting could be a core language. Somewhat combination of PHP and Javascript and Gentee.

P.S.

It is a veery good thing to develop a Basic which can - for example - provide easy access to C math libraries. FreeBASIC can do this, but only by more sophisticated way as C do.
Last edited by hedergabor on Nov 19, 2015 11:55, edited 2 times in total.
jcfuller
Posts: 325
Joined: Sep 03, 2007 18:40

Re: Is there any real Basic implementation for GTK+ ?

Post by jcfuller »

Just a FYI

I have been investigating gtk+(2&3) for a new windows/linux translator (basic -> c/c++).
I envisioned a simplified basic syntax wrapper for the more common features.
It turned out to be MUCH more effort that I am willing to do.

The first obstacle I encountered was obtaining the libraries for Windows.
I attempted to compile them but found my msys setup would not work.
I did manage to track down some precompiled Windows packages but they
are not as up to date as the sources, or the ones installed on my linux machine.
I never did find 64bit static libraries.

I had very limited gtk+2 background so I figured I should start there and work my way up to gtk+3.
There were many gtk+2 examples on the internet (zetcode) and I also purchased Foundations of GTK+ Development by Andrew Krause.

Until recently the very good (c/c++) zetcode examples were not up to date with the current gtk+2 version and led to much frustration, as did the examples in the book.

Demos that compiled and ran fine on windows would throw warnings and errors on linux.
These were mostly because the dev packages on linux were more up to date.

Most forums advocate using gtk+3 for new projects but I found gtk+3 on windows is buggy and not well maintained. The documentation is gnome-centric as are the examples I could find.

James
SARG
Posts: 1766
Joined: May 27, 2005 7:15
Location: FRANCE

Re: Is there any real Basic implementation for GTK+ ?

Post by SARG »

Hi,

Have a try to IUP Library.
Very easy to use (simple and clear instructions, full documentation, dynamic or static Library,... )
When you have understood the principles no real issues.

Currently I'm rewriting Fbdebugger (only GUI part) to be multiplatform.
I found some bugs/typos and exchanged with the dev in order to fix them or to add features. He responds very quickly.

SARG
badidea
Posts: 2591
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: Is there any real Basic implementation for GTK+ ?

Post by badidea »

Is it not that the 'real' BASIC way of doing thing doesn't match the current computer architecture any more?

Instead of a single core processor, single program, single thread code, like:

Code: Select all

do this
wait for that
poll thing1
poll thing2
goto begin
More complex code with callbacks and sleeping is needed to keep everything else run smoothly as well?

On variables name formats, I use my own, which probably no one else likes. But not using indentation, I cannot imagine, all my code would turn into an unreadable collection of text.

E.g. this:

Code: Select all

function balls_type.add(p as xy_sgl, v as xy_sgl) as integer
	dim as integer i
	if (numBalls < MAX_BALLS-1) then
		for i = 0 to MAX_BALLS-1
			if (ball(i).value = -1) then
				ball(i).value = 0
				ball(i).p = p
				ball(i).v = v
				numBalls += 1
				return i
			end if
		next
	end if
	return -1
end function
Versus this:

Code: Select all

function balls_type.add(p as xy_sgl, v as xy_sgl) as integer
dim as integer i
if (numBalls < MAX_BALLS-1) then
for i = 0 to MAX_BALLS-1
if (ball(i).value = -1) then
ball(i).value = 0
ball(i).p = p
ball(i).v = v
numBalls += 1
return i
end if
next
end if
return -1
end function
And with geany's indentation guides:
Image
Tourist Trap
Posts: 2958
Joined: Jun 02, 2015 16:24

Re: Is there any real Basic implementation for GTK+ ?

Post by Tourist Trap »

hedergabor wrote:It is a veery good thing to develop a Basic which can - for example - provide easy access to C math libraries. FreeBASIC can do this, but only by more sophisticated way as C do.
Hello hedergabor,

Just a remark from my personal experience. I've been using VB since 2007 (yet casually), and I've very early discovered that even if the GUI is improving year by year, it is not sufficent. To do something correct you'll need access to the core of the system even under windows via a pure microsoft windows language! So you'll still have to learn at least some of the windows api , and it wont be so simple in VB to understand the deal since pointers are forbidden (at least in a simple way, but I wouldn't be affirmative for versions beyond 2005, since I use .net 2 and vb2005 - to keep the range of potential user wider, even if I'm the unique one in general!). Think for example of adding a background to a textbox, it seems so simple, and is not! unless you enter rather big business (you have to change things in the inheritance scheme but as far as I remember you have to bypass some resistance, the dawbaground stuff wouldn't leave you easily change his design, then you'll have to deal with the slowness and so on). My conclusion was then that for doing good job you just have to forget what is promised in the box, it wont be just drag and drop and as one would expect at first glance.

So what I mean also is that there is not a language bundled with a GUI that wont show quickly serious limitations to the user wishes. For this reason, I like FB, since you get immediatly familiar with this idea. You can always use very nice built-in stuff, crossplatform, and often backward compatible, but switching to external libs, or windows api, wont appear like a treason and break you heart. FB in this wouldnt lie to you. It certainly make most of things as easy as possible, since its basic derived from QB is still very friendly, but when it has to come to pointers, or graphical programmation with memory addresses, it just doesn't discourage you doing so this way. So doing you are helping also yourself as an user in order to learn true stuff related to how a computer work.

I think that in the long term this is a good approach.

However I agree with you that if the gtk lib would come wrapped in a module this would be an interesting addition. But by no mean an ultimate one. Gtk, even if very big is very peculiar, I'm mean here, not a gui to the taste of everyone.
hedergabor
Posts: 23
Joined: Feb 15, 2013 10:13
Location: Europe
Contact:

Re: Is there any real Basic implementation for GTK+ ?

Post by hedergabor »

@ badidea

Good day dear (Mr.) badidea !

Ithink this is out of the original topic, but your code look like this for my taste :

Code: Select all


function balls_type.add(p as xy_sgl, v as xy_sgl) as integer

dim as integer i

if (numBalls < MAX_BALLS-1) then

for i = 0 to MAX_BALLS-1
if (ball(i).value = -1) then
ball(i).value = 0
ball(i).p = p
ball(i).v = v
numBalls += 1
return i
end if
next

end if

return -1

end function

I agree that it is not look like as pretty as your indented version, but much less work in a very simple text editor, plus it became my habit in Crimson Editor.

@Tourist Trap

Good day dear sir ! Thank you the advise.
Post Reply