Re: [Scilab-users] mprintf("%d *\n", nHiters, M) horizontal format iterator ?

2016-02-24 Thread Serge Steer


As far as I know there is no iterator operator in C format, but it is 
quite easy to generate an "iterated format* using scilab.


suppose the patterm of the format has been save in the variable f
then the "iterated format" can be generated by
strcat( f+emptystr(1,n)," ") //here I suppose the patterns are separated 
by a space



example
//Create the data
x1=(1:5)';t1="sin(x)="+string(sin(x1));x2=(1:5)'/10;t2="cos(x)="+string(cos(x2));

f="x=%f %s";//The format template
mprintf(strcat( f+emptystr(1,2)," ") +"\n",x1,t1,x2,t2)

Le 24/02/2016 15:27, Samuel Gougeon a écrit :

Hello,

I am pretty sure that an horizontal iterator was recently implemented 
for the format
used within mprintf(), but i am failing to find any information about 
how to use it.


Or am i getting confused with this feature described in the/help 
print_conver//sion/ page:


"A field width or precision can be indicated by an |*| (asterisk) 
instead of a digit string.
In this case, an integer |value| parameter supplies the field width or 
precision.
The |value| parameter converted for output is not fetched until the 
conversion
letter is reached, so the parameters specifying field width or 
precision must

appear before the value to be converted (if any)."

?

By the way, i did not find any examples for any of both features in 
help pages

of m*print()  functions.

Thanks for any help
Regards
Samuel Gougeon



___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] mprintf("%d *\n", nHiters, M) horizontal format iterator ?

2016-02-24 Thread Samuel Gougeon

Le 24/02/2016 17:10, Clément David a écrit :

Hi Samuel,

Le mercredi 24 février 2016 à 15:27 +0100, Samuel Gougeon a écrit :

I am pretty sure that an horizontal iterator was recently implemented for the 
format
used within mprintf(), but i am failing to find any information about how to 
use it.

What do you mean by "horizontal iterator" ? Is it like the "argument_index$" 
for Java [1] ?


I don't know much java, but as Fortran format allows it with "#(...)", 
this one replicates at most #times the content of ()
(that may have other (...) patterns (recursive 
replication/substitution))... Then, for all provided data, the format is 
feed with
row-wise input data and builds the output with replicating the format as 
many times as some input data remain
(for the current row), and then stop without error (even before the end 
of the format).


Unfortunately, write() that could manage such a handy fortran format is 
not well implemented:


 * the write() format cannot mix input data types (bug 3798)
   
 * when the write() format meets a string (a), its parsing stops (bug
   12476) 

Being so handicaped, write() has not much interest wrt mprintf(), and 
AFAIK, there is presently
no native Scilab function handling input data in this way. We are 
compelled to use things

like this msprintf():

--> NL=4; NC=6; Nchar=5;

--> data = 
matrix(strsplit(ascii(grand(NL*NC*Nchar,1,"uin",32,126)),(1:NL*NC-1)*Nchar),NL,NC)

 data  =

!/6QV0  L)3zw  I mprintf(strcat(emptystr(1,size(data,2))+"%10s ")+"\n", data)
 /6QV0  L)3zw  I write(%io(2), data, "((2x a))")
  /6QV0
  +`kUF
  FdBRS
  xJZH3
  L)3zw
  !'{*`
  !Gsp"
  W!(g"
  I___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] mprintf("%d *\n", nHiters, M) horizontal format iterator ?

2016-02-24 Thread Clément David
Hi Samuel,

Le mercredi 24 février 2016 à 15:27 +0100, Samuel Gougeon a écrit :
> I am pretty sure that an horizontal iterator was recently implemented for the 
> format 
> used within mprintf(), but i am failing to find any information about how to 
> use it.

What do you mean by "horizontal iterator" ? Is it like the "argument_index$" 
for Java [1] ?

[1]: http://docs.oracle.com/javase/8/docs/api/java/util/Formatter.html

--
Clément
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users