|
Page 1 of 1
|
[ 6 posts ] |
|
| Author |
Message |
|
bk8190
Rookie
Joined: Fri Feb 29, 2008 8:12 pm Posts: 3
|
 String problems
Hi, I am having problems using strings. I need to be able to access the individual characters of a string by index. Are there any library functions that I missed that could do this, or are there other methods?
|
| Fri Feb 29, 2008 8:15 pm |
|
 |
|
bk8190
Rookie
Joined: Fri Feb 29, 2008 8:12 pm Posts: 3
|
I need to be able to access the individual characters of the string, or to convert the string into a byte array or something similar.
|
| Sun Mar 02, 2008 4:06 pm |
|
 |
|
Dick Swan
Creator
Joined: Fri Feb 09, 2007 9:21 am Posts: 613
|
Eventually ROBOTC will allow string access the same way that you access a array of char. The current workaround is to "memcpy" the string to a 'char[20]" array, manipulate the array and then 'strcpy' the result back. Here's an example.
This does require a new version of the 'strcpy' intrinsic if you are using version earlier than 1.17. The new version is
|
| Tue Mar 04, 2008 10:30 am |
|
 |
|
bk8190
Rookie
Joined: Fri Feb 29, 2008 8:12 pm Posts: 3
|
I inserted the code and the modified strcpy function, but when I compiled, RobotC crashed. Now, whenever I start RobotC, after I click "Evaluate RobotC," the main screen briefly appears and then the program crashes.
I am tried using the beta version, but the beta does not support strings. Also, in the beta, when I try to create too many int arrays like
 |  |  |  | Code: int temp7[7][5]= {{1,0,0,0,1}, {1,0,0,0,1}, {1,0,0,0,1}, {1,1,1,1,1}, {1,0,0,0,1}, {1,0,0,0,1}, {1,0,0,0,1}};
|  |  |  |  |
I get the error
My arrays complied fine in v 1.10.
|
| Tue Mar 04, 2008 6:04 pm |
|
 |
|
tfriez
Site Admin
Joined: Wed Jan 24, 2007 10:42 am Posts: 537
|
Dick will have to field the issue about the memory allocation and running out of space.
As for the Beta and not launching (crashing as soon as it opens), you can alleviate this is issue by deleting your ROBOTC registry. ROBOTC remembers the last file you had opened and compiles it when ROBOTC opens.
To delete the registry manually, follow these steps:
1. Go to "Start" then "Run" then type "regedit"
2. Navigate to: HKEY_CURRENT_USER\Software\Robotics Academy
3. Delete this entire Key Folder...close regedit.
4. Open ROBOTC for Mindstorms again, this will generate new registry keys and reset ROBOTC back to Day 1.
_________________Timothy Friez ROBOTC Developer - SW Engineer tfriez@robotc.net
|
| Tue Mar 04, 2008 7:35 pm |
|
 |
|
Dick Swan
Creator
Joined: Fri Feb 09, 2007 9:21 am Posts: 613
|
When you provide an isolated code snippet that compiles fine like
 |  |  |  | Code: int temp7[7][5]= {{1,0,0,0,1}, {1,0,0,0,1}, {1,0,0,0,1}, {1,1,1,1,1}, {1,0,0,0,1}, {1,0,0,0,1}, {1,0,0,0,1}}; |  |  |  |  |
then I cannot diagnose your problem! You need to send me the complete file ( dickswan@sbcglobal.net).
I suspect you're encountering an issue where temporary working variables cannot be allocated if you already have more than 256 words of user declared variables within a code block. You could verify this by moving some variables out of procedure declaration to global scope and seeing if this clears up the problem. Alternatively some of the variable might be appropriate to declare with the "static" keyword.
This issue will be fixed in an upcoming release. I just noticed it yesterday.
|
| Tue Mar 04, 2008 8:05 pm |
|
|
|
Page 1 of 1
|
[ 6 posts ] |
|
Who is online |
Users browsing this forum: No registered users and 6 guests |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum
|
|