MSDN > 論壇首頁 > Small Basic > This might be a good extension..
發問發問
 

已答覆This might be a good extension..

  • 2009年7月3日 上午 09:43Ron Hudson 使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     
    How about a "plot" extension.

    It initializes a window.

    You can tell it the size and range of the x and y axis. You can also specify labels for the axises.
    For example if you are plotting a sine function, perhaps you want the coordinates on the x axis to
    run from - 2*pi to 2*pi, and the y axis perhaps should run from -1.5 to 1.5

    plot.xaxis(-6.28, 6.28, "Sine", "Ticks")
    plot.yaxis(-1.5, 1.5, "", "NoTicks)

    for x = -6.28 to 6.28 step .1
        plot.point(x,math.sin(x))
    endfor

    This would generate a nice sine plot with 2 axises.

    This is not exactly like the graphics.window because it is self-scaling, It simplifies
    plotting for the user.

    The inspiration for this is the plotting routines for the HP87 computer.

解答

  • 2009年7月3日 下午 08:01FremyCompany解答者使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     已答覆
    This looks like a good project to write in SmallBasic rather than having it done by new commands; the purpose of SB is to learn programming using a small set of easily remembered commands rather than using a large menu of high level functions.  You could write some subroutines that use an array of x,y data, work out the limits of the data and generate an appropriately scaled plot (converting data coordinates to pixels) with labels etc within a defined region of the GraphicsWindow.
    I agree with you, here. Small Basic should not provide tons of functions, but let them be wrotten by users. This is the intent.
    Small Basic should only provide functions that could otherwhise not be wrotten in Small Basic by a beginner.

    A small thing that would help in this situation is implementing C#/VB.NET-like extension. With those languages, you can extend objects.

    I propose a syntax like :

        Sub Plot.DrawCurve(data) ' This is a sub like any other, except that it seems to be in a "Plot" namespace in the intellisense.
            DrawCurve_X = 0
            DrawCurve_LastPoint = ""
            DrawCurve_CurrentPoint = ""
            While (data[DrawCurve_X]["X"] <> "") And (data[DrawCurve_X]["Y"] <> "")
               DrawCurve_LastPoint = DrawCurve_CurrentPoint
               DrawCurve_CurrentPoint = data[DrawCurve_X]
               ' ...
               ' Do something with the point
               ' ...
            EndWhile
        EndSub

        curve1[0]["X"] = ...
        curve1[0]["Y"] = ...
        ...
        
        Plot.DrawCurve(curve1)
    Fremy - Developer in VB.NET, C# and JScript ... - Feel free to try my extension

所有回覆

  • 2009年7月3日 下午 06:35litdev解答者使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     
    This looks like a good project to write in SmallBasic rather than having it done by new commands; the purpose of SB is to learn programming using a small set of easily remembered commands rather than using a large menu of high level functions.  You could write some subroutines that use an array of x,y data, work out the limits of the data and generate an appropriately scaled plot (converting data coordinates to pixels) with labels etc within a defined region of the GraphicsWindow.
  • 2009年7月3日 下午 08:01FremyCompany解答者使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     已答覆
    This looks like a good project to write in SmallBasic rather than having it done by new commands; the purpose of SB is to learn programming using a small set of easily remembered commands rather than using a large menu of high level functions.  You could write some subroutines that use an array of x,y data, work out the limits of the data and generate an appropriately scaled plot (converting data coordinates to pixels) with labels etc within a defined region of the GraphicsWindow.
    I agree with you, here. Small Basic should not provide tons of functions, but let them be wrotten by users. This is the intent.
    Small Basic should only provide functions that could otherwhise not be wrotten in Small Basic by a beginner.

    A small thing that would help in this situation is implementing C#/VB.NET-like extension. With those languages, you can extend objects.

    I propose a syntax like :

        Sub Plot.DrawCurve(data) ' This is a sub like any other, except that it seems to be in a "Plot" namespace in the intellisense.
            DrawCurve_X = 0
            DrawCurve_LastPoint = ""
            DrawCurve_CurrentPoint = ""
            While (data[DrawCurve_X]["X"] <> "") And (data[DrawCurve_X]["Y"] <> "")
               DrawCurve_LastPoint = DrawCurve_CurrentPoint
               DrawCurve_CurrentPoint = data[DrawCurve_X]
               ' ...
               ' Do something with the point
               ' ...
            EndWhile
        EndSub

        curve1[0]["X"] = ...
        curve1[0]["Y"] = ...
        ...
        
        Plot.DrawCurve(curve1)
    Fremy - Developer in VB.NET, C# and JScript ... - Feel free to try my extension
  • 2009年7月8日 下午 02:37Ron Hudson 使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     
    An extension like this would make small basic more attractive to math student who are not really in it for programming.

    Fremy  - Small basic does not have parameters in it's subroutine calls, or was that some other language?

    I understand you want to keep the syntax simple for new programmers, since this would be an optional extension
    (You don't have to install it if you don't want to) that would only add one item to the top level help wheel I don't think
    it violates that goal.

    Yes I suppose I could write a general curve plotter in small basic (does small basic even have include files?) but it would
    add variables to the variable pool (I'd have to name them like 'PlotXAxisTitle' = "Sine" 'PlotData' (an array). ugh.)
    not simple or clean.



  • 2009年7月8日 下午 02:49FremyCompany解答者使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     
    @Ron: The intent of Small Basic is to learn programmation the people.
    If Small Basic provide a function for each thing a beginner can need,
    the beginner will not learn to create functions as everything he need
    already exsits.

    My code is Small Basic 2.7 :-)
    In fact, it's a propossal to allow to create extensions of Small Basic in
    Small Basic Language, allowing to create exensions that don't polluate
    the variable pool. Each "imported" sb file would have its own variable
    pool, only subs would be shared. It's possible to create "objects" by
    writing "Sub MyObj.TheSub". It needs parameters, too.

    Yes, it needs to register the file in a sort of header like :
       
       Use "PlotExtension.sb"
       Use "FC.SmallBasic.Complements.dll"
       
       ' Your small basic program


    Fremy - Developer in VB.NET, C# and JScript ... - Feel free to try my extension
  • 2009年7月8日 下午 04:06Ron Hudson 使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     
    What is this Small Basic 2.7 of which you speak?

    Us mortals only have 0.5 : ^ o



  • 2009年7月8日 下午 04:11FremyCompany解答者使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     
    What is this Small Basic 2.7 of which you speak?
    It was a joke. It was to speak about a non-existant version of Small Basic.

    Fremy - Developer in VB.NET, C# and JScript ... - Feel free to try my extension
  • 2009年7月8日 下午 04:21Ron Hudson 使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     
    Oh, I thought you were the developer of small basic and thus had access to unreleased versions.


  • 2009年7月8日 下午 07:32bigdaddyo 使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     
    I'm not sure how useful SB is for much math (at least scientific math) at this point, it can't handle large numbers or scientific notation.
  • 2009年7月8日 下午 07:35FremyCompany解答者使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     

    The objective would be to create specific programs.
    You may have to use many time the same set of formula to get what you want.

    Or you may write a program that you can reuse. Small Basic is a good language
    for people that don't have made programs yet but that want to make their first apps.

    But after some time, they would probably use another language like VB.NET or C#.


    Fremy - Developer in VB.NET, C# and JScript ... - Feel free to try my extension
  • 2009年7月25日 上午 07:35Ron Hudson 使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     
    Hey Bigdadyo

    1x10^27 ain't bad..

    true = 1
    false = 0
    TextWindow.Show()
    c = 1
    TextWindow.WriteLine("Starting")
    b = 0
    a = true
    While a=true
      b = b + 1
      c = 10 * c
      TextWindow.Write(b+" ")
      TextWindow.WriteLine(c)
      If b = 30 Then
        a = false
      endif
    EndWhile
    TextWindow.WriteLine("Done")

    Gets up to 28 before it overflows.

    BTW arent there actual values for True and False?
    I sort of makeshifed them here.

  • 2009年7月25日 上午 07:43Ron Hudson 使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     
    Take a look at SNC433
     
    It would have greatly benefited from the plot window extension. Import it and see the
    hoops I had to jump through to scale the plotting and to handle the graphic window being
    re-sized. Not having a "graphics" background I had to experiment to get everything just right

    As long as the program is running and re-plotting the bell curve you can re-size the graphic
    window. I usually shorten the text window to a few lines and widen the graphic window to match the text
    window in width.