Page 1 of 1
Posted: 14 Dec 2016, 00:44
by woodslanding
I'm using the write to file script, and it's insisting on writing to the root of G: Which it can't find, although I do have a g drive at the moment. but it's nowhere I want to write the file.....
Is there a way to point it to the home directory of HH, rather than using an absolute path?
Like to read and write to/from the HH directory somewhere, preferably within CONFIG.....
Posted: 14 Dec 2016, 01:21
by sephult
function GetApplicationPath:string; //give the absolute path of the current Usine's folder
It's in the wiki under declarations and references. There is a file section.
You could just concat the remaining CONFIG to the directory.
Posted: 14 Dec 2016, 08:44
by 23fx23
ive notice while back sometimes on windows had to run usine as admin also to get authorisations to write in some special folders, to usine subs shouldn't be a problem
Posted: 14 Dec 2016, 10:47
by sephult
your right 23fx23,
I've also run into that same problem.
I've had other oddities besides file writing putting Usine in my program files folders too.
Since then I've always ran direct desktop, at the root in a folder, or on an external drive.
Another side-note is that if you raise the administrative privileges you run into drag and drop problems between applications.
-s
Posted: 14 Dec 2016, 13:00
by oli_lab
there's a script example that tackle this :
//////////////////////////
// write text File
/////////////////////////
// declaration
const filenameDefault = 'c:speak.txt';
var fname,input : Tparameter;
var st : TStringList;
// save
procedure SaveToTextFile;
begin
st.create;
st.add(GetStringValue(input));
st.SaveToFile(GetStringValue(fname));
st.free;
end;
// Callback
procedure callBack(n:integer);
begin
SaveToTextFile;
end;
// initialisation : create parameters
procedure init;
var i : integer;
begin
Input := CreateParam('in',ptTextField);
SetIsOutPut(Input,false);
fname := CreateParam('file name',ptTextField);
SetStringValue(fname,filenameDefault);
SetIsOutPut(fname,false);
end;
Posted: 14 Dec 2016, 22:13
by woodslanding
Yes, that's what I started with. But it uses a hard coded file path, which is not helpful at all.
To be clear, before I disappear down this rabbit hole, is there no way to store string data per preset using the existing usine preset system?
I tried with the basic text widgets, but their text data is not stored with the preset.
Hmmm, maybe a list where the preset recalls the line associated with that preset.....??
might end up being more complicated than scripting, with a number of different text elements.....
Posted: 14 Dec 2016, 22:47
by woodslanding
Okay, so not a rabbit hole. In fact, I'll be storing a ton of data this way, I think, unless there is some big cpu penalty or something.....
Here's a more useful script than the default, which will try to write to a folder you probably don't have permission for, which makes it a poor example!
thanks all!!
Code: Select all
//////////////////////////
// write text File, eric moon remix
/////////////////////////
// declaration
const filenameDefault = 'writeFileText.txt';
var filenameIN,folderIN,textIN : Tparameter;
var st : TStringList;
var filename : string;
// initialisation : create parameters
procedure init;
var i : integer;
begin
textIN := CreateParam('text',ptTextField);
SetIsOutPut(textIN,false);
folderIN := CreateParam('folder',ptTextField);
SetIsOutPut(folderIN,false);
filenameIN := CreateParam('file name',ptTextField);
SetStringValue(filenameIN,getApplicationPath + filenameDefault);
SetIsOutPut(filenameIN,false);
end;
// save
procedure SaveToTextFile;
begin
st.create;
st.add(GetStringValue(textIN));
st.SaveToFile(filename);
st.free;
end;
// Callback
procedure callBack(n:integer);
begin
if ((n = filenameIN) or (n = folderIN)) then begin
filename := getApplicationPath() + 'config'
+ getStringValue(folderIN) + ''
+ GetStringValue(filenameIN) + '.txt';
end
else if (n = textIN) then begin
SaveToTextFile;
end;
end;
Posted: 15 Dec 2016, 11:01
by 23fx23
woodslanding wrote:Yes,
To be clear, before I disappear down this rabbit hole, is there no way to store string data per preset using the existing usine preset system?
I tried with the basic text widgets, but their text data is not stored with the preset.
textfield do save and recall their text with presets actually, man just have to check 'saved in preset' on module properties wich is off by default.
text pannel don't, but alternatively, as text is array, adding an array display or set out of any text element will be saved/recall in preset