My issues about freebasic

For other topics related to the FreeBASIC project or its community.
dodicat
Posts: 6357
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: My issues about freebasic

Postby dodicat » Mar 11, 2020 17:27

withdrawn.
Last edited by dodicat on Mar 11, 2020 18:07, edited 1 time in total.
SARG
Posts: 1033
Joined: May 27, 2005 7:15
Location: FRANCE

Re: My issues about freebasic

Postby SARG » Mar 11, 2020 17:50

@dodicat
Be carefull it seems to change fonts for other windows. Need to restart my box to get the normal ones.
dodicat
Posts: 6357
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: My issues about freebasic

Postby dodicat » Mar 11, 2020 18:08

SARG wrote:@dodicat
Be carefull it seems to change fonts for other windows. Need to restart my box to get the normal ones.


OK SARG.
I have removed it.
Thank you.
badidea
Posts: 1989
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: My issues about freebasic

Postby badidea » Mar 11, 2020 22:57

A start for the 'library review' I had in mind for the wiki.

=== true type font ===

Name: FBTrueType static Win/Lin 32/64-bit
Url: viewtopic.php?f=14&t=25083
Tested: 11-03-2020, Ubuntu 18.04 linux 64-bit, fbc 1.07.1 32-bit gas & 64-bit gcc
Result: All examples compile & run as expected

Name: Freetype2
Url: https://freebasic.net/wiki/wikka.php?wa ... bfreetype2
Tested: 11-03-2020, Ubuntu 18.04 linux 64-bit, fbc 1.07.1 32-bit gas & 64-bit gcc
Result: Problems
* 32-bit fbc: Linker can not freetype library, although installed on system
* 64-bit fbc: ft2_test.bas: Ok, ft2_print.bas: Crash. Both needs conversion integer to long.

Name: CharSet2FBFont
Url: https://www.freebasic-portal.de/downloa ... nt-88.html
Tested: 11-03-2020, Ubuntu 18.04 linux 64-bit, fbc 1.07.1 32-bit gas & 64-bit gcc
Result: Converter not working, only small fixes needed?

Name: Simple and Fast Multimedia Library
Url: viewtopic.php?f=14&t=26678
Tested: Not yet
Remark: Larger library (system, window, graphics, audio, network)

Edit:
List is far from complete, this 'review' will definitely be a lot of work.
* Cairo graphics can also do truetype font rendering
* And I forgot this one: https://www.freebasic.net/forum/viewtop ... =8&t=12078. Available here with some bug fixes: https://github.com/verybadidea/XFont-Lib. This uses xf-files, not sure how this relates to ttf-files.
* And raylib: viewtopic.php?f=14&t=28380
Helium5793
Posts: 36
Joined: Jun 21, 2016 13:06

Re: My issues about freebasic

Postby Helium5793 » Mar 13, 2020 18:27

I need to review those links, and will get back to you.
John
Helium5793
Posts: 36
Joined: Jun 21, 2016 13:06

Re: My issues about freebasic

Postby Helium5793 » Mar 14, 2020 14:40

Where did you see the program maybe someone here can help you to get it to work?
The program was in the freebasic forums from about 2010.

I personally have never used ttf in a FreeBASIC program but surely someone has?

They talk about using TTF with FreeBASIC's Draw String statement here in the Graphics and Games section?
https://code.google.com/archive/p/fb-extended-lib/

The few times I have used fonts I just roll my own using bitmap images as there is no innate support for them in FreeBASIC.
When you say "rolled your own" do you have a process, or one that works that I can see?

Some google results:
https://www.freebasic.net/wiki/wikka.ph ... Drawstring
https://www.freebasic.net/wiki/KeyPgWidth
https://freebasic.net/forum/viewtopic.php?t=21916
http://www.phatcode.net/~fb/forum/viewtopic.php?t=9146

I read these, and it certainly sounds doable. I could use a sample one that works. Then I might be able to take it from there.
John
Helium5793
Posts: 36
Joined: Jun 21, 2016 13:06

Re: My issues about freebasic

Postby Helium5793 » Apr 01, 2020 18:06

I have pretty much solved my issues by learning window9. While the google translated .chm file is pretty good, and they give a ton of simple examples, I would love to see the examples more fully explained. (This is not a complaint; one can figure them out, but it would be faster with a statement about what each number means) For example
1 is the item number, 30,30, is x, y upper left corner. 100,100, is the size of the window.
#Include "window9.bi"
Dim As HWND hwnd,hwnd1
hwnd=OpenWindow("1",30,30,100,100)

