[Scilab-users] Dot Notation

Serge Steer Serge.Steer at inria.fr
Tue Jan 8 17:20:00 CET 2013


Le 08/01/2013 10:03, samy a écrit :
> hi serge,
> the example work fine, but i have a question can you explain the 
> individual steps.
> i understand what the code do, but not completely.
> thanks.
>
> ------------------------------------------------------------------------
>
> ***digits=string(0:9);**
> **txt=stripblanks(mgetl('your file'));**//read the file and remove the 
> leading and trailing blanks of each line
> **txt(txt=='')=[]; //remove blank lines**
> **n=size(txt,1); //the number of lines**
> **I=[];**
> **for k=1:n**//loop on each line
> ** t=tokens(txt(k),"=");**
> *
*//if txt(k) contains something like *ASY.Pr.VER = 2.0 the variable  t 
will be equal to ["ASY.Pr.VER","2.0"]
> *** if size(t,'*')==2 then**//there is an = sign in the line
> **   t2=stripblanks(t(2));**
> **   if or(part(t2,1)==digits) then**//check if the first character of 
> t(2) is a digit
> *
*//t2 begins with a digit, I assume t2 contains the representation of a 
number , the associated line is not modified*
//because ASY.Pr.VER = 2.0 is a valid Scilab instruction
> ***     I=[I;txt(k)];**
> **   else**
> *
*//t2 does not represent a numbe, expression like  ASY.Pr.NAME= Samy is 
not a valid Scilab instrution
// (at least is Samy is not a defined variable)
//such lines are transformed into ***ASY.Pr.NAME= "Samy"*
*
> ***I=[I;t(1)+"="""+t2+""""];**
> **   end**
> ** else**
> *
*//if txt(k) does not contains an = sign, like ***ASY.Pr.LOG **this does 
not represent an assignment
*//such lines are transformed into ***ASY.Pr.LOG= [] (empty matrix 
assigned to ****ASY.Pr.LOG)**
> ***I=[I;txt(k)+"=[]"];**
> ** end**
> **end**
> **clear ASY**
> *
*//here I contains a sequence of valid Scilab instruction*s that can be 
used to defined a struct
> ***execstr(I)**//evaluate it
> **//here ASY is a struct with one field named Pr and ASY.Pr is a struct**
> **ASY.Pr**
> *
>
> Serge Steer
>
> Le 03/01/2013 09:35, samy a écrit :
>
>     Hello everyone,
>
>     i want to read a text file with the following Output:
>
>     ASY.Pr.VER = 2.0
>
>     ASY.Pr.NAME = Samy
>
>     ASY.Pr.REKE = XY
>
>     ASY.Pr.LOG
>
>     and give it as a tlist in scilab for example
>     tlist(['Pr,'VER','NAME','REKE','LOG'],2.0,Samy, XY)
>
>     it's possible?
>
>     i have a large file
>
>     I thank you in advance for any help.
>
>
>
>     --
>     View this message in context:http://mailinglists.scilab.org/Dot-Notation-tp4025607.html
>     Sent from the Scilab users - Mailing Lists Archives mailing list archive at Nabble.com.
>     _______________________________________________
>     users mailing list
>     [hidden email]  <http:///user/SendEmail.jtp?type=node&node=4025609&i=0>
>     http://lists.scilab.org/mailman/listinfo/users
>
>
>
> _______________________________________________
> users mailing list
> [hidden email] <http:///user/SendEmail.jtp?type=node&node=4025609&i=1>
> http://lists.scilab.org/mailman/listinfo/users
>
>
> ------------------------------------------------------------------------
> If you reply to this email, your message will be added to the 
> discussion below:
> http://mailinglists.scilab.org/Dot-Notation-tp4025607p4025609.html
> To unsubscribe from Dot Notation, click here.
> NAML 
> <http://mailinglists.scilab.org/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble:email.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble:email.naml-instant_emails%21nabble:email.naml-send_instant_email%21nabble:email.naml> 
>
>
> ------------------------------------------------------------------------
> View this message in context: RE: Dot Notation 
> <http://mailinglists.scilab.org/Dot-Notation-tp4025607p4025626.html>
> Sent from the Scilab users - Mailing Lists Archives mailing list 
> archive 
> <http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html> 
> at Nabble.com.
>
>
> _______________________________________________
> users mailing list
> users at lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20130108/c462fade/attachment.htm>


More information about the users mailing list