 Hi everyone, again welcome to the LPS class we are going to continue our lecture on tickle if you remember like I mean in the last lecture we talked about the TK predominantly we completed the TK we give some more advanced to tickle processes basically as to how one can load in tickle as a dot is so and call tickle functions from anywhere things like that that we talked about today we are going to take another step in that direction but mainly we are going to talk about tickle in synopsis tools these are the tools that you use for your labs and also like I mean in real world you will be using a lot and synopsis has actually modified tickle a little bit for the better so we will be learning about how to use tickle in synopsis tools and what kind of support that they provide because tickle is not only their language but language of choice but actually it has lot of good things basically so today we will be talking mostly about tickle in synopsis tools which is mostly an extension of the existing tickle so we will be talking about lot of the concepts that we already covered just to reinforce so that you you also know what it is so number one thing as with any other tickle we have number of variables the variable names are mostly like if they are the scalar names basically and you can simply say any name it can become a variable name and you can assign a value to that variable by using the set command so simply like set a one will be same as a equal to one a will have a value of one and then these variables this values can be integer integer or floating and then we will soon see like I mean other variable extensions these are some of the things that we already saw like I mean in the first lecture of tickle and then one of the key concepts that we also talked about was the variable substitution that is also valid so once you have this and then now you can select set the $ a so that deal also be equal to one so those are the things basically that you can do and other ones like the various other functions and things like that are also like supported like incremental or additions and whether the info exists kind of things basically info exists is essentially like that is one thing which returns if the variable is true info exists it returns a one if the variable exists and if it is a it does not exist does not exist in terms of zero and then you can also have info wars and here you can give like some wild card say x star and this returns all the variables beginning with x and then the precision rules are very similar to the regular tickle rules that means that when you start with an integer and then as you go to further operations may be like to this result stays as an integer and then you again divide by 2.0 now this becomes a float answer 1.0 so and then if you use the float as the first one the result will be a float so those are those kind of things basically need to be aware of then one thing that synopsis provides is also set of predefined variables one example is the ENV so ENV is a variable that contains all the environmental variables so we can use commands like array names ENV this command will print out the list it contains elements element names that correspond to the name of the environment and then to show like a particular environment variable within that we can also use an echo command echo doll V and V home will print out whatever the value that is set as home and synopsis also provides a predefined command called get ENV so the get ENV command is very simple this is the get ENV and variable name and then it for it dumps that particular variable so home has whatever it is that gets dumped out so these are this is the nifty command that you can use and now let us go into script basically what is the script the script is nothing but it is a tickle so it has tickle commands and synopsis commands so these are all like grouped together and so you can run like some synopsis commands to get some data and then process it through using your regular tickle commands and then also like apply that back into like a synopsis tool so that becomes part of the script and along with the commands scripts essentially like I mean you know that already the hash if you use it that is for comments and this can come anywhere in the line and the only thing is after the hash everything in that line will be treated as a comment the only exception is if you are extending the comments using the back the backslash arrow and use the backslash arrow even the next line whatever it is that is treated as a comment as you know this is the continuation character and basically it will be this and any kind of preceding character will replace with nothing so this has a new line to it that will be preceded that will be replaced with just a blank and that is why this line will be then continuous with the next one and how do we run a script we use the command called source so for example source my dot tickle my dot tickle can be a script that contains all these tickle commands from the synopsis commands and we simply do a source to run the script so once you do the source you can redirect using the rather than symbol so this is all the standard ones that we already saw about saw this these things now let us go to the next one which is the data types as we have seen in the regular even synopsis also supports the three basic types of data which are strings array and list the string is nothing but a sequence of characters and string can be within codes basically in embed strings within codes or you can have like this generic strings of just some letters the strings are usually operated on by a string command so string command takes many arguments essentially so for example string and then we can say compare here we give the first string and then the second string so it compares these two and if they are same it generates a one otherwise and it's a zero and then string to upper and then string name this will convert the string from lowercase to uppercase so similarly there are many operations that are possible the main ones are format regex reg sub which is essentially uses a regular expression to do a substitution also you can do scam like a string scam or and then string string provides a set of string manipulation functions and then string substitutes is a BST which is for substitutions so this will be a pure substitution a reg sub will be based on a regular expression it can do a substitution so these are the commands that synopsis will support let us do link lists the list is nothing but an ordered group of elements so it is usually inclusive in the square bracket and we can also use a list command create a list so list and then set of elements will be turned into a list and you know like I mean the command substitution the square bracket command substitution and then I also think that you remember in tickle there are grouping basically there is a loose grouping all the with the braces and then more strict grouping with the quotes it may be like viewers but the main difference is that here when you have like a variable color X it does the variable substitution whereas here it does not do any substitution they are preserved assets so this is more strict and this is more loose okay so based on that I mean you can actually group the list elements so if you group it here anything under the inside the brace is treated as one object in the list and then the others will be submitted out also a list has index the L index you can do L index and then give a number and then access any of the elements and it usually it starts with 0 and then it goes to end so L index end will give the last element and then 0 will give the first element so these things they do not change other list operations are contact join L append L index that I mentioned L insert then length or L length L range L range is also like a it is a very useful operator it is basically it extracts the elements in a list within a given range L replace L search L sort and split we went in much more details we covered I think like pretty much you can use that way so the tickle interpreter within the synopsis tool can work with all these different setups so now we come to the arrays that is this element here so array is the tickle it uses the associative array we know that basically the index doesn't matter it can be a real number it can be a integer it can be a string whichever one that we can use so typically an array name will be a it is an array name followed by element and usually the arrays will have a two-dimensional lookup table basically like one is index and another value it is like a key value pair almost think of it that way tickle also supports the expr so you can use the expr as well for evaluating any expression so the array commands are typically like array and then similar to the list commands and I have put a question mark here there is a fourth data type which is what is what makes synopsis tools with special you will talk about that towards the end of this lecture this is called collection so collection is a data type in synopsis tools you can actually use this the very very useful data type it is kind of list but it is even more advanced than a list we will look at it as to how to use it and how actually it is being used today so operators essentially I mean this is this mainly goes back to that what I was mentioning regarding the expressions expressions are given by expr and then you can have like one argument which is in enclosed in the in the braces the inside that you can have like a B time C plus D whatever you want so maybe it is wrong at all so have the total substitution as well so the operators essentially like I mean that you can use within the expr command or addition subtraction multiplication division less than greater than this is basically a shift operator where it shifts the value to the left by so many bits so if you say like a B a it shifts B the number of bits as to A so if A is 2 it shifts left by 2 and this is a shift right operator and this is the equal to as a logical operation and not equal to a logical operation these are also so these are the relational operation value but the these are bitwise and this is bitwise XOR bitwise R and this is a conditional operator there if if A is non-zero then take B otherwise take C so if you say like set X A question mark B3 if A is 1 then X is B if A is 0 then X is C okay so the all the other operators basically you can also use a logical operations instead of bitwise and the logical operations typically use inside some control flow structure so let us see like what are the control flow structures in the synopsis tickle number one is the if else if else here you do not have to have these both these things it can just be if so if as two arguments one is the expression and then the second argument is and you can see that I am putting in greater so that they can work they are grouped as one and two in an else's case we specify the expression say expression one and then you execute script one else is and then we can give expression two and then script two and then finally else and then just good three so you can see that actually like it can flow nicely with all the other classes here so when the if command evaluates the expression if it is the expression result is not a zero then the if it is zero then it just goes to the next one and this else is can continue on and on now the while command so quick question how many arguments do you think it takes so the while command has two arguments just similar to the this is the bare bone is command it is a while then condition or an expression and then what body is just a script which so these are the two arguments for why how about for for is something that we studied also how many arguments do you think for for is also another way of looping structure so look at for for has actually three arguments actually four arguments so the first argument is the initial expression and then the second one is the termination the third one is a re-init expression so what is this we will talk about that and then finally the body or the script itself so the re-init expression is basically like from initial to the termination how to go about doing that so in a simple case like you can say initial can be set x 0 and then the termination condition can be all of x less than or equal to 10 and then where the re-init expression will be increment x increment on yeah x and then you can have the body so that that particular loop will be repeated 10 times now comes for each how many arguments do you think for each takes this one one two three four or command takes four this takes three how many do you think for each takes actually for each takes also for each takes actually three arguments actually like this is two arguments while takes two arguments for takes four and for each takes three so what are the three arguments does it take so it takes a variable then the input list and then the body it picks up one variable at a time from the list and then runs the body for each one of them now there are two other actually three other controls three other control flow commands which can actually cause changes in the way the four is being run so one such command is break the break command will cause the innermost loop to terminate as soon as it hits the break and these can be used to actually change the flow for power for each and why now the next one is the continue command continue command actually passes the innermost party for innermost loop to stop but it continues from there it left off it won't terminate the whole thing so it causes the current iterations of the innermost loop to start to terminate but the next iteration will still continue so continue is kind of it's more safer kind of a command compared to break but you may have situations where you use the one you can only use one or the other they are not interchangeable and sometimes like the big one pick in there the continue fits in and vice versa now the last one is the switch command the switch command how many arguments does it take actually believe it or not it takes only two arguments so the switch as a variable and the whole bunch of value and then script this entire thing is actually in close to the one place so you can almost say that basically for given variable if it is of one pattern then do one script it is of a different pattern then do a second things like that and it progresses I mean until you have no more patterns and the switch command also has three options that we will talk about it can be exact exact match or a globe match GLOV this is not to be confused with a selector this is a globe GLOV match is essentially kind of a loose match and then finally we get basically so these are three different options that provide for the switch command now let's talk about the basic file commands so before we talk about these additional commands basically we have CD and PWD I think you guys know that CD stands for the change directory and then PWD the present working directory those are pretty much the same then you can use that inside synopsis tickle command interpreter and now let's look at file commands and there are two of them basically like meaning like the we can use two different types of options here in the file or GLOV and Bob you know that basically matches the regular expressions in this context so the file commands are directory name to get the directory part of the file name and then you can also do file exists and then a given a file name which returns one if the name exists or 0 if it doesn't exist file extension is give the extension part of the root or text it returns the text and then each directory is a command that returns one if the file name specified is a directory and 0 otherwise and each file also works the same thing if it returns one if the name next to it is actually a file that exists otherwise it returns to 0 these are all like file testing commands then readable is another one which is written the permissions are set such that the file can be readable and then the root name is another one which is gives the root part of the file name size gives the size of file name bytes and then file tail file name will return the file name some part of the from the path string and then you also have like writable which is basically returns also one is writable or 0 otherwise now the globe is actually like I put it to the end basically the globe matching is something that we talked about in this context it actually returns for files it is a globe command it is mainly for pattern matching and reporting files and the globe you can say like start or very long and then start a text this will return collection of very long and text files okay so so far so good let us continue on file access commands essentially because how can you open a file and access actually the first command is file open command or just open here you can stay like what is a file and then what is access mode the access mode can be R which is just read only R plus it is used for reading and writing and the W it is open only for writing W plus is open for reading and writing and if it is the file exists it truncates it otherwise it will create the file then a is open the file for writing only and then the new data is appended to the file so the existing data is kept and then the new data is just getting up into the file here the only requirement is that the file name should exist it will create that particular file and a plus is the same thing only for now we can use it for reading and writing and here if the file does not exist it creates the file and then the new data is also like appended to the file similar to the previous command and to close a file we just specify the close command the close followed by a file ID not a file ID close that particular file then we also have another command called flush command literally means flushing so but the way that it is the flushing it happens is whatever stored in the buffer gets written into the file at this point usually when it exits that's when it gets written out in this case when you issue the flush command at that point gets written out into the main file so no buffer is being kept now we have other two commands also to get information from the file or put something into the file these are just the inputs so the gets command essentially given the file ID and the variable it reads line by line into that the put command essentially like whatever you find the line gets put into the file and also there are two other commands from non sequential file access meaning you can go directly to middle of the file and then start reading from that and those commands are seek and tell the tell command essentially it is used to obtain the current position of the pointer in the file there as a seek command will just given an offset it goes to that particular location see what is there now we come to much more interesting stuff which is procedure so as we saw actually we can define procedures and then then we can run these procedures instead of the native commands and then the main command that creates the table procedure is proc so and then proc has three more arguments it is the name name of the proc arguments and then the body so we saw like I mean lot of these things about procedures in the previous lecture and we also talked about the variable scope in the context of the tickle in the overall tickle and this is essentially the scope determines like how to access the variable so if you want to preserve the scope from a global variable into the procedure we use the keyword global so that particular variable is visible inside the environment or inside the procedure now if you want to pass a procedure pass a variable back to the the calling process and without actually passing it as a results we can do that using a form and we can also do up script to upload the script itself these are some of the commands that we solved it and we can also specify defaults for the arguments just right next to it as a single element essentially and then tools will take it now coming to the variable number of arguments this is specified as ARGS in the procedure so if one of the one of the arguments is this called ARGS then tickle this as the variable number of arguments so it will keep reading that until it is fully exhausted and arrays in procedures you can use arrays inside procedures basically again the scope needs to be determined and then you can assign a scope and then it is quite pervasive at the time and arrays can also be added into procedures extension this procedure extension essentially so synopsis actually supports some built-in features that can actually enhance the whole tickle script writing it is no longer field-second script but it is a full-blown program so two of such commands are defined proc attributes proc name and then optionally a name for text or the second one is parse proc arguments which has the dash arguments key with the argument list and then there is a result which generates the result so the advantages of using these scripts the define script and the parse script is that when somebody request a help on this command it automatically produces a help so the define proc command essentially takes as I said proc name it can have in some info information textual information with dash info there are other things which are not very relevant which is the command group hide body hidden permanent and don't abbreviate so I have put the those additional options now the next one is the parse proc arguments the part proc arguments has arg list as one of the arguments and then result array so the results array will contain the parsed arguments essentially so let's store in the result array and then the arg list is essentially Mr. arguments that needs to be passed the procedure the reason why we use these two commands are mainly so that it makes the procedure more readable and also it gives a consistent messaging around the proc the define proc commands proc commands also goes with the fan proc attributes command that actually gives more information about the all the attributes for the arguments the parse proc arguments command essentially that if you don't have this the the particular script will not respond to the dash help you can make it work by using a help procedure name and then minus verbose but in if you want to get the procedure added you need to define the part parse proc arguments then once we define how do we display the procedures for that we have several commands we can have info args info body so these are some of the commands that we can use in a procedure so now we come to the collection which is one other data structure which is unique synopsis the collections are set of similar type of objects you can have collection of actually multiple type also say with attributes they like nets into a collection all the cells into a collection and then you can have a single collection which can then move nets and cells but they are all grouped separately so if you have a name called x in the nets and corresponding x in the name cells they both are separate first of all inside the array itself and then we can separately destroy one of them if the other one needs to be more prominent so if you remove any objects it calls for like cells so if you remove x it can be the cell or net and it if it removes it from the cells the x the net x is still retained inside the collection so other important thing to note about corrections with corrections memory less so it is created when at least one element get added and it is destroyed automatically even the last element is removed so by itself it does not have any kind of bearing on what and for creating collections there are two commands one is get any get star is a tickle command for creating collections and then all underscore star is also another command so if you want to display objects in a collection we use query objects command and for selecting objects from a collection again filter expression is one attributes select an object from a collection we can use a filter option or filter collection command so this one is like the filter and then whole bunch of attributes now how do we add and remove objects from a collection you already saw like how to add the first element using the get or actually the set commands but for adding and removing objects from a collection we have to use these two commands either add to collection or remove from collection so these are preset commands basically which will help add new objects into the collection or remove the existing ones and as I said basically like the last element is removed this array c state this collection c state and basically it is completely destroyed so I mentioned earlier that the collections are very versatile and it is probably like the best thing happened here so to compare to collections we use the compare collections and then if you want to iterate over a collection use for each collection see basically the common theme is the collection collections becoming more and more and to copy collection basically we just use for copy command or copy underscore collection command for each collection also has just two arguments and then for to copy the collection use the copy collection command and the extracting objects should be using the query of command so I think like I mean this pretty much is the overview of how we can use some tickle in synopsis tool how this is useful we will probably like go through some examples in the next lecture okay thank you but it is only a Sunday