re-naming a CONST array name

Coding and general discussion relating to the compiler

Moderators: David Barker, Jerry Messina

Jon Chandler
Registered User
Registered User
Posts: 185
Joined: Mon Mar 10, 2008 8:20 am
Location: Seattle, WA USA
Contact:

Re: re-naming a CONST array name

Post by Jon Chandler » Fri Feb 21, 2014 5:53 pm

Jerry Messina wrote:
Here is the short version.
and here's the long version... http://www.electro-tech-online.com/thre ... ix.139965/

This is probably futile, but try using David's first example....
Thanks for referencing the original...um.... I'll be polite and just call it a thread rather than a pile of crap.

I explained to MrDEB....I mean toyman.... in fairly complete detail what he needs to do without writing the code for him, which I refuse to do for reasons outlined in the link.

Sadly, I think MrDEB.... I mean toyman.... holds constant arrays in some mystical high regard, and doesn't understand that the constant value can be stuffed into a variable.

Of course, as explained by David, the idea that a constant is invariable, unchanging, fixed, or, as the name says, constant, seems lost on him too.
Jon

Check out the TAP-28 PIC Application board at http://www.clever4hire.com/throwawaypic/

Jerry Messina
Swordfish Developer
Posts: 1473
Joined: Fri Jan 30, 2009 6:27 pm
Location: US

Re: re-naming a CONST array name

Post by Jerry Messina » Fri Feb 21, 2014 6:47 pm

...the idea that a constant is invariable, unchanging, fixed, or, as the name says, constant
Perhaps, to quote a famous American statesman, "It depends on what the meaning of the words 'is' is."

Jon Chandler
Registered User
Registered User
Posts: 185
Joined: Mon Mar 10, 2008 8:20 am
Location: Seattle, WA USA
Contact:

Re: re-naming a CONST array name

Post by Jon Chandler » Fri Feb 21, 2014 6:52 pm

LOL. True Jerry.
Jon

Check out the TAP-28 PIC Application board at http://www.clever4hire.com/throwawaypic/

bitfogav
Registered User
Registered User
Posts: 169
Joined: Sat Oct 09, 2010 1:39 pm
Location: United Kingdom

Re: re-naming a CONST array name

Post by bitfogav » Fri Feb 21, 2014 6:57 pm

It's quite funny, I thought the posted code on this topic had MrDeb written all over it. :lol:

toyman
Posts: 39
Joined: Tue Feb 18, 2014 8:25 pm

Re: re-naming a CONST array name

Post by toyman » Sat Feb 22, 2014 2:20 pm

Still curious why a sub route jumbles up the data.

Jerry Messina
Swordfish Developer
Posts: 1473
Joined: Fri Jan 30, 2009 6:27 pm
Location: US

Re: re-naming a CONST array name

Post by Jerry Messina » Sat Feb 22, 2014 2:58 pm

If you really want to know, post the code with the subroutine and we can tell you why

toyman
Posts: 39
Joined: Tue Feb 18, 2014 8:25 pm

Re: re-naming a CONST array name

Post by toyman » Sat Feb 22, 2014 5:41 pm

Here is what I was trying when doing the sub route . David Barkley posted this suggestion

Code: Select all

Include "usart.bas"
Include "convert.bas"   
Const A_Data(9)As Byte = (%11111111,
                          %00011000,                           
                          %00100100,
                          %01000010,
                          %00000001,
                          %00000000,
                          %00000000,
                          %00000000,
                          %00000000) 
                         
sub Assign(byrefConst array() as byte)
   dim index as byte
   dim Anodes_Data(9) as byte 
   Anodes_Data = array
   For index = 0 To Bound(Anodes_Data)
      USART.Write("Value = %", BinToStr(Anodes_Data(index), 8),13,10)
   Next
end sub
                         
' program start...
USART.SetBaudrate(br19200)       
Assign(A_Data) 
When I ran this sub routine using the Uart it outputs just fine but using the sub routines output in my code to display on the matrix it is all jumbled. Bitfogav mention it might not pass in right order, all jumbled up. Which it did. Just curious as to why and be aware of it for future use.

bitfogav
Registered User
Registered User
Posts: 169
Joined: Sat Oct 09, 2010 1:39 pm
Location: United Kingdom

Re: re-naming a CONST array name

Post by bitfogav » Sat Feb 22, 2014 6:02 pm

It's probably all jumbled up because your not taking care of the led matrix correctly. you need to look at correctly controlling the matrix using Multiplexing...

User avatar
David Barker
Swordfish Developer
Posts: 1214
Joined: Tue Oct 03, 2006 7:01 pm
Location: Saltburn by the Sea, UK
Contact:

Re: re-naming a CONST array name

Post by David Barker » Sat Feb 22, 2014 6:14 pm

Toyman - re-posting working code that I have already posted is of no use whatsoever. A specific request was made for you to post your code and we would try and help. I do not want this or any other thread on the Swordfish forum to degenerate like threads I have seen on other forums. I would respectfully ask all other users to only make a contribution if it will help this thread move closer to a solution. If invalid, inappropriate or just useless snippets of code are posted by the starter of this thread, then please refrain from posting any sort of reply at all, allowing us all to move on to more productive tasks...

Jon Chandler
Registered User
Registered User
Posts: 185
Joined: Mon Mar 10, 2008 8:20 am
Location: Seattle, WA USA
Contact:

Re: re-naming a CONST array name

Post by Jon Chandler » Sun Feb 23, 2014 3:26 am

Toyman aka MrDEB, doesn't seem to understand tow important points:

1. Constants are fixed. Neither the value nor the name can be changed.

2. Variables can be set equal to the value of a constant.

For example, consider:

Const A = 5

Const B = 7

Dim C as Integer

The statement

C = A + B makes C = 12

C = A makes C = 5. This sets the value of your variable equal to the value of the constant.

It works exactly the same way for arrays; I don't have the exact syntax on the op of my head but MrDEB should be able to look that up.

So, as I explained before, if you create a constant for each letter, you can add each to your variable array and increment through this data a byte at a time.

If your variable is called Message, you would do something like this. I apologize for not having the exact syntax:

Message (0 5) = A

Message (6 10) = Blank

Message (11 16) = S

Message (17 23) = T

Message (24 31) = U

Message (32 37) = P

...... and so on.

The letters to the right of the equal sign are the constant array for each character. Message is the data array and the numbers in parenthesis are the position in the data array where the constant value will be stored; they must correspond to the width of each character.

One the data is stored in the data array, display the first 8 bytes. Wait. Move one byte (which is one column of the character) and display 8 bytes. Repeat.

If a "right-side-up" set of date produces an upside down character, your connects to the rows should be flipped. This makes more sense that creating the character data upside down.

I really, truly recommend some form of A Big Dummies Guide to Basic to understand constants, variables and arrays. This is an essential and important "day one concept" of every programming language. The fact that you're asking how to change a constant is undeniable proof that you don't understand an essential item.
Jon

Check out the TAP-28 PIC Application board at http://www.clever4hire.com/throwawaypic/

toyman
Posts: 39
Joined: Tue Feb 18, 2014 8:25 pm

Re: re-naming a CONST array name

Post by toyman » Sun Feb 23, 2014 1:54 pm

THANKS Jon for the explanation. Is there supposed to be a comma between the two numbers?
Message (0 5) = A

I have never seen CONST arrays addressed this way. Am wondering is it the same as
portc = anodes(x) . bits(y)

On using the sub route, I have moved on to my posted solution that David and Bitfograv posted. I changed alot of code using the sub route.
I feel that the method I have to display scrolling letters does not utilize correct if any multiplexing. Battery drain is to be considered as well.
Experimenting using STEP 8 to address the cathodes.
Using the suart (I should use this more often) I think I am getting the multiplexing sorted out CORRECTLY
Going to try this Message (0 5) = A to address the array.

Post Reply