/* label window with readt filename */
readtlabel(w, full)
{
local s, f = "";
(w, full) = readtlabel_parse_args(w, full);
/* force window */
w = castwindow(w);
/* find "readt" in formula */
s = strfind("readt", getwform(w), 0);
if (strlen(s) > 0)
{
s = strget(1, s, ";");
if (strlen(s) > 0)
{
f = strget(2, s, '"');
if (strlen(f) <= 0)
{
f = strget(2, s, "'");
}
}
}
if (strlen(f) > 0)
{
/* check if we do not use full path */
if (not(full))
{
(p, f) = dirpath(f, 0);
}
if (strlen(f) > 0)
{
label(w0, f);
}
}
}
/* parse args */
readtlabel_parse_args(w, full)
{
local ww, ff;
ww = ff = {};
if (argc == 2)
{
if (iswindow(w))
{
ww = refwindow(w);
ff = full;
}
else
{
ff = w;
ww = {};
}
}
else if (argc == 1)
{
if (iswindow(w))
{
ww = refwindow(w);
}
else
{
ff = w;
ww = {};
}
}
else
{
ww = refwindow(w0);
}
if (not(iswindow(ww)))
{
ww = refwindow(w0);
}
if (isempty(ff))
{
ff = 0;
}
return(getwnum(ww), ff);
}