Oh that’s easy, that line is about all it takes to implement a fileTrimTop, full function would look like:
def fileTrimTop(fname, trimOffset){
fileData = readFile(fname)
writeFile(fname, fileData.substring(trimOffset)
}
Oh that’s easy, that line is about all it takes to implement a fileTrimTop, full function would look like:
def fileTrimTop(fname, trimOffset){
fileData = readFile(fname)
writeFile(fname, fileData.substring(trimOffset)
}
I've been trying [unsuccessfully] to get Google Charts to read and plot a data set using html and csv files on my HE. I had basically abandoned the idea because I thought it would be impractical to manually "manage" the source data file when it got too long. Your driver seems to be able to solve that problem. The next hurdle is pulling that data into a google charts object. The documentation says it's possible, but I'm not a programmer so the developer docs might as well be written in ancient Sanskrit...
v0.1.0 changes:
v0.1.0 should allow you to do this via:
* execute the readFile command
New webCoRE functionality (as of 30Mar22) natively lets you:
v0.2.0 Adds a callback option for apps that want to use this as an addon device instead of a child device, i.e.
input "fileDev", "capability.actutator", title: "Select File Device", required: true, submitOnChange: true
Using this option, implementation on the app side will look similar to:
def retVal
fileDev.readFile("someFile.txt") {cb ->
retVal = cb
}
Shoutout to @gopher.ny for pointing out this option to me.
Awesome!! Thanks for the heads up.
v0.2.2 corrects the retrieval of text files that have embedded extended characters, i.e. characters that use umlauts etc.
v0.2.3 Adds the ability to read and upload image files
Can your driver create folders so the root is not too messy?
Doesn’t appear to be supported..
In RM, how do i access the file contents?
Driver page works great.
How do I get it into a string to manipulate with RM?
It should place the return of a read into the attribute fileContent, which should be available under the Custom Attributes.
Where am I going wrong?
I change the contents of the file, RM shows null.
Device works in device tab.
I thought I had it!
Did you do a readFile to load the attribute? (It clears the attribute after 30 seconds BTW.)
Not sure why RM doesn’t like it but
Found the issue, on line 47 change
attribute "fileContents", "string"
to
attribute "fileContent", "string"
Bingo!
Thanks for this driver, it has great potential.
Off to experiment with it.