Sifteo: how to create a file.txt with LUA script? - scripting

i'm trying to create a Sifteo game able to detect accelerometer data and write them on a file.txt;
I know that several methods exist that allow to visualize data on the shell (but it need to connect the base on the pc) or storing them in a StoredObject, but i'd like to create a text file.
In the documentation of sifteo sdk I found something about script lua.
I didn't understand it, Can you help me???
Thanks

If you're simply asking for how to make a .txt file in a lua script it should be something like
file = io.open("FileName.txt","w")
file:write("Information")
file:close()
If you're new to lua you can also insert information from a variable or a table by replacing it with the string "Information".
Hope this helped.

Related

is there any way to splitting Variables in VSCode?

I wonder there is any way to splitting some variables in VSCode?
my example will explain my question better:
I have an exe file in such path C:\path\to\workspace\main\project\project.exe
my cpp source path that will create exe file is this C:\path\to\workspace\main\project\test.cpp
I want to create a task in tasks.json but my oder of variables does not give me the right path
as you understand:
${workspaceFolder} is C:\path\to\workspace
${fileDirname} returns C:\path\to\workspace\main\project
and ${relativeFileDirname}.exe returns main\project.exe
and combination of "${fileDirname}\\${relativeFileDirname}.exe" as a command will return C:\path\to\workspace\main\project\main\project.exe that is wrong.
so I wanted to know there is any other variable that just return the parent of current file or not?
if not can we split variables with \ ?
I hope it makes some sense
thanks
Add new fileDirnameBasename variable
see https://github.com/microsoft/vscode/commit/551db7ec94f02a4bdc8999092cf8bef642b3992d
${fileDirnameBasename} is being added to vscode v1.52 which I believe is what you are looking for.
You can use the extension Command Variable
Use the commands:
extension.commandvariable.file.fileDirBasename
extension.commandvariable.file.fileDirBasename1Up
extension.commandvariable.file.fileDirBasename2Up
btw, as an workaround, this worked for me
"${fileDirname}\\*.exe"
but need a variable for getting parent folder of current open file
any idea?

How to fix 'File name too long' errors when using Snakemake

When using Snakemake, I store the values for my variables as part of the filenames (ex. "processed/count_{project}.tsv"). Recently, I've started using R formulas with many covariates as a variable. Now I get an error because the the filename is too long for the operating system. Has anyone else run into this issue and have any suggestions? Is there a canonical Snakemake approach for this problem?
Personally, I don't think it is a good idea to store information into the filename.
Rather, I would create a temp file in tabular or yaml format linking the file in question to covariates or other data. Then read this file in R or else to extract the relevant information.
One idea is to use paths instead since paths allowed to be longer.

Change output file format to *.csv using dymosim.exe instead of *.mat

I am trying to understand if it's possible to change the model output format to .csv instead of the default .mat file when simulating a model using dymosim.exe.
I can do this in dymola itself by using the function "convertMATtoCSV" in the base Data files library. Something like below,
DataFiles.convertMATtoCSV("output.mat", {"t"}, "output.csv");
Is there a way to do this conversion using dymosim.exe?
Kindly advise.
Thanks.
Note: cmd "dymosim.exe -h" has some options for .csv but I am not sure how to use this.
No, it is currently not possible to have dymosim.exe generated by Dymola write the result as csv-file. The CSV-options used by dymosim.exe are only for running multiple simulations.
You can:
Generate a txt result instead, if that is easier to handle for you. (By setting Simulation Setup>Output>Textual data format, this is stored as last element of settings in dsin.txt).
Perform the conversion using dymola\bin\alist.exe
Have the model write a cvs-file as well
Set up to perform this as a post-processing command in Dymola 2017 FD01.

How to get values of variables after simulation in open modelica?

I've simulated a model in open modelica, now is it possible to get values of all variables that they had during the simulation? If yes, how can I get them?
When you simulate you can give outputFormat="csv" and then you get a result file Model_res.csv containing all variable values for all the time steps. You can then open this file in Excel if you want.
https://build.openmodelica.org/Documentation/OpenModelica.Scripting.simulate.html
In OpenModelica Connection Editor (OMEdit) you go to Simulation->Simulation Setup, tab Output and select csv.
I'm not sure I understand your question. Normally, when you run OpenModelica, you'll get a results file. This file contains all the simulation data for all variables.
How you read that file depends on what platform you are running on and what tools you are using. Is that the issue?

How to Store BLOB data in Sqlite Using Tcl

I have a Tcl TK application that has a Sqlite back-end. I pretty much understand the syntax for inserting, manipulating, and reading string data; however, I do not understand how to store pictures or files into Sqlite with Tcl.
I do know I have to create a column that holds BLOB data in Sqlite. I just don't know what to do on the Tcl side of things. If anyone knows how to do this or has a good reference to suggest for me, I would really appreciate it.
Thank you,
Damion
In my code, I basically open the file as a binary, load its content into a Tcl variable, and stuff that into the SQLite db. So, something like this...
# load the file's contents
set fileID [open $file RDONLY]
fconfigure $fileID -translation binary
set content [read $fileID}
close $fileID
# store the data in a blob field of the db
$db eval {INSERT OR REPLACE INTO files (content) VALUES ($content)}
Obviously, you'll want to season to taste, and you're table will probably contain additional columns...
The incrblob command looks like what you want: http://sqlite.org/tclsqlite.html#incrblob
The "incrblob" method
This method opens a TCL channel that
can be used to read or write into a
preexisting BLOB in the database. The
syntax is like this:
dbcmd incrblob ?-readonly?? ?DB? TABLE COLUMN ROWID
The command returns a new TCL channel
for reading or writing to the BLOB.
The channel is opened using the
underlying sqlite3_blob_open()
C-langauge interface. Close the
channel using the close command of
TCL.