Author Topic: Banned from the FreeAsic forum, hooray!  (Read 4833 times)

_japheth

  • Member
  • **
  • Posts: 115
Re: Banned from the FreeAsic forum, hooray!
« Reply #15 on: February 23, 2022, 12:53:36 AM »
Well, I read this fb thread and must say, the ban rather did come "out of the blue". So what was the real reason? Just this "Masmbasic" pushing? ( which IMO indeed is slightly trollish in a BASIC forum )
Dummheit, gepaart mit Dreistigkeit - eine furchtbare Macht.

jj2007

  • Member
  • *****
  • Posts: 13945
  • Assembly is fun ;-)
    • MasmBasic
Re: Banned from the FreeAsic forum, hooray!
« Reply #16 on: February 23, 2022, 01:32:11 AM »
Andreas,
FB claims to be BASIC, but it has become extremely beginner-unfriendly, because everybody wants to add the latest C++ gadget, and nobody cares for BASIC functionality. So every now and then I demonstrate, for example, how "basic" loading a textfile into a string array could be, using Recall (the name is stolen from good ol' GfaBasic), or how handy GetFiles can be instead of the clumsy Dir(). I don't do that to sell MasmBasic (there is no market, and I will probably remain the only user forever), but simply to demonstrate "it can be done".

The bigger issue is the incompatibility of FreeBasic with Windows, and my insistence that they should do something about it. Take this simple boilerplate code:
Code: [Select]
#Include "windows.bi" ' JJ 3.5.2021 - a WinGUI template in 104 lines
#Include "win\commctrl.bi" ' for CreateStatusWindow
Dim Shared as Handle hEdit, hList, hStatus ' bat@TinyFB.bat for use with TinyIDE
Function WndProc(hWnd As HWND, msg As  UINT, wParam As WPARAM, lParam As LPARAM) As LRESULT
  Dim As RECT rc
  Dim As PAINTSTRUCT ps
  Dim As HANDLE PtDC
  Dim As HMENU hMenu, hPopup, hPop2
  Dim As String linect
  Select Case msg
  Case WM_CREATE
hMenu=CreateMenu() ' create the main menu
hPopup=CreatePopupMenu() ' create a sub-menu
AppendMenu(hMenu, MF_POPUP, hPopup, "&File") ' add it to the main menu
AppendMenu(hPopup, MF_STRING, 101, "&Open") ' one more main item
hPop2=CreatePopupMenu() ' create a sub-menu
AppendMenu(hPop2, MF_STRING, 121, "&sources") ' fill it
AppendMenu(hPop2, MF_STRING, 122, "&includes") ' with various
AppendMenu(hPop2, MF_STRING, 123, "&DLLs") ' options
AppendMenu(hPopup, MF_POPUP, hPop2, "&Dir") ' and add it to the main menu as "Dir"
AppendMenu(hPopup, MF_STRING, 102, "&Save") ' one more main item
AppendMenu(hPopup, MF_STRING, 103, "E&xit") ' one more main item
SetMenu(hWnd, hMenu) ' attach menu to main window
hStatus=CreateStatusWindow(WS_CHILD or WS_VISIBLE or WS_CLIPSIBLINGS or SBS_SIZEGRIP, 0, hWnd, 99)
SetWindowText(hStatus, @"This is my status bar")
hEdit=CreateWindowEx(WS_EX_CLIENTEDGE, "edit", "Hello, I'm an edit control",_
WS_CHILD Or WS_VISIBLE or ES_MULTILINE, 0, 0, 100, 100, hWnd, 101, 0, 0)
hList=CreateWindowEx(WS_EX_CLIENTEDGE, "listbox", 0,_
WS_CHILD Or WS_VISIBLE, 0, 0, 100, 100, hWnd, 100, 0, 0)
For ct As Long=1 To 9
linect="line "+Str(ct)
SendMessageA(hList, LB_ADDSTRING, 0, @linect[0])
Next
If Open(Command(1) For Binary Access Read As #1) = 0 Then
Dim As UByte file_char ( LOF(1))
Get #1, , file_char()
Close #1
SendMessage(hEdit, WM_SETTEXT, 0, CAST(LPARAM, @file_char(0))) ' type madness to avoid a useless warning
endif
  Case WM_COMMAND
Select Case wParam
  Case 101: MessageBox(hWnd, "Open not implemented", 0, MB_OK)
  Case 102: MessageBox(hWnd, "Save not implemented", 0, MB_OK)
  Case 121: MessageBox(hWnd, "No *.bas files found", 0, MB_OK)
  Case 122: MessageBox(hWnd, "No *.inc files found", 0, MB_OK)
  Case 123: MessageBox(hWnd, "No *.dll files found", 0, MB_OK)
  Case 103: SendMessage(hWnd, WM_CLOSE, 0, 0)
End Select
  Case WM_PAINT
PtDC=BeginPaint(hWnd, @ps)
SetBkMode(PtDC, TRANSPARENT)
TextOut(PtDC, 4, 4, "Greetings from the WM_PAINT handler", 35)
EndPaint(hWnd, @ps)
  Case WM_KEYDOWN
  if wParam=VK_ESCAPE then SendMessage(hWnd, WM_CLOSE, 0, 0)
  Case WM_SIZE
GetClientRect(hWnd, @rc)
MoveWindow(hEdit, 3, 28, rc.right-66, rc.bottom-50, 0)
MoveWindow(hList, rc.right-60, 28, rc.right-6, rc.bottom-50, 0)
  Case WM_DESTROY
PostQuitMessage(0)
  End Select
  return DefWindowProc(hwnd, msg, wParam, lParam)
End Function
type pCall as function (xy as any ptr) as long
type DLLVERSIONINFO
cbSize as long
dwMajorVersion as long
dwMinorVersion as long
dwBuildNumber as long
dwPlatformID as long
end type
Function WinMain(hInstance As HINSTANCE, hPrevInstance As HINSTANCE, lpCmdLine As LPSTR, nShowCmd As Integer) As Integer
  Dim wc As WNDCLASSEX, msg As MSG, hDll As HANDLE, hIconLib As HANDLE, pGetVersion as pCall, dvi As DLLVERSIONINFO
  dvi.cbSize=sizeof(DLLVERSIONINFO)
  hIconLib=LoadLibrary("shell32")
  wc.hIcon = LoadIcon(hIconLib, 239) ' get the butterfly icon
  FreeLibrary(hIconLib)
  hDll=LoadLibrary("ComCtl32")
  pGetVersion=GetProcAddress(hDll, "DllGetVersion")
  pGetVersion(@dvi)
  if @dvi.dwMajorVersion then print "Using common controls version ";str(dvi.dwMajorVersion);".";str(dvi.dwMinorVersion)
  FreeLibrary(hDll)
  wc.cbSize = sizeof(WNDCLASSEX)
  wc.hbrBackground = COLOR_BTNFACE+1
  wc.hCursor = LoadCursor(0, IDC_ARROW)
  wc.hIconSm = wc.hIcon
  wc.hInstance = hInstance
  wc.lpfnWndProc = @WndProc
  wc.lpszClassName = @"FbGui"
  wc.style = CS_HREDRAW Or CS_VREDRAW
  RegisterClassEx(@wc)
  if CreateWindowEx(0, wc.lpszClassName, "Hello World",_
WS_OVERLAPPEDWINDOW Or WS_VISIBLE, (GetSystemMetrics(SM_CXSCREEN) / 2) - 150,_
(GetSystemMetrics(SM_CYSCREEN) / 2) - 150, 300, 300, 0, 0, hInstance, 0)=0 then
    MessageBox(0, "Creating hMain failed miserably", 0, MB_OK)
    return 0
  End If
  While GetMessage(@msg, 0, 0, 0)
      TranslateMessage(@msg)
      DispatchMessage(@msg)
  Wend
  return msg.wParam
End Function
WinMain(GetModuleHandle(NULL), NULL, COMMAND(), SW_NORMAL)

Note that I use a whopping seven different correct types above, and they are all DWORD. Nonetheless, the compiler is deeply offended, and greets the n00b like this:
Code: [Select]
TmpFb.bas(14) warning 2(2): Passing pointer to scalar, at parameter 3 of APPENDMENU()
TmpFb.bas(20) warning 2(2): Passing pointer to scalar, at parameter 3 of APPENDMENU()
TmpFb.bas(27) warning 1(2): Passing scalar as pointer, at parameter 10 of CREATEWINDOWEX()
TmpFb.bas(29) warning 1(2): Passing scalar as pointer, at parameter 10 of CREATEWINDOWEX()
TmpFb.bas(32) warning 2(2): Passing pointer to scalar, at parameter 4 of SENDMESSAGEA()
TmpFb.bas(77) warning 1(2): Passing scalar as pointer, at parameter 2 of LOADICON()
TmpFb.bas(80) warning 4(2): Suspicious pointer assignment
TmpFb.bas(85) warning 4(2): Suspicious pointer assignment

I'm not sure if that makes C++ coders happy, and I doubt it (Pelles C does not produce such crap warnings). FreeBasic can't handle many of the Windows APIs. SendMessage, for example, produces nonsense warnings most of the time. Apparently, the fanatic type checking is needed to make FB's C compiler backends happy.

So, every time that I mention this issue, somebody feels personally offended, instead of solving the issue.

P.S.:
Code: [Select]
SetWindowText(hStatus, @"This is my status bar") ' OK
SetWindowText(hStatus, "This is my status bar") ' OK

Dim As String linect
SendMessageA(hList, LB_ADDSTRING, 0, @linect[0]) ' ok
SendMessageA(hList, LB_ADDSTRING, 0, @linect) ' ok
SendMessageA(hList, LB_ADDSTRING, 0, linect) ' NOT OK
SendMessageA(hList, LB_ADDSTRING, 0, linect[0]) ' ok

The underlying principle is called "trial and error", because RTFM won't help. Definitely, a beginner will give up very soon, and as a matter of fact there are almost exclusively experienced C, Pascal, Java coders in this "basic" forum.

_japheth

  • Member
  • **
  • Posts: 115
Re: Banned from the FreeAsic forum, hooray!
« Reply #17 on: February 23, 2022, 02:24:37 AM »

I'm not sure if I did understand everthing what's uttered in the thread but

- your "linker problem", which was the thread topoc, has been solved, and it wasn't actually a true linker problem, just the fact that the gnu linker doesn't understand specific MS extensions like /defaultlib?

- the other issue was a crash in a second "Print" line and you blame the compiler/linker for not emitting a warning, calling this "Beginner unfriendly"? Well, I looked at this code and could also find no reason at all why the compiler should refuse this syntax.


Dummheit, gepaart mit Dreistigkeit - eine furchtbare Macht.

José Roca

  • Member
  • **
  • Posts: 182
Re: Banned from the FreeAsic forum, hooray!
« Reply #18 on: February 23, 2022, 03:18:21 AM »
> SendMessageA(hList, LB_ADDSTRING, 0, linect)   ' NOT OK

It will also fail if you try to use it with PowerBasic, which has little type checking. Passing a string to a function that expects a pointer or an scalar is deemed to fail.

Regarding the warnings, there is a compiler option (-w none) to suppress all of them. Use it.

There have been too many toothless Basic compilers already, which have given a bad reputation to this language. If you make a language for beginners only, you won't attract skilled programmers.

jj2007

  • Member
  • *****
  • Posts: 13945
  • Assembly is fun ;-)
    • MasmBasic
Re: Banned from the FreeAsic forum, hooray!
« Reply #19 on: February 23, 2022, 04:28:51 AM »

I'm not sure if I did understand everthing what's uttered in the thread but

- your "linker problem", which was the thread topoc, has been solved, and it wasn't actually a true linker problem, just the fact that the gnu linker doesn't understand specific MS extensions like /defaultlib?

It rather seems that the MasmBasic lib depends in part on Masm32.lib, which I didn't realise. No such problem with a DLL based only on MasmBasic lib, though, so that could be the preferred solution.

Quote
- the other issue was a crash in a second "Print" line and you blame the compiler/linker for not emitting a warning, calling this "Beginner unfriendly"? Well, I looked at this code and could also find no reason at all why the compiler should refuse this syntax.

The point here is (if I understood correctly) that the library returns in eax a pointer to a zstring. FreeBasic can handle that when assigning a string: MyString=calltolib(xyz), i.e. the friendly compiler converts the zstring to a bstring, correctly and without complaining about the wrong type. When trying to do the same with Print calltolib(xyz), it crashes.

> SendMessageA(hList, LB_ADDSTRING, 0, linect)   ' NOT OK

It will also fail if you try to use it with PowerBasic, which has little type checking. Passing a string to a function that expects a pointer or an scalar is deemed to fail.

I pass strings all the time to Windows APIs, never had a problem. A string is a pointer. You may argue that a BASIC string is more than a pointer, as it has also the length info, a DWORD before the start of the memory block that it points too. Fine, then the old string in MyNew$=MyOld$ can return the zstring ptr, and MyNew$ can get the length info knowing that it's in the DWORD before, while the Windows API doesn't have to know that there is additional info before the pointer.

Quote
Regarding the warnings, there is a compiler option (-w none) to suppress all of them. Use it.

Suppressing all warning does not sound like a good idea. Why would there be warnings if they are all useless? The problem here is that if you are flooded with 100 warnings, you will overlook the one warning that will bite your customer, years later. The simple Windows template above spits out 7 warnings per 100 lines of code; applied to my RichMasm source, that would be over 1,500 warnings - madness. No thanks.

Quote
There have been too many toothless Basic compilers already, which have given a bad reputation to this language. If you make a language for beginners only, you won't attract skilled programmers.

Good point. However, PowerBasic is fast and far less complicated than FreeBasic. MasmBasic lacks some features, especially in math, but it's generally much faster than FreeBasic, and has a number of functions that FB does not offer. Check profiling, for example.

IMHO FreeBasic is a thin wrapper for GCC & friends, and suffers from not being able to fulfill the promise of "Beginners' All Purpose Symbolic Instruction Code". The few skilled programmers that it attracts come from C or C++, so what is their specific interest in BASIC...?

José Roca

  • Member
  • **
  • Posts: 182
Re: Banned from the FreeAsic forum, hooray!
« Reply #20 on: February 23, 2022, 07:21:48 AM »
If you pass a FreeBasic string to a function, the compiler will try to pass the address of the string descriptor. If you want to pass a pointer to the string data, then use STRPTR(string).

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 10583
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Banned from the FreeAsic forum, hooray!
« Reply #21 on: February 23, 2022, 09:36:08 AM »
JJ,

Its generally the case that collective projects are subject to what would normally be called "politics". A number of conflicting interests fighting with each other to dominate the end result. At one end you have a team like the "ffmpeg" developers who produce excellent and very powerful software and at the other end you have a pile of cat scratching and childish power games.

A basic compiler is a complicated piece of software in its guts and at best a reuse of the GCC tool chain which is a native C compiler will turn up the occasional incompatibility with what basic originally tried to be. I would personally never use a re-purposed C compiler, if I had a use for that tool chain, I would be writing C with it.

Bite the bullet, buy yourself the two PowerBASIC compilers and enjoy tools written by a very good assembler programmer, a guy with a narrow vision of what he was after and skilled enough to make it work.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

jj2007

  • Member
  • *****
  • Posts: 13945
  • Assembly is fun ;-)
    • MasmBasic
Re: Banned from the FreeAsic forum, hooray!
« Reply #22 on: February 23, 2022, 11:38:02 AM »
Regarding the warnings, there is a compiler option (-w none) to suppress all of them. Use it.

Attached an equivalent C source. ZERO warnings in C, seven useless and misleading warnings in FreeBasic. As I wrote earlier, extrapolated to a real project like RichMasm that would be 1,500 warnings of this type:
Code: [Select]
TmpFb.bas(14) warning 2(2): Passing pointer to scalar, at parameter 3 of APPENDMENU()
TmpFb.bas(20) warning 2(2): Passing pointer to scalar, at parameter 3 of APPENDMENU()
TmpFb.bas(27) warning 1(2): Passing scalar as pointer, at parameter 10 of CREATEWINDOWEX()
TmpFb.bas(29) warning 1(2): Passing scalar as pointer, at parameter 10 of CREATEWINDOWEX()
TmpFb.bas(78) warning 1(2): Passing scalar as pointer, at parameter 2 of LOADICON()
TmpFb.bas(81) warning 4(2): Suspicious pointer assignment
TmpFb.bas(86) warning 4(2): Suspicious pointer assignment

The Pelles C version has 90 lines, vs about 100 for FreeBasic. Attached also a roughly equivalent MasmBasic version, 18 lines.
Try googling site:freebasic.net "simple window"...

P.S.: The attachment advertises Pelles C and FreeBasic (plus MasmBasic, but that is genuine Assembly code :greensml:). Knowing Hutch, he will kill me instead of banning me permanently. To lower my death risk a little bit, I include a 90 lines pure Masm32 SDK version :cool:

guga

  • Member
  • *****
  • Posts: 1467
  • Assembly is a state of art.
    • RosAsm
Re: Banned from the FreeAsic forum, hooray!
« Reply #23 on: February 23, 2022, 01:14:33 PM »
JJ,

Its generally the case that collective projects are subject to what would normally be called "politics". A number of conflicting interests fighting with each other to dominate the end result.

Totally Agree :thumbsup: 
Coding in Assembly requires a mix of:
80% of brain, passion, intuition, creativity
10% of programming skills
10% of alcoholic levels in your blood.

My Code Sites:
http://rosasm.freeforums.org
http://winasm.tripod.com

aurel

  • Regular Member
  • *
  • Posts: 12
Re: Banned from the FreeAsic forum, hooray!
« Reply #24 on: February 23, 2022, 06:51:31 PM »
Hey jj2007

how you can say this:
Quote
, because FreeBasic is perhaps (next to PowerBasic) the last good BASIC compiler around

did you maybe forget something ....maybe  :bgrin:

yes you do my favorite basic - assembler - compiler  Oxygen Basic

if you ask me it is better ,easier and much more BASIC  than  FB.

i am also pisse'off with warnings about pointers.scalars and all other things connected with fb
but when i see that fb produced exes triger very large amount of alerts on VT ( i know VT is a crapp) .
fb is good ..there are all kind of libs for fb but i can use them in o2 too(with some trickery of course   heh)

about ban ..ahh yes that is because you tend to discuss with "fb experts" ... and i don't  :nie:
all best ..

ps. jj...do i need to post o2 version of SimpleEditor to u that you see difference?

jj2007

  • Member
  • *****
  • Posts: 13945
  • Assembly is fun ;-)
    • MasmBasic
Re: Banned from the FreeAsic forum, hooray!
« Reply #25 on: February 23, 2022, 10:44:35 PM »
ps. jj...do i need to post o2 version of SimpleEditor to u that you see difference?

Yes please :biggrin:

jj2007

  • Member
  • *****
  • Posts: 13945
  • Assembly is fun ;-)
    • MasmBasic
Re: Banned from the FreeAsic forum, hooray!
« Reply #26 on: February 24, 2022, 01:02:06 AM »
There is now a new thread at the FB forum titled "Bugs". It deals mostly with CBOOL, or is it CBool?

"CBool: Converts numeric or string expression to a boolean (Boolean)"

Anyway, it's fascinating, but I wanted to show you a nice piece of C code. This compiles fine with GCC:

Code: [Select]
#include <stdio.h>
struct somestruct {int enabled:1;};
   
int main(void) {
  somestruct s;
  s.enabled = true;
  if (s.enabled == true) {
printf("Is enabled\n");
  } else {
printf("So s.enabled alias %i is disabled, oh really?\n", s.enabled);
  }
  if (s.enabled) {
printf("s.enabled is %i, which means non-zero, so it is enabled\n", s.enabled);
  } else {
printf("disabled\n");
  }
}

Output:
So s.enabled alias -1 is disabled, oh really?
s.enabled is -1, which means non-zero, so it is enabled
 :cool:

TimoVJL

  • Member
  • *****
  • Posts: 1318
Re: Banned from the FreeAsic forum, hooray!
« Reply #27 on: February 24, 2022, 01:39:13 AM »
It's actually gcc C
enabled is int, so what ever differ from zero is possible true.
You was after odd value in binary for bool ?
It's possible, that you can't compile it with true C99 compiler.

May the source be with you

jj2007

  • Member
  • *****
  • Posts: 13945
  • Assembly is fun ;-)
    • MasmBasic
Re: Banned from the FreeAsic forum, hooray!
« Reply #28 on: February 24, 2022, 02:00:52 AM »
Timo, don't worry, the good thing about C is that it's cross-platform and compatible and standardised bla bla :greensml:

TimoVJL

  • Member
  • *****
  • Posts: 1318
Re: Banned from the FreeAsic forum, hooray!
« Reply #29 on: February 24, 2022, 02:08:54 AM »
I have known that years.
gcc was it's own version of C, also like msvc version :biggrin:
May the source be with you