CONST STRING problem

This is the technical support forum for users.

CONST STRING problem

Postby Blacks85 » Tue Apr 20, 2010 12:47 am

Hello,

i'm new to this kind of device and i have a problem i can't solve with constant string. I see the example on the user manual

CONST STRING * 6 STRTBL = (“COMFILE”, “BASIC”, “ERROR”, “PICTURE”)

and i tried to use the string this way. When i print the result is

STRTBL(0) = "COMFILE BASIC ERROR PICTURE"
STRTBL(1) = "BASIC ERROR PICTURE"
STRTBL(2) = "ERROR PICTURE"
STRTBL(3) = "PICTURE"

i want to use only the item for its index, example: STRTBL(0) = "COMFILE".

how i can do that ?
i search all the forum and manuals but i can't find any other examples,

thank you in advance
See you
Blacks85
Terminator
 
Posts: 8
Joined: Tue Apr 20, 2010 12:40 am

Re: CONST STRING problem

Postby Garrett » Tue Apr 20, 2010 8:36 am

Not really sure how that could happen, but I see you're putting a couple of 7-character words into 6-character strings. You might be overwriting the null character at the end of the string, then all bets are off.
User avatar
Garrett
Site Admin
 
Posts: 475
Joined: Tue Nov 07, 2006 1:04 pm
Location: Cubloc HQ

Re: CONST STRING problem

Postby Blacks85 » Tue Apr 20, 2010 11:19 pm

I don't think so. That is the exmple from the user manual pasted (just 2 rows below there's write "MAKE SURE THAT THE LENGTH IS GRAETER THAN ANY STRING" :D :D )

i tried several time to increase also the maximun to 15, 20, fill with space, everything...but with no success...

any other ideas?
Blacks85
Terminator
 
Posts: 8
Joined: Tue Apr 20, 2010 12:40 am

Re: CONST STRING problem

Postby Garrett » Wed Apr 21, 2010 9:30 am

Try putting a RAMCLEAR right after your device definition, any unexpected characters in memory could throw off the string array behavior.

I got some strange results before adding RAMCLEAR too.

Also, don't just copy text directly from the manual PDF, type it in. The character set is different and things like quote marks can be tricky.
User avatar
Garrett
Site Admin
 
Posts: 475
Joined: Tue Nov 07, 2006 1:04 pm
Location: Cubloc HQ

Re: CONST STRING problem

Postby Blacks85 » Wed Apr 21, 2010 10:57 pm

Thank you for your reply. Unfortunatlyh i can't solve the problem.

I already noticed that doing copy & paste from PDF or external document can't be tricky. So i tried to write all the text again twice but the result wasn't different

This is my last code, i don't know if this can help you...

Thank you

*********************************
'Device information
Const Device = CT1720
Const Cadr = &hffe
Ramclear

Const String * 10 Lingua = ("Italiano","English","Francais","Deutsch")

'Create Menu
Menu4 Lingua(0),Lingua(1),Lingua(2),Lingua(3)

'Create 4 keys menu
Sub Menu4(Str1 As String, Str2 As String, Str3 As String, Str4 As String)
Font 0,0
Style 0,0,0
Menuset 1,2,48,48,132,96
Menutitle 1,14,16,Str1
Menuset 2,2,180,48,264,96
Menutitle 2,17,16,Str2
Menuset 3,2,48,144,132,192
Menutitle 3,14,16,Str3
Menuset 4,2,180,144,264,192
Menutitle 4,17,16,Str4
Font 4,0
End Sub

************************************************
Blacks85
Terminator
 
Posts: 8
Joined: Tue Apr 20, 2010 12:40 am

CONST STRING problem

Postby LaPuce » Mon Apr 09, 2012 11:15 am

Hello all

I submit a sample table of constant.

Const Device = CB320

Ramclear

'Set Display 2,0,1,100

'Cls
'Delay 200
'Csroff
'Set Pad 0,1,10
'Set Pad 5,1,10
'Set I2c 11,12
'On Pad Gosub PAD_RTN

Const String*9 TabCycle = ("Arrosage","Platine","Temporisation","Lumiere","Cycle 4","Cycle 5","Cycle 6")
Const String*8 TABJS = ("Lundi","Mardi","Mercredi","Jeudi","Vendredi","Samedi","Dimanche")
Const String*6 TabProg = ("Heure","Minute","Marche","Arret","Prog 4","Prog 5","Prog 6")

Dim B1 As Byte

For B1=0 To 6
Debug TabCycle(B1)," ",TabProg(B1)," ",tabjs(B1),Cr
Delay 2000
'Debug "",Cr
Next

End



Why when the program reads it constantly displays no matter what

This one should show : Arrosage, Lundi, Heure

But it appears Platine, Minute, Minute

Why No Arrosage, 2 X Minute and no Lundi

Sorry for the google translation but does help

Thank you all for your Help :mrgreen:
LaPuce
MasterGoo
 
Posts: 2
Joined: Sat Jan 28, 2012 9:12 am

Re: CONST STRING problem

Postby Mike » Mon Apr 09, 2012 6:57 pm

The reason you don't see "Arrosage Heure Lundi" first is that your program is executing before the Com port on the PC has time to open and read data. So it misses the first few strings. Therefore, at the beginning of your program add a Delay 500 or so to ensure the PC's com port has time to open and read data.

That being said there appears to be a bug in the Cubloc. I've notified the developers and hope to see a fix, but right now consecutive strings seem to be a problem for the Debug statement. Instead, change you code as shown below to get better results.

Code: Select all
For B1=0 To 6
    Debug TabCycle(B1),Cr
    Debug TabProg(B1), Cr
    Debug tabjs(B1),Cr
    Debug "*****************", Cr
    Delay 2000
Next
Mike
Mike
SuperDuperDuper
 
Posts: 373
Joined: Thu Mar 17, 2011 3:54 pm
Location: Seoul, South Korea

Re: CONST STRING problem

Postby LaPuce » Tue Apr 10, 2012 9:15 am

Good evening Mike

It works super genial :P

In life it is easier to ask than to recreate

I can continue my Hobby

Thank you thank you Regards :mrgreen:
LaPuce
MasterGoo
 
Posts: 2
Joined: Sat Jan 28, 2012 9:12 am


Return to Technical Support

Who is online

Users browsing this forum: Google [Bot] and 1 guest

cron