Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3368: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3370: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3371: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3372: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
OrbWorks Community Forum • View topic - Using string character accessor

Using string character accessor

Postby ris12345 on Wed Sep 25, 2002 1:53 pm

Following code snippet generates run time error "string index out of range"

on_h2
{
string csum1;

csum1@[0] = serrecv();
csum1@[1] = serrecv();
csum1@[2] = serrecv();
csum1@[3] = serrecv();
csum1@[4] = '\00';
}

What I am trying to do here is read 4 characters in from the serial port and load them into a string and then null terminate it. I have tried initialising the string variable to a "12345678" to ensure it is at least 8 chars long but this doesn't seem to make a difference

Any help gratefully received

Rgds

Richard Stone
ris12345
 
Posts: 5
Joined: Wed Sep 25, 2002 1:41 pm

Postby shayneham on Wed Sep 25, 2002 9:46 pm

Can you use serrecva? This is all in my head cause I'm at work and all my pocketC code is at home, but if I remember correctly I do something like this....

string csum1;
char mychars[5];

serrecva(5,&mychars)
ctostr(mychars,csum1)

I may have variables and what not in the wrong place but it should be enough to get you started....

Shayne Hamel
Quote Software
shayneham@attbi.com
Shayne Hamel
Quote Software
shayneham
 
Posts: 52
Joined: Thu Sep 19, 2002 7:48 pm
Location: USA

Postby ris12345 on Thu Sep 26, 2002 9:20 am

Thanks for that - basically what you said works once I'd sorted out the syntax. However I am still confused why my original code generated the error!
ris12345
 
Posts: 5
Joined: Wed Sep 25, 2002 1:41 pm

Postby shayneham on Thu Sep 26, 2002 3:29 pm

I think what is going on is you are putting chars(the actual ascii value) into the string ie. a number from 1-255, so it may work if you instead did (string)serrecv();

Just a guess :)



Shayne Hamel
Quote Software
shayneham@attbi.com
Shayne Hamel
Quote Software
shayneham
 
Posts: 52
Joined: Thu Sep 19, 2002 7:48 pm
Location: USA

Postby ris12345 on Fri Sep 27, 2002 6:45 am

Quite possibly Shane. To be honest this is nowthe least of my problems with using the serial port - I'm composing another post now with additional problems! Thanks for your help
ris12345
 
Posts: 5
Joined: Wed Sep 25, 2002 1:41 pm

Postby shayneham on Fri Sep 27, 2002 6:17 pm

I also am currently working on serial port stuff, check out my post under the Development. Check out my post over at...

All Forums
2. Development Discussion
PocketC on Palm OS
Need suggestions for some of my Serial code

Maybe we can help each other :) since none of the regular users seem to be interested...

Shayne Hamel
Quote Software
shayneham@attbi.com
Shayne Hamel
Quote Software
shayneham
 
Posts: 52
Joined: Thu Sep 19, 2002 7:48 pm
Location: USA

Postby ris12345 on Mon Sep 30, 2002 9:08 am

Hi Shane,

What is frustrating me is that IMHO the PocketC documentation is lacking in detail. I don't expect to have to experiment to find out how functions work! I want it spelling out particularly when you have paid out for a product.

I have extensive experience of programming in C on microcontrollers where you have access to all the information you need about serial port functionality plus the ability through the lanquage to get at all the flags, registers etc. so I find it frustrating when you have to second guess how something works all the time

I guess serial port stuff is a bit of a minority interest on this forum which is why you don't get many replies.

Amyway enough whinging for now! I'll look at your stuff asap and try and assist

Rgds

Richard
ris12345
 
Posts: 5
Joined: Wed Sep 25, 2002 1:41 pm


Return to PocketC for Palm OS KB

Who is online

Users browsing this forum: No registered users and 2 guests

cron