Loading...
Pages: 1 [2]   Go Down
Author Topic: Algorithm to rotate data  (Read 520 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Sr. Member
****
Karma: 15
Posts: 463
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Basic uses 1-based arrays.
I know that
Code:
90     get #1,c+b // read byte "offset + index"
But that's not an array - it's file, isn't it?

The "get" command gets one byte from the file pointer "1" at index "c+b" and stores it in the string variable "d$". Then, using "asc(d$)" gives me the value of the byte. For example, if the byte at file location 24 was the letter "A", I would get this:

* get #1, 24
* (now d$ == "A")
* asc(d$) == 65 (a.k.a. 0x41)

Let's say the first 8 bytes of the font file are 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07.

The result would be:

fin(0) == 0
fin(1) == 1
fin(2) == 2
......
fin(6) == 6
fin(7) == 7

See? fin() in BASIC is the same thing as fin[] in C. At the top of the program where I do "dim fin(8)" is the same thing as "char fin[8];" in C.

Make sense?

Logged

Temple, Texas
Offline Offline
Sr. Member
****
Karma: 14
Posts: 354
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Basic uses 1-based arrays.
I know that
Code:
90     get #1,c+b // read byte "offset + index"
But that's not an array - it's file, isn't it?
Ok, Basic uses 1-based random-access-files smiley
Logged

Global Moderator
UK
Online Online
Brattain Member
*****
Karma: 137
Posts: 19003
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Makes a bit of sense, but all this swapping between zero and unity origin indexing is crazy.
Why isn't it consistent?
Logged

Pete, it's a fool looks for logic in the chambers of the human heart.

Temple, Texas
Offline Offline
Sr. Member
****
Karma: 14
Posts: 354
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Makes a bit of sense, but all this swapping between zero and unity origin indexing is crazy.
Why isn't it consistent?

That *is* a rhetorical question, right?

http://c2.com/cgi/wiki?ZeroAndOneBasedIndexes
Logged

Global Moderator
UK
Online Online
Brattain Member
*****
Karma: 137
Posts: 19003
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I think I'm beginning to understand Dijkstra's comments about BASIC and brain-damage   smiley-twist
Logged

Pete, it's a fool looks for logic in the chambers of the human heart.

Offline Offline
Sr. Member
****
Karma: 15
Posts: 463
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I think I'm beginning to understand Dijkstra's comments about BASIC and brain-damage   smiley-twist

Quote
"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC; as potential programmers they are mentally mutilated beyond hope of regeneration." -- EwDijkstra
Logged

Offline Offline
Edison Member
*
Karma: 114
Posts: 2205
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC; as potential programmers they are mentally mutilated beyond hope of regeneration." -- EwDijkstra

It is surprising that such an elitist view comes within the Arduino community, given that both Arduino / BASIC are largely motivated by dumbing down things for newcomers.

Logged

Global Moderator
UK
Online Online
Brattain Member
*****
Karma: 137
Posts: 19003
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I didn't realise Dijkstra was a member of this community, and given that he died over ten years ago, he must've been a pre-founding father.
Logged

Pete, it's a fool looks for logic in the chambers of the human heart.

Milton Keynes UK
Offline Offline
Tesla Member
***
Karma: 88
Posts: 6287
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It is surprising that such an elitist view comes within the Arduino community, given that both Arduino / BASIC are largely motivated by dumbing down things for newcomers.

If you're familiar with Basic then I'm surprised that you're surprised that it is treated so scornfully.
Logged

Anaheim CA.
Offline Offline
Edison Member
*
Karma: 31
Posts: 2304
Experienced old Whitebeard with a Full head of Hair...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The Hardest thing I have to do is "Unlearn" what I learned to do in basic.. This, compounded by several years with Basic Stamps and the Picaxe and their severe limitations to finally drive me here to learn what a real, embeddable and useful controller can be and how to work with it as well.
Because of both my engineering background and my basic familiarity with basic as I wrote apps to run on a '386 from the command line with Micro$oft's PDS 7.1 and my later experience designing process controllers for the Irrigation industry (I specified and tested but did not write the Pic firmware)..
learning C and C++ has been a battle that I am slow to win but winning it I am.

Bob
{Edit RKJ}
« Last Edit: January 13, 2013, 06:51:06 pm by Docedison » Logged

“The solution of every problem is another problem.” -Johann Wolfgang von Goethe

Pages: 1 [2]   Go Up
Print
 
Jump to: