Welcome Guest
Log In | Register )
You last visited December 9, 2016, 5:30 am
All times shown are
Eastern Time (GMT-5:00)

What software does a novice need to learn to write and run math analysis programs?

Topic closed. 40 replies. Last post 6 years ago by Domeman.

Page 2 of 3
PrintE-mailLink
RL-RANDOMLOGIC's avatar - usafce

United States
Member #59354
March 13, 2008
3973 Posts
Offline
Posted: April 17, 2011, 5:09 pm - IP Logged

Added "DIM SQROOT AS DOUBLE" for more accuracy for larger numbers.

 

SCREEN _NEWIMAGE(960, 648, 256):
_TITLE "MY FIRST PROGRAM IN QB64"
COLOR 79, 79
DIM SQROOT AS DOUBLE

CALCSQR:
CLS
COLOR 0, 79
LOCATE 1, 2: INPUT "ENTER NUMBER TO CALCULATE SQ-ROOT ", SQROOT
LOCATE 2, 2: PRINT "THE SQUARE ROOT OF"; SQROOT; "="; SQROOT ^ .5


LOCATE 4, 2: PRINT "PRESS (E) TO EXIT OR (N) FOR NEXT "
DO
_LIMIT 200
CMD1$ = RIGHT$(INKEY$, 1)
CMD1$ = UCASE$(CMD1$)
IF CMD1$ = "E" THEN EXIT DO
IF CMD1$ = "N" THEN GOTO CALCSQR
LOOP
SYSTEM ' EXITS PROGRAM

    pick4hawk's avatar - Trek HAND3.gif

    United States
    Member #19982
    August 9, 2005
    226 Posts
    Offline
    Posted: April 17, 2011, 5:30 pm - IP Logged

    There is a program called Nbasic for windows that uses line numbers. Sort of like Gw-basic for Dos.

    However there is another program called Powerbasic for windows that is way better then QB basic for windows.

    It is all in what you personally feel is easy to use. The C language is what they teach in school these days.

    Personally, I feel C is very lengthy to do anything. They teach Pascal conventions but in the "C" language.

    Powerbasic does have a user forum. It’s best you know what you want to do math wise before programming it in any language.

    HAWK

      Avatar

      United States
      Member #105312
      January 29, 2011
      435 Posts
      Offline
      Posted: April 17, 2011, 6:30 pm - IP Logged

      Added "DIM SQROOT AS DOUBLE" for more accuracy for larger numbers.

       

      SCREEN _NEWIMAGE(960, 648, 256):
      _TITLE "MY FIRST PROGRAM IN QB64"
      COLOR 79, 79
      DIM SQROOT AS DOUBLE

      CALCSQR:
      CLS
      COLOR 0, 79
      LOCATE 1, 2: INPUT "ENTER NUMBER TO CALCULATE SQ-ROOT ", SQROOT
      LOCATE 2, 2: PRINT "THE SQUARE ROOT OF"; SQROOT; "="; SQROOT ^ .5


      LOCATE 4, 2: PRINT "PRESS (E) TO EXIT OR (N) FOR NEXT "
      DO
      _LIMIT 200
      CMD1$ = RIGHT$(INKEY$, 1)
      CMD1$ = UCASE$(CMD1$)
      IF CMD1$ = "E" THEN EXIT DO
      IF CMD1$ = "N" THEN GOTO CALCSQR
      LOOP
      SYSTEM ' EXITS PROGRAM

      RL:  My EXCEL donealready does square roots.

        Avatar

        United States
        Member #105312
        January 29, 2011
        435 Posts
        Offline
        Posted: April 17, 2011, 6:31 pm - IP Logged

        There is a program called Nbasic for windows that uses line numbers. Sort of like Gw-basic for Dos.

        However there is another program called Powerbasic for windows that is way better then QB basic for windows.

        It is all in what you personally feel is easy to use. The C language is what they teach in school these days.

        Personally, I feel C is very lengthy to do anything. They teach Pascal conventions but in the "C" language.

        Powerbasic does have a user forum. It’s best you know what you want to do math wise before programming it in any language.

        HAWK

        Thanks pick4hawk

          RJOh's avatar - chipmunk
          mid-Ohio
          United States
          Member #9
          March 24, 2001
          19830 Posts
          Offline
          Posted: April 17, 2011, 9:42 pm - IP Logged

          There is a program called Nbasic for windows that uses line numbers. Sort of like Gw-basic for Dos.

          However there is another program called Powerbasic for windows that is way better then QB basic for windows.

          It is all in what you personally feel is easy to use. The C language is what they teach in school these days.

          Personally, I feel C is very lengthy to do anything. They teach Pascal conventions but in the "C" language.

          Powerbasic does have a user forum. It’s best you know what you want to do math wise before programming it in any language.

          HAWK

          I down loaded that NBasic and may give it a try.  NBasic has a lot more commands than GWBasic ever had.  I haven't used any of the graphic commands in GWBasic for years so I don't remeber if they are similar or not.  I did notice NBasic had a command "DAY" which calculate the day of any date and in my GWBasic programs I had to write a routine to do that.

          Looks like NBasic has enough commands to run any of the older Basic programs on the newer machines.  Thanks for sharing.

          I agree one should know what they want a program to do math wise before trying to write a program to do it.

           * you don't need to buy more tickets, just buy a winning ticket * 
             
                       Evil Looking       

            RL-RANDOMLOGIC's avatar - usafce

            United States
            Member #59354
            March 13, 2008
            3973 Posts
            Offline
            Posted: April 17, 2011, 10:01 pm - IP Logged

            RL:  My EXCEL donealready does square roots.

            josephus

            Just giving some examples of the syntax

            RL

              Avatar

              United States
              Member #105312
              January 29, 2011
              435 Posts
              Offline
              Posted: April 18, 2011, 7:25 am - IP Logged

              josephus

              Just giving some examples of the syntax

              RL

              Thanks RL.  When I asked this question I assumed there was a single, simple answer more better than other answers. I figured I'd get a little nudge in a direction I'd follow step by step in my own plodding way until I could program the computer to do some things I can't do, EXCEL can't do, or EXCEL can do but I just never figured out how to make it do it.

              I can see I was looking for over-simplifications and a lot of roads lead to Rome.

              I appreciate your post.

                Avatar
                New Member

                United States
                Member #90563
                April 30, 2010
                9 Posts
                Offline
                Posted: April 18, 2011, 10:45 am - IP Logged

                You guys, especially those that use QB, might want to look at FreeBasic.

                It is open source, has a true compiler, is compatible with QB, has a forum etc.

                In fact it has software switches to compile QB programs.

                I have used it to compile QB programs with no problems.

                It is fast, much faster that QB.

                I believe, but not posttive, that it uses an open source C compiler behind its Basic front end.

                It also, unlike QB64 the last I looked, doesn't use a Bunch of dependent files to work.

                There are a couple of free editors that you can get to use it in that work very well.

                If you like Basic, but would like more power if you want it and don't want to buy PureBasic or PowerBasic, then this might be for you. It also runs in Vista and Win7 because it is 32 bit.

                I have other compilers so I mostly use it once in a while to compile QB programs that I want to try, but it has always worked well and made fast .exe programs.

                Regards,

                Jerry

                  RL-RANDOMLOGIC's avatar - usafce

                  United States
                  Member #59354
                  March 13, 2008
                  3973 Posts
                  Offline
                  Posted: April 18, 2011, 11:02 am - IP Logged

                  Josephus

                  I have borland turbo C++, VB3 vb4, vbnet, qbx, qb45, Python, and QB64 all on my computer but I use QB64

                  99% of the time.  I am not looking to produce consumer grade apps and as far a crunching numbers qb64

                  does anything/everything I need.  I have a toolbox with tons of subs and functions that I have written over 

                  the years that I can copy and paste.  When I get a new Idea to test I can code it minuets and be on my way.

                  What you need depends on where you want to end up. If you want something to test a few ideas or crunch

                  some data then I would say qb64 because it is very easy to learn.  Don't let the name Quick Basic fool you it

                  has all the guts just without the flash.  The only thing I don't like about qb64 is that I can't bit-bang the serial/

                  parallel ports without using other software to gain access but this is being worked on or may be added in the

                  future.       

                  RL

                    RJOh's avatar - chipmunk
                    mid-Ohio
                    United States
                    Member #9
                    March 24, 2001
                    19830 Posts
                    Offline
                    Posted: April 18, 2011, 11:11 am - IP Logged

                    Thanks RL.  When I asked this question I assumed there was a single, simple answer more better than other answers. I figured I'd get a little nudge in a direction I'd follow step by step in my own plodding way until I could program the computer to do some things I can't do, EXCEL can't do, or EXCEL can do but I just never figured out how to make it do it.

                    I can see I was looking for over-simplifications and a lot of roads lead to Rome.

                    I appreciate your post.

                    Learning EXCEL or a computer language well enough to do all the things it's capable of doing takes time and some effort, good luck on what ever you decide to do.

                     * you don't need to buy more tickets, just buy a winning ticket * 
                       
                                 Evil Looking       

                      Avatar

                      United States
                      Member #105312
                      January 29, 2011
                      435 Posts
                      Offline
                      Posted: April 18, 2011, 11:42 am - IP Logged

                      Learning EXCEL or a computer language well enough to do all the things it's capable of doing takes time and some effort, good luck on what ever you decide to do.

                      Thanks RJOH:  You're a master of understatement.  EXCEL is great for a lot of things and learning to do anything on it has always been a time-consuming labor for me.  It's possible a lot of what I want to do that I don't believe EXCEL is capable of could be done using a db system, but I'm afraid it would be trading a headache for an upset stomach.

                      But a lot of the problem for me with EXCEL is that it's a memory hog and I find with the large files I work with I run out of RAM before I run out of fancy ideas.  Which is to say, I load up my storage with frequent saves under progressive file names so as to be able to go back to the last save when EXCEL crashes and wants to use up an hour or three trying to recover my 'work' when it crashed.  By saving after every operation I found I can go into the task manager and kill EXCEL, then bring up the previous saved file a lot more quickly than would be possible if I waited for it to try to recover the work between the most recent save and the crash.

                      I thought possibly I could get around some of that by letting some program that's not a memory hog do some of the calculations.

                      Thanks again.

                        garyo1954's avatar - garyo
                        Dallas, Texas
                        United States
                        Member #4549
                        May 2, 2004
                        1720 Posts
                        Offline
                        Posted: April 18, 2011, 2:21 pm - IP Logged

                        Thanks RJOH:  You're a master of understatement.  EXCEL is great for a lot of things and learning to do anything on it has always been a time-consuming labor for me.  It's possible a lot of what I want to do that I don't believe EXCEL is capable of could be done using a db system, but I'm afraid it would be trading a headache for an upset stomach.

                        But a lot of the problem for me with EXCEL is that it's a memory hog and I find with the large files I work with I run out of RAM before I run out of fancy ideas.  Which is to say, I load up my storage with frequent saves under progressive file names so as to be able to go back to the last save when EXCEL crashes and wants to use up an hour or three trying to recover my 'work' when it crashed.  By saving after every operation I found I can go into the task manager and kill EXCEL, then bring up the previous saved file a lot more quickly than would be possible if I waited for it to try to recover the work between the most recent save and the crash.

                        I thought possibly I could get around some of that by letting some program that's not a memory hog do some of the calculations.

                        Thanks again.

                        Josephus,

                        I've been sitting in the background watching. It is interesting to see the many flavors of BASIC. I'm not familiar with JustBasic, NBasic, or FreeBASIC. It appears they have some minor difference but the language conventions are the same.

                        It sounds like what you want to do is what I do now. I derive my data by program and then take it into Excel to juggle, flip-flop, manipulate, investigate, inspect, detect, and look over. Like RL, I try to keep my programs uniform so parts can be slapped in place in another program with the least amount of editing.

                        With all this in mind, I pulled out a short program to show some idea of how simple, and yet, how powerful BASIC can be. I chose this program because it has all necessary ideas used in working with data. It makes use of string data, sets parameters, inputs data from a file, checks the data against the parameters, displays output to the screen, and writes data to a file that you can take into Excel. (That's a mouthful of words for a short program.)

                        I don't know how many posts this will take, but what I want to do is post the program, explain each part, post screen shots of what it displays and and finally, what the output file will look like.

                        You will need to download this file. Click here. This is a boxnet (http://www.box.net/shared/4y1na10itl) link to a file called night3.txt for the Texas Pick 3 nightly drawing. Place this file in your QB64 directory.

                        Copy and paste this in QB:

                        CLS: REM:calculate the percentage of sums for all draws
                        A$ = "In": B$ = "Drawings, the sum is between": C$ = "and": D$ = "times."
                        E$ = "Winning Percentage "
                        FOR Y = 0 TO 27
                            FOR Z = 0 TO 27
                                IF Z < Y THEN 520
                                OPEN "H:\QB64\night3.txt" FOR INPUT AS #1 '<-- change the 'H' to the drive where QB64 is located. 
                                DO UNTIL EOF(1)
                                    INPUT #1, G$, M, DT, YR, N1, N2, N3, S
                                    I = I + 1
                                    IF S >= Y AND S <= Z THEN HIT = HIT + 1
                                    IF S < Y OR S > Z THEN MISS = MISS + 1
                                    R = R + 1
                                LOOP
                                'Showme
                                PRINT A$; I; B$; Y; C$; Z; HIT; D$
                                PRINT E$; USING "##.###"; (HIT * 100) / I
                                'Writeme
                                OPEN "H:\QB64\sumdata.dat" FOR APPEND AS #2 '<-- change the H to the drive where QB64 is located
                                WRITE #2, I, Y, Z, (HIT * 100) / I
                                CLOSE #2
                                CLOSE #1: HIT = 0: R1 = 0: I = 0: MISS = 0
                            520 NEXT Z
                        522 NEXT Y
                        525 IF Y > 9 THEN 550
                        550 CLOSE #1: END

                        This is what the output screen will look like:

                        What this program is doing is checking each draw against a low and high total, counting to total times a sum in that range hit, printing it all to the screen with a percentage of hits vs draws.

                        Forgive me while I get anal, but let's break the program down and see what is actually happening behind the output screen in the next post.

                          garyo1954's avatar - garyo
                          Dallas, Texas
                          United States
                          Member #4549
                          May 2, 2004
                          1720 Posts
                          Offline
                          Posted: April 18, 2011, 3:08 pm - IP Logged

                          I apologize again for getting anal but it is essential for a novice, as the title of the thread suggests, to understand the components in a program and what they are doing.

                          Here's our program broken into sections with explanation:

                          The first three lines clear the screen (CLS). The REM statement is a reminder of what the program is designed to do.  The A$ through E$ is data I want printed to the screen to make the output understandable. Otherwise I would have a bunch of meaningless numbers flashing by.

                          CLS: REM:calculate the percentage of sums for all draws
                          A$ = "In": B$ = "Drawings, the sum is between": C$ = "and": D$ = "times."
                          E$ = "Winning Percentage "

                          These next three lines set the parameters. Y is the low value. Z is the high value. Together they work like an odometer in a car starting at 0,0; 0,1; 0,2; to 27,27. Each time Z reaches 27, Y will go to the next higher digit. The third line, IF Z<Y THEN 520, ensures Z is never less than Y. If so the program will procreed to the NEXT Z statement ad get the next higher digit.

                          FOR Y = 0 TO 27
                              FOR Z = 0 TO 27
                                  IF Z < Y THEN 520

                          We've now set out parameters and in this case we're going to compare those to data in a file. The OPEN statement tells the program to open night3.txt to input the data. Our DO UNTIL EOF(1) tells the program to continue inputting data until it reached the End Of File. The INPUT#1 statement tells the program what data to use. G$ is Game. M is Month, DT is Date. YR is Year. N1 is number one, N2 is number 2, and N3 is number 3. S is sum. I is an interval counter telling the program how many times it has run through this LOOP.

                                  OPEN "H:\QB64\night3.txt" FOR INPUT AS #1 '<-- change the 'H' to the drive where QB64 is located. 
                                  DO UNTIL EOF(1)
                                      INPUT #1, G$, M, DT, YR, N1, N2, N3, S
                                      I = I + 1

                          IF S >= Y AND S <= Z THEN HIT = HIT + 1 <-- This statement checks the sum to see if it is between the low sum Y and the high sum Z. If so then HIT adds 1 to the total.
                          IF S < Y OR S > Z THEN MISS = MISS + 1 <--- This statement counts the number of times the sum is not between Y and Z.
                          R = R + 1 (This is an artifact left over from rewrite 9317. Serves no useful purpose, but to make Jimbooble ask questions. Everybody else can ignore it. )


                                      IF S >= Y AND S <= Z THEN HIT = HIT + 1
                                      IF S < Y OR S > Z THEN MISS = MISS + 1
                                      R = R + 1
                                  LOOP

                          Now that our data is being calculated we can set and watch a blank screen give out eyes something to look at! So let's do that. These statements tell the program what to write to the screen:

                                  'Showme
                                  PRINT A$; I; B$; Y; C$; Z; HIT; D$
                                  PRINT E$; USING "##.###"; (HIT * 100) / I

                          While the program is displaying the information we want to see, we also want to write that data into a file we can take into Excel. To do that we again use  the OPEN statement with a couple of changes. We're going to open the file for APPEND so that we can write to the file. And we're going to open it as file #2. Notice in the WRITE #2 statement, we're only writing the Interval, the low total, the high total, and the percentage of HITS.

                                  'Writeme
                                  OPEN "H:\QB64\sumdata.dat" FOR APPEND AS #2 '<-- change the H to the drive where QB64 is located
                                  WRITE #2, I, Y, Z, (HIT * 100) / I

                          These lines CLOSE our files and set the counters back to zero. The program proceeds to the NEXT high and low values and runs the entire cycle again. It will continue until both counters reach 27. Then program then closes the file and jumps to END.

                                  CLOSE #2
                                  CLOSE #1: HIT = 0: R1 = 0: I = 0: MISS = 0
                              520 NEXT Z
                          522 NEXT Y
                          525 IF Y > 27 THEN 550 <---This is another artifact leftover from rewrite 11734.
                          550 CLOSE #1: END

                          Okay. I'm through with anal for the day.

                            time*treat's avatar - radar

                            United States
                            Member #13130
                            March 30, 2005
                            2171 Posts
                            Offline
                            Posted: April 18, 2011, 3:12 pm - IP Logged

                            Thanks RL.  When I asked this question I assumed there was a single, simple answer more better than other answers. I figured I'd get a little nudge in a direction I'd follow step by step in my own plodding way until I could program the computer to do some things I can't do, EXCEL can't do, or EXCEL can do but I just never figured out how to make it do it.

                            I can see I was looking for over-simplifications and a lot of roads lead to Rome.

                            I appreciate your post.

                            I have found things I wanted to do in XL that weren't explained in any of the books I have for it (the web was helpful in those cases) -- but I've not yet run into anything it couldn't actually do, in the number-crunching arena. Cool

                            In neo-conned Amerika, bank robs you.
                            Alcohol, Tobacco, and Firearms should be the name of a convenience store, not a govnoment agency.

                              garyo1954's avatar - garyo
                              Dallas, Texas
                              United States
                              Member #4549
                              May 2, 2004
                              1720 Posts
                              Offline
                              Posted: April 18, 2011, 3:17 pm - IP Logged

                              Finally, if we open out sumdata.dat file in notepad it will show the total number of draws, the low sum, the high sum and the percentages of hits from the total draws. From there we can open them in Excel to manipulate it in any way we choose. The sumdata file will look like this: