 Hi everyone again welcome to this another lecture of the LPS class today we are going to talk about we will continue to talk about the tickle ticket that we left last time last class or the last lecture we saw from the canvas as a widget and we got a lot of commands as to how to play with the canvas and how to actually get people to use the canvas we also found some of these new commands like first of all like the bind command that we started talking about it like a couple of weeks ago that bind commands and then we also associated with bind tags because there are more than one binding for an event so essentially like I mean when there is an event whether it is a button press or a move of a mouse or whatever it is on a particular graphical user interface we typically use the bind command to create a binding for an action so when you actually select or put together a command using the button press we can write all the characters and then you need to press run that command gets run in the background that is because of this binding that causes it to run where the run command is bound to that event or that event is actually bound to the front command so that is something that we have seen now we also talked about this bind tags essentially the bind tags essentially like I mean we that determines it is a command that determine which binding supply to a window and the order of evaluation so a bind command itself is created creating the binding and then the binding is associated usually with a window a class or all so you can specify one of them basically so we saw this in the previous lectures the bind tags and command actually now determine which bindings apply to the window and order of the evaluation what does that mean so the usage is essentially it is bind tags window ordered by the tag list so an example will be bind tags dot B is our window and then the order that we specify is all dot button and then dot B so when an event happens basically like the supply to the all which is like everywhere outside and plus the button and then to the top level then the button itself whatever is that is going on that will be evaluated and then finally like dot B so this will allow you to actually like this multiple events can be trapped and then they I mean sorry multiple bindings can be trapped and then they can be a run and then they don't need to be running at the same time or all simultaneously which they follow this order by which it will be run so this is something that I wanted to tell you like I mean last time we saw this bind tags we didn't explain at that point whole lot now it is there and then the other widgets that we haven't really touched upon but I really want you to understand try to read upon this is the tree widget this is also like very common when you look at your outlook main or any kind of form lists basically like I mean the views that are displayed are based on the tree so the tree view widget can display and allow browsing through a hierarchy of items and show one or more attributes of each item as columns to the right of the tree so you have like big thing basically you have each item which is displayed and on the right hand side there are columns there it is displaying the its attributes so if it is a mail program you can see the subject from date to things like that the various fields that you can think of or a particular mail I mean you can also like say like important priority whatever so for this mail you can associate all these attributes also and then this particular widget is created by the tree view command so here we create tree view dot tree then dot tree is the widget and then if you want to add anything to the tree we just say like dot tree insert and then rearranging items is dot tree move and we can detach an item from the tree using dot tree touch or even completely delete that item using dot tree delete then we can open widgets basically so that is like set is open command first we need to specify whether it is an open is true and then set is open to open the widget and then by opening the widget we can now add stuff into it delete stuff query stuff things like so this is another widget that we never talked about in the previous lecture but I just want you to know so useful one so in today's lecture we will be talking about extending tickle with C and then some of the third-party tickle extensions or expect BLT and tickle die and then finally the future of tickle TK actually this is more like the past past kind of determines the future past of tickle TK what are the various versions and what they did what kind of thing and then what is the latest version so that is what we will cover today and now let us look at the topics so extending tickle so the main philosophy that we will be talking about is to focus on the primitives and then we will have like some basics on the interpreters and how to execute scripts how to implement new commands dynamic loading managing the results thing I am not going to talk about it today the main thing is essentially like I mean this is regarding machine level understanding as to what are the different memory pieces and where the result goes into and how do you manage the whole results and then we will also like look at some useful libraries like parsing variables lists and so we saw this in the very early lectures of tickle one is usually we can write usually better to write a tickle script rather than a sequel it is quick development and more flexible and it is high level so no compilation it is also like a higher level way to write and why do we write it in C this is something that we also like talked about earlier you need to access the lower level facilities that is like hardware resources can be managed like in fact malloc or mLoc actually is a memory allocation in C that specifically goes to the heap and actually allocates the memory we can request all those kind of different hardware features directly using C then there is also efficiency concerns basically like when we have like iterative calculations C and since it is a compile language in optimize and hence it provides much faster execution and then finally if you need the more structure and then if the code is complex say for example we are generating a program for DNA sequencing algorithm or DNA sequencing that entire algorithm can be coded as a C program than tickle script again this is the hypothetical and probably ideal case you may argue even for a tickle board which is okay but when this board gets complex we need to have like definite infrastructure to be in place and for that C is better the if you have to write a new tickle command like I mean that implementing new tickle commands that provide few simple orthogonal committees so it is low level to provide independent access to all the key features but at the same time it can be high level to hide unimportant details and allow efficient implementation so that is the reason why we can implement new tickle commands so here quickly like a weather reports so the goal is to retrieve weather reports over network from different servers so if you use the tickle command set one where we say like retrieve report format print on standard output that is too high level so it is inflexible now let us look at a second set of the month we open a socket to the weather server select a station ready the first line of the report this is too low level so you can see that actually like we still use the same tickle command set here and here now consider a third command set which is basically returns the list of all the available stations and even a station name retrieve report that is a that is your command structure this is just right so we will look at how to do it with these kind of so commands itself so in this section like I mean to designing a new command we want to make sure that we need to choose the textual names for the objects for example . dialogue . bottom . okay file 3 or STD in so really like objects can be aimed in the textual context if this is the case then we have to use like hash tables to map to the C structures other one is essentially like we can also try to use the object oriented commands for example we can say like dialogue bottom okay configure foreground red this kind of style is good for small set of small number of well-defined objects they do not pollute the namespace basically each one will be independent and also like allows similar commands for different objects so there is there are definite advantages in doing objects so in its commands and then the third category is actually the action oriented command which is string compare dollar X dollar Y this one is good if many objects or short load objects so again when you design a new command make sure that your considerations go through these three things now how do you format the the new commands so usually the preferred days make them easy to parse with tickle script so somebody else writes a tickle script they can easily parse your command results so for example here 10 53 high 58 low 37 precipit precipit point to sky part so this kind of thing basically now you can move that okay this is the index and this is the value so the current temperature is 53 highest is 68 low is 37 and amount of precipitation is 0.02 and then sky is partly cloudy whatever it is and make them symbolic wherever possible example it is we do not want to specify just numbers alone so these kind of in between like those things will make it easier now we can also use package prefixes in the command names and global variables for example instead of the stations we can stay with the stations or if the weather station is xxx we can say like weather stations xxx on the score xxx instead of just saying like this except same weather report and then maybe play think like that basically like we can use the package prefixes so this way like I mean it allows you to allows for the packages to coexist without any main crashes now let us talk about the interpreters so that is the basic one and then now the interpreters so pickle inter interpreter inter structure this is a structure that captures that encapsulates is the executing execution state what are the execution states it variables the commands implemented in C the tickle procedure the execution stack so it encapsulates this entire the execution states you can have many interpreters in a single application but usually there is only one in fact there so the way to create the interpreter is tickle interrupt use a star or Asterix interrupt this basically creates the structure and then we can just point that structure to the create command create an interrupt command so once we have the structure then you just say basically interrupt people to tickle create interrupt and this is just an object or in command which now creates your interrupt and then if you want to delete use the procedure tickle delete inter I in T T so this will delete the interpreter and if you want to execute tickle scripts the basically like define integer code and then code equal to tickle eval inter set a equal to 1 or set a 1 now it evaluates this one and then sets the value of that as a code the code typically indicates the success or failure is it tickle okay normal completion tickle error error another way to do it is the set a 1 you can put it inside the init dot tickle and then you can say tickle eval file interrupt in it dot tickle and there is yet another third way to do the tickle evaluation which is interrupt set a 1 as 3 different strings so now the interrupt result points to the string the result or an error message and then the application will display the result or message for the user okay and then where do scripts come from basically you can read from the standard input read from the script file or associate X events and wait for the events invoke the associated scripts with this the TK and then embedded in the sequel this is fixed or private scripts that we will talk about so creating this new tickle commands essentially so we write the command procedure in C so eq command client data the client data tickle interrupt where we create that one basically like then we have the integer arc C and the char star star we argue so this is an in C it is written so if it is less than 3 or like not equal to 3 then we just say like wrong arguments otherwise we go and like compare the argue v1 and argue 2 from here and then if they are not the same then result is 1 otherwise result is 0 so this is basically to compare two commands to see whether it is the same or not and then we return the return to the main and then once we create this command procedure then we register this with the interpreter that is tickle create command interrupt eq eq command client data and now so the eq command is now called eq which is essentially a string compare now once we register this the eq command will be called whenever eq command is involved in the intro and the interpreter you can also be delete you can delete the command by just giving the tickle delete command interrupt eq so this is the most useful for object oriented now so we talked about the client data what is client data so in the tickle command file here so we talked about the client data uppercase client data and then lower case and data so here we talk about it again it is used to pass any one word value to the command procedures and call back so the second client data is usually the pointer to the data structure manipulated by the procedure so we pass the first one and then the second one is manipulated by the procedure can and then the cache pointers in and out of the client data types basically so we can say like client data is more pointer and then pointer we can define that basically like star and then the client data so we can have many objects share one command procedure by using this so this is how we write new commands and register new commands with the interpreter so now let us look at the packages so our goal is now to make it easy to develop and use tickle extensions so we can use the package prefixes to prevent name conflicts so this is the one of the things that we talked about in the earlier one right and the other slides we use a package prefix so we can pick a short prefix for a package for example RDB so we use this in all the global names essentially so in C procedure it is uppercase RDB open the variable is RDB and then the tickle command is also like RDB so now once we have specified or use the package prefixes now we create the package initialization procedure and it is named after the package so RDB underscore in it is the package initialization procedure this creates packages commands and then evaluates any startup script if you specify so here is an example there is int RDB init tickle interpreter in TRP then we create the tickle command first create command tickle create command and then return to return tickle eval file with that and then what the init dot tickle is now if you want to use the package basically we need to compile this as a shared library so here we do the cc compile so RDB dot C compile that and then we load it as RDB dot O and output is RDB dot SO now we can dynamically load into the PCL shell you are wish so to load it basically load RDB dot SO and then the top level RDB now tickle will call the RDB init to initialize the package so this dynamic initialization is fairly new I mean the versions we will talk about today and where tickle and TK what versions are there and what we should use so now let us talk about the load command the load has several forms load file name load file name package name load nothing package name here the file name is the name of the file basically here you have belt it as RDB dot SO so that will be the package that will be the file name and then the package name is the top level package specification that is inside which is in this case is RDB so in this case it be just XOR so we whether we load it as a DLL dynamic link library or SO dot SO is we can use info shared live extension to decide between these two we can also use info loaded command to see what packages I mean loaded into this if you want to load a program statically then we specify that tickle static package is tickle and trigger and character star packaging so that points to the thing and then we also specify the tickle package init proc which is star init proc and then tickle package init proc star safe in once we specify this then we can say load XMT of course in the scenario the dynamic loading is preferred now the fourth option for managing results if you use library procedures so tickle result set result interpreter string this will replace the old value and if you say like tickle append the result then that extends the old value and if you do append element then it extends the old value but now as a list if you do use reset result now that clears the old value now let us look at the utility procedures and one of them is parsing this is used by command procedures to parse arguments usually it takes in a value and a code the code is just to tickle get int interpreter or be one and then value it stores the integer in value and it returns tickle okay or tickle you know if there is a parse error then it returns a tickle error and leave message in interpret result other useful procedures tickle get double tickle expression double tickle get boolean expression boolean expression long and expressions form the tickle get boolean accepts s false 1 0 extra and expr is essentially like variations interpret argument as an expression so in utility procedures what are variables essentially like so basically they can be read write or unset so here an example basically like we have a character value value is tickle get war interpreter a something and then tickle set to war interpret something and then unset something else so we can use get set and unset basically pretty much rewrite and unset then you can also set traces basically so that is you can trace a variable so that is trace war and then we can say okay tickle trace reads people try writes trace procedure and plan data so we can trace it through how the value actually is changing throughout the program throughout the script so and then the trace proc is it will be called basically to doing each read or write of a they can you can monitor the accesses and override value and read or the value value read or written now for parsing assembling proper list use the tickle split list and tickle merge the hash tables are quite flexible basically in it hash table create has entry point has entry delete has entry and delete the whole hash table the hash table is just like having tickle associative arrays in C it is also excellent way to store the client data records for object oriented command model and then dynamic strings is through this these procedures the string in it this thing append these things the string append element the string value and then finally the dynamic strings grow efficiently without bounds like a good string class in C++ it is used internally by tickle for result management so this is again another data structure within tickle in terms of extending tickle interfaces to see itself are very simple so tickle is designed to make this true and when we write when we extend tickle we focus on the primitives and use tickle script to compose basic features so we write the most primitive procedures first and then we basically combine the features of tickle to come in multiple primitives into one and then all that the larger command if you are writing a widget for pk the good news is that one which one widget that can work on Unix windows etc so that is your best one but so the pk port uses the port of Xlib to suppose that so it's okay but what is the bad news is that you will have to write to Xlib so TK actually uses only Xlib which is the lowest level part of the Xlib it doesn't use XP just now motive etc so to draw you have to use the Xlib also so TK supplies utilities for example the 3D outcome drawing the font utilities even notification timers idle procs etc and then you have to supply the tickle commands the initialization procedure configuration table even handlers and deletion callbacks then we use object oriented command paradigm that is one tickle command per widget class and one tickle command per widget instance the now I will talk about couple of other meta languages or metascripts basically one such thing is called the expect the expect is really the scripting language to interface with FTP telnet FSTK etc which cannot be automated so one way to it's also a very good way to create DUIs for interactive command line applications it's also good way to react to prompts from the command line maps and usually they expect an automate tedious interactive processes view GUI actions to simulate keyboard outputs and reattach the subclasses to people and one thing to notice it works only on true politics of the unit systems so uses the pseudo TTYs basically TTYs a unit construct and that's the reason why it doesn't work well in others so expect the commands are like this basically there is a command called spawn you can say basically it's telnet and which machine it is the server and then what is the port number so the expect response to patterns from type for example expect can say like connect connection refuse unknown host login default so when connection refuse basically that means that exit unknown host is DNS so complain then we have the login we connect to a pipe to the console so the other one is the BLT essentially this is also it's a toolkit offering set of widgets and geometry manager so this helps you to draw pictures display graphs very easy and this particular tool kit offering is written in C it has several mega widgets the BLT graph is one of the sub one and that is the most useful one and that is the one that is very popular also then other commands basically like highlight text drag and drop bar chart table things like that can be built using the BLT so to invoke a BLT graph widget we specify the BLT graph command with the dog D as the widget name and then we specify all the other things then here we are just configuring the dog D and then we can configure the x-axis and y-axis as to what the value should be here the x-axis is pretty much it's time and y-axis so once we create the configure this and then we create the various axis the x-axis and the y-axis we then create the the elements basically elements we see one x data is $x1 y data is Y1 and then what is the line with foreground background and then similarly we can plot another set of data as well so this is that is how the BLT graph widget is used which is very common now let us look at one more thing which is the TC tickle die essentially this is usually the front end to corba projects the it lets tickle TK talks directly to the Cobra object the Cobra let us objects written in different languages communicate essentially so corba is a place sitting in the center and it gets the objects in from various languages and it communicates the TK GUI is the TQ TK GUI for remote objects are easy and very powerful TK die scripts are faster and easier than C++ so okay so this this is pretty much the technical aspects of it of the tickle TK let us look at some of the releases and what is the latest and so 7.6 and TK 4.2 was originally there and this one has revision of reader needed for spectacle FCS C API change for channel drivers actually the beta release and all that happened so you know that statement there and then 7.6 plug and photo photo 2 plug which is which is have features needed for next K plug-in and you can just use the plug-in information and then safety of them in already released in plug-in binaries and no source release until tickle 7.7 and TK 4.5 is also like pasta so 7.3 is essentially 7.5 is the latest greatest sorry not 7.5 basically we will talk about that but after 7.6 the 7.7 came into being and tickle TK was from 4.2 it became 4.3 here basically we had native widgets on PCs and Mac there is a new mechanical menu mechanism essentially the menu bars are implemented with the menu widgets there is a new menu option for the top-level windows the chair of menus are clones and it can use the same menu in several places and hiding the pair of entries is another issue so the new font mechanism basically like this is very nice for non-units machines basically we specify label and then $ L I mean for dot L and font times 12 bold and then we say font create title family Helvetica Helvetica size 24 and various bold and then we label basically to title and then font configure title and size 36 so the other things were basically virtual bindings essentially and even generation so this is something that we did not touch upon the TK windows can create a virtual bindings essentially virtual events which can be bound inside so you do not really need to do all the actions that the the the tool is expecting now it also supports the standard dialogue there is a portable file commands R M M E made and etc. It also supports the binary IO so read write blocks of data inside extract fields of blocks and then copy between channels and then other possible extensions to 10.7 and TK 4.3 or mega widgets image revisions in that channel support and then finally more text improvements these are all the original dates essentially but the the next one is the TK 8.0 this one has a bytecode compiler and this is fdp.newsoft.com I should have it and then we have a new object system for data representation the new C API for command procedures many other TK library procedures the old interface is still not supported but it is slow I mean it is still supported but it is low and then what about name spaces basically like that is another thing that we need to stop we need to worry about okay so in TK 8.0 also made some possible changes to the semantics the more aggressive list syntax checking is enabled in TK 8.0 and then the conversion for LFN and LX for for the TK 8.0 you have the bytecode compiler essentially and you can go to the fdp.newsoft.com for the third-party items there is a new object system for the data representation the new C API for command procedures and many other library procedures so here the old interfaces are still supported but they are very slow and what about the name spaces and then there is also like some changes to the semantics a more aggressive list syntax checking basically LFN then L index and then changes to the error messages error info and then line numbers so the view the schedule basically like these are all like the same so the latest one is tickle is tickle TK 8.6 tickle supports object oriented programming it has a stack less evaluation so when the procedures are called and the procedures are nested the next procedures are called in the sequence previously it used to use a stack for the execution basically it stores all the state in a stack and then it executes the next one and if that also nest another procedure it retains everything into another stack and then go on so in the new one that particular thing has changed basically like that that is that was found to be like failing efficient so it is changed and then it's a stackless execution in tickle 8.6 it also has enhanced exception handling the commands called try and throw which attempts to actually catch an exception and then actually also like to change the course when then exception happens okay and then there are many other enhancements to to the tickle 8.6 on the TK front there is a built-in support for PNG format for the graphics there is also a new command for busy windows essentially it's called TK busy command there is support for angled text and moving things on camels and other projects basically the spectacles spec Java web edit micro scripting basically like we can use the we can edit web pages just what you see what you get kind of the mode using the web edit we can insert tickle TK scripts at various places and then the script fire at interesting times essentially and then the safe tickle basically which is so has a better TK it has better PK support the socket communication and developing in interesting and interesting security policies you can add authentication for example the MD5 signatures so that's pretty much what I wanted to cover in terms of PK so today mainly like I mean we looked at several areas basically so in once again like I just wanted to summarize so things that we did for today so mainly like I mean we talked about the extending tickle with C we also looked at the third-party tickle extensions the expect PLT and tickle die and then we talked about the past and the future and the present of tickle and TK which is essentially like which versions what is what are supported what can you expect in future so I think this concludes this lecture once again thank you very much for listening thank you