|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
file i/o
Is it possible to open a file off the crio read or write to the file and close the file all inside of a while loop. I have been able to open the file outside of the loop, then read or write to the file inside of the loop and close the file after the while loop is done but this stops me from being able to choose from a bunch of files on the fly while the loop is running and open / close the files as needed.
When I move the open/close's inside of the loop the fileref number increases at the same speed as the iteration counter for that loop. I would post a sample of what I have been trying to do but can't seem to find it on my system. what i'm trying to accomplish is the ability to create a series of "macro" files that we can update in teleop mode by choosing which one we want to update. press a button or two on the joystick run the robot on the field for 15 seconds and then close the file. then in the "other" or disabled state i want to be able to select one of those file and when we enter into auto enabled open and run that file then close the file before we enter teleop mode. Thank you for any help. |
|
#2
|
||||
|
||||
|
Re: file i/o
You should be able to open files inside of a while loop, and it is normal that the fileref is increasing but...
it sounds like what you really want to do is select a file, which you can easily do from a case structure. im not sure i understand why you need a loop to do this? are you loading many file's contents into an array? |
|
#3
|
|||
|
|||
|
Re: file i/o
To avoid as many changes to your tele, I'd build the array in the tele -- either keep all drive values, or encode them as dT and dDrive. After tele is over, save it to a file by opening writing, and closing. You may also be able to use the Write to binary file and a Close, but I'm not sure if RT will raise the file dialog correctly. You should be able to do file I/O at a pretty good clip, so if you'd rather do it in the loop, go ahead, but don't open and close it for each element you write, or the overhead will cause changes to how your program behaves.
Greg McKaskle |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to use the data obtain in one C file to another C file? | tommy_chai | Programming | 8 | 11-01-2008 02:17 |
| "Error.MCP" file after HEX file trans | iwdu15 | Programming | 1 | 24-01-2007 20:05 |
| Help! making an inventor file into an autodesk file | kjhobin | Inventor | 5 | 19-03-2006 23:04 |
| Configuration File? | FFnut | Programming | 2 | 03-02-2006 17:38 |
| How do we convert a modified user routines file into a valid .HEX file | HuskieRobotics | Programming | 13 | 28-02-2004 12:12 |