
cosplaying_bunny
hi all, i was just wondering a thing.
(example) you have the following code:
__________
read file
if file exists :
create a variable for each row with data
empty file
modify variables for each data row if needed
write file
else:
write file with default values
__________
i know this is possible wih ez-script,
but is it also possible with a given amount of rows, without modifying the code?
if so, how? :s
note: this might be usefull for when adding things to robot projects which save data to files, and in the end, it will save time coding if it is modular code.
this
That's the bit I struggle to understand...
As DJ pointed out, you can rewrite a file or you can append to the file.
If neither of those options are suitable for whatever it is you are attempting, let us know what you are trying to achieve there may be a different method available.
(please don't mind any bad coding, as its just an example i wrote in a few minutes)
Code:
Check for file, If file exists start reading it with the string reader. That will basically turn the whole file into a searchable string. Then check the string for what you want to replace. Get it's starting position in the string. Now that you know where the info is start writing at that position. I can't remember but, I know there's a way to start writing at a specific position.
I know this is a crummy explanation but maybe someone can fill it in better. I know it can be done in C# because I had to do something similar this summer for an IT Specialist course. Granted, it was only a 10 line text file and I'm fuzzy on the details but my logic is sound.
- Creates a File
- Read a File (means open a file for read)
- Read a specific line from a file
- Overwrite a file (delete the contents and start from scratch)
- Append to the file
Which of those would you like help with? Have you looked at the File Operations Example Project that is included with ARC?
you only needed to look at this:
Code:
by which i mean: execute the script below with different inputs, like a custom function
there is the scriptstart in the ControlCommand function, but it doesn't allow custom parameters (like $file, $row, $data_array and so) as in my custom php function.
i hope i'm clear enough now, as i don't really know how to explain it precisely..
edit: nevermind, i just saw this in the script documentation:
"Variables are global throughout the entire ARC environment" this solves my whole problem.
so it isn't needed at all, sorry for bothering you all with this relatively dumb question *blush*
and thank you all for your support!