1st Lesson On Tcl

01:11 < jag> very soon u can send tcl scripts
01:11 < jag> thru the bot :D
01:11 < dspstv> who me?
01:11 < jag> yeah if u wanted to
01:11 < dspstv> ahh
01:11 < jag> i could program ur whole din
01:11 < jag> reprogram on the fly
01:12 < jag> livecode here
01:12 < dspstv> i CAN?T program
01:12 < jag> and u will hear the results
01:12 < dspstv> no no
01:12 < jag> well dspstv u enter commands
01:12 < jag> its only a short leap to programming
01:12 < dspstv> yes, almost as cp paste
01:13 < jag> cud teach u
01:13 < dspstv> but every time i try it the error is impossible to understand
01:13 < jag> something like
01:13 < dspstv> ad google comes up wth tons of ideas
01:13 < dspstv> related to the "error"
01:13 < jag> bot: proc go [] {puts {hello world}}
01:14 < jag> then
01:14 < jag> bot: go
01:14 < jag> will print hello world
01:14 < dspstv> ok,
01:14 < dspstv> questionnn
01:14 < jag> in tcl
01:14 < jag> startup tclsh
01:14 < jag> lets have a tutorial now
01:14 < dspstv> yes
01:14 < dspstv> wait
01:14 < dspstv> let me ask something re the line up there
01:14 < jag> no dont worry
01:14 < dspstv> [] ?
01:14 < jag> u will understand that l8r
01:14 < dspstv> ok
01:15 < jag> tcl is very easy
01:15 < dspstv> thats what all the book i triy say
01:15 < jag> dont be put off by the []
01:15 < jag> {}
01:15 < jag> and ""
01:15 < jag> but only these 3 are there :D
01:15 < dspstv> yes, ive read that
01:15 < jag> startup tclsh
01:15 < jag> or better
01:15 < jag> tkcon.tcl
01:15 < jag> u can download it
01:16 < jag> 1 click
01:16 < dspstv> wait, need to install
01:16 < jag> k
01:17 < jag> wassup
01:17 < dspstv> installed
01:17 < dspstv> but
01:17 < dspstv> i dont know how to invoke it
01:17 < dspstv> is not as
01:17 < dspstv> tkcon
01:18 < dspstv> theres nothing in the path
01:18 < dspstv> looookin
01:18 < jag> no no
01:18 < jag> where u downloaded
01:18 < jag> there the files there
01:18 < jag> tkcon.tcl
01:18 < jag> type wish tkcon.tcl
01:18 < dspstv> wonder where ubuntu installs it
01:18 < dspstv> loookin
01:19 < jag> firefox download…
01:19 < jag> its running noisely here
01:20 < dspstv> runnin
01:20 < jag> nice
01:20 < dspstv> tkcon 2.5 main
01:20 < jag> in tcl and in din
01:20 < jag> we only have commands
01:20 < jag> a command
01:20 < jag> is of the form
01:20 < jag> command_name arguments
01:20 < jag> first word is command name
01:20 < dspstv> k
01:20 < jag> rest are arguments
01:21 < jag> so
01:21 < jag> lets set a variable
01:21 < dspstv> read that in the url you provided 2 days ago
01:21 < dspstv> ok
01:21 < jag> set a hello
01:21 < jag> here
01:21 < jag> set is the command
01:21 < jag> a and hello are its arguments
01:22 < jag> type that out in ur console
01:22 < jag> the weird thing is im a newbie in tcl too ;)
01:22 < jag> but i know i love it
01:22 < jag> its destiny :D
01:22 < jag> did u do it yet?
01:23 < dspstv> k
01:23 < dspstv> hello
01:23 < jag> cool
01:23 < jag> now as i said
01:23 < jag> for the command set
01:23 < jag> a and hello are arguments
01:24 < jag> what it does with the arguments is upto the command
01:24 < jag> tcl doesnt care
01:24 < dspstv> dumb question
01:24 < jag> yeh go
01:24 < dspstv> if a and hello are arguments
01:25 < dspstv> why hello gets printed and a gets discarded?
01:25 < jag> very good question
01:25 < dspstv> is xenophobia?
01:25 < jag> in tcl dumb questions are actually deep questions
01:25 < jag> a tcl command always outputs a string
01:26 < jag> it could be empty
01:26 < jag> it could be something
01:26 < jag> always a string
01:26 < jag> thats convention
01:26 < jag> u will see why that is very powerful soon
01:26 < jag> so set a hello
01:26 < jag> the set command is returning the string hello
01:27 < jag> now type
01:27 < jag> set a
01:27 < dspstv> opps
01:27 < dspstv> hello again ?
01:27 < jag> of course
01:27 < jag> the set
01:27 < jag> command
01:27 < jag> only takes 2 arguments
01:27 < jag> the 1st argument is variable name
01:27 < jag> the 2nd argument is value
01:28 < jag> if u omit the 2nd argument
01:28 < dspstv> ok
01:28 < dspstv> a is a variable
01:28 < jag> it prints the value of the first argument
01:28 < dspstv> k
01:28 < jag> which is the variable name
01:28 < jag> now try
01:28 < jag> set a hello world
01:28 < dspstv> error
01:29 < dspstv> this is when i go to google
01:29 < jag> of course error
01:29 < jag> because there are 3 arguments :)
01:29 < dspstv> 3 element
01:29 < dspstv> yes
01:29 < jag> yep
01:29 < jag> a hello and world
01:29 < jag> 3
01:29 < dspstv> ok, i need a break
01:29 < dspstv> brbr
01:29 < jag> lol
01:29 < jag> back quickly
01:29 < jag> cos i wnat to crash
01:31 < dspstv> me too
01:31 < dspstv> so 3 argument cant fit with set


01:32 < jag> yes
01:32 < jag> so
01:32 < jag> cant we put hello world into a then?
01:32 < dspstv> with quotes?
01:32 < jag> whats the problem
01:32 < jag> the space inbetween
01:32 < dspstv> or similar
01:33 < jag> yeah quotes
01:33 < dspstv> let me try
01:33 < jag> but ur telling it like a parrot :D
01:33 < dspstv> works
01:33 < jag> the problem is the space inbetween
01:33 < jag> hello and world
01:33 < jag> that makes world into 3rd argument
01:33 < jag> we want to eliminate that space
01:34 < jag> so u could try
01:34 < jag> set a hello_world
01:34 < jag> :)
01:34 < jag> that will work
01:34 < dspstv> dirty but yes
01:34 < jag> or another way is to put a \ followed by space
01:34 < jag> between hello and world
01:35 < jag> now this \ says discard the usual meaning of the character following me
01:35 < dspstv> k
01:35 < dspstv> better one
01:36 < jag> now set a
01:36 < jag> now type
01:36 < jag> set a
01:36 < jag> hello world
01:36 < jag> the double quotes is another way
01:37 < dspstv> yeap
01:37 < jag> but
01:37 < jag> now
01:37 < jag> set a
01:37 < jag> prints hello world
01:37 < jag> nice
01:37 < jag> but set a is painful to type
01:37 < dspstv> it does
01:38 < jag> short cut:
01:38 < jag> replace set<space> with $
01:38 < jag> ie
01:38 < jag> type
01:38 < jag> $a <enter>
01:39 < jag> $a<enter> if u like
01:39 < dspstv> and somewho the variable gets "exectued"
01:39 < dspstv> i get an error
01:39 < jag> yeah
01:39 < dspstv> invalid command hello world
01:40 < jag> and my friend tell me why did the variable get executed?
01:40 < dspstv> every word is a command.. so… uhmm
01:40 < jag> not every word
01:40 < jag> the 1st word
01:40 < dspstv> oh yes
01:40 < jag> but wait
01:41 < jag> $a is the first and the only word in the command u gave
01:41 < jag> but it doesnt say $a is invalid command
01:41 < jag> when tcl sees $ before a variable name
01:41 < jag> it substitutes its value
01:42 < dspstv> so the variable gets translated into.. a command ?
01:42 < jag> its value is hello\ world
01:42 < jag> there is no command called hello\ world
01:42 < dspstv> sure
01:42 < jag> yeah :)
01:42 < jag> ok now
01:43 < jag> proc "hello world" "" {puts "hello world"}
01:43 < jag> :)
01:43 < jag> or
01:44 < jag> proc hello\ world "" {puts hello\ world}
01:45 < jag> wassup?
01:45 < dspstv> trying to understand what the hell is proc
01:45 < jag> dont try to understand
01:45 < jag> im here to explain :)
01:45 < jag> just type it in
01:46 < jag> if it comes up with an error fix the typo :)
01:46 < dspstv> nothing gets printed
01:46 < jag> thats good news isnt it
01:46 < jag> the unix way
01:46 < dspstv> went into the void
01:46 < jag> ok
01:46 < dspstv> hehe
01:46 < jag> noise
01:46 < jag> now
01:46 < jag> $a<enter>
01:47 < dspstv> oh, i see it now
01:47 < dspstv> hello world
01:47 < dspstv> clean
01:47 < jag> no error now
01:47 < jag> we use proc to define a command
01:47 < dspstv> no
01:47 < jag> syntax of proc is
01:47 < jag> proc <command_name> <arguments> <body>
01:48 < jag> dont try to understand it…let it go into ur subconscious :)
01:48 < dspstv> k
01:48 < jag> trust ur mind :)
01:48 < dspstv> but
01:48 < dspstv> "" is what part of the above?
01:48 < jag> nice question
01:48 < jag> no arguments
01:48 < jag> empty string
01:48 < dspstv> k
01:49 < dspstv> the void
01:49 < jag> yep
01:49 < jag> now
01:49 < jag> info body hello\ world<enter>
01:49 < dspstv> puts hello\ world
01:50 < jag> of course
01:50 < jag> thats our function body :)
01:50 < jag> our command body
01:50 < jag> or procedure body
01:50 < dspstv> ok,
01:50 < jag> now
01:50 < dspstv> let me copy paste ths
01:50 < jag> yeah keep this
01:50 < jag> now
01:50 < dspstv> i can do it when we stop
01:51 < dspstv> eyes are tired now
01:51 < jag> last one
01:51 < dspstv> k
01:51 < dspstv> !
01:51 < jag> proc hello\ world name {puts "hello, $name"}
01:52 < dspstv> done
01:52 < jag> great
01:52 < jag> now
01:52 < jag> $a<enter>
01:53 < dspstv> i get a wrong red message teling me how it should be
01:53 < jag> wrong # args
01:53 < jag> $a is hello\ world
01:53 < jag> we have rewritten this procedure
01:54 < jag> and it takes 1 argument
01:54 < jag> that goes into variable name
01:54 < jag> we have not given the argument
01:54 < jag> the command name is fine
01:54 < jag> its in $a
01:54 < jag> tcl found a command matching it
01:54 < jag> but it wants an argument :)
01:55 < jag> give it an argument
01:55 < jag> go on give it
01:55 < dspstv> hello, arg
01:55 < jag> lol
01:55 < dspstv> interactive
01:55 < jag> $a alejo
01:56 < jag> ok now
01:56 < jag> last 1
01:56 < jag> b4 we shut
01:56 < dspstv> ok
01:56 < jag> how do we print
01:56 < jag> hello alejo, jagan, manu
01:56 < jag> ?
01:57 < jag> simpler one
01:57 < jag> how do we print
01:57 < jag> hello alejo,jagan,manu
01:57 < dspstv> im slow, let me think 1 min
01:57 < jag> yehh
01:54 < jag> that goes into variable name
01:54 < jag> we have not given the argument
01:54 < jag> the command name is fine
01:54 < jag> its in $a
01:54 < jag> tcl found a command matching it
01:54 < jag> but it wants an argument :)
01:55 < jag> give it an argument
01:55 < jag> go on give it
01:55 < dspstv> hello, arg
01:55 < jag> lol
01:55 < dspstv> interactive
01:55 < jag> $a alejo
01:56 < jag> ok now
01:56 < jag> last 1
01:56 < jag> b4 we shut
01:56 < dspstv> ok
01:56 < jag> how do we print
01:56 < jag> hello alejo, jagan, manu
01:56 < jag> ?
01:57 < jag> simpler one
01:57 < jag> how do we print
01:57 < jag> hello alejo,jagan,manu
01:57 < dspstv> im slow, let me think 1 min
01:57 < jag> yehh
01:58 < dspstv> we will need 3 arguments
01:58 < dspstv> no?
01:58 < dspstv> i try
02:00 < dspstv> works not
02:00 < dspstv> uhmm
02:00 < jag> tcl is very simple but its like an optical illusion
02:00 < jag> magic trick :)
02:00 < jag> stare hard
02:00 < dspstv> i need to read back
02:00 < dspstv> in set
02:00 < jag> i can leave this as homework if u like ;)
02:00 < dspstv> ye
02:00 < dspstv> yes
02:00 < jag> k
02:00 < dspstv> i will read whn i cp it
02:01 < jag> but i will pick it up 2morrow
02:01 < dspstv> then think of it in bed
02:01 < jag> when u solve this
02:01 < jag> u will have stepped into a new realm
02:01 < dspstv> np, gracias mille
02:01 < jag> a realm where new powers await thee
02:01 < jag> bigger dragons to slay
02:01 < jag> virgins to lay
02:01 < dspstv> hehe
02:02 < jag> gnnnnnnn
02:02 < dspstv> gn jag

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License