Pages: 1 [2]   Go Down
Author Topic: Algorithm to rotate data  (Read 1676 times)
0 Members and 1 Guest are viewing this topic.
Worst state in America
Offline Offline
God Member
*****
Karma: 32
Posts: 792
View Profile
WWW
 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

Gentlemen may prefer Blondes, but Real Men prefer Redheads!

Temple, Texas
Offline Offline
Sr. Member
****
Karma: 14
Posts: 360
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
Offline Offline
Brattain Member
*****
Karma: 290
Posts: 25764
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." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Temple, Texas
Offline Offline
Sr. Member
****
Karma: 14
Posts: 360
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
Offline Offline
Brattain Member
*****
Karma: 290
Posts: 25764
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." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Worst state in America
Offline Offline
God Member
*****
Karma: 32
Posts: 792
View Profile
WWW
 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

Gentlemen may prefer Blondes, but Real Men prefer Redheads!

Offline Offline
Edison Member
*
Karma: 116
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
Offline Offline
Brattain Member
*****
Karma: 290
Posts: 25764
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." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

UK
Offline Offline
Shannon Member
****
Karma: 222
Posts: 12549
-
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

I only provide help via the forum - please do not contact me for private consultancy.

Anaheim CA.
Offline Offline
Faraday Member
**
Karma: 46
Posts: 2865
...
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

--> WA7EMS <--
“The solution of every problem is another problem.” -Johann Wolfgang von Goethe
I do answer technical questions PM'd to me with whatever is in my clipboard

Pages: 1 [2]   Go Up
Jump to: