Calculator Community > Casio Calculators

Getting started in Casio-Basic? You can ask here.

<< < (22/25) > >>

flyingfisch:
a mistake that newbies usually make is to say some thing like: 1 -> Mat A[1,1]

when actually, you need to do this first to prevent a mem error: [[0][0]] -> Mat A

That creates a matrix. 1-> Mat A[1,1] does not create a matrix, so if it doesn't exist, you get a mem error.

Just thought i'd add that info, since a lot of BASIC progs have that problem.

Jonius7:
There are other ways to create a matrix other than [[0][0]] -> Mat A, however, I have not programmed casio for 2 years and have forgotten. Something like Dim Mat A, or setting the number of rows and columns

m1ac4:

--- Quote from: Jonius7 on October 20, 2011, 09:33:27 am ---There are other ways to create a matrix other than [[0][0]] -> Mat A, however, I have not programmed casio for 2 years and have forgotten. Something like Dim Mat A, or setting the number of rows and columns

--- End quote ---
You are right, the syntax is {<rows>,<columns>} -> Dim Mat A.
It's also worth noting that the closing brackets at the end are optional (e.g [[0][0->Mat A).  It looks messier but it saves space.

Jonius7:
I know there are ways to check for particular values in a matrix:
And display certain characters as a result:
Eg: a 5 x 5 matrix


--- Code: ---[[5][5]]->Mat A
[[1,2,3,1,2][2,3,1,2,1][3,1,2,1,2][1,2,1,2,3][2,1,2,3,1]]->Mat A
For 1->A To 5
For 1->B To 5
Mat A[A,B] = 1 => Locate B,A, "O"
Mat A[A,B] = 2 => Locate B,A, "M"
Mat A[A,B] = 3 => Locate B,A, "N"
Next
Next

--- End code ---

Try and see what that says

DJ Omnimaga:
So has anyone figured out a way to have dynamic coloring? I mean for example if I got the code:


--- Code: ---For 1->A To 10
Red Locate 1,1,"HELLO WORLD!"
Red Locate 1,2,"THIS IS A TEST"
Red Locate 1,3,"PROGRAM!"
Red Locate 1,4,"BUT IT TAKES"
Red Locate 1,5,"WAY TOO MUCH"
Red Locate 1,6,"BLEEPING SPACE"
Red Locate 1,7,"OPTIMIZE PLZ!"
Magenta Locate 1,1,"HELLO WORLD!"
Magenta Locate 1,2,"THIS IS A TEST"
Magenta Locate 1,3,"PROGRAM!"
Magenta Locate 1,4,"BUT IT TAKES"
Magenta Locate 1,5,"WAY TOO MUCH"
Magenta Locate 1,6,"BLEEPING SPACE"
Magenta Locate 1,7,"OPTIMIZE PLZ!"
Blue Locate 1,1,"HELLO WORLD!"
Blue Locate 1,2,"THIS IS A TEST"
Blue Locate 1,3,"PROGRAM!"
Blue Locate 1,4,"BUT IT TAKES"
Blue Locate 1,5,"WAY TOO MUCH"
Blue Locate 1,6,"BLEEPING SPACE"
Blue Locate 1,7,"OPTIMIZE PLZ!"
Cyan Locate 1,1,"HELLO WORLD!"
Cyan Locate 1,2,"THIS IS A TEST"
Cyan Locate 1,3,"PROGRAM!"
Cyan Locate 1,4,"BUT IT TAKES"
Cyan Locate 1,5,"WAY TOO MUCH"
Cyan Locate 1,6,"BLEEPING SPACE"
Cyan Locate 1,7,"OPTIMIZE PLZ!"
Green Locate 1,1,"HELLO WORLD!"
Green Locate 1,2,"THIS IS A TEST"
Green Locate 1,3,"PROGRAM!"
Green Locate 1,4,"BUT IT TAKES"
Green Locate 1,5,"WAY TOO MUCH"
Green Locate 1,6,"BLEEPING SPACE"
Green Locate 1,7,"OPTIMIZE PLZ!"
Yellow Locate 1,1,"HELLO WORLD!"
Yellow Locate 1,2,"THIS IS A TEST"
Yellow Locate 1,3,"PROGRAM!"
Yellow Locate 1,4,"BUT IT TAKES"
Yellow Locate 1,5,"WAY TOO MUCH"
Yellow Locate 1,6,"BLEEPING SPACE"
Yellow Locate 1,7,"OPTIMIZE PLZ!"
Next
--- End code ---

Pretty repetitive, right? O.O

Well I wonder if I can simply have something like the following pseudo code?

--- Code: ---For 1->A To 10
For 1->B To 6
If B=1
Then
<code to set color to Red>
EndIf
If B=2
Then
<code to set color to Magenta>
EndIf
If B=3
Then
<code to set color to Blue>
EndIf
If B=4
Then
<code to set color to Cyan>
EndIf
If B=5
Then
<code to set color to Green>
EndIf
If B=6
Then
<code to set color to Yellow>
EndIf
<color set> Locate 1,1,"HELLO WORLD!"
<color set> Locate 1,2,"THIS IS A TEST"
<color set> Locate 1,3,"PROGRAM!"
<color set> Locate 1,4,"BUT IT TAKES"
<color set> Locate 1,5,"WAY TOO MUCH"
<color set> Locate 1,6,"BLEEPING SPACE"
<color set> Locate 1,7,"OPTIMIZE PLZ!"
Next
Next
--- End code ---

I forgot if we need the Then/EndIf when there's only one command to execute, since it has been so long since I last coded in Casio BASIC, but you get the idea. It might also be very helpful for tilemap generation.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version