Basic course for newbies

صفحة 10/11
3 | 4 | 5 | 6 | 7 | 8 | 9 | | 11

بواسطة Poltergeist

Champion (279)

صورة Poltergeist

31-12-2013, 13:03

First things first then: Start with the simple thing: screenhandling is relatively easy in Basic, diskhandling is hard, so I would start with the problem of showing more files than fit on the screen.

First of all: how many files do fit on the screen? Let's say you want to display 5 files per line, and use 20 lines (you could go up to 24, but you might want to display some statusdata, the name of your program, functionkeys on the bottom, et cetera. You can still display 100 files on one screen, and still have some room to spare.

some pseudo code (which you should be able to translate to real basic)
Now, lets set variable AP (which stands for ArrayPointer) to 0.
Display files:
Display files AP to AP+99 on screen

if cursorline >20 then cursorline=20: ap=ap+5: if ap>numberoffiles-99 then ap=ap-5: goto display files else goto displayfiles
if cursorline <0 then cursorline=0: if ap<0 then ap=0: goto display files else goto display files

It's up to you to create some errorhandling, and to determine what file is pointed at, but that should not be to hard. For testing use fill the array FO$ with 1000 different names.


Enlighted (5976)


08-01-2014, 13:34

edoz wrote:
Manuel wrote:

That line makes no sense, please recheck the post I did about TIME. Or explain what you're doing here Smile

You can't blame Edoz here... That was my change... Although this is more like habit, there is a reason behind it: Many times I want to know how fast the routine is actually working and I do that by adding "'" as REM in front of the timing line. Then I make changes to speed things up and remove the REM. How ever I also tend to write RENUM very often, so if I use GOTO on timing line while it is commented out I usually have to fix the linenumber as well... So... in the end it is related more to my coding style than functionality.

At least I was understanding it Big smile .. I use renum also very often indeed!

There is also another trick to get rid of the RENUM problem... You can use ELSE instead of REM in the beginning of line. This will skip the line, but the RENUM will still fix the line numbers. Wink

بواسطة edoz

Prophet (2451)

صورة edoz

08-01-2014, 13:40

Thanks! Big smile I'm still working on the loader .. but at the moment I'm bit busy to learn symbasic Big smile

بواسطة anonymous

incognito ergo sum (116)

صورة anonymous

02-11-2014, 01:49

Hello, I think this topic will a useful topic for me. Thanks.

Diskbasic 1.0 - I can't print two types of variables

I'm trying to output a string and an integer. However I'm getting error.

10 CLS
30 TESTSTR = "test"
40 PRINT "teststr = " + TESTSTR
60 NUM = 10
70 PRINT "num = "; NUM

teststr = test
num = 10
Type mismatch in 90

How can I fix this error?

بواسطة meits

Scribe (6528)

صورة meits

02-11-2014, 02:01

Variables and strings can only be two characters long and you can't just add a string to a variable...
TESTSTR is being read as TE
STR$ is being read as ST$
NUM is being read as NU
ALLSTR is being read as AL
The error you get is because you add a numeric value (variable) to an alphanumeric value (string)
if the value in STR$ is numeric, you could use the VAL command to read the numeric value in the string as a variable...

بواسطة nikel

Supporter (3)

صورة nikel

02-11-2014, 04:06

Thank you for quick reply, sorry for double post. This line works fine:


بواسطة Manuel

Ascended (19058)

صورة Manuel

02-11-2014, 15:45

For those reading: STR$ is actually a function to convert the argument into the string type... So it should not have been in the list posted by Meits.

بواسطة Vampier

Prophet (2402)

صورة Vampier

16-11-2014, 22:04

haven't posted here in a while. Just a quick example for beginning MSX basic programmers (just pause at the beginning of the movie for the listing)


Enlighted (5976)


17-11-2014, 05:31

Very nice one, Vampier! Now when I try to remember back, exactly these kind of easy animations for MSX2 were one of the reasons I totally felt in love with MSX-BASIC!

TIP: SIN and COS take angle parameter as radians. Full circle in radians is same as ATN (1)*8 in BASIC.
Excercise: Use this information to fix the "bug" seen in video.

بواسطة Poltergeist

Champion (279)

صورة Poltergeist

17-11-2014, 09:28

@Vampier: Nice example
@nikel: Meits isn't completely right. He is right about the length of the variablenames. Only the first two are used, so teststr would be the same as testnum (for example)

STR$ is a basic command to convert a numerical value to a string. You are using it right, but the error is not just in line 90: you're already starting wrong.

First you're using a defstr A-Z, which simply says: every variable I'm using is going to be a string. You then fill the variable teststr with a string. This works.
Then you're redefining all variables as an integer. You give num the value of 10. This also works, but while redefining all variables, you loose the value of teststr. If you would insert line 75 with print teststr, it would give a 0, not test
After that, you are redefining all variables again as strings. You're loosing the value of Num (which is now "" (emtpy), because it's a string)
In line 90, you're trying to convert the variable num (which is a string) to a string. str$ needs a numerical value, and num is a string. Hence the error

What I would do: Loose the defint en defstr command. For strings, use the $ to indicate a string as variablename (like teststr$="test") and % for the integers (e.g. num%=10)

not tested example:

10 CLS
30 TESTSTR$ = "test"
40 PRINT "teststr = " + TESTSTR$
60 NUM% = 10
70 PRINT "num = "; NUM%
صفحة 10/11
3 | 4 | 5 | 6 | 7 | 8 | 9 | | 11