The doors part so you can enter the Auditorium. Carlin Auditorium Contents: Alison Luke_Skywriter Final Test Section Obvious exits: Out Creg_Kross has arrived. Creg_Kross enters from the Quad. Mark_Farrell strides in and walks up to the lectern and sets out some notes. Creg_Kross pokes Luke ... Luke_Skywriter pokes CK. Luke_Skywriter sits down at a fold-out chair. Alison whispers something to Creg_Kross. Creg_Kross whispers something to Alison. You say "I will start in a few minutes, but let's have a quick check of where people are in terms of coding ability." Creg_Kross nods. Alison whispers something to Creg_Kross. Creg_Kross whispers something to Alison. You say "Okay. Alison - how would you rate your knowledge of the parser/coding?" Creg_Kross tilts his head, thinks for a while, and moves his seat even farther away from Luke ... Alison says "very basic sir, i got your notes but am sorting thru em," Mark_Farrell nods. "Creg? JetFire has arrived. JetFire enters from the Quad. JetFire waves *Mark_Farrell* Merchant Pilot JetFire is looking at you. *Mark_Farrell* Ensign Alison is looking at you. Mark_Farrell smiles back at Jetfire as she walks in. JetFire says "yes I actually left my Nav console :)" Mark_Farrell chuckles. JetFire grins Creg_Kross says "I can just do simple objects. Such as a replicator, or a pet. But I thik I've still yet to learn about the interaction with the MUSE instead of just with the people (listen,command)." Hey - careful when you put me down. WiP shakes and nearly falls apart. JetFire ducks Mark_Farrell places the work In Progress object down. You say "Okay - Luke - how would you rate your abilities?" Creg_Kross grins ... Luke_Skywriter @baps Creg. Norm has arrived. Norm enters from the Quad. Norm quietly takes a seat in the rear. Creg_Kross says "Sowwy Luky ..." Norm whispers something to JetFire. Luke_Skywriter says "So, so. I can create basic objects and pets with multiple listen/here commands. Pretty basic." JetFire whispers something to Norm. Mark_Farrell nods. "Jetfire? Norm - rate your abilities please. Example(#14199I) created. Locked. Norm says "Medium -- I've coded a variety of objs, $/^ commands, arrays(whee!).." Dropped. JetFire says "bout this much = ><= :)" Flag set. Rusty has arrived. Rusty enters from the Quad. You say "Okay. I'll run quickly thought a basic ! command, and a simple responding @pemit. That should let us move onto some more advanced work with functions and work-saving that I covered in lecture 9." Norm whispers "If you'd like, you can do another basic lecture. I'm not sure 'bout anybody else." Rusty snaps to attention to Mark :) Norm nods. Teeki has arrived. Teeki enters from the Quad. Example grows ears and can now hear. You say "At ease, Rusty. Take a seat." Rusty relaxes and sits Creg_Kross waves to the Example ... You say "Nav heading from Place A to Place B" Example says "The heading is " You say "A basic !command is on example/va" Example(#14199vI) Owner: Mark_Farrell Credits: 1 Status: Thing Org: None(#-1) Type: Thing Flags: visible inherit Lock:Mark_Farrell(#16055PeoIqFct) Va:!* says "Nav heading from * to *":"The heading is Home: Ready Room Location: Carlin Auditorium You say "Three wildcards in the pattern matching code - the text matches is going to be put into stack registers V(0), V(1) and V(2) respectively." Luke_Skywriter waves, he's gotta go. Luke_Skywriter leaves the Auditorium. Luke_Skywriter has left. Creg_Kross waves ... You say "Okay. basic functions we are going to cover - lookin(), and a bunch of the maths functions." JetFire nods and scribbles You say "If we code something similar to the existing nav heading code, we'll get something ugly like:" *Mark_Farrell* $nav heading from * to *:@pem %#={[switch(s([or(eq(words(v(0)),1),eq(words(v(0)),3))][or(eq(words(v(1)),1),eq(words(v(1)),3))]),01,{Error: First Argument is invalid.},10,{Error: Second argument is invalid.},00,{Error: Both arguments are inv alid.},11,{The heading is: [heading(extract(ifelse(eq(words(v(0)),3),v(0),de_(lookup(v(xd),v(xc),v(0),0))),1,1),extract(ifelse(eq(words(v(0)),3),v(0),de_(lookup(v(xd),v(xc),v(0),0))),2,1),extract(ifelse(eq(words(v(0)),3),v(0),de_(lookup(v(xd),v(xc),v(0),0 ))),3,1),extract(ifelse(eq(words(v(1)),3),v(1),de_(lookup(v(xd),v(xc),v(1),0))),1,1),extract(ifelse(eq(words(v(1)),3),v(1),de_(lookup(v(xd),v(xc),v(1),0))),2,1),extract(ifelse(eq(words(v(1)),3),v(1),de_(lookup(v(xd),v(xc),v(1),0))),3,1))]})]} You say "Notice all the repetition." Plant has arrived. Plant enters from the Quad. Plant leaves the Auditorium. Plant has left. You say "Let's break that down into stages." Plant has arrived. Plant enters from the Quad. You say "First thing the code does is to check for the 'from' and the 'to' places being given as coordinates or as planet names." Maniatis has arrived. Maniatis enters from the Quad. Plant sits next to Jetfire, ever so quietly You say "So - for our code, we are going to need something to take a planet name, and return the coordinates of it." You say "Read 'help lookin()' if you are not familiar with it." lookin(,,) Arguments: 3 Type: String Searches for a case-insensitive, non-wildcard match of in , and if it exists, returns the word offset by in . Basically, the same as: lookup(,,,) This is really useful for one register arrays. A few examples will help clarify. Examples: lookin(Engineering va Bridge vb Lounge vc,Bridge,1)= vb lookin(Engineering va Bridge vb Lounge vc,va,-1)= Engineering * See also: lookup(), wlookin(), wlookup(), arrays Norm whispers something to Plant. Plant whispers something to Norm. You say "The code on example/vb is a simple demonstration of lookin() in the context that we will be using it in." Maniatis leaves the Auditorium. Maniatis has left. Example(#14199vI) Owner: Mark_Farrell Credits: 1 Status: Thing Org: None(#-1) Type: Thing Flags: visible inherit Lock:Mark_Farrell(#16055PeoIqFct) Va:!* says "Nav heading from * to *":"The heading is Xa:Earth 0:0:0 Beowulf 90:34:90 Vb:!* says "find planet *":"Planet coordinates are [lookin(v(xa),v(0),1)] Home: Ready Room Location: Carlin Auditorium You say "Find planet Earth" Example says "Planet coordinates are" Norm whispers something to Plant. Mark_Farrell demonstrates easy mistake number 1. The v(0) should be a v(1). v(0) is the name of the player. We need the planet name (2nd wild card - hence v(1)). You say "Find planet Earth" Example says "Planet coordinates are 0:0:0" Mark_Farrell smiles. JetFire smiles Creg_Kross nods. Plant smiles/nods Example(#14199vI) Owner: Mark_Farrell Credits: 1 Status: Thing Org: None(#-1) Type: Thing Flags: visible inherit Lock:Mark_Farrell(#16055PeoIqFct) Va:!* says "Nav heading from * to *":"The heading is Xa:Earth 0:0:0 Beowulf 90:34:90 Vb:!* says "find planet *":"Planet coordinates are [lookin(v(xa),v(1),1)] Home: Ready Room Location: Carlin Auditorium Plant whispers something to Norm. You say "Find planet Beowulf" Example says "Planet coordinates are 90:34:90" Norm whispers something to Plant. You say "And so on. I have only put two places into xa, so only those two will be found." Plant whispers something to Norm. Norm will be idle, but will read the scroll-back. Rusty wonders if Mark is logging this... You say "From a safe coding point of view, we need to be able to trap error conditions - such as missing planets, or worse, someone saying 'Find Planet 0:0:0'" Mark_Farrell nods. You say "Find planet 0:0:0" Example says "Planet coordinates are Beowulf" You say "If we later come to use 'Beowulf' where we are expecting a 3 digit bearing, elevation and range, we obviously have a problem." You say "One of the easiest solutions to this class of problem when you are using lookin() is to add a known character to the start of each item you want to match." You say "Instead of having 'Earth 0:0:0 Beowulf 90:34:90' in xa, we could have put something like: '>Earth 0:0:0 >Beowulf 90:34:90'" You say "And then in the lookin() we have to prefix v(1) with a '>' so that we can only then match valid planet names," Mark_Farrell modifies the code to do this - read 'help strcat()' I don't see examplee here. Example(#14199vI) Owner: Mark_Farrell Credits: 1 Status: Thing Org: None(#-1) Type: Thing Flags: visible inherit Lock:Mark_Farrell(#16055PeoIqFct) Va:!* says "Nav heading from * to *":"The heading is Vb:!* says "find planet *":"Planet coordinates are [lookin(v(xa),strcat(>,v(1)),1)] Xa:>Earth 0:0:0 >Beowulf 90:34:90 Home: Ready Room Location: Carlin Auditorium You say "The lookin has become lookin(v(xa),strcat(>,v(1)),1), and with the changes to xa:" You say "Find planet earth" Example says "Planet coordinates are 0:0:0" You say "Find planet beowulf" Example says "Planet coordinates are 90:34:90" You say "Find planet 0:0:0" Example says "Planet coordinates are" You say "So, we have removed the capability for the lookin to match the coordinates." You say "We have another case to deal with though - that of multiple word names." Maniatis has arrived. Maniatis enters from the Quad. You say "Take for example, Shiralea VI, or Alpha Centauri." JetFire nods Maniatis leaves the Auditorium. Maniatis has left. You say "Because lookin() is essentially a wrapper around extract() and member(), we have the limitations of member() to deal with." Creg_Kross nods. You say "In short - member() will match a single word against a list of words. We require matching a phrase against a list of phrases." You say "Now, we could use the set of functions for handling a delimited list - if you check help functions though, you will see that there are all double starred - indicating they are very time consuming for the muse." You say "Hence, we will use a neat trick to turn our 'phrase' in to a 'word'" Creg_Kross smiles ... You say "If we 'edit(v(1),spc(1),_)', we can turn all the spaces in v(1) into underscores." You say "So, Alpha Centauri would become Alpha_Centauri" You say "This 'trick' is so widespread, that there is a sorter form for the edit() - called put_()" JetFire grins You say "The following are identical in function: 'edit(the phrase,spc(1),_)' and 'put_(the phrase)'" You say "The corresponding reversals - 'edit(The_Underscored_Phrase,_,spc(1))' and 'de_(The_Underscored_Phrase)" You say "Can be used to go back the other way." You say "To keep the code neat, I'll use put_(). The list in xa is going to have the planet names in there with _'s instead of spaces." Example(#14199vI) Owner: Mark_Farrell Credits: 1 Status: Thing Org: None(#-1) Type: Thing Flags: visible inherit Lock:Mark_Farrell(#16055PeoIqFct) Va:!* says "Nav heading from * to *":"The heading is Vb:!* says "find planet *":"Planet coordinates are [lookin(v(xa),strcat(>,put_(v(1))),1)] Xa:>Earth 0:0:0 >Beowulf 90:34:90 >Alpha_Centauri 294:-30:251931 Home: Ready Room Location: Carlin Auditorium Mark_Farrell adds Alpha Centauri to the example. You say "Find planet Alpha Centauri" Example says "Planet coordinates are 294:-30:251931" You say "Notice also that:" You say "Find planet Alpha_Centauri" Example says "Planet coordinates are 294:-30:251931" You say "Works too. Now this is hopefully what you'd expect." You say "Now. Lets move on from that a little. Wouldn't it be nice if we could have the code match an abbreviation of a planet name." You say "Find planet Alpha" Example says "Planet coordinates are" You say "for this we need to do a wildcard match, instead of the 'member' that lookin() gives us." You say "There is a function (isn't there always) that does what we want - namely wlookin()." wlookin(,,) Arguments: 3 Type: String Searches for a case-insensitive, wildcard match of in , and if it exists, returns the word offset by in . Basically, the same as lookin, except it allows wildcards in . Example: wlookin(Engineering va Bridge vb Lounge vc,Eng*,1)= va * See also: lookin(), lookup(), wlookup(), extract(), match(), arrays JetFire snickers You say "Now - if we are going to allow wildcards, we need to put a * onto the end of the planet name before we do the wlookin()." Plant has disconnected. You say "We have a choice here - either we can nest another strcat() around the existing one, or use an alternative method for producing a concatanated string." Plant has connected. You say "Since nesting strcat(strcat(>,put_(v(1))),*) looks a little ugly, and gets more so if we add more things to it - let me show you the other technique." You say "If we use s(), we can do something like s(>*)" You say "If we use s(), we can do something like s(>[put_(v(1))]*)" You say "For more complex examples, the use of s() in this way can be very efficient." Teeki has disconnected. You say "If we need to concatanate the results of a lot of functions, then you get an increasingly ugly nesting of strcat(), or something like s([string(-,78)]%%r[cjust(The big title,78)]%%r[string(-,78)]), whoch prints two lines of 79 '-'s with the big t itle centered between them." Mark_Farrell changes the example code... You say "Okay - things to notice are the use of square brackets here." You say "The S() function basically reparses the argument, as if it had passed through the queue. So, what we have to do for the parser, is tell it that put_() is a function." You say "Hence, the brackets: s(>[put_(v(1))]*)" Teeki whispers something to Rusty. Mark_Farrell diverges slightly. "There are only two cases where you don't need brackets. The first is for a function dorectly after the first = sign. You paged Alison with "that's free too. Just try to catch me around between about 2pm and 5pm EST during the week.". You say "Something like '@pe %#=put_(The string)'" Alison slowly makes her way out of the hall You say "The other, is for a function before the first equals sign." Alison leaves the Auditorium. Alison has left. You say "I always recommend that you put them in, even though they are optional." You say "Anyway, back to the code..." Example(#14199vI) Owner: Mark_Farrell Credits: 1 Status: Thing Org: None(#-1) Type: Thing Flags: visible inherit Lock:Mark_Farrell(#16055PeoIqFct) Va:!* says "Nav heading from * to *":"The heading is Vb:!* says "find planet *":"Planet coordinates are [wlookin(v(xa),s(>[put_(v(1))]*),1)] Xa:>Earth 0:0:0 >Beowulf 90:34:90 >Alpha_Centauri 294:-30:251931 Home: Ready Room Location: Carlin Auditorium You say "I'm going at a fair pace - any questions, or have I lost everyone already?" Creg_Kross smiles ... Attached to Federation . JetFire smiles "i'm keeping up okay" Creg_Kross thinks he needs to read through the log .. but he's keeping up ok ... You say "Okay... Let me demonstrate the wlookin() function, and check I have the code right before we move on." You say "Find planet Alpha" Example says "Planet coordinates are >Earth" Mark_Farrell now gets to examine the code to find out why it returned 'Earth' JetFire frowns at the v(1) You say "Okay. One of the techniques to use when an object doesn't do what you expect, is to set it 'dark' and 'puppet'. This puts it into a verbose debugging mode, where it echos the commands it does back to the owner." Teeki whispers something to Rusty. Flag set. Flag set. Rusty whispers something to Teeki. Teeki leaves the Auditorium. Teeki has left. Rusty goes home. Rusty has left. You say "Find planet Alpha" Example>> "Planet coordinates are >Earth Example> You say "Planet coordinates are >Earth" Example says "Planet coordinates are >Earth" Creg_Kross grins ... Mark_Farrell smiles. "Okay. Having set it dark and puppet, it ecohed to me: You say "Example>> "Planet coordinates are >Earth" You say "Example> You say "Planet coordinates are >Earth"" You say "Obviously this hasn't shown us very much of the internal goings on of the wlookin() function." You say "The next thing we can check is to see what the s() is giving us back." You say "The easiest way is to code a quick test function." Example(#14199pDvI) Owner: Mark_Farrell Credits: 1 Status: Thing Org: Federation (#7479) Type: Thing Flags: puppet dark visible inherit Lock:Mark_Farrell(#16055PeoIqFct) Va:!* says "Nav heading from * to *":"The heading is Vb:!* says "find planet *":"Planet coordinates are [wlookin(v(xa),s(>[put_(v(1))]*),1)] Xa:>Earth 0:0:0 >Beowulf 90:34:90 >Alpha_Centauri 294:-30:251931 Vc:!* says "TEST *":@pe %#= Home: Ready Room Location: Carlin Auditorium You say "Okay - take a look at example/vc" You say "We've basically isolated the section of code that we think is causing the problem and put together a little test." Vc:!* says "TEST *":"[s(>[put_(v(1))]*)] You say "TEST Alpha" Example>> ">Alpha* Example> You say ">Alpha*" Example says ">Alpha*" You say "Okay - so that seems to work okay too." You say "What we do next varies, but is either a case of trial and error, or systematic bug tracking." Mark_Farrell just loves it when a lecture goes horribly wrong :-) JetFire nods Creg_Kross grins ... You say "Okay. Let's take off the '*' from the wlookin() to try to move back a step in the development." You say "If we step back enough, then eventually, it will work, and we will be able to work on the specific problem." You say "This is why I like to test things as I go along. It can be _very_ taxing to trace problems then you have something like the code I showed you at the start, and there is something subtle/not so subtle wrong." Vb:!* says "find planet *":"Planet coordinates are [wlookin(v(xa),s(>[put_(v(1))]),1)] You say "Find planet Alpha Centauri" Example>> "Planet coordinates are >Earth Example> You say "Planet coordinates are >Earth" Example says "Planet coordinates are >Earth" wlookin(,,) Arguments: 3 Type: String Searches for a case-insensitive, wildcard match of in , and if it exists, returns the word offset by in . Basically, the same as lookin, except it allows wildcards in . Example: wlookin(Engineering va Bridge vb Lounge vc,Eng*,1)= va * See also: lookin(), lookup(), wlookup(), extract(), match(), arrays You say "Okay. So the '*' at the end isn't the problem." You say "Find planet Beowulf" Example>> "Planet coordinates are >Earth Example> You say "Planet coordinates are >Earth" Example says "Planet coordinates are >Earth" You say "Okay - so it looks like the culprit is wlookin() itself." Mark_Farrell moves back to lookin() to check that hypothesis. You say "Find planet Beowulf" Example>> "Planet coordinates are 90:34:90 Example> You say "Planet coordinates are 90:34:90" Example says "Planet coordinates are 90:34:90" JetFire says "ummm missing a ) i think" Mark_Farrell doesn't see one, but is willing to look again. Example(#14199pDvI) Owner: Mark_Farrell Credits: 1 Status: Thing Org: Federation (#7479) Type: Thing Flags: puppet dark visible inherit Lock:Mark_Farrell(#16055PeoIqFct) Va:!* says "Nav heading from * to *":"The heading is Vb:!* says "find planet *":"Planet coordinates are [lookin(v(xa),s(>[put_(v(1))]),1)] Xa:>Earth 0:0:0 >Beowulf 90:34:90 >Alpha_Centauri 294:-30:251931 Home: Ready Room Location: Carlin Auditorium JetFire can't see em very weel thou Creg_Kross can't see one either .... You say "Find planet Alpha Centauri" Example>> "Planet coordinates are Example> You say "Planet coordinates are" Example says "Planet coordinates are" Norm leaves the Auditorium. Norm has left. You say "Okay. lookin() doesn't like the trailing '*' and either wlookin() is broken, or I'm missing something obvious. (I hope it's not the latter ;-) )" JetFire grins and looks at mark's clock You say "Lets carry on from having the command match a full, multi-word name." You say "What we need now is to develop the function further, so that it can recognize of the planet name is not a name, but a set of coordinates." You say "I'm moving towards having a function that we can use in the nav heading code to give us coordinates for the calculations we will need to do." You say "We have seen already that if the name of the planet isn't found in the list, that an empty string is returned." Saving TrekMUSE DataBase. Response will be slow for a few minutes. Chris_Semos has arrived. Chris_Semos enters from the Quad. Chris_Semos smiles and takes a seat in the back. You say "We can use this fact to provide either an ifelse() switch, or another switching technique." You say "Now, I'm fairly fond of using something like:" You say "> first(s( the defaults))" You say "> first(s([lookin(......)] [the defaults]))" You say "So, if you follow it through from the inside out, if the lookin() returns nothing, then the 'first' of the result is going to be the defaults." You say "Otherwise, it'll be the thing we looked up from the table." You say "Other ways of coding this vary - we could have done it as:" You say "> ifelse(lookin(.....),lookin(....),defaults)" You say "Now - the ifelse case means that we have done two lookins instead of the one before." You say "An objective of good coding is to reduce the function count." You say "And even more so, the @command count." Mark_Farrell details a little bit of information about ifelse(). You say "I expect that you all think that ifelse() does exactly that - it only does the code for one or other of the cases - either the true case or the false case." You say "In actuality, because of the way in which the parser works, it does _both_ cases, and then throws away one of the results." Drynthre has arrived. Drynthre enters from the Quad. Drynthre leaves the Auditorium. Drynthre has left. Mark_Farrell introduces an important trick for advanced coders. You say "To do either/or, you use a construct like: s(ifelse(condition,{[true-case},{false-case}))" You say "To do either/or, you use a construct like: s(ifelse(condition,{[true-case]},{[false-case]}))" Mark_Farrell fights the parser for square brackets, but gets it right the second time. JetFire grins You say "It is more cumbersome to work with, and you generally will not have much call to use it unless you code a heavily used object, or both the true and false functions are very very complex/time consuming." Mark_Farrell has covered this trick in another lecture, and doubtless will cover it again at a later date. You say "Okay. going back to the insertion of the defaults." I don't see example.vb here. Vb:!* says "find planet *":"Planet coordinates are [lookin(v(xa),s(>[put_(v(1))]),1)] You say "Find planet 4:20:400000" Example>> "Planet coordinates are 4:20:400000 Example> You say "Planet coordinates are 4:20:400000" Example says "Planet coordinates are 4:20:400000" You say "Take a look at example/vb" Example(#14199pDvI) Owner: Mark_Farrell Credits: 1 Status: Thing Org: Federation (#7479) Type: Thing Flags: puppet dark visible inherit Lock:Mark_Farrell(#16055PeoIqFct) Va:!* says "Nav heading from * to *":"The heading is Xa:>Earth 0:0:0 >Beowulf 90:34:90 >Alpha_Centauri 294:-30:251931 Vb:!* says "find planet *":"Planet coordinates are [first(s([lookin(v(xa),s(>[put_(v(1))]),1)] [edit(v(1),spc(1),:)]))] Home: Ready Room Location: Carlin Auditorium You say "what I've done here is to use the first(s()) technique, along with the edit() function to produce the desired output. What we would probably do if we had some more time this week is to expand on the defaults code - just the edit(v(1),spc(1),:) - and get it to check that the user supplied a 3 digit input." You say "So, we'd use something like ifelse(eq((words(v(1)),3),....,....)" You say "And possibly check that each arguement is actually a number." You say "However, as I have another meeting to go to, I'm afraid that we are going to have to call it a night at this point." You say "I hope that you have found this lecture useful, and informative - and that it's shown you some of the 'tricks of the trade'" Plant noddies Creg_Kross nods. "Thank you." Plants Majic Box has arrived. Plant dropped Plants Majic Box. JetFire bows to your knowlage :) Plant will now kick his still not working box :) Plant kicks his box You say "The log will be available in a day or so's time, and will be sent out be email request, as usual. I have a growing list of accounts in the distribution list, and make a note in your +mail/email request that you want to be added (if you do, of cou rse)." Creg_Kross grins at Plants new method of coding .. Example has left. Plant grrs Chris_Semos stands up. JetFire says "Thank you Mark :)" Plant stands up Creg_Kross stands up ... Plant says "thanks mark.." Creg_Kross stretches ... Mark_Farrell checks his watch. "I must dash. Thankyou all for attending. Having a good audience makes staying up late (2am) worthwhile." Mark_Farrell waves. The doors part allowing you to leave.