Dream of sugar

General discussion for topics related to the FreeBASIC project or its community.
Post Reply
oyster
Posts: 274
Joined: Oct 11, 2005 10:46

Dream of sugar

Post by oyster »

Some of the following are posted here before, but some are new.

It is too long nonsense, please don't take it seriously. ;)

1. Showcase
As far as I know, FreeBASIC is born to make QB alive/mimic QB in today's os, once this goal is achieved, I feel that the development slow down recently.

Gallery of Applications for some notable examples presents a feel of last century, and says "FreeBASIC can only be a toy language for non-serious or commercial applications".

As a contrast, purebasic, xojo/realbasic or even freepascal/Lazarus look beautiful and modern.

The capability and realization are not the same things. Maybe something prevents FreeBASIC from writing applications. So the first dream is on eye candy: an up-to-date FreeBASIC application gallery to show where FreeBASIC can be used in, and which level the current FreeBASIC projects can meet.

2. Syntax
Yes, maybe FreeBASIC has supplied the features to write applications by extending some new feature. But QB/VB and C, are born decades ago. More features are introduced in the new languages since then.

Maybe someone would say "hey, you are talking about python, not FreeBASIC. Go to your f*king python".
  • No, think about !"string" in FreeBASIC, which is not BASIC's syntax; why FreeBASIC accepted it?
  • No, as we all know, FreeBASIC has borrowed many features from C which do not exist in QB/VB
  • No. what do you think about "for each" in VB
  • No. what do you think about interpolated string in Vb.net
The answer is convenience and productivity, I think.

Well, I know it is hard to add new syntax, too hard from my ability, so I think this just will always be a dream.

Furthermore, the idea to break some old syntax is doomed to make someone very very angry. Please don't blame me, I don't want to offend anyone. I said it is a dream.

But it could be better if the (impatient) user, for example me, can find a way with less code/keyboard-typing to write the program by using some sugar syntax.

For example,

2.1 "for each" in VB.net to enumerate, or enumerate in python

2.2 'in' to judge whether something is in another. Yes, there is `InStr` to locate the first occurrence of a substring within a string

2.3 slice, the ONE syntax can be used to
  • replace LEFT$, RIGHT$, and MID$ in BASIC,
  • choose element every Nth character in the original string or in the reversed string to a new string
  • reverse a string.
python uses
  • object[indx] to get the object on index
  • object[start_pos:end_pos] to get a subrange object from start_pos to end_pos( excluded)
  • object[start_pos:end_pos:step] to get a subrange object from start_pos to end_pos( excluded) at a stride of step
  • index, start_pos, can be positive( 0, 1, ... len(obj)-1) or negative(-len(obj), -len(obj)+1, ..., -1)
The `start_pos:end_pos` syntax appears in Matlab, julia and Go. Although `start_pos:end_pos:step` does not apear in all the above.

Meanwhile, https://nim-lang.org/]Nim and Rust says something like s[0..5] in which the stride is not supported

I often do work with text, this slice style is more readable, especially if I make a chain of operations. And the negative index and the stride give me more ease.

This is not a really totally new operation in FreeBASIC. Currently, FreeBASIC has Operator[] (String Index) which is not in QB but new in FreeBASIC, or, I think, is borrowed from C. But it can only use one index to return one char/wchar

Code: Select all

dim a as wstring * 20= "你好hello"

dim as integer i
for i = 0 to len(a)-1
    ? wchr(a[i])
next

so this purpose is just an extension of the existed feature in FreeBASIC

2.4 we can use three all of the above on string and array, or even customized type.

2.5 string syntax for multiline text, so that we do not need to add CR/LF at the ends of every line manually. Perhaps, in the time when QB lived, the computer can not deal too long string easily, so QB breaks them down line by line. But nowadays, we often meet long text with many paragraphs, for example, webpage source, XML, CSS and so on. The old-school QB's way to write such text is too clumsy and has low efficiency. Yes, we can use "\n" in "!string", but for long text, it will still be hard to read, there is an example

https://github.com/PaulSquires/WinFBE/b ... o.bas#L404

In python, a couple of three quoted mark is used.

Or since we have

Code: Select all

!"string with escaped \n"
in FreeBASIC which has broken QB syntax already, how about

Code: Select all

m"I'm 
string
on multiline
"
2.6 if there is a multiline string, please do not use "_" to continue the lines

2.7 if "_ " is eliminated in multiline string, how about

Code: Select all

dim as integer i = 10

if (
  i > 1 and
  i<100) then
  ? i
end if
since the syntax is clear even there is no "_".

"_" is kept, but it is only needed in the case we have to use it else the syntax is wrong.

2.8 as for comment, how about using

Code: Select all

# this is a comment which is common in bash/python/perl..., but may be hard for FreeBASIC due to the macro/preprocessor/...


or rapideuphoria's style

Code: Select all

-- this is a comment
or purebasic's style

Code: Select all

; this is a comment
or C/CPP's style

Code: Select all

 /*  
 this is a comment 
 on many lines
 */
 
 // comment on one line
  
to instead

Code: Select all

' a single quote mark, the old QB-style comment
so that we can write

Code: Select all

aString = 'string in this way, so we can use "Double quote mark" in it easily'
2.9 string interpolation in C# or f-string in python.
Yes the string interpolation is supplied in Formatting library (C++20) or in fmt, the modern formatting library, for C++.

2.10 native multi-dimensional array/matrix operator. But this may be done via the operator overload perhaps.

3. Beyond traditional Application

3.1 the ability and document to develop an application for Android/iOS. I mean a real application, not a "hello world"

3.2 or the ability to devleop web appliaction like spiderbasic does

4. a GUI library
4.1 which uses Visual Format Language.

I find Visual Format Language is used in swift/javascript/Objective-C mostly, but can also be tested on line.

I find only wNim runs on MS Windows, which is implemented in https://nim-lang.org/]Nim language. You may find that it is so terse to describe the GUI layout: line 72 - line 79.

At the same time, wNim supports to place the control widgets at pixel coordinate and set the width/height of widgets via pixel unit just like VB6 does.

4.2 Or maybe up-to-date GUI inc in FreeBASIC for up-to-date GUI library. I can't remember too much, but only iup and FLTK-C are in the candidate list. However, FLTK looks in a strange fashion :(

How about wxWidgets? But it is a CPP project.

wNim, iup, wxWidgets use grid/box way to locate the controls. Whereas wNim, FLTK and wxWidgets use pixel coordinate, it is tedious to design and calculate the coordinate if there is no GUI layout editor.

In wNim/iup/FLTK-C, there is no need to write the parent control where a new control is created in, so it is easy to change the layout before the final release.
nov79
Posts: 47
Joined: Feb 23, 2020 15:31

Re: Dream of sugar

Post by nov79 »

I just want FreeBASIC to copy GAMBAS' syntax and OOP system. I admit I'm not comfortable with the current OOP system.

p/s: Please don't ask me why don't I just use GAMBAS. I like compiled language and a standalone binary, do not depend on other guys' interpreter. If someone come up with a compiler for GAMBAS I will switch. Sorry, I do not want to praise GAMBAS, another BASIC dialect and underestimate FreeBASIC, but I really feel more comfortable with GAMBAS than FreeBASIC.
marcov
Posts: 3462
Joined: Jun 16, 2005 9:45
Location: Netherlands
Contact:

Re: Dream of sugar

Post by marcov »

Hmm. You are not very clear about why the language extensions are needed other than <insert flavor of the day language here> has it.

This is the old fatal trap of assuming language features determining a language's (or better: development system's) success. It doesn't. You don't get successful by copying others already dated syntax.

There are two things import to success:
1 a sponsor with deep pockets. Preferably billions.
2 being placed correctly with the next IT fad. Tomorrow's "artificial intelligence" so to speak. Having libraries, a language extension or two, and a slick development system.

Oh, and (1) can help with (2), and btw, Apple only standards are beyond useless outside the Apple world. Standardizing on them is not sane, unless Apple is your (1).

With the realisation that exponential growth is unlike in the absence of such factors, the best you can do is simply make a system for the people that now use it (rather than the ones you THINK you can get), and most importantly, provide the manpower.

Since ultimately, whoever does the work decides in the end.
badidea
Posts: 2591
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: Dream of sugar

Post by badidea »

Many of the suggestion would break backward compatibility.
Or introduce even more ways to do something in freebasic.
oyster wrote: [*]No, think about !"string" in FreeBASIC, which is not BASIC's syntax; why FreeBASIC accepted it?
There is no commission of wise men (or women) that discusses every proposed change. Most likely, someone suggested it, and a developer thought it useful and implemented it. 'Mysoft' raised a valid point; why not allow option escape for the standard #fb language: https://freebasic.net/forum/viewtopic.php?f=17&t=28004

Code: Select all

#lang "fblite"
option escape
print "test\n123"
oyster wrote: [*]No. what do you think about interpolated string in Vb.net[/list]

Code: Select all

Dim name = "John"
Dim greeting = $"Hello, {name}!"
Is that so much different then:

Code: Select all

var name_ = "John"
var greeting = "Hello, " & name_ & "!"
Lost Zergling
Posts: 538
Joined: Dec 02, 2011 22:51
Location: France

Re: Dream of sugar

Post by Lost Zergling »

@oyster. As you are looking for a "ForEach" like feature, I suggest you have a look to lzle project on wich I may do some support and evolutions. About multi dimensional operators on arrays, lzae project (wip) is targeting instructions to help users designing their own routines between arrays and lists. I had little time last year, I hope to restart these projects soon. Users suggestions and help would be welcome, thus helping me to find motivation for it. Despite some technical limitations, these projects offers solutions and/or alternatives available in FB environment.
Boris the Old
Posts: 139
Joined: Feb 04, 2011 20:34
Location: Ontario, Canada

Re: Dream of sugar

Post by Boris the Old »

@oyster

Missing features are no big deal - a programmer's job is to work with the tool's you're given. And if the language can't be made to work the way you want, then use another language that's more suitable. If a hammer won't work - try using a screwdriver.

I've been programming for almost 60 years, and I've been using BASIC for 55 years (since it was invented). But I've also programmed in many other languages, from second generation machine code to many of today's high level languages, on mainframes, minis, and micros. One thing that was common to all the languages I've used, is that none of them was perfect. They all had shortcomings that had to be worked around.

Yes, FreeBASIC has its faults, but it also has the built-in features to allow a programmer to fill the gaps in the language. For example, FreeBASIC does not have a true "Fixed String" data type that allows embedded null bytes, but it can be simulated using a byte array, plus some macros and support procedures.

Here's an example from one of my modules - it makes use of macros to structure the code, and to invoke a custom routine that simulates a "fixed string" MID statement. I've removed some comments to improve the formatting on the screen:

Code: Select all

'
'-----------------------------------------------
'  Procedure 62 : put a string field into the isam buffer
'
BeginExportedSubroutine (subPutString) _
    BRef (brsStringValue,                   typString) _ 
  , BVal (bviPosition,                      typInt32) _
  , BVal (bviWidth,                         typInt32) _
  ParmEnd
'
  LocalField (sWork1,                       typString)
'
  sWork1                                    = LTRIM(brsStringValue)
  MidPutFixed(pruRecordX.xDataX, bviPosition, bviWidth, sWork1)
'
EndExportedSubroutine


And here is the "MidPutFixed" macro:

Code: Select all

'
'-----------------------------------------------
'
'  Macro 240 : MidPutFixed                  put a substring into a fixed string
'
'  bvsMacroFixed                            16866 : macro parm:  fixed string value
'  bvsMacroPosition                         17204 : macro parm:  position of a field within a data block (base=1)
'  bvsMacroCount                            16840 : macro parm:  generic count value
'  bvsMacroString                           16845 : macro parm:  string based value (string, char, date, time, etc)
'
'
#MACRO MidPutFixed(bvsMacroFixed, bvsMacroPosition, bvsMacroCount, bvsMacroString)
  modExt.subMidPutFixed(bvsMacroFixed(), bvsMacroPosition, bvsMacroCount, bvsMacroString)
#ENDMACRO
And here is the procedure in the "Extra Language Support" module that makes it happen:

Code: Select all

'
'-----------------------------------------------
'  Procedure 14 : put a substring into a fixed string
'
'  if the source length is less than count, then the fixed field is padded with spaces
'
'
BeginExportedSubroutine (subMidPutFixed) _
    BFix (brxFixedTarget) _
  , BVal (bviStartPosn,                     typInt32) _
  , BVal (bviCount,                         typInt32) _
  , BRef (brsStringValue,                   typString) _
  ParmEnd
'
  LocalField (iOffset,                      typInt32)
  LocalField (iLoop,                        typInt32)
  LocalField (sWork1,                       typString)
  LocalField (iEndPosn,                     typInt32)
  LocalField (iSourceLength,                typInt32)
  LocalField (iTargetLength,                typInt32)
  LocalField (bPadByte,                     typByte)
'
  iSourceLength                             = LEN(brsStringValue)
  IF (iSourceLength < 1) OR (bviCount < 1) THEN
    ExitSubroutine
  END IF
  iTargetLength                             = LengthFixed(brxFixedTarget)
  IF (bviStartPosn < 1) OR (bviStartPosn > iTargetLength) THEN
    ExitSubroutine
  END IF
  iEndPosn                                  = bviStartPosn + bviCount - 1
  IF iEndPosn > iTargetLength THEN
    iEndPosn                                = iTargetLength
  END IF
  bPadByte                                  = iASC_BLANK
  iOffset                                   = 0
  Decrement (iSourceLength,                 1)
  FOR iLoop = bviStartPosn TO iEndPosn
    IF iOffset > iSourceLength THEN
      brxFixedTarget(iLoop)                 = bPadByte
    ELSE
      brxFixedTarget(iLoop)                 = brsStringValue[iOffset]
    END IF
    Increment (iOffset,                     1)
  NEXT
'
EndExportedSubroutine
This may not be the world's fastest code, but it's functional and bug free - which is what's important for reliable business systems. And by using macros for code structure, the code becomes more self-documenting than the standard BASIC syntax. This is important for me, because I'm often upgrading 30 or 40 year old code - so clarity is important.

Rod

Added a few extra comments since posting 3 hours ago.
dodicat
Posts: 7983
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: Dream of sugar

Post by dodicat »

Hello rod.
None of your examples compile, they don't look like freebasic.
Maybe the snippets are written in one of your other languages posted in error.
mid will insert chr(0,0. . . .) into a fixed length string.
otherwise you can do a little custom thing to suit your needs.

Code: Select all

function insert( byval s as string,position as long,chars as string) as string
If position > 0 And position <=Len(s)+1 Then
s=Mid(s,1,position-1)+chars+Mid(s,position)
End if
return s
end function

dim as string * 11 g="ABCDEFGHIJK"
print g

'mid(g,3,5)=chr(0,0,0,0,0) 
g=insert(g,3,chr(0,0,0,0,0))
print g
print

for n as long=0 to len(g)-1
    print g[n],chr(g[n]),n+1
    next
#print typeof(g)
sleep

 
Boris the Old
Posts: 139
Joined: Feb 04, 2011 20:34
Location: Ontario, Canada

Re: Dream of sugar

Post by Boris the Old »

@dodicat

Sorry to disappoint you, but the code fragments are 100% pure FreeBASIC, as are all my applications. The only external library I use is FLTK.

As for FB's Fixed Strings, they contain an ending null character, which makes it useless for mapping to external data records, etc. Also, if a null is placed into the fixed string, and the fixed string is copied, all data after the inserted null is ignored because the null is seen as a terminating character.

Since other languages, such as PowerBASIC and COBOL, treat fixed strings for what they are (a byte array with no terminating null), I coded a series of macros and support functions, in FB, to do what the other languages do.

By the way, if you want to compile my code fragments you might want to add some data declarations, and include some of the following macros in the mix. :-D

Rod

Code: Select all

'    1   Dummy                              dummy macro
'    2   Me                                 self reference to a class
'    3   BeginLibraryDeclare                declare links to dynamic library procedures
'    4   EndLibraryDeclare                  end links to dynamic library procedures
'    5   PrototypeSubroutine                declare an exported subroutine
'    6   PrototypeParmEnd                   declare the end of a subroutine parameter list
'    7   PrototypeFunction                  declare an exported function
'    8   PrototypeParmReturn                declare a prototype function return
'    9   BeginClass                         begin a class definition
'   10   EndClass                           end a class definition
'   11   BeginClassDeclarations             begin the class declarations
'   12   EndClassDeclarations               end the class declarations
'   13   BaseClass                          parent class of the current class
'   14   BeginClassProcedures               begin the class methods and procedures
'   15   EndClassProcedures                 end the class methods and procedures
'   16   ProtectedDeclarations              declare the protected variables and procedures
'   17   PublicDeclarations                 declare the public properties and procedures
'   18   ProtectedProcedures                protected class procedures
'   19   PublicProcedures                   public class properties and procedures
'   20   typAccount                         element type:  account
'   21   typByte                            element type:  byte
'   22   typChar                            element type:  char
'   23   typDate                            element type:  date
'   24   typDecimal                         element type:  decimal  (x.9999)
'   25   typDouble                          element type:  double
'   26   typSingle                          element type:  single
'   27   typInt16                           element type:  int16
'   28   typInt32                           element type:  int32
'   29   typProcPtr                         element type:  procedure pointer
'   30   typCurrency                        element type:  currency  (x.9999)
'   31   typBoolean                         element type:  boolean
'   32   typUInteger                        element type:  uint32 (for COBOL compatibility)
'   33   typObject                          element type:  object
'   34   typPointer                         element type:  pointer
'   35   typInt64                           element type:  int64
'   36   typString                          element type:  string
'   37   typTime                            element type:  time
'   38   typUInt16                          element type:  uint16
'   39   typUInt32                          element type:  uint32
'   40   typUInt64                          element type:  uint64
'   41   typFixed                           element type:  fixed string
'   42   typYear                            element type:  year
'   43   typZString                         element type:  zstring
'   44   LocalField                         define a local variable
'   45   LocalFixed                         define a local fixed length string
'   46   LocalZString                       define a local zero terminated string
'   47   LocalZStringPointer                define a local zstring pointer
'   48   LocalPointer                       define a local pointer
'   49   LocalObject                        define a local object
'   50   LocalFieldArray                    define a local variable array
'   51   LocalPointerArray                  define a local pointer array
'   52   LocalObjectArray                   define a local object array
'   53   LocalFieldDynamic                  define a local variable dynamic array
'   54   LocalPointerDynamic                define a local pointer dynamic array
'   55   LocalObjectDynamic                 define a local object dynamic array
'   56   DeclarePublicConstructor           declare the class constructor procedure
'   57   BeginPublicConstructor             begin the class constructor procedure
'   58   EndPublicConstructor               end the class constructor procedure
'   59   DeclarePublicDestructor            declare the class destructor procedure
'   60   BeginPublicDestructor              begin the class destructor procedure
'   61   EndPublicDestructor                end the class destructor procedure
'   62   DeclarePublicGetField              declare a field property : get
'   63   DeclarePublicSetField              declare a field property : set
'   64   DeclarePublicGetPointer            declare a pointer property : get
'   65   DeclarePublicSetPointer            declare a pointer property : set
'   66   DeclarePublicGetObject             declare an object property : get
'   67   DeclarePublicSetObject             declare an object property : set
'   68   DeclarePublicGetFieldArray         declare a field property array : get
'   69   DeclarePublicSetFieldArray         declare a field property array : set
'   70   DeclarePublicGetPointerArray       declare a pointer property array : get
'   71   DeclarePublicSetPointerArray       declare a pointer property array : set
'   72   DeclarePublicGetObjectArray        declare an object property array : get
'   73   DeclarePublicSetObjectArray        declare an object property array : set
'   74   ProtectedField                     define a protected variable
'   75   ProtectedFixed                     define a protected fixed length string
'   76   ProtectedZString                   define a protected zero terminated string
'   77   ProtectedPointer                   define a protected pointer variable
'   78   ProtectedObject                    define a protected object variable
'   79   ProtectedFieldArray                define a protected field array
'   80   ProtectedPointerArray              define a protected pointer array
'   81   ProtectedObjectArray               define a protected object array
'   82   ProtectedFieldDynamic              define a protected field dynamic array
'   83   ProtectedPointerDynamic            define a protected pointer dynamic array
'   84   ProtectedObjectDynamic             define a protected object dynamic array
'   85   PublicGetField                     get a field property
'   86   PublicGetFieldOpt                  get a field property (optional procedure)
'   87   PublicSetField                     set a field property
'   88   PublicSetFieldOpt                  set a field property (optional procedure)
'   89   PublicGetPointer                   get a pointer property
'   90   PublicGetPointerOpt                get a pointer property (optional procedure)
'   91   PublicSetPointer                   set a pointer property
'   92   PublicSetPointerOpt                set a pointer property (optional procedure)
'   93   PublicGetObject                    get an object property
'   94   PublicGetObjectOpt                 get an object property (optional procedure)
'   95   PublicSetObject                    set an object property
'   96   PublicSetObjectOpt                 set an object property (optional procedure)
'   97   PublicGetFieldArray                get a field array property
'   98   PublicGetFieldArrayOpt             get a field array property (optional procedure)
'   99   PublicSetFieldArray                set a field array property
'  100   PublicSetFieldArrayOpt             set a field array property (optional procedure)
'  101   PublicGetPointerArray              get a pointer array property
'  102   PublicGetPointerArrayOpt           get a pointer array property (optional proc)
'  103   PublicSetPointerArray              set a pointer array property
'  104   PublicSetPointerArrayOpt           set a pointer array property (optional proc)
'  105   PublicGetObjectArray               get an object array property
'  106   PublicGetObjectArrayOpt            get an object array property (optional proc)
'  107   PublicSetObjectArray               set an object array property
'  108   PublicSetObjectArrayOpt            set an object array property (optional proc)
'  109   GlobalSubroutine                   define a global subroutine
'  110   GlobalSubroutineCdecl              define a global subroutine (cdecl calls)
'  111   GlobalFunction                     define a global function
'  112   GlobalFunctionCdecl                define a global function (cdecl calls)
'  113   MapSubroutinePointer               map a procptr to a subroutine definition
'  114   MapFunctionPointer                 map a procptr to a function definition
'  115   PerformProcedure                   perform a procedure via a procedure pointer
'  116   GlobalField                        define a global variable
'  117   GlobalFixed                        define a global fixed length string
'  118   GlobalZString                      define a global zero terminated string
'  119   GlobalPointer                      define a global pointer variable
'  120   GlobalObject                       define a global object variable
'  121   GlobalFieldArray                   define a global variable array
'  122   GlobalPointerArray                 define a global pointer array
'  123   GlobalObjectArray                  define a global object array
'  124   GlobalFieldDynamic                 define a global dynamic array:  type = field
'  125   GlobalPointerDynamic               define a global dynamic array:  type = pointer
'  126   GlobalObjectDynamic                define a global dynamic array:  type = object
'  127   DeclarePublicSubroutine            declare a class public subroutine
'  128   DeclarePublicVirtualSubroutine     declare a class public virtual subroutine
'  129   BeginPublicSubroutine              begin a class public subroutine
'  130   BeginPublicVirtualSubroutine       begin a class public virtual subroutine
'  131   EndPublicSubroutine                end a class public subroutine
'  132   DeclareProtectedSubroutine         declare a class protected subroutine
'  133   BeginProtectedSubroutine           begin a class protected subroutine
'  134   EndProtectedSubroutine             end a class protected subroutine
'  135   DeclareExportedSubroutine          declare a namespace exported subroutine
'  136   BeginExportedSubroutine            begin a namespace exported subroutine
'  137   EndExportedSubroutine              end a namespace exported subroutine
'  138   DeclarePrivateSubroutine           declare a namespace private subroutine
'  139   DeclarePrivateSubroutineCdecl      declare a namespace private subroutine (cdecl)
'  140   BeginPrivateSubroutine             begin a namespace private subroutine
'  141   BeginPrivateSubroutineCdecl        begin a namespace private subroutine (cdecl)
'  142   EndPrivateSubroutine               end a namespace private subroutine
'  143   DeclarePublicFunction              declare a class public function
'  144   DeclarePublicVirtualFunction       declare a class public virtual function
'  145   BeginPublicFunction                begin a class public function
'  146   BeginPublicVirtualFunction         begin a class public virtual function
'  147   EndPublicFunction                  end a class public function
'  148   DeclareProtectedFunction           declare a class protected function
'  149   BeginProtectedFunction             begin a class protected function
'  150   EndProtectedFunction               end a class protected function
'  151   DeclareExportedFunction            declare a namespace exported function
'  152   BeginExportedFunction              begin a namespace exported function
'  153   EndExportedFunction                end a namespace exported function
'  154   DeclarePrivateFunction             declare a namespace private function
'  155   DeclarePrivateFunctionCdecl        declare a namespace private function (cdecl)
'  156   BeginPrivateFunction               begin a namespace private function
'  157   BeginPrivateFunctionCdecl          begin a namespace private function (cdecl)
'  158   EndPrivateFunction                 end a namespace private function
'  159   CreateObject                       create a new object
'  160   DestroyObject                      destroy an object
'  161   IsFile                             true if the item is a file
'  162   NotFile                            true if the item is not a file
'  163   IsObject                           true if the item is an object
'  164   NotObject                          true if the item is not an object
'  165   IsWidget                           true if the item is a widget
'  166   NotWidget                          true if the item is not a widget
'  167   Empty                              return an empty string value
'  168   IsEmpty                            true if a string is empty
'  169   NotEmpty                           true if a string is not empty
'  170   IsTrue                             true if an expression is not zero
'  171   IsFalse                            true if an expression is zero
'  172   NotTrue                            true if an expression is zero
'  173   NotFalse                           true if an expression is not zero
'  174   TrueValue                          return a true value:  -1
'  175   FalseValue                         return a false value:  0
'  176   FunctionPtr                        return a function pointer
'  177   SubroutinePtr                      return a subroutine pointer
'  178   Nothing                            indicates an item reference is no longer valid
'  179   BRef                               a variable is passed by reference
'  180   BVal                               a variable is passed by value
'  181   BObj                               an object is passed as a byval pointer
'  182   BPtr                               a pointer is passed by value
'  183   BArr                               an array is passed by reference
'  184   BFix                               a fixed string is passed by reference
'  185   BeginBlock                         begin a block declaration
'  186   EndBlock                           end a block declaration
'  187   BlockField                         declare a block variable
'  188   BlockFixed                         declare a block fixed length string
'  189   BlockZString                       declare a block zero terminated string
'  190   BlockPointer                       declare a block pointer
'  191   BlockObject                        declare a block object
'  192   BlockFieldArray                    declare a block field array
'  193   BlockPointerArray                  declare a block pointer array
'  194   BlockObjectArray                   declare a block object array
'  195   BlockFieldDynamic                  declare a block variable dynamic array
'  196   BlockPointerDynamic                declare a block pointer dynamic array
'  197   BlockObjectDynamic                 declare a block object dynamic array
'  198   Increment                          increment a value
'  199   Decrement                          decrement a value
'  200   Ref                                returns a reference pointer to a variable
'  201   GuiEventRouter                     reference to the gui event router
'  202   PeekText                           peek a string from a memory block
'  203   PeekBoolean                        peek a boolean value from a memory block
'  204   PeekByte                           peek a byte value from a memory block
'  205   PeekCurrency                       peek a currency value from a memory block
'  206   PeekDouble                         peek a double value from a memory block
'  207   PeekSingle                         peek a single value from a memory block
'  208   PeekInt16                          peek an int16 value from a memory block
'  209   PeekInt32                          peek an int32 value from a memory block
'  210   PeekInt64                          peek an int64 value from a memory block
'  211   PeekUInt16                         peek a uint16 value from a memory block
'  212   PeekUInt32                         peek a uint32 value from a memory block
'  213   PeekUInt64                         peek a uint64 value from a memory block
'  214   PokeText                           poke a string into a memory block
'  215   PokeBoolean                        poke a boolean value into a memory block
'  216   PokeByte                           poke a byte value into a memory block
'  217   PokeCurrency                       poke a currency value into a memory block
'  218   PokeDouble                         poke a double value into a memory block
'  219   PokeSingle                         poke a single value into a memory block
'  220   PokeInt16                          poke an int16 value into a memory block
'  221   PokeInt32                          poke an int32 value into a memory block
'  222   PokeInt64                          poke an int64 value into a memory block
'  223   PokeUInt16                         poke a uint16 value into a memory block
'  224   PokeUInt32                         poke a uint32 value into a memmory block
'  225   PokeUInt64                         poke a uint64 value into a memory block
'  226   ValAccount                         convert a string to an account value
'  227   ValDecimal                         convert a string to a decimal value
'  228   ValUInteger                           convert a string to a uinteger value
'  229   CopyMemory                         copy a memory block to another location
'  230   FillMemory                         fill a memory block with a byte value
'  231   CopyUdt                            copy a udt (zero fill)
'  232   FillUdt                            fill a udt with a byte value
'  233   CopyFixed                          copy a fixed string (pad with blank)
'  234   FillFixed                          fill a fixed string with a ubyte value
'  235   ReadFixed                          convert a fixed string to a string (trim all blank)
'  236   WriteFixed                         convert a string to a fixed string (pad with blank)
'  237   VarPtrFixed                        pointer to a fixed string variable
'  238   LengthFixed                        return the length of a fixed string
'  239   MidGetFixed                        get a substring from a fixed string
'  240   MidPutFixed                        put a substring into a fixed string
'  241   FormatAccount                      format an account value using an edit mask
'  242   FormatByte                         format a byte value using an edit mask
'  243   FormatDate                         format a date value using an edit mask
'  244   FormatDecimal                      format a decimal value using an edit mask
'  245   FormatDouble                       format a double value using an edit mask
'  246   FormatSingle                       format a single value using an edit mask
'  247   FormatInt16                        format an int16 value using an edit mask
'  248   FormatInt32                        format an int32 value using an edit mask
'  249   FormatInt64                        format an int64 value using an edit mask
'  250   FormatCurrency                     format a currency value using an edit mask
'  251   FormatUInteger                        format a uinteger value using an edit mask
'  252   FormatTime                         format a time value using an edit mask
'  253   FormatUInt16                       format a uint16 value using an edit mask
'  254   FormatUInt32                       format a uint32 value using an edit mask
'  255   FormatUInt64                       format a uint64 value using an edit mask
'  256   FormatYear                       format a year value using an edit mask
'  257   SystemDate                         the current date in yyyymmdd format
'  258   GlobalLock                         place a lock on all other dvs applications
'  259   GlobalUnlock                       remove the lock from all other dvs applications
'  260   PostCustomEvent                    post a custom event to a gui object
'  261   MakeDirectory                      make a directory structure
'  262   RemoveDirectory                    remove a directory structure
'  263   Remainder                          find the remainder from an integer division
'  264   BeginNamespace                     begin a namespace definition
'  265   EndNamespace                       end a namespace definition
'  266   BeginNamespaceDeclarations         begin the namespace declarations
'  267   EndNamespaceDeclarations           end the namespace declarations
'  268   DeclareExportedConstructor         declare the namespace constructor
'  269   BeginExportedConstructor           begin the namespace constructor procedure
'  270   EndExportedConstructor             end the namespace constructor procedure
'  271   DeclareExportedDestructor          declare the namespace destructor procedure
'  272   BeginExportedDestructor            begin the namespace destructor procedure
'  273   EndExportedDestructor              end the namespace destructor procedure
'  274   ExportedDeclarations               declare the exported variables and procedures
'  275   PrivateDeclarations                declare the private variables and procedures
'  276   BeginNamespaceProcedures           begin the namespace procedures
'  277   EndNamespaceProcedures             end the namespace procedures
'  278   PrivateProcedures                  private namespace procedures
'  279   ExportedProcedures                 exported namespace procedures
'  280   ExportedField                      declare an exported variable
'  281   ExportedFixed                      declare an exported fixed length string
'  282   ExportedZString                    declare an exported zero terminated string
'  283   ExportedPointer                    declare an exported pointer variable
'  284   ExportedObject                     declare an exported object variable
'  285   ExportedFieldArray                 declare an exported field array
'  286   ExportedPointerArray               declare an exported pointer array
'  287   ExportedObjectArray                declare an exported object array
'  288   ExportedFieldDynamic               declare an exported field dynamic array
'  289   ExportedPointerDynamic             declare an exported pointer dynamic array
'  290   ExportedObjectDynamic              declare an exported object dynamic array
'  291   PrivateField                       declare a private variable
'  292   PrivateFixed                       declare a private fixed length string
'  293   PrivateZString                     declare a private zero terminated string
'  294   PrivatePointer                     declare a private pointer variable
'  295   PrivateObject                      declare a private object variable
'  296   PrivateFieldArray                  declare a private field array
'  297   PrivatePointerArray                declare a private pointer array
'  298   PrivateObjectArray                 declare a private object array
'  299   PrivateFieldDynamic                declare a private field dynamic array
'  300   PrivatePointerDynamic              declare a private pointer dynamic array
'  301   PrivateObjectDynamic               declare a private object dynamic array
'  302   FltkColour                         convert an html colour code to the fltk format
'  303   PerformCallback                    perform a package callback procedure
'  304   Round                              round a decimal or currency value
'  305   ParmEnd                            end a subroutine parameter list
'  306   ParmReturn                         end a function parameter list and return a value
'  307   EraseFieldDynamic                  erase a dynamic array:  type = field
'  308   ErasePointerDynamic                erase a dynamic array:  type = pointer
'  309   EraseObjectDynamic                 erase a dynamic array:  type = object
'  310   ResizeFieldDynamic                 resize a dynamic array:  type = field
'  311   ResizePointerDynamic               resize a dynamic array:  type = pointer
'  312   ResizeObjectDynamic                resize a dynamic array:  type = object
'  313   IsZero                             true if the item value is zero
'  314   NotZero                            true if the item value is not zero
'  315   Shrink                             shrink a string to use a single delimiter char
'  316   ClipLeft                           remove characters from the left of a string
'  317   ClipRight                          remove characters from the right of a string
'  318   ClipMid                            remove characters from the middle of a string
'  319   JustifyLeft                        left justify a substring within a string
'  320   JustifyRight                       right justify a substring within a string
'  321   JustifyCentre                      centre a substring within a string
'  322   Extract                            extract a substring delimited by mask
'  323   ExtractAny                         extract a substring delimited by any mask char
'  324   Remain                             return a substring following mask
'  325   RemainAny                          return a substring following a mask char
'  326   Join                               join array entries delimited by mask
'  327   UnJoin                             populate a string array from a delimited string
'  328   Parse                              extract a field by index, delimited by mask
'  329   ParseAny                           extract a field by index, delimited by mask char
'  330   ParseCount                         count number of fields delimited by mask
'  331   ParseCountAny                      count number of fields delimited by mask chars
'  332   PathName                           extract a pathname component
'  333   RemoveMask                         remove the mask substring from a string
'  334   RemoveAny                          remove the mask characters from a string
'  335   RemoveCount                        remove a specified number of chars from a string
'  336   Repeat                             create a string with multiple copies of mask
'  337   Replace                            replace mask string with new string
'  338   ReplaceAny                         replace any mask characters with new character
'  339   Retain                             retain only the substrings matching mask
'  340   RetainAny                          retain only characters contained in mask
'  341   Insert                             insert a substring into a string
'  342   Reverse                            reverse the contents of a string
'  343   Tally                              count the number of mask in a string
'  344   TallyAny                           count the number of mask characters in a string
'  345   Verify                             verify that each character in string is in mask
'  346   Wrap                               add paired chars to start and end of string
'  347   UnWrap                             remove paired chars from start and end of string
'  348   ExitFunction                       exit a function immediately and return a value
'  349   ExitSubroutine                     exit a subroutine immediately
'  350   SeekPosition                       convert a dvsam offset to a basic file position
'  351   SeekOffset                         convert a basic file position to a dvsam offset
'  352   Spaces                             blank character:  &H20
'  353   LowValues                          low value character:  &H00
'  354   HighValues                         high value character:  &HFF
'  355   DvsamLowKey                        dvsam low key character:  &H01
'  356   DvsamHighKey                       dvsam high key character:  &HFE
'  357   ElementName                        return an element name:  type + name
Last edited by Boris the Old on Mar 14, 2020 19:33, edited 1 time in total.
dodicat
Posts: 7983
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: Dream of sugar

Post by dodicat »

Indeed if you want to omit the chr(0) at the string end you must pass a ubyte array.
Similarish:
viewtopic.php?f=2&t=27632&p=261056&hilit=fixed#p261056
I don't have FLTK, you made no mention of FLTK.
Boris the Old
Posts: 139
Joined: Feb 04, 2011 20:34
Location: Ontario, Canada

Re: Dream of sugar

Post by Boris the Old »

I was just mentioning that I now use only FreeBASIC, in conjunction with the FLTK GUI library, for all our in-house development.

Over the years we've built up an extensive library of active business applications, some of them still written in DOS-COBOL and DOS-MASM, but most in PowerBASIC. So over the past 7 or 8 years I've been looking into the best alternative for our needs.

FreeBASIC is the best fit for us. It's compatible with PowerBASIC, is cross-platform, has low-level features, plus a good macro processor, OOP support, and access to a wide range of libraries. It's also a good fit with our programming standards and code generators.

Rod
dodicat
Posts: 7983
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: Dream of sugar

Post by dodicat »

Thank you Rod.
Also it's free.
BasicCoder2
Posts: 3906
Joined: Jan 01, 2009 7:03
Location: Australia

Re: Dream of sugar

Post by BasicCoder2 »

@oyster
We have to use the tools we are given. Unless you are able to add features to FreeBASIC you have to take it as it is.

The only way I know to add sugar is to write your own commands in FreeBASIC as a call to a function or a method.
For example in graphics I might use:
DrawLine(x1,y1,x2,y2,penSize,Color)
printText("How are you doing " + name + "?")

I was never a fan of the QBASIC syntax. New commands can all be in the same form.
Circle (x,y),4,rgb(255,0,0),,,,f
vs.
DrawCircle (x,y,radius,color,penSize,penColor,brushColor,FILL)
or something with a simpler or more complicated set of parameters implemented using over riding functions.
Boris the Old
Posts: 139
Joined: Feb 04, 2011 20:34
Location: Ontario, Canada

Re: Dream of sugar

Post by Boris the Old »

In the interests of clarity, and bug proofing, I've always preferred using separate statements for attributes. A missing comma can easily be overlooked, and someone not familiar with the language would have great difficulty figuring out exactly what the statement does.

I prefer the following approach (in pseudo code) :

Code: Select all

modGui.BeginCircle = name
modGui.SetX = x
modGui.SetY = y
modGui.SetRadius = radius
modGui.SetColour = colour
modGui.SetPenSize = pensize
modGui.SetPenColour = pencolour
modGui.SetBrushColour = brushcolour
modGui.DrawCircle
modGui.EndCircle

modGui.BeginCircle = name
modGui.ChangeColour = colour
modGui.EndCircle
Using this approach, all the actual GUI related code is isolated in the module "modGui". So in the future, if I wish to replace FLTK with something else, all I need do is change a single module. Nothing has to change in the other 2 million lines of application code.

Rod
Post Reply