View unanswered posts | View active topics It is currently Thu Dec 13, 2018 9:05 pm






Reply to topic  [ 10 posts ] 
EV3 file access code examples please 
Author Message
Rookie

Joined: Mon Jun 29, 2015 6:58 am
Posts: 5
Post EV3 file access code examples please
I am currently trying to use the file access functions available on the EV3. However I am struggling to get the code right. I would really appreciate some sample code showing how to use the functions on this page:

http://help.robotc.net/WebHelpMindstorm ... %7C_____15

I am trying to create a file that is used to represent objects in a room where 1 represents an object and a 0 represents empty space. This means the file only has to read and right binary values.

An alternative solution would have been to use an array to store this information but RobotC seems to have a cap on the total memory that can be allocated to an array. It won't even let me initialise a 100x100 binary array! That's not so much to ask is it?

If anyone can provide some examples of file access code then that would be great but any alternative solution to my problem is just as valid.

Thanks in advance, Tom.


Mon Jun 29, 2015 7:09 am
Profile
Site Admin
Site Admin
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3654
Location: Rotterdam, The Netherlands
Post Re: EV3 file access code examples please
Hi there,

You can easily create a 100x100 matrix, just make sure it's a global variable.
Attachment:
Screenshot at 13-29-54.png
Screenshot at 13-29-54.png [ 64.66 KiB | Viewed 7532 times ]


As for file access, you can find those in the Samples folder, under Sample Programs\EV3\Miscellaneous\ called filetesting.c

= Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Mon Jun 29, 2015 7:32 am
Profile WWW
Rookie

Joined: Mon Jun 29, 2015 6:58 am
Posts: 5
Post Re: EV3 file access code examples please
Thanks for the fast reply.

The global variable helps, thanks. However this still only allows for an array of size 122x122 max (123x123 is still too large).

Also, I don't seem to be able to find the sample program you mentioned?? I have no 'Miscellaneous' directory under 'EV3'. The miscellaneous folder is located under 'advanced examples' and even then does not contain 'filetesting.c'. A quick directory search of EV3 also led to no results for this file.

Tom


Mon Jun 29, 2015 8:34 am
Profile
Site Admin
Site Admin
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3654
Location: Rotterdam, The Netherlands
Post Re: EV3 file access code examples please
Unfortunately, the amount of memory on the EV3 is limited to that amount. We do have plans to increase it. As for the file, I have attached it.

Regards,
Xander


Attachments:
filetesting.c [6.04 KiB]
Downloaded 268 times

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]
Mon Jun 29, 2015 8:44 am
Profile WWW
Rookie

Joined: Mon Jun 29, 2015 6:58 am
Posts: 5
Post Re: EV3 file access code examples please
Thanks for this information.

The filetesting.c code has various compiler errors.
For example:
**Error**:Not enough parameters specified. Call to 'FileOpenWrite'. Parameter: 'short & fileHandle' is 'None specified'.

This is what is confusing me when it comes to file access. What is the correct method for using 'FileOpenWrite' because
fileHandle = FileOpenWrite(filename)
produces this error.

Also, all read and write procedures are not defined.
For example the fileWriteData() procedure produces the following error.

**Error**:Undefined procedure 'fileWriteData'.

Could this simply be an issue with my version of RobotC?
Below is a screenshot of the filetesting.c program.


Attachments:
RobotC - filetesting.png
RobotC - filetesting.png [ 47.65 KiB | Viewed 7518 times ]
Mon Jun 29, 2015 9:28 am
Profile
Site Admin
Site Admin
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3654
Location: Rotterdam, The Netherlands
Post Re: EV3 file access code examples please
Are you sure you have the platform set to EV3 and are using the latest version of ROBOTC (4.32)? This compiles very well on my system.

= Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Mon Jun 29, 2015 9:36 am
Profile WWW
Rookie

Joined: Mon Jun 29, 2015 6:58 am
Posts: 5
Post Re: EV3 file access code examples please
It turns out I am indeed running an old version of the software and this is likely to be the problem. I thought I'd updated as I tried to but it seems I was blocked by my school internet filtering. I will update when I get home and let you know the outcome. I suspect this was the problem all along and I am sorry for wasting your time with such a simple solution (hopefully)!

Tom


Mon Jun 29, 2015 10:02 am
Profile
Site Admin
Site Admin
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3654
Location: Rotterdam, The Netherlands
Post Re: EV3 file access code examples please
It won't have been a waste if it fixes the problem :)

= Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Mon Jun 29, 2015 10:31 am
Profile WWW
Rookie

Joined: Mon Jun 29, 2015 6:58 am
Posts: 5
Post Re: EV3 file access code examples please
Perfect :)
All sorted after a quick update! Thank you for your help and information!
I look forward to an increase in memory allowance in the future.
Just a thought - surely an array of type Boolean should be able to hold more items than an array of type character if the memory locations are used efficiently?


Mon Jun 29, 2015 11:08 am
Profile
Site Admin
Site Admin
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3654
Location: Rotterdam, The Netherlands
Post Re: EV3 file access code examples please
A bool takes up as much as a char, I'm afraid.

= Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Mon Jun 29, 2015 3:03 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 10 posts ] 

Who is online

Users browsing this forum: No registered users and 2 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

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.