assigning returned strings

34 views
Skip to first unread message

Jordan McLeod

unread,
Oct 11, 2011, 7:24:10 PM10/11/11
to fityk-users
I may be missing the point of the commands that return a string, but I
thought it would be useful for naming output files from FitYk. I
should mention that I'm very short of funds, as a student, so I'm
using the free FitYk (v. 0.9.8). If this has been corrected in later
versions, my apologies.

I'm trying to use the return of "title", which returns a string on the
command line when used with such commands as p, print, i, info, etc.
However, I can't seem to find a way to call the string in, for
example, the following lines:

@0: print all: x, y, F(x), F[0](x), F[1](x), F[2](x), y-F(x) > 'C:
\Users\Jordan\Desktop\Data For Jordan\' + return title + '.dat'
@0: print all: x, y, F(x), F[0](x), F[1](x), F[2](x), y-F(x) > 'C:
\Users\Jordan\Desktop\Data For Jordan\' + {title} + '.dat'
@0: print all: x, y, F(x), F[0](x), F[1](x), F[2](x), y-F(x) > 'C:
\Users\Jordan\Desktop\Data For Jordan\'.{title}.'.dat'

which would hopefully be executed as:

@0: print all: x, y, F(x), F[0](x), F[1](x), F[2](x), y-F(x) > 'C:
\Users\Jordan\Desktop\Data For Jordan\title.dat'


Ideally, this would export the data to a space separated value .dat
file named after the title of the file opened in FitYk. However, it
doesn't work. I've tried every function call method and common
toString() function that I can think of without success.

Incidentally, with this experimentation, I've found that I cannot
assign any strings to variables as $_str = string or $_str = 'string'
throw errors. I'm not sure assigning strings is a huge deal, but if I
could use {title} to call the value of title, it would help, as would
some kind of concatenation for strings. This would allow for greater
ability to name.

My initial hope was to create a script to analyse data and automate it
with a .bat file. If there isn't a way, I may have to scrap this
nearly entirely and setup using C or something.

Jordan McLeod
Student
State University of New York at Brockport

Marcin Wojdyr

unread,
Oct 14, 2011, 1:47:17 PM10/14/11
to fityk...@googlegroups.com
Jordan,
fityk mini-language doesn't support string operation and variables
store only mathematical expressions.
The latest version come with embedded Lua, that may help in some
cases, although using it can make scripts much more complicated.

Best
Marcin

> --
> http://groups.google.com/group/fityk-users

vchev

unread,
Mar 6, 2012, 4:52:22 PM3/6/12
to fityk...@googlegroups.com
Marcin,

I purchased fityk 1.1.1 and am interested in assigning the result of fityk commands to variables in Lua.

For example, how would I assign the result of the fityk "print title" command to a Lua variable?

I tried
---------
a={}
F:redir_messages(a)
F:execute("print title")
---------
but it failed since redir_messages expects a FILE.

I then tried to use the pl.stringio module (after updating the package.path) and use a stringio.create() object as argument to redir_messages but that still didn't work.

I realize I could write to a file, close it and read it back in, but there must be a better way....

thanks
Vincent



On Friday, October 14, 2011 12:47:17 PM UTC-5, Marcin Wojdyr wrote:
Jordan,
fityk mini-language doesn't support string operation and variables
store only mathematical expressions.
The latest version come with embedded Lua, that may help in some
cases, although using it can make scripts much more complicated.

Best
Marcin

On Wed, Oct 12, 2011 at 00:24, Jordan McLeod

Marcin Wojdyr

unread,
Mar 7, 2012, 7:57:04 AM3/7/12
to fityk...@googlegroups.com
Hi Vincent,

It's great to see Lua interface used.

> For example, how would I assign the result of the fityk "print title"
> command to a Lua variable?

title = F:get_info("title")

get_info() actually returns output of the info command, but it's the
same in this case.
If you'd like get result of "print <expression>" e.g. "print
%_1.center", use F:calculate_expr("%_1.center")

Marcin

Vincent Chevrier

unread,
Mar 7, 2012, 10:14:29 AM3/7/12
to fityk...@googlegroups.com
Hi Marcin,

thanks this answered my question!

> --
> http://groups.google.com/group/fityk-users

Reply all
Reply to author
Forward
0 new messages