![Profile Picture](/uploads/avatars/2323.jpg)
cosplaying_bunny
Netherlands
Asked
— Edited
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.
That's not how a file has ever been used before. Operating systems allow you to rewrite or append to a file - not modify contents at specific locations very easily. What is it you are wanting to achieve? I'll see what I can do to help
well, i am basically asking if there there can me a modular version of this
Is it me or does that not make sense?.. (could be me, running on no sleep again)
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.
hmm... i know how to archieve it in php, so i'll give you the example of what i mean in the php language: (please don't mind any bad coding, as its just an example i wrote in a few minutes)
You would probably have to use the SDK. I'm only really familiar with C# in C# I know you can read a file using the string reader function/method. Not sure on what the code would look like off hand and its kind of complicated but in short: 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.
But I'm pretty sure you'd need the SDK to do this.
That php example does not allow you to modify specific lines of a file. That php example does what the EZ-Script file commands do, and less. The php example...
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're looking at the wrong place of the script, @dj
(yeah, i made the code a bit too long maybe ^^; )
you only needed to look at this:
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.![;)](/images/emoticons/wink.svg)
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!![:D](/images/emoticons/happy.svg)
Glad you figured it out
Awesome!
The only truly dumb question is the one not asked![:)](/images/emoticons/smiles.svg)
Amen, Brother!