Menu

My First Program

Tuxtoo
2020-04-14
2020-04-19
  • Tuxtoo

    Tuxtoo - 2020-04-14

    Just bought 'The Waite Group's GW_BASIC Primer Plus' from Amazon and have started working my way through the book. The first issue I have is with DATE$, it returns the date in the U.S. Format (mm-dd-yyy), but I would rather have the date in the European Format (dd-mm-yyyy).

    I may be getting ahead of myself, but I have written a subroutine to convert DATE$ to the European Format in the form '14 Apr 2020' so there is no confusion between the U.S. And European Format. As this is my first program I would be grateful if anyone cares to comment on whether I have done this correctly or is there a more efficient way of doing this.

    100 GOSUB 1000
    110 PRINT D$
    120 END
    130 '
    140 '
    1000 'Convert DATE$ to an unambiguous format returned in D$
    1010 OPTION BASE 1
    1020 DIM M$(12)
    1030 DATA "Jan","Feb","Mar","Apr","May","Jun"
    1040 DATA "Jul","Aug","Sep","Oct","Nov","Dec"
    1050  FOR I=1 TO 12
    1060    READ M$(I)
    1070  NEXT I
    1080 '
    1090 D$=DATE$
    1100 DAY$=MID$(D$,4,2)
    1110 MONTH=VAL(LEFT$(D$,2))
    1120 YEAR$=RIGHT$(D$,4)
    1130 '
    1140 ' Swap position of D$=DAY$ and M$(MONTH) for US date format.
    1150 D$=DAY$+" "+M$(MONTH)+" "+YEAR$
    1160 RETURN
    

    Stuart

     

    Last edit: Tuxtoo 2020-04-16
  • Smithdoor

    Smithdoor - 2020-04-14

    The best book I found was the IBM from 1981
    They upate later it came mail and put page that was updated the
    You try looking on Ebay
    It only book I used and still using the book

     
  • Tuxtoo

    Tuxtoo - 2020-04-14

    Dave, Can you give me the full name of the IBM book you refer and the author and possibly the ISBN number in oder for me to try and find a copy.

    Stuart

     

    Last edit: Tuxtoo 2020-04-14
    • Smithdoor

      Smithdoor - 2020-04-15

      No ISBN found The book name is "IBM BASIC"It was sold with the computer. 
      Microsoft also had book not as good but very close.  "Microsoft GW BASIC"Trying email this one if do get the down load let know. 

      Sent from Yahoo Mail on Android

      On Tue, Apr 14, 2020 at 11:44 AM, Tuxtootuxtoo@users.sourceforge.net wrote:
      Dave, Can you give me the full name of the IBM book you refer to and possibly the ISBN number in oder for me to try and find a copy.

      Stuart

      My First Program

      Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/pcbasic/discussion/general/

      To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/

       
  • Tuxtoo

    Tuxtoo - 2020-04-15

    Dave, I am confused. Was it you who uploaded the above book (MsGwBasic.pdf) or was it from Sourceforge?

    Stuart

     
  • Smithdoor

    Smithdoor - 2020-04-16

    I used email to send the pdf file
    Did not know it would put on site
    I hope help the book help you
    The book is close to IBM Basic book

    Dave

     

    Last edit: Smithdoor 2020-04-16
  • Tuxtoo

    Tuxtoo - 2020-04-16

    Many thanks Dave, much appreciated.

    Stuart

     
  • Smithdoor

    Smithdoor - 2020-04-18

    Stuart I have not found my info on Mouse for PC-Basic but did find my data for Qbasic 4.0 from 1987 did some upates to notes.

    I only Qbasic for mouse work for still like using PC-Basic for programing.
    Here is code you may want later

    DEFINT A-Z
    DECLARE SUB Mouse (MIU)
    '
    ' This was around since in 1987 from my files David B Smith
    '
    "Mouse" Sub-Routine
    ' sample program changing color only runs on QBASIC 4 or QBASIX 4.5 update 2020
    '
    First you will need to start QB/etc. with the /L option
    ' Type QB/L it files need QB.BI
    '
    later the program needs ABSOLUTE.ASM
    ' also the file mouse.com
    '
    SCREEN 0 is 639 X 199 H X V
    ' MIU Is only a name and can be changed AKA (Mouse In Use) or MIU
    '
    This only shows a box in Screen 0 and other screens a Arrow
    '
    '
    MOUSE 1 * turned on Box or Arrow You can see it on the screen.
    ' MOUSE 2 * turned off. You can no longer see it on the screen.
    '
    MOUSE 3 * status is returned into by using PEEK is used for reading
    ' B = PEEK(&HAAA) * Current button being pressed (1 = left, 2 = right)
    '
    h = PEEK(&HBBB) + PEEK(&HBBC) * 256 * Current Horizontal position on screen
    ' V = PEEK(&HCCC) + PEEK(&HCCD) * 256 * Current * Vertical position on screen
    '
    ''''''''''''''''''''''' Enter your code here Initialize Program just use PC-BASIC ''''''''''''''''''''''''''''''''
    SCREEN 0, 0, 0: ' ### srceen can be 0 to 13
    COLOR 14, 1
    CLS
    PRINT "Press Esc to end": ' ### Demo showing how both Keyboard and mouse can work on same screen
    LOCATE 13, 28: PRINT "Press mouse botton on box >"; STRING$(4, 177);:' ### Demo box
    10 LOCATE 7, 10
    th = (INT(h / 36)): '
    used for box not need for most games
    tv = (INT(V / 8)): ' v/8 gives about 25 lines
    PRINT B, V, h, tv, th: '
    display information on the mouse
    ' Below shows button press at location 12, 12 and buttons L, M & R press
    IF th = 12 AND tv = 12 AND B = 1 THEN COLOR 0, 3
    IF th = 12 AND tv = 12 AND B = 4 THEN COLOR 15, 4
    IF th = 12 AND tv = 12 AND B = 2 THEN COLOR 2, 1
    Mouse 1 ' ###
    Display Arrow Only IF THEN need to be above this line
    A$ = INKEY$: ' ### note use GOTO at bottom only DO Not use IF A$="" This so mouse info is read data use data
    IF A$ = CHR$(27) THEN PRINT "END only used for demo": END
    Mouse 3 ' *** ### status is returned Button , Vert and Horiz position
    B = PEEK(&HAAA) ' * Get values for: Buttons
    h = PEEK(&HBBB) + PEEK(&HBBC) * 256 ' * Horizontal position ( 2 bytes )
    V = PEEK(&HCCC) + PEEK(&HCCD) * 256 ' * Vertical position ( 2 bytes )
    GOTO 10

    ' " " " "
    ' " " " "
    ''''''''''''''''''''''' END OF program ''''''''''''''''''''''''''''''''
    ''''''''''''''''''''''' Mouse sub program ''''''''''''''''''''''''''''''''
    SUB Mouse (MIU) STATIC 'Define sub & parameter(s) passed.
    SHARED B, h, V 'Share variables with main sub.
    IF MIU = 1 THEN Crsr = 1 'Show Cursor.
    IF MIU = 2 AND Crsr = 0 THEN EXIT SUB 'Don't hide Cursor more than once.
    IF MIU = 2 AND Crsr = 1 THEN Crsr = 0 'Hide Cursor.
    POKE 100, 184: POKE 101, MIU: POKE 102, 0 'Poke machine code necessary for
    POKE 103, 205: POKE 104, 51: POKE 105, 137 'using the mouse into memory
    POKE 106, 30: POKE 107, 170: POKE 108, 10 'starting at offset 100 in the
    POKE 109, 137: POKE 110, 14: POKE 111, 187 'current segment. This code is
    POKE 112, 11: POKE 113, 137: POKE 114, 22 'then executed as a unit, via the
    POKE 115, 204: POKE 116, 12: POKE 117, 203 'statement " Call Absolute ".
    CALL Absolute(100) 'Call machine code.
    B = PEEK(&HAAA) 'Get values for: Buttons
    h = PEEK(&HBBB) + PEEK(&HBBC) * 256 'Horizontal position ( 2 bytes )
    V = PEEK(&HCCC) + PEEK(&HCCD) * 256 'Vertical position ( 2 bytes )
    END SUB 'End of sub-program.

     
  • Tuxtoo

    Tuxtoo - 2020-04-18

    Dave, Thanks for that, but I am a long way off from learnig Qbasic. I've just started with GW-BASIC.

    However, I think I may have found a possible solution to your missing mouse program. I was updating the links on my website ( https://gw-basic.netlify.app ) and I was looking through Gary Peek's BASIC Source Code Archive and I came across a some programs regarding the mouse - ROUTINES.BAS that can be found here and another two; MOUSEPOS.BAS and SLOWMOUS.BAS which can be found on this page.

    Now, I have not used any of the programs and I am not sure what milage you will get from them. From what I see they require assembly language which may not work on PC-BASIC or even GW-BASIC on DOSBox. I hope this is of some help. Let me know how you get on.

    Stuart

     
  • Smithdoor

    Smithdoor - 2020-04-19

    Thank you
    I will try it
    Note Qbasic can be same as GW-Basic most time modifications

     
  • Smithdoor

    Smithdoor - 2020-04-19

    Thank you Stuart
    It works great
    Next is to work to fit in program
    I try on my phone using GW-Basic
    I add screen 1 to work on my phone

    Thank you
    Dave

    100 KEY OFF:CLS:PRINT "(G)RAPHICS OR (T)EXT? (S)CREEN 1"
    110 INPUT GMODE$
    120 IF GMODE$="G" THEN SCREEN 2
    130 IF GMODE$="T" THEN SCREEN 0
    135 IF GMODE$="S" THEN SCREEN 1,0,0
    140 CLS
    150 GOSUB 540:REM LOAD ASSEMBLY LANGUAGE SUBROUTINE
    160 REM -----
    170 REGAH%=&H0:REGAL%=&H3 :REM FILL "REGISTERS"
    180 REGBH%=&H0:REGBL%=&H0
    190 REGCH%=&H0:REGCL%=&H0
    200 REGDH%=&H0:REGDL%=&H0
    210 INTERRUPT%=&H33:GOSUB 390 :REM CALL ASSEMBLY LANGUAGE SUBROUTINE
    220 X=(REGCH%256)+REGCL%
    230 Y=(REGDH%
    256)+REGDL%
    240 REM -----
    250 IF GMODE$="T" THEN 300
    260 REM -----
    270 PSET(X,Y),1
    280 GOTO 320
    290 REM -----
    300 LOCATE (Y/8)+1,(X/8)+1:PRINT CHR$(219);
    310 REM -----
    320 LOCATE 12,35:PRINT "BUTTON STATUS-";
    330 LOCATE 13,40:PRINT (REGBL% AND 7)
    340 IN$=INKEY$:IF IN$="" THEN 170 ELSE END
    350 IF IN$=CHR$(27) THEN END
    360 GOTO 170
    370 REM ----------------------------------------------------------------------
    380 REM SET UP AND CALL ASSEMBLY LANGUAGE SUBROUTINE
    390 DEF SEG=&H4B :REM POINT TO SEGMENT
    400 POKE 31,INTERRUPT% :REM INTERRUPT TO CALL
    410 POKE 4,REGAH%:POKE 3,REGAL%
    420 POKE 6,REGBH%:POKE 5,REGBL%
    430 POKE 8,REGCH%:POKE 7,REGCL%
    440 POKE 10,REGDH%:POKE 9,REGDL%
    450 ASMSUB=0:CALL ASMSUB :REM CALL ASSEMBLY LANGUAGE SUB. FOR INTERPRETER
    460 REM CALL ABSOLUTE(0) :REM CALL ASSEMBLY LANGUAGE SUB. FOR COMPILER
    470 REGAH%=PEEK(4):REGAL%=PEEK(3)
    480 REGBH%=PEEK(6):REGBL%=PEEK(5)
    490 REGCH%=PEEK(8):REGCL%=PEEK(7)
    500 REGDH%=PEEK(10):REGDL%=PEEK(9)
    510 DEF SEG:RETURN :REM RETURN TO BASIC SEGMENT
    520 REM ----------------------------------------------------------------------
    530 REM LOAD AN ASSEMBLY LANGUAGE SUBROUTINE
    540 DEF SEG=&H4B:FOR I=0 TO 51:READ B:POKE I,B:NEXT:DEF SEG:RETURN
    550 REM -----
    560 DATA &HEB,&H09,&H90
    570 DATA &H00,&H00,&H00,&H00,&H00,&H00,&H00,&H00 :REM REGISTERS AX-DX
    580 DATA &H2E,&HA1,&H03,&H00
    590 DATA &H2E,&H8B,&H1E,&H05,&H00
    600 DATA &H2E,&H8B,&H0E,&H07,&H00
    610 DATA &H2E,&H8B,&H16,&H09,&H00
    620 DATA &HCD,&H21 :REM INTERRUPT XX
    630 DATA &H2E,&HA3,&H03,&H00
    640 DATA &H2E,&H89,&H1E,&H5,&H0
    650 DATA &H2E,&H89,&H0E,&H07,&H00
    660 DATA &H2E,&H89,&H16,&H09,&H00
    670 DATA &HCB :REM RETF
    680 LOCATE 1,1:PRINT REGBL% AND 7
    

     
  • Tuxtoo

    Tuxtoo - 2020-04-19

    Dave, Glad you got it working, however I am not so lucky. On running the program I get 'Syntax error in 220'

    220 X=(REGCH%256)+REGCL%
    - If I ammend it to -
    220 X=(REGCH256)+REGCL%

    On running the program again I then get 'Syntax error in 230'

    230 Y=(REGDH%256)+REGDL%
    I then ammend it to
    230 Y=(REGDH256)+REGDL%

    Having fixed the above errors and on running the program in all three modes (G)raphics, (T)ext or (S)creen I get the following message in the centre of the screen 'Buttton Status - 0' is this the results to be expected?

    Stuart

     
  • Smithdoor

    Smithdoor - 2020-04-19

    So far I only get to work in GW BASIC from 1984.
    Try using different screen numbers 0-13
    I did try PC-BASIC on this group but did not work.

    Most of my programing was for Engineering and Booking
    I own a mouse in 1983 but did using till Windows 95 and AutoCAD
    I wish had notes today from 1980's on the mouse

    DaveDave

     
  • Tuxtoo

    Tuxtoo - 2020-04-19

    Okay, I will have a go with it using GW-BASIC and report back.

    Stuart

     
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.