Declare problem

General discussion on mikroBasic for dsPIC30/33 and PIC24.
Post Reply
Author
Message
nervous
Posts: 80
Joined: 13 Feb 2007 08:35
Location: Italy

Declare problem

#1 Post by nervous » 29 Dec 2008 21:56

I would like declare a string constant... this string is composed by many different substrings.. Actually I use this method:

Code: Select all

CONST Command as string [Cmd]="ABCDEFGHI"
But is more nice for me define in this way :

Code: Select all

CONST Command as string [Cmd]="AB" 
                                                    "CD"
                                                     "EF"
                                                     "GH"
                                                     "IL"

. 

Can I do something like that ?
Thanks in advance.
Cheers
Nervous

norbie
Posts: 160
Joined: 06 May 2006 22:40
Location: Vista, California

#2 Post by norbie » 18 Jan 2009 20:07

Hi nervous,
I don't think this is going to compile as it is.

Code: Select all

CONST Command as string [Cmd]="ABCDEFGHI" 
The [Cmd] is a variable and will probably not pass the syntax check.

Code: Select all

CONST Command as string [10]="ABCDEFGHI" 
Above will create a constant one dimensional array with 9 elements.

Code: Select all

Const cmd as String[9] = "AB" +
"CD" + 
"EF" +
"IL"
This will work too, but is in general the same as before, since it becomes a string with 8 elements again.

Code: Select all

' To select the desired Character pair
Dim Command as String
command = cmd(0) + cmd(1) 
'command now has "AB" in String
command = cmd(2) + cmd(3)
'command now has "CD" in String
'Don't know if this is what you are looking for

There is ways to define an array as I think you want, however this would have to be done in a Multi dimensional array.
Cheers,
Norbert

You don't need to know the answer, you just need to know where to find it!

nervous
Posts: 80
Joined: 13 Feb 2007 08:35
Location: Italy

#3 Post by nervous » 20 Jan 2009 09:39

Hi Norbie
norbie wrote:
I don't think this is going to compile as it is.

This will work too, but is in general the same as before, since it becomes a string with 8 elements again.

Code: Select all

' To select the desired Character pair
Dim Command as String
command = cmd(0) + cmd(1) 
'command now has "AB" in String
command = cmd(2) + cmd(3)
'command now has "CD" in String
'Don't know if this is what you are looking for

There is ways to define an array as I think you want, however this would have to be done in a Multi dimensional array.
Yes, of course... is what finally I've done.. but for the clearness of the code that don't help... Anyway, waiting for the multi dimension array, we have to solve in some way :)

Thanks again for your help.
Cheers
Nervous

Post Reply

Return to “mikroBasic for dsPIC30/33 and PIC24 General”