loop

This is a simple example, but a few of the examples can confuse. Anyway look carefully at the line to make a window, simple, elegant, and if python programmers are "pythonic" window9 programmers are "basiconic" (pronounced base-iconic) It works under windows and it works under linux. Looks nice and is simple to program. I am hoping to upload an example soon. Thanks window9 programmers, I have what I need now!

John
thebigh
Posts: 34
Joined: Dec 14, 2018 11:11

Re: My issues about freebasic

Postby thebigh » Apr 02, 2020 9:53

Yes. What I love about this language is that it combines the performance and flexibility and performance of C with the readability of traditional forms of BASIC, but without being as gimmicky as things like python. I'm an old C curmudgeon at heart so some of the new C++ inspired features are taking a while to seep into my brain but I am getting there.
Tourist Trap
Posts: 2842
Joined: Jun 02, 2015 16:24

Re: My issues about freebasic

Postby Tourist Trap » Apr 03, 2020 19:18

Helium5793 wrote: The basic part works great, but when it comes to displaying things I am having difficulties.

Hi John.

My opinion is that what you find lacking today is not bound to freebasic core. Freebasic core language is really clean and powerful. It has basic syntax with the power of C.
I use in a regular basis now other languages, like VBA, VB.net, Python, PyQt, a little of PHP, Javascript that I've come to learn for professional matter. They are all the same, there is a time when you'll need more control and efficiency, without starting coding in assembly. (more control means also using your own choosen coding paradigms) Then you'll have C maybe, but its syntax is not as easy as freebasic's one for me.

In one word, for me freebasic was a good investment for the future that still helps me a lot everyday when I use other languages. - Not mentionning that the community will virtually answer any technical question you can find in an out.

Wait I have a good word. I would say that freebasic is not the kind of language where you search in a catalog of library which one could do something for you, if you comply to its paradigm. Freebasic is more a what you can do for yourseflf with a tool that offer all the freedom you may dream of.

Now, how to solve most of the issues you mentioned? In my opinion again, it's a simple question of finding what library you want to bind to your programs. When I use Python or Javascript, I rather never use them pure. That's always tons of imports and other includes. If I compare freebasic pure, to those languages without any external libs, then FB wins.

Of course, the problem remains. What library could fit to FB to make it more useful for ones specific needs? I don't know. There is still not really an official guideline about this. This is perfectly possible to have fonts with FB. But time passing, I tend to find the little default ones good enough for most usages. But maybe you're right there could be some gain of attractiveness if we could have an official ready made official font library made avaiable. That would be probably something to include optionnaly. Not a bad idea. But I personnally can live without now, and simply use dodicat's fonts when I want to impress people :)

Not sure it helps, but my humble opinion at the hour.
Helium5793
Posts: 36
Joined: Jun 21, 2016 13:06

Re: My issues about freebasic solved -by windows9

Postby Helium5793 » Apr 16, 2020 1:11

I finished my first program using FB and window9. It was written in linux but probably would compile under windows. I am posting the source code here. The only thing that might not work is the window centering. Since I have 2 monitors I wrote a little program to center the window on the right hand monitor and wrote the info to a file. This program reads the file (which looks like this. If you want to try the program, you will have to disable the file read.
2
3520,1200
1600,1200
1920,1080
The program is called dilution.bas and it calculates how to dilute various acids and bases to get various molar solutions. What I find interesting is that the program handles a window, 18 buttons, 2 message boxes, 2 input boxes, and 5 textgadgets in 134 lines. So you might want to look at the code to see how easy it is to do windows programs with window9.

Code: Select all

/'Dilution, rewritten in FreeBasic using window9 2020-0408 '/
#Include "window9.bi"
'------display------------------
declare sub messages()
declare sub display()
declare sub calculate()
dim shared as integer xxsize, yysize,num_monitors,i
dim shared as integer monitor(2,2)
Dim shared As integer hwnd,but,event
dim shared as integer xcenter2,ycenter2,xsize,ysize,indx
dim shared as string message1,message2,reagname(20),mil
dim shared as single mLs, molarity,reagconc(20),moles_needed
dim shared as single mls_needed,mls_reagent
'--------------------------------
messages()
display()
xsize=800
ysize=400
xcenter2=int((monitor(1,1)+monitor(2,2)/2)-xsize/2)
ycenter2=int((monitor(2,2)/2)-ysize/2)
hwnd=OpenWindow("The Solution for Dilution",xcenter2,ycenter2,xsize,ysize)

ButtonGadget(1,1,30,260,30,reagname(1))
ButtonGadget(2,1,60,260,30,reagname(2))
ButtonGadget(3,1,90,260,30,reagname(3))
ButtonGadget(4,1,120,260,30,reagname(4))
ButtonGadget(5,1,150,260,30,reagname(5))
ButtonGadget(6,1,180,260,30,reagname(6))
ButtonGadget(7,1,210,260,30,reagname(7))
ButtonGadget(8,1,240,260,30,reagname(8))
ButtonGadget(9,1,270,260,30,reagname(9))
ButtonGadget(10,1,300,260,30,reagname(10))

ButtonGadget(11,261,30,260,30,reagname(11))
ButtonGadget(12,261,60,260,30,reagname(12))
ButtonGadget(13,261,90,260,30,reagname(13))
ButtonGadget(14,261,120,260,30,reagname(14))
ButtonGadget(15,261,150,260,30,reagname(15))
ButtonGadget(16,261,180,260,30,reagname(16))

ButtonGadget(17,650,10,100,30,"Directions")
ButtonGadget(18,650,40,100,30,"Calculate")

TextGadget(19,1,5,120,20,"Common Acids     ")
TextGadget(20,260,5,120,20,"Common Bases")
TextGadget(21,320,260,120,30,"mLs Desired: ")
EditorGadget(22,440,260,80,30,"   ")
TextGadget(23,290,300,120,30,"Molarity Desired: ")
EditorGadget(24,440,300,80,30,"   ")
textgadget(25,320,220,250,30,"Reagent")

Do
 event=WaitEvent()
 If event=EventClose Then End
 'If event=eventgadget Then MessBox("Russian","You pressed button")
  Select Case event

 case EventGadget
   select case EventNumber
   case 1 to 16
setgadgettext(25,reagname(EventNumber))
setgadgettext(25,reagname(EventNumber))
indx=EventNumber
case 17
Messbox("Directions",message1)
case 18
mls=val(getgadgettext(22))
molarity=val(getgadgettext(24))
calculate()
Messbox("Dilution",message2)

 End Select
   
 End Select
 
Loop
sub calculate()


moles_needed=molarity*mls/1000

        mls_needed=(moles_needed/reagconc(indx))*1000
 mil=str(mLs_needed)
 mil=left(mil,5)       
       

message2="Take " + mil + " mLs of " + reagname(indx) + " and dilute to " + str(mLs) + " mLs final volume."


end sub

sub display()
Open "Display_setup.csv" for input as #1
input #1, num_monitors
Input #1, xxsize, yysize

for i = 1 to num_monitors
input #1,monitor(i,1),monitor(i,2)
next
close #1
end sub

sub messages()
message1="Select the reagent you want to dilute. Select the molarity of the solution, and how many mLs you wish to prepare. Then press 'Calculate'."
reagname(1)="Acetic Acid glacial (100%...17.4M)"
reagconc(1)=17.4
reagname(2)="Formic Acid (90%...23.4M)"
reagconc(2)=23.4
reagname(3)="Hydrofluoric Acid (50%...25.7M)"
reagconc(3)=25.7
reagname(4)="Hydrochloric Acid (37%...12.1M)"
reagconc(4)=12.1
reagname(5)="Hydrobromic Acid (48%...8.8M)"
reagconc(5)=8.8
reagname(6)="Hydroiodic Acid (47%...5.5M)"
reagconc(6)=5.5
reagname(7)="Nitric Acid (70%...15.4M)"
reagconc(7)=15.4
reagname(8)="Perchloric Acid (70%...11.6M)"
reagconc(8)=11.6
reagname(9)="Phosphoric Acid (85%...14.7M)"
reagconc(9)=14.7
reagname(10)="Sulfuric Acid (100%...17.6M)"
reagconc(10)=17.6
reagname(11)="Aqueous Ammonia (29%...14.8M)"
reagconc(11)=14.8
reagname(12)="NaOH (50%...19.1M)"
reagconc(12)=19.1
reagname(13)="KOH (45%...11.7M)"
reagconc(13)=11.7
reagname(14)="N(Me)4 OH (25%w/w...2.4M)"
reagconc(14)=2.4
reagname(15)="N(Et)4) OH (35% w/w...2.43M)"
reagconc(15)=2.43
reagname(16)="N(Bu)4 OH (40%w/w...1.57M)"
reagconc(16)=1.57
end sub


Return to “Community Discussion”

Who is online

Users browsing this forum: No registered users and 2 guests