Announcement

Collapse
No announcement yet.

To PowerBASIC.. discussion about future PB/WIN and CC versions

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • #81
    Also, let’s face it, GOSUB is no longer needed and surely must be considered bad practice in modern BASIC programming.
    GOSUB is a very important BASIC command. In my commercial software package (DLL) I use it over 230 times!

    It produces very clean, readable and fast executing code.

    The suggestion to replace FUNCTION = with RETURN is a likely from those who have experience with C. The problem is that programmers tend to gravitate towards one particular programming language, and often wish that another language use the syntax of their favorite (or at least most used) language.

    I had a similiar experience, but it was the opposite. I complained about the use of RETURN in functions to return values (even used in SUBs) by a BASIC language compiler (not PB), written by a programmer I assume is more experienced with C than Basic.

    One of the things that I like about PowerBasic is that it sticks to the long time BASIC language syntax dating back to early Microsoft Basic compilers. It adds new constructs, while maintaining the long time syntax Basic programmers are use to.

    I have downloaded and tried a number of so called Basic language compilers and I didn't like their deviation from pure Basic syntax. They should advertise their compilers as "Basic like" or "similiar to Basic", rather than as true Basic compilers.

    I tend to not like so called Basic compilers, that favor C style syntax, over the long time Basic syntax.
    Chris Boss
    Computer Workshop
    Developer of "EZGUI"
    http://cwsof.com
    http://twitter.com/EZGUIProGuy

    Comment


    • #82
      just glad to know about the limitation now so I can plan for it and work around it
      Could someone please tell me how in the 21st century a so-called Windows' programmer could not figure out for himself that #COMPILE DLL would be the two-minute 'workaround?

      (Assuming a limitation on number of source code lines actually exists.)

      (Who the heck would put 300 kloc in one module anyway? Terrific upgrade strategy in that design. Wish I'd thought of it first. Gee, I'd be sooooo rich....).

      MCM

      Comment


      • #83
        Call me crazy or call me naive, but seems to me multithreading supports parallel computing just ducky, and it does it today, not some time in the future.

        'THREAD CREATE' in the help file sounds promising.

        Comment


        • #84
          I doubt many will exceed the limitations of the PB compiler (lines of code it can compile) in most applications. Also likely maximum limits have a lot more to do with how many variables, constants, types, etc are used, not just some preset maximum number of source code lines.

          Compiler developers likely have to make many choices that effect what and how much their compiler can compile. Speed is one of them!

          PB is very fast (in compiling) and likely that comes at some cost. Choices likely had to be made in how to parse code the fastest and it only makes sense that some limitations may be required.

          Even if PB had such a limit (which I do not know if it does), it is easy to move some code to DLL's, when an application gets too large.

          Also I find that some applications may be too large (too many lines of code) because the programmer does not try to follow a more modular approach. The more code is reused (modular) in an app, the smaller it will be.

          My customers are programmers and at times they are surprised by the simplicity of the code I post on my forums to solve their problems. I try to keep my code very modular and it often is quite simple because of that. I would rather write a reusable function, that could be used over and over again, than to write code specific to a specific routine.

          Modularity keeps programs smaller and as a professional programmer, I doubt I personally will ever exceed any so called limitations of the PB compiler.

          Besides, modularity at times means, "put it in a DLL" if need be.
          Last edited by Chris Boss; 25 Dec 2007, 02:40 PM.
          Chris Boss
          Computer Workshop
          Developer of "EZGUI"
          http://cwsof.com
          http://twitter.com/EZGUIProGuy

          Comment


          • #85
            Originally posted by Fred Harris View Post
            One can already use the C Runtime (and Jose Roca has translated most or all the usual C Headers, available at his new site) no problem, i.e., printf, fprintf, puts, etc. I guess all that's left to incorporeate would be the brackets.
            A macrotemp behavious somewhat similar, while it's not getting out of scope when exitting the macro.

            local a as long
            a = 1
            {
            local a as long
            a = 2
            }

            Msgbox Str$( a )

            Should print: 1

            But then.. replacing the { for a macro.. inline won't do is it?
            hellobasic

            Comment


            • #86
              Originally posted by Chris Boss View Post
              ...The problem is that programmers tend to gravitate towards one particular programming language, and often wish that another language use the syntax of their favorite (or at least most used) language...
              I don't think so, a while ago i had to deal with several c compilers.
              All of the compilers c/c++ remain very difficult.
              I suspect those compilers are usually used by fokes started with these compilers.
              Moving from a BASIC language to an ordinary c compiler is to me still a no-no.

              Except.. c#, here it is, the few benefits in c like local scope and a few other (silly) aspects are available + the way it is brought to us finally something a BASIC user can learn.

              I just wanted to notify PB that a few things in c are better and that a few aspects in current BASIC are a bit old-fashion.
              for example, Setting a return value to function and then exit the function is actually odd.

              FUNCTION = 123

              What *is* FUNCTION?
              We can override the return value by setting it again but we can't read it like:
              a = FUNCTION

              Therefore it's something invented in 1970 or so and we are still dealing with this oddity, time to move on..

              Of course the things i have in mind are all tiny changes but imo rather handy.
              hellobasic

              Comment


              • #87
                A graphics function to specify the direction of text would be useful. Right now, I have to flip text on its side with my own code.

                John Harvill
                Last edited by John Harvill; 25 Dec 2007, 04:38 PM.

                Comment


                • #88
                  I remember how horrified I was when I took my first look at VB.NET soon after it came out. What horrified me was the direct incorporation of C language reserved words such as struct into a BASIC language. In fact, the fact that it so affronted my sensibilities even surprised me. I guess something in me wanted to maintain their 'seperateness'. For these reasons I'm not really enthused about mixing the languages up.

                  I've always felt that if there are two logically seperate ways to do anything, BASIC family languages will usually do it one way and C family languages the other. C uses null terminated strings, BASIC dynamic strings (length of string stored seperately). C doesn't collect its garbage, BASIC does. C passes parameters by value, BASIC by reference. The list goes on and on. Understanding both approaches has, I think, made me a better programmer (I hope).

                  Therefore, in my opinion, each language has its own inner logic. I use both about evenly, and have no desire to see them co-mixed.

                  Added Later:

                  And over the years it kind of seems to me that C++ borrowed more from BASIC than the other way around. After many early DOS programmers moved to C++ due to the limitations of the early versions of BASIC, they needed to do something about the C situation with strings, so they borrowed BASIC's string handling methods. Also, having to pass a pointer in function calls (as all the API functions do) wasn't as clean or notationally concise as the BASIC pass by reference so C++ adopted that too.
                  Last edited by Fred Harris; 25 Dec 2007, 06:56 PM.
                  Fred
                  "fharris"+Chr$(64)+"evenlink"+Chr$(46)+"com"

                  Comment


                  • #89
                    I agree John, that would be helpful.
                    I do several federal forms, some of which print the word "Form" at a 90 degree
                    angle. Right now i use a bitmap and Render to 'print' it which works nicely (except i have never gotten it to work from a resource file only as a bitmap with the path if different included).

                    PCL 5 and below down to i think pcl 3 used a Ec&a#P where Ec is escape and # is an angle 90,180,270,0 etc. to print text at a different angle on the same
                    page as other text.
                    Client Writeup for the CPA

                    buffs.proboards2.com

                    Links Page

                    Comment


                    • #90
                      Originally posted by Edwin Knoppert View Post
                      I just wanted to notify PB that a few things in c are better and that a few aspects in current BASIC are a bit old-fashion.
                      for example, Setting a return value to function and then exit the function is actually odd.

                      FUNCTION = 123

                      What *is* FUNCTION?
                      We can override the return value by setting it again but we can't read it like:
                      a = FUNCTION

                      Therefore it's something invented in 1970 or so and we are still dealing with this oddity, time to move on..
                      The help really explains why and what in the FUNCTION / END FUNCTION topic, starting in the AS type section. As for moving on, change for the sake of change is more of what it seems to be suggesting. Yet consider how C/C++ parallels BASIC.

                      In C/C++ you would need to tell the function what value to return, if one is to be reurned, using the keyword return in a way that is different than BASIC return keyword used in GOSUBs. It is even different in its aspects than the RET instruction in assembler.
                      Code:
                      int sum(int x, int y)
                      {
                          int ans = 0;     //holds the answer that will be returned
                          ans = x + y;    //calculate the sum
                          return ans        //return the answer
                      }
                      So Edwin,of course if you want to query the value before it is returned, assign a variable first, query that ... like C/C++ would do. So IMO, FUNCTION = is a good PB addition to BASIC.. It maintains the BASIC flavor of assignments using the "=" operator. You do not have to use "FUNCTION =" if you do not want, since you can use the MS BASIC's version as well: function_name = More importantly it keeps "return" for use in returning from subroutines contained in a function, much to the purpose like assembler's plain RET instruction does.

                      And speaking of 1970's .... both BASIC and what came to be called C started in the mid '60's, but since PC's did not really take off en-mass until IBM enter ed the market in 1981, maybe it would be more apropos to consider BASIC since compiled BASIC and C on a PC became more popular.. So for the most part both languages have maintained and/or extended many of their root aspects, while constantly improving. Come to think of it, there just might be more BASIC programmers to whom C/C++ might seem to be an oddity as well.
                      Rick Angell

                      Comment


                      • #91
                        Originally posted by Richard Angell View Post
                        ...C/C++ might seem to be an oddity as well.
                        There's always Pascal:

                        Code:
                        {-----------------------------------------------------------------------}
                        function Startswith ( BigString, LittleString : String ) : Boolean;
                        begin
                            if Copy ( BigString, 1, length ( LittleString ) ) = LittleString then
                                StartsWith := True
                            else
                                StartsWith := False;
                        end;

                        Comment


                        • #92
                          Yes, Chris, .. and quite likely several other languages as well. Simply note though how the Pascal example is similar to the MS function return, as it uses the function name, StartsWith, for assigning the return value.

                          On another note, same song, nth verse, GOTO and GOSUB are both excellent, long standing language functions. They mimic their assembler counterparts JMP and CALL where the usage matches. As Chris Boss pointed out, in addressing GOSUB; "It produces very clean, readable and fast executing code." Many of the long time, professional and novice programmers here do use both and have said so many times.

                          It really helps though if one can understand when and why they are a real help to keeping the code tight and fast. Those discussions have been here in the forum on many occasions, search and ye shall find, and find, and find.

                          In a nutshell, GOSUB and also GOTO can avoid unneccessary processing overhead. PB Help says this about GOSUB: "For time critical or high-performance code, using a GOSUB to perform a repetitive task is almost always faster then performing a call to a Sub or Function, since there is no overhead in setting up a stack frame for a GOSUB." Well designed and commented source that employ GOTO and GOSUB are no more difficult to debug than a plethora of functions ... and may actually be easier to debug where all the really relative action is taking place.
                          Rick Angell

                          Comment


                          • #93
                            A new mixing mode for the GRAPHIC COPY statement which automatically overlays the source bitmap onto the destination bitmap. It would work similar to the default "%mix_CopySrc" mode, except the destination pixel would remain unchanged whenever the corresponding source pixel equaled zero. In essence, it's like assigning a background color of -2 in

                            GRAPHIC COLOR forground_color, -2

                            Otherwise, I must perform the overlay using an if/then comparison in my own code (if I understand the mixing modes correctly on the help screen).

                            John Harvill

                            Comment


                            • #94
                              Simply note though how the Pascal example is similar to the MS function return, as it uses the function name, StartsWith, for assigning the return value
                              Um, so does PB... from the PB/CC 4.03 help file:

                              [{FuncName | FUNCTION} = ReturnValue]
                              ...

                              You can specify the return value of the Function by explicitly setting the value, either by assigning a value to the FUNCTION keyword, or by assigning a value to the function name.

                              Comment


                              • #95
                                I had already noted that in the post previous to the last one:

                                " You do not have to use "FUNCTION =" if you do not want, since you can use the MS BASIC's version as well: function_name ="

                                Although I used the wording "MS BASIC's version", the intent is not to imply that they were the first to use the syntax form: function_name =. They did however contribute to its widespread use in the BASIC community.
                                Rick Angell

                                Comment


                                • #96
                                  PBTools - library of the best functions like .JPG support.
                                  Yes, I know the source code forum can be used, but not always the best functions. This would be a new product or a subscription.
                                  https://www.tesla.com/roadster

                                  Comment

                                  Working...
                                  X