none
Which steps should I take to contribute a Small Basic program?

    Question

  • Excuse me but I couldn't grasp whether all I must do is just paste my code here or whether there is some other place to candidate one's programs for upload.

    Many thanks

    '=================================
    '    ANALOG CLOCK
    '
    '   This program is transcribed as faitfully 
    '   as possible from an original written for
    '   MS-DOS 3.0 BASICA at some time in 1985 
    '   (perhaps at the beginning of 1986) by my
    '   colleague Luciano Ghinelli and me (Cesare
    '   Brizio).
    '   It operated in "SCREEN )" mode (640x350)
    '   Text coordinates were as usual for the time 
    '   the 24 lines x 80 columns system.
    '   In hindsight, Small Basic's (for that purpose.
    '   any "recent" Basic's!) syntax seems to me
    '   convolute, inefficient and counter-intuitive!
    '=================================
    TextWindow.WriteLine("Per uscire, battere un tasto")
    CLRTXT=Text.GetCharacter(219)
    h = 350 'height
    w = 640 'width  
    GraphicsWindow.Height = h
    GraphicsWindow.Width = w
    GraphicsWindow.KeyDown = OnKeyDown
    GraphicsWindow.BackgroundColor = "Black"
    GraphicsWindow.Show()
    '------------------------------------------------------------------------------
    '    CALCULATING THE COORDINATES AROUND THE CIRCLE
    '------------------------------------------------------------------------------
    R = 150
    X = 320
    Y = 9
    PI = 3.141593
    IND = 0
    FOR I = -PI / 2 TO PI * 3 / 2 STEP PI / 30
      X = Math.Floor(320 + (R * math.Cos(I)*0.97))
      U = Math.Floor(320 + (R * math.Cos(I)*0.90))
      S = Math.Floor(320 + (R * math.Cos(I)*0.75))
      Q1 = Math.Floor(320 + ((R + 10) * math.Cos(I)))
      Y = Math.Floor(175 + (R  * math.Sin(I)*0.97))
      V = Math.Floor(175 + (R  * math.Sin(I)*0.90))
      T = Math.Floor(175 + (R  * math.Sin(I)*0.75))
      Q2 = Math.Floor(175 + ((R + 10) * math.Sin(I)))
      COORDX[IND] = X 
      COORDY[IND] = Y
      ORAX[IND] = S
      ORAY[IND] = T
      MINX[IND] = U
      MINY[IND] = V
      LANX[IND] = Q1
      LANY[IND] = Q2
      IND= IND + 1
    ENDFOR

    '----------------------------------------
    '   DRAWING THE CLOCK FACE
    '----------------------------------------
    GraphicsWindow.PenColor = "White"
    GraphicsWindow.DrawEllipse(165,20,2*R + 10,2*R +10)'OK
    GraphicsWindow.DrawEllipse(170,25,2*R,2*R) 'OK
    'GraphicsWindow.DrawEllipse(310,165,20,20)
    GraphicsWindow.DrawEllipse(146,1,2*R + 46,2*R +46)
    GraphicsWindow.PenColor = "Yellow"
    FOR OO = 0 TO 60
      GraphicsWindow.DrawLine(LANX[OO],LANY[OO],COORDX[OO],COORDY[OO])
    ENDFOR
    GraphicsWindow.BrushColor = "Yellow"
    GraphicsWindow.DrawText(312,0,"12")
    GraphicsWindow.DrawText(245,14,"11")
    GraphicsWindow.DrawText(168,84,"10")
    GraphicsWindow.DrawText(150,166,"9")
    GraphicsWindow.DrawText(174,252,"8")
    GraphicsWindow.DrawText(228,308,"7")
    GraphicsWindow.DrawText(315,333,"6")
    GraphicsWindow.DrawText(400,308,"5")
    GraphicsWindow.DrawText(456,252,"4")
    GraphicsWindow.DrawText(480,168,"3")
    GraphicsWindow.DrawText(458,82,"2")
    GraphicsWindow.DrawText(400,24,"1")
    PREICS=0
    PREIPS=0
    exiting = "False"     'User interaction - Has any key been pressed??
    While exiting = "False"
      '----------------------------------------------------------------
      '    CALCULATING SECONDS AND COORDINATES
      '----------------------------------------------------------------
      SEC = Clock.Second
      ICS = COORDX[SEC]
      IPS = COORDY[SEC]
      MSEC = SEC - 1
      IF MSEC < 0 THEN 
        MSEC = 59
      Endif
      MICS = COORDX[MSEC]
      MIPS = COORDY[MSEC]
      GraphicsWindow.PenWidth = 1
      GraphicsWindow.PenColor = "White"
      GraphicsWindow.DrawLine(320, 175, ICS , IPS)
      'GraphicsWindow.BrushColor = "White"
      'GraphicsWindow.fillEllipse(310,165,20,20)
      GraphicsWindow.BrushColor = "White"
      GraphicsWindow.DrawText(0,0,Clock.Time)
      Text.GetCharacter(65)
      IF PSEC <> SEC THEN 
        Sound.PlayClick()
        PSEC = SEC 
      ELSE 
        GOTO SecondUnchanged
      EndIf
      GraphicsWindow.PenWidth = 4
      GraphicsWindow.PenColor = "Black"
      GraphicsWindow.DrawLine(320, 175, MICS , MIPS)
      GraphicsWindow.BrushColor = "Black"
      GraphicsWindow.FillRectangle(0,0,100,30)
      
      SecondUnchanged:
     
      '----------------------------------------------------------------
      '    CALCULATING MINUTES AND COORDINATES
      '----------------------------------------------------------------
      MIN = Clock.Minute

      ICS = MINX[MIN]
      IPS = MINY[MIN]
      GraphicsWindow.PenWidth = 2
      GraphicsWindow.PenColor = "Blue"
      GraphicsWindow.DrawLine(319, 174, ICS - 1, IPS - 1)
      GraphicsWindow.DrawLine(320, 175, ICS , IPS)
      GraphicsWindow.DrawLine(321, 176, ICS + 1, IPS + 1)
      IF (PREMIN = MIN) THEN 
        GOTO MinuteUnchanged
      EndIf
      PREMIN = MIN
      MMIN = MIN - 1
      IF (MMIN < 0) THEN 
        MMIN = 59
      EndIf 
      MICS = MINX[MMIN]
      MIPS = MINY[MMIN]
      GraphicsWindow.PenWidth = 6
      GraphicsWindow.PenColor = "Black" 
      GraphicsWindow.DrawLine(319, 174, MICS - 1, MIPS - 1)
      GraphicsWindow.DrawLine(320, 175, MICS , MIPS)
      GraphicsWindow.DrawLine(321, 176, MICS + 1, MIPS + 1)
      MinuteUnchanged:
      '----------------------------------------------------------------
      '    CALCULATING HOURS AND COORDINATES
      '----------------------------------------------------------------
      ORA = Clock.Hour
      IF (ORA > 11) THEN 
        ORA = ORA - 12
      ENDIF
      ORA = Math.Floor(ORA * 5 + (MIN / 15))

      ICS = ORAX[ORA]
      IPS = ORAY[ORA]
      GraphicsWindow.PenWidth = 4
      GraphicsWindow.PenColor = "Green"
      GraphicsWindow.DrawLine(319, 174, ICS - 1, IPS - 1)
      GraphicsWindow.DrawLine(320, 175, ICS , IPS)
      GraphicsWindow.DrawLine(321, 176, ICS + 1, IPS + 1)
      IF (PREORA = ORA) THEN 
        GOTO HourUnchanged
      EndIf
      PREORA = ORA
      IF (PREICS = 0 AND PREIPS = 0) THEN 
        PREICS = ICS
        PREIPS = IPS
        Goto HourUnchanged
      EndIf
      GraphicsWindow.PenWidth = 8
      GraphicsWindow.PenColor = "Black"
      GraphicsWindow.DrawLine(319, 174, PREICS - 1, PREIPS - 1)
      GraphicsWindow.DrawLine(320, 175, PREICS , PREIPS)
      GraphicsWindow.DrawLine(321, 176,PREICS+ 1, PREIPS + 1)
      PREICS = ICS
      PREIPS = IPS
      HourUnchanged:
    endwhile

    Program.End()

    '-----------------------------------------------------------------------------------------------------------
    '--- Take note of the fact that a key has been pressed. 
    '-----------------------------------------------------------------------------------------------------------
    Sub OnKeyDown
      exiting = "True"
    EndSub

    Saturday, March 18, 2017 7:54 PM

All replies

  • 1) You can publish your program as you have done: copy as text in your posting.

    2) Another way is to click on the "Insert code block" (second from the right) at the top of the window where you write your posting, paste your program in the left frame and press"Insert"

    3) Or you can click the "Publish" button at the top of the Small Basic IDE. THen you get a codenumber (three letters and three digits (e.g. ABC123 ), which you can publish in you posting.

    BTW: nice program (hint: remove the TextWindow, you can use "GraphicsWindow.Title="To stop, press any key""


    Jan [ WhTurner ] The Netherlands


    Sunday, March 19, 2017 12:22 PM
    Answerer