Author Topic: BASIC beginner questions  (Read 336 times)

0 Members and 1 Guest are viewing this topic.

Offline ComSoft6128

  • ..................................
  • Supporter
  • 6128 Plus
  • *
  • Posts: 1.613
  • Country: scotland
  • CPC THEN CPC NOW
    • index.php?action=treasury
  • Liked: 1656
  • Likes Given: 3562
BASIC beginner questions
« on: 18:23, 10 December 19 »
Found this at the weekend - DISPRAV.BAS (Display Raven)

It's at least twenty five years old and I don't know if it was a PD program or if someone wrote it for me as a demonstration file.

 
https://www.youtube.com/watch?v=5RMVQZBuSn8

Questions:

1. Line 50 seems to show a loop going back to Line 30 - Why?
    If all the program does is to load/display a screen what purpose does this serve?

2. Does Locomotive BASIC support wildcards?
    I.E. In Line 20 the filename is shown - would it be be possible to replace this with *.scr and load in multiple Mode 2 files?

Thanks,

Peter

Offline AMSDOS

  • Supporter
  • 6128 Plus
  • *
  • Posts: 3.893
  • Country: au
    • index.php?action=treasury
    • Programs for Turbo Pascal 3
  • Liked: 1104
  • Likes Given: 1869
Re: BASIC beginner questions
« Reply #1 on: 23:23, 10 December 19 »
Found this at the weekend - DISPRAV.BAS (Display Raven)

It's at least twenty five years old and I don't know if it was a PD program or if someone wrote it for me as a demonstration file.

<snip>

Quote
Questions:

1. Line 50 seems to show a loop going back to Line 30 - Why?
    If all the program does is to load/display a screen what purpose does this serve?


Apart from preventing Ready from being displayed, which a 50 GOTO 50 would also do, that GOTO 30 points to a FOR loop which acts as a Delay, so when that delay is reached, line 40 sets the screen inks to Bright White Background & Border with Black Foreground. Playing with that line you could change it to:


Code: [Select]
40 INK 0,INT(RND*27):INK 1,INT(RND*27):BORDER INT(RND*27)

so after the FOR loop completes its cycle, the colours change.

Quote
2. Does Locomotive BASIC support wildcards?
    I.E. In Line 20 the filename is shown - would it be be possible to replace this with *.scr and load in multiple Mode 2 files?

Thanks,

Peter


No, the wildcards can only be used through the RSX commands AMSDOS provides for example, so things like LOAD which are BASIC Commands won't work. There was that Graph Programme you had earlier though from the AA Covertape which came with that unusual Menu Selection programme, which wasn't working correctly for 464 Users which placed Filenames into a string. I think it had something like this, though I've altered it a little bit, so it would be possible to load a file with a random number:


Code: [Select]
10 a$="file"
20 n=INT(RND*5)+1
30 n$=a$+MID$(STR$(n),2,1)+".scr"
40 LOAD n$
50 FOR a=1 TO 8000:NEXT a
60 GOTO 20


This example works by using a screen file called "file" and a random number is stored into the n variable between 1 and 5 (line 20), line 30 puts all that information together because the random number produced is a number, it needs to be converted into a String, which is what STR$(n) does, but because STR$ places a Space inbetween the start of the line and the number I want to use, MID$ is used to remove the Space, however RIGHT$(STR$(n),1) works just as well, so the line would read:


Code: [Select]
30 n$=a$+RIGHT$(STR$(n),1)+".scr"


Line 40 - Loads the Screen (hopefully to the screen), and so on....
« Last Edit: 00:33, 11 December 19 by AMSDOS »
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3