Magsbot Class, Session 4
Saturday March 18, 2006 6pm VRT

Sohraiyah:    Hyas Sylsea
Sylsea:    Saturday comes around so fast now :-)
Sohraiyah:    how do ye get enhanced aw?
Magine:    afternoon, all :)
Sohraiyah:    Hello Magine
Sylsea:    Hi  Magine :-)
Magine:    how is everyone today?
Sohraiyah:    I am good, You?
Magine:    pretty good
Sylsea:    doing ok, thanks, Magine, thanks
Chanes:    doing well, magine.. thanks
Magine:    so...any questions left over from last time?
Sohraiyah:    mags rename Shirynah
[Jarvis]:    hi
Chanes:    no, not really Magine....
Keshi:    hello all
Chanes:    but you know me... hehe
Sylsea:    not at this time, Magine
Chanes:    button pusher that i am
Sohraiyah:    Hello Keshi
Magine:    hi keshi
Draco.:    good morning
Keshi:    Smiles  good to see you all
Keshi:     Hiya  Draco
Sylsea:    Hi Draco
Sylsea:    Hi Keshi
Chanes:    hav eyour coffee, D?
Chanes:    hhe
Draco.:    noooo..
Draco.:    still recovering from alarm going off
Magine:    me too :D
Chanes:    LOL
Draco.:    hehe
Chanes:    [_]D for you both
Sohraiyah:    Shirynah stay
Sohraiyah:    Been reading class notes from all her courses, i feel lost ... hope today will help me alot
Sylsea:    thanks
Magine:    what part are you lost about, sohraiyah?
Sohraiyah:    *chuckles & hides face* just about all of it ... newb to programming fully
Magine:    well there is a question i should ask: how many of you have any programming experience, and how much?
Magine:    it's not required, i just want to get an idea....
Sohraiyah:    I have none, I am a techie, but the building pcs part ... not developer part
Chanes:    none
Sylsea:    none
Magine:    you all understand basic concepts like what a variable is, and that sort of thing?
Chanes:    yes
Sylsea:    yes
Draco.:    yea
Keshi:    yep
Sohraiyah:    no, but i can read up on that at my leisure, this is program class, i wish not to take away from those that have been here since day one
Magine:    well, i find things are usually easiest to understand with an example, so let's start with an example
Magine:    i was just playing around before class, adding a few buttons to the Movement tab
Magine:    so we can talk about those
Draco.:    oh cool, huh Chanes?
Chanes:    oh cool
Chanes:    LOL D
Draco.:    lol
Chanes:    more buttons
Chanes:    hehe
Magine:    oh btw let's walk over to the fountain area behind the tower, nicer than standing in the road here :D
Sohraiyah:    shirynah follow
Magine:    ok....first off,  let me talk about how buttons can be used as functions
Magine:    you all have an idea of what a function is, in programming?
Chanes:    yes
Sohraiyah:    that i understand at least
Sylsea:    yes
Keshi:    yes
Magine:    it's a subroutine that returns a result, a number or a string of characters
Magine:    and the buttons can be used for that purpose in magsbot
Chanes:    correct
Magine:    the simplest way is the CLICKBTN command
Magine:    that command activates the specified button, like CLICKBTN "Follow - Stop" would have the same effect as if you had clicked the Follwo - Stop button
Magine:    when you use the CLICKBTN command, any variables that you have created beforehand, will be passed into the button, and any variables changed or created in the button will be passed back out
Magine:    actually i should probably say something about the different kinds of variables in magsbot before i continue
Magine:    we already talked about the global variables, that you can see by pressing ctrl-F3
Magine:    those are called "global" because they can be seen from anyplace within magsbot, any code that you write
Magine:    but there are also "local" variables that can only be used within a particular piece of code that you write
Magine:    a local variable list is created for each event that takes place, or each time you click a button
Magine:    and that list is destroyed after the event has been handled, or after the code in the button has completed
Magine:    you assign a value to a local variable with a command like
Magine:    @x=12
Magine:    or $z="this is an example"
Magine:    you can assign a value to a global variable similarly, like
Magine:    @@x=12
Magine:    or
Magine:    $$z="this is an example"
Magine:    the double @@ or $$ indicates that you want the variable to be global
Draco.:    do you call variables created in UDF global?
Magine:    well the .udf file is something entirely different...those are macros, not variables
Magine:    we will get to that in a later class, but basically the code in the .udf file just lets you subsitute a simpler bit of code for something more complicated
Magine:    but yes, macros are global in scope
Draco.:    yes... but you cant use something like @date as a variable is what I was getting at
Magine:    you can use it like that, but it is a macro and not a variable  :)
Magine:    a variable is really a location in memory where you store some value
Magine:    a macro on the other hand, is something that replaces something else
Magine:    so if you wrote some code like $$x="here is a string"
Magine:    then $x would become a global variable, and you could see it in the list by pressing ctrl-F3,
Magine:    and you could access that variable from any code in the program
Magine:    but if you put $x="here is a string" in the .udf file
Magine:    it would not be stored as a variable, and even though it could be used anywhere in your code, you couldn't change it
Draco.:    that was the part i was getting at ;)
Magine:    rather, whenever you used the $x macro in your code, the $x would be replaced by the "here is a string" before the code was executed
Magine:    we can go into more detail about the .udf file and macros in another session
Magine:    let's do something to illiustrate the difference between global and local variables
Magine:    press F5 and type $$myglobal="whatever text you want to put here"
Magine:    and hit Ok
Magine:    now press ctrl-F3, and you will see $myglobal in the list
Magine:    and then, press F3 and type $myglobal
Magine:    you will see the result in the log window
Magine:    everyone done with that?
Sohraiyah:    Hey it worked
Keshi:    yes
Chanes:    no
Sylsea:    yes
Magine:    say when, chanes :)
Draco.:    Chanes needs an F3 button to push
Sylsea:    so we "evaluated an expression" via f3
Chanes:    aw shaddup
Draco.:    hehehe
Chanes:    no, was dealing with my kids.. so lagging behind a little
Chanes:    done now
Magine:    right, F3 is like a little calculator you can use
Magine:    ok, now by comparison,
Magine:    press F5 again (and select and delete the stuff in there from before) and type:
Magine:    $mylocal="some other text";  report "global="+$myglobal; report "local="+$mylocal
Magine:    when you click Ok, you should see global=some text and local=some other text in the chat window
[Duckey]:    yes
Sylsea:    cool
Magine:    then press F3 and the $myglobal should still be there, so just press enter, to see that the global is still there :D
Sylsea:    yes
Magine:    but then, press F3 once more, and this time type $mylocal....and see what happens
Keshi:    hmm
Sylsea:    yep
Magine:    you will get an error, because $mylocal only exists temporarily, within the command that you typed in the command window (F5)
Magine:    does that make sense to everyone?
Draco.:    yea
Magine:    ok, now let's try some examples of that same sort, but using buttons
Magine:    did you create a new tab for your test buttons, in a previous class?
[Duckey]:    oooh, buttons
Keshi:    hmm
Sylsea:    yes
Keshi:     ok i din't gget it to  work  but i understand it
Magine:    well try to get it to work now :D
Magine:    right click on the Actions tab, choose Category>Add
Keshi:    oh  the button i have
Magine:    oh you mean you didn't get the example we just did to work?
Keshi:     i ment  stuff we  just did
Magine:    what happened when you tried?
Keshi:    my typo  messed it up
Sohraiyah:    ok created Project Tab
[Duckey]:    i can't right click on the tab.. won't work
[Duckey]:    and i did make a tab, but doesn't appear now
Keshi:    got my button for testing  ready
Magine:    you made it the other day?
[Duckey]:    2 weeks ago
Magine:    if there are no buttons in a tab, magsbot doesn't save the tab
[Duckey]:    oh, then taht's why
Magine:    so try to create it again now
Draco.:    oh oh... wow do you space buttons farther appart? I did by accident once and canrt remember how
Draco.:    how*
Magine:    if you drag the actions panel out to a separate window and then dock it again, the buttons will respace themselves so the largest name will fit
Draco.:    ohhh... cool! ty
Magine:    ok, so do you all remember how to add a button?
Magine:    either right click and choose New, or else just press the Ins key
Keshi:    okj
Magine:    so let's add a button called GlobalTest
Magine:    and in the button, lets type  REPORT $myglobal
Magine:    and i'm sure you can all guess what happens when you click that :D
Sylsea:    hehe
Sohraiyah:    *smilin*
Magine:    but, you can also call the button as a function
Magine:    so once you have that button made (and click it to test that it works)
Immigration Officer:    You are being joined by Poseidon.
Magine:    you can press F5 (delete whatever was left in there from before) and type CLICKBTN "GlobalTest"
Magine:    but i will warn you ahead of time....it's not going to work :D
Magine:    can anyone guess why that is?
Poseidon:    Hi Mags :)
Magine:    hi pos :)
Magine:    welcome to the class
Sohraiyah:    Because we deleted its string?
Poseidon:    Cheers
Sylsea:    hi Guri Lady, Hi Poseidon
Magine:    nope...it didn't work because we didn't say what tab the button is on
Sylsea:    oh she left
Sylsea:    oooooh
Magine:    so actually, we should have pressed F5 and  typed "Tests/GlobalTest"  (or whatever name you gave your new tab)
Magine:    when you do that, you should see the stuff you put in $myglobal again
Keshi:    oh it worked
Magine:    everyone caught up? :)
Chanes:    dang.. i'm gonna have to try later.. i've got kids all over the place... so very distracted
Chanes:    but i understand
Magine:    ok, chanes :)
Magine:    now let's try something else
Magine:    let's a create another button, called LocalTest
Magine:    and in that, put REPORT $mylocal
Magine:    then click that button...but guess, what is going to happen when you click it?
Magine:    anyone?
[Duckey]:    error...
Draco.:    has nothing assigned to it
Magine:    you'll get an error, because $mylocal doesn't exist
Sylsea:    that was not saved
Sylsea:    right
[Duckey]:    variable not found
Sohraiyah:    am i supposed to get error? I am actually getting text that i mis-entered from first mylocal one
Magine:    ah, sohrayah, you accidentally created mylocal as a global? :D
Sohraiyah:    I guess so *blush*
Magine:    sohraiyah, press ctrl-F3 and see if you can find $mylocal in there
Sohraiyah:    ok
Magine:    if you, then select it and click the Delete menu at the top of the variables window
Magine:    "if you do", i meant to say
Magine:    then click your LocalTest button and see if you get an error (you should)
Magine:    (heheh funny, helping people to get an error)
Draco.:    i dont need help for that :p
Poseidon:    ;)
Sylsea:    haha...
Sohraiyah:    got that all done, now i get nothing beside the numbers in chat window
Poseidon:    I get them all on my own
Magine:    well....anyway....now here is the instructive part :D ....press F5 again and (deleting what was in there before as always) type
[Duckey]:    i cause them all on my own
Magine:    $mylocal="some text"; CLICKBTN "Tests/LocalTest"
Magine:    and click Ok
Magine:    and what happened that time?
Sylsea:    I got my localtest button contents
Magine:    this time, there was no error...because the local variable you assigned within the F5 window, was passed into the LocalTest button using the CLICKBTN command
Sylsea:    statement
Sylsea:    ahh ok...
Sylsea:    but would one want to do this for any reason?
Magine:    of course you would! think: any code that is going to be used over and over, you can put in a button
Sylsea:    no but button part yes
Chanes:    does it matter if i put spaces in button name?
Chanes:    cuz i'm getting error
Magine:    what does the error say?
[Duckey]:    Evaluation Error: Variable not found:
Magine:    generally in magsbot, if you use spaces in a name, then you need to put quotes around the name
[Duckey]:    in button Bot Class/Local Test
Sylsea:    but if, in this instance, the $mylocal doesn't exist if you use CLICKBTN w/out pujtting $mylocal in as we did now...does this statement serve a purpose if we already have the button?
Sylsea:    not sure I'm explaining that right
Magine:    i'm not sure what you're asking sylsea...
Sylsea:    first you had us try CLICKBTN $mylocal
Sylsea:    and it didn't work
Sylsea:    even tho the button existed
Sylsea:    then you had us put $mylocal first
Sylsea:    and it worked
Magine:    nope
Sylsea:    ok
Magine:    i never said CLICKBTN $mylocal
Magine:    i said CLICKBTN "Tests/LocalTest"
Sylsea:    ok that was it
Sylsea:    but it didn't work if I recall
Magine:    you are calling the LocalTest button, and passing the $mylocal variable into it
Sylsea:    lost the thread now haha..would have to go back
Magine:    no....what didn't work was when we put CLICKBTN "LocalTest" or CLICKBTN "GlobalTest"
Sylsea:    ok
Sylsea:    then we did the $mylocal....CLICKBTN
Magine:    maybe i should not have done that at the time, because that had nothing to do with variables
Draco.:    could make $mylocal="Tests/LocalTest"   hehe
Sylsea:    no worries
Sylsea:    we can move on
Keshi:    'well i am  lost to  see the purpose other than  to see if your  local variable is written in a  readible way   so  um  maybe you can enlighten us
Magine:    i shouldn't have told you to do CLICKBTN "GlobalTest"....which resulted in an error only because we didn't include the whole path to the button, like CLICKBTN "Tests/GlobalTest"
Magine:    which was an entirely different issue, unrelated to variables
Sylsea:    yes, I understood we were missing the tab...
Magine:    that only had to do with button names....so i probably should not have done that just then, confused the issue, sorry
Sylsea:    hehe no, it's probably me...trying not to have coffee today haha
Magine:    what i'm trying to show here, is that when you use the CLICKBTN command, whatever local variables you have defined will be available inside the button
Sylsea:    got it, thanks
Magine:    (to Poseidon) later :)
Magine:    so if you just click the LocalTest button, you get a "varialbe not found" error because there is no $mylocal defined
Magine:    but if you call LocalTest from the command window, after first assigning $mylocal, then the LocalTest button does not have an error
Magine:    because it got the $mylocal from the command window
Sylsea:    got it
Magine:    i dunno....did i clear that up for everyone? or have i hopelessly confused everyone? :D
Sohraiyah:     [12135328] Error in Action Button: Invalid variant type is the the right error?
Magine:    (to Sohraiyah) nope
Draco.:    where should CLICKBTN be used rather than FTN?
Magine:    well i'm trying to do this one step at a time, draco :D
Magine:    brb
Sylsea:    no no, it's clear
Draco.:    ok, sorry
Sylsea:    the rest is just a matter of various uses
Chanes:    no, it's clear.. or will be when i play with it more.. i have basic understanding
Keshi:    ok so  we just have to remember  make sure the local variable is present  before we try to use it
Keshi:    i mean  presently  defined
Magine:    yes
Guri Lady:    sorry I'm late, Magine.  Hello everyone. :)
Chanes:    hiya GL
Magine:    hi guri :)
Draco.:    hugs Guri
Keshi:    hi  Guri   Hugs
Magine:    let's now add another button, named CallLocalTest
Guri Lady:    *hugs to all*
Magine:    and in it put
Magine:    $mylocal="something or other"; CLICKBTN "LocalTest"
Sylsea:    wb Guri Lady :-)
Guri Lady:    Thanks, Sylsea. :)
Magine:    then click the new button, the CallLocalTest button
Magine:    so, this is basically the same as we did in the command window, only this time the CallLocalTest button is using CLICKBTN to call LocalTest
Magine:    and $mylocal is define in CallLocalTest so there is no error
Magine:    i hope :)
Magine:    everyone do that?
Sohraiyah:    I did, but looks like ill have to fiddle with it after class to fix my first error
Keshi:    i got an error let me look for typos
Chanes:    me too raiyah
Chanes:    lol
Magine:    ok...hopefully the log will help, sohraiyah
Sohraiyah:    It should *smiles*
Sohraiyah:    Ill just redo everything from begin
Chanes:    me too.  hehe
Chanes:    my kids are driving me nuts
Chanes:    LOL
Magine:    well i dont want to rush on if the majority are scratching their heads and counting on understanding it from the log later :D
Guri Lady:    hehe
Sohraiyah:    mine was do to that first mistake i made, not your lesson ... my own error
Chanes:    no, i got this part.. it's just the actual DOING it Magine.. i keep hopping up and handling kids.. then sitting back down
Sylsea:    yes, it was saved from before
Magine:    people....i'm getting a lot of whispers here....
Magine:    i'd prefer if people asked questions out loud, i can't follow 3 converstations at once
Magine:    one is hard enough :D
Sylsea:    b-b-but..you're Superwoman, aren't you??
Magine:    :P
Guri Lady:    lol
Sylsea:    *chuckles*
Magine:    in regards to a whispered question....any changes you make [to buttons] are not saved until you exit magsbot, or save the changes deliberately
Magine:    F7 to save button changes
Magine:    so.. is everyone...or anyone...caught up?
Magine:    you should have a CallLocalTest button with this in it:
Keshi:    well  minenot  working
Draco.:    yea
Magine:    $mylocal="some text"; CLICKBTN "LocalTest"
Magine:    and clicking it will of course show "some text"
Magine:    what is the problem keshi? what's it doing?
Keshi:    it  is not  keeping what i  put in the button
Magine:    when you edit the button, you click OK when done?
Guri Lady:    *quickly reads the chat and makes a button...*  *Hair starts to stand straight up off her head...making her look crazier...*
Magine:    if you press Esc when editing, it will discard any changes, so
Magine:    ok, well i'll hope for the best and move on :D
Magine:    you should see how local variables are passed in
Magine:    but they are also passed back out...
Magine:    let's add anothe button, LocalTest2
Magine:    and in that,put:
Magine:    REPORT "IN LocalTest2: "+$mylocal; $mylocal="something new";
Magine:    and add one more button, CallLocalTest2, and in that put
Magine:    $mylocal="something or other"; CLICKBTN "LocalTest2"; report "AFTER LocalTest2: "+$mylocal
Magine:    and then click CallLocalTest2 ...what happens?
Magine:    anyone?
Magine:    problems?
Magine:    everyone died from shock!
Chanes:    poop...
Draco.:    lol
Chanes:    must be cuz i didn't complete the local one yet, as my kids made me get up
Magine:    heheh
Magine:    people with squealing children are excepted, heheh
Chanes:    lol
Chanes:    phew
Magine:    any other survivors here?
Draco.:    yep
Sylsea:    trying to see why I'm getting an error..
Draco.:    even almost got coffee
Magine:    feel free to cut and paste that code, if you are having typo problems
Sohraiyah:    I get dual report from clicking on calllocaltest2 button
Draco.:    yay!
Magine:    sohraiyah, good, that's just what you should get
Sohraiyah:    OMG i did that right?
Draco.:    woohoo Raiyah
Magine:    when you click CallLocalTest2, you should see two different strings...
Keshi:    hm  i get  no  local variable
Magine:    showing that when $mylocal was changed in LocalTest2, the changes were passed back out again
Chanes:    lol Raiyah
Magine:    hopefully that will make sense :)
Keshi:    i must not e  defining the  local variable right
Magine:    what's happening keshi?
Keshi:    the  results
Magine:    what are the results?
Keshi:    just  say
Keshi:    IN Localtest2;   and   AFTER  Localtest2:
Keshi:    IN Localtest2:  but no variable      and   AFTER  Localtest2:
Magine:    right
Magine:    what do you have in LocalTest2, exactly?
Magine:    i think i know what happened, but tell me so i can be sure...
Sohraiyah:    REPORT "IN LocalTest2: "+$mylocal; $mylocal="something new"; is what i added
Magine:    hmmm
Keshi:    ut oh
Keshi:    REPORT "IN Localtest2: ";$mylocal="something new"
Keshi:    noi semicolon at end
Magine:    that's what i figured
Magine:    you need to end every command with a semicolon
Magine:    and no extra spaces, so:
Magine:    REPORT "IN LocalTest2:" + $mylocal    << would be wrong
Magine:    REPORT "IN LocalTest2:"+$mylocal    << would be right
Magine:    and BTW carriage returns between commands are ignored
Magine:    so
Magine:    command1; command2
Magine:    is the same as
Magine:    command1;
Magine:    command2
Sohraiyah:    I get this when i press the localtest2 button  [12135328] Evaluation Error: Variable not found
Sohraiyah:     [12135328] "IN LocalTest2:"+$mylocal
Sohraiyah:     [12135328]  in button Project/LocalTest
Magine:    what do you have in CallLocalTest2 ?
Magine:    should be:
Magine:    $mylocal="something or other"; CLICKBTN "LocalTest2"; REPORT "AFTER LocalTest2: "+$mylocal
Magine:    i'm betting you missed a semicolon between "something or other" and CLCIKBTN
Guri Lady:    I got that
Guri Lady:    I made sure I copy pasted hehe
Chanes:    ok, Magine.. I'm sorry.. but I have to leave.. i'll stay to get logs tho
Draco.:    *passes out cups of fresh coffee*
Chanes:    my most profuse apologies
Magine:    ok, so how does CallLocalTest2 work now?
Guri Lady:    Bye, Chanes
Magine:    ok chanes, thanks for coming :)
Magine:    np, i understand :)
Magine:    how is everyone doing?
Guri Lady:    Thanks for the coffee, Draco
Guri Lady:    I'm caught up :)
Keshi:    Alright i got it to  work   yippie
Guri Lady:    yay
Sylsea:    :-(
Magine:    ready for another one? :D
Keshi:    haha  sure  am on a roll
Guri Lady:    I am.. ut-oh Sylsea
Magine:    what's happeneing sylsea?
Sylsea:    goodness knows...I deleted my test tab by accident, so had to rebuild everything
Magine:    oops
Guri Lady:    Ohh
Sylsea:    but, those call buttons..I'm getting errors
Magine:    what kind of errors?
Sylsea:    variable not found
Magine:    well yeah some of them will do that
Magine:    oh, the CALL buttons?
Sylsea:    yes, the actual buttons
Magine:    not the TEST buttons?
Sylsea:    the test buttons
Magine:    LocalTest and LocalTest2 will cause errors when clicked
Sylsea:    CallLocalTest and test2
Sylsea:    and the LocalTest
Magine:    CallLocalTest and CallLocalTest2 should not cause errors
Sylsea:    I must've missed a step somewhere, but I keep going back to where you had us create each button and what you told us to put in them..
Sylsea:    so I'm not sure where I skipped
Sylsea:    I do cut and paste yes
Sylsea:    I'll figure out later
Sylsea:    we can go on
Sohraiyah:    OMG *really red faced now* So my new buttons are working right ... so sad
Magine:    quick summary, you can cut and paste:
Magine:    LocalTest:
Magine:    REPORT $mylocal
Magine:    LocalTest2:
Magine:    REPORT "IN LocalTest2: "+$mylocal; $mylocal="something new"
Magine:    CallLocalTest:
Magine:    $mylocal="something or other"; CLICKBTN "LocalTest"
Magine:    CallLocalTest2:
Magine:    $mylocal="something or other"; CLICKBTN "LocalTest2"; REPORT "AFTER LocalTest2: "+$mylocal
Magine:    GlobalTest:
Magine:    REPORT $myglobal
Magine:    that's all of them
Magine:    so far :D
Guri Lady:    hehe
Sylsea:    hmmm didn't have localtest2
Guri Lady:    Thanks for the summery.. added that chat to my notes :D
Magine:    and the LocalTest and LocalTest2 will cause errors, the CallLocalTest and CallLocalTest2 will not cause errors
Magine:    BTW button names are case sensitive, so careful about that
Magine:    if the button is CallLocalTest and you type CLICKBTN "calllocaltest" ....it won't find the button
Magine:    so, moving on.... :)     the point here is that $mylocal is changed in LocalTest2 and the changed version is passed back out
Sohraiyah:    so in this case RED means RED .. if typed that way
Magine:    with CLICKBTN, all local variables are passed in, and all are passed back out
Magine:    but there is another way to call a button as a function
Magine:    by using the FTN command instead of CLICKBTN
Magine:    with the FTN command, only the local variables that you specify are passed in
Magine:    also, the button that is called, will expect certain variables
Magine:    let's now add LocalTest3
Magine:    and in that, put:
Magine:    REPORT "IN LocalTest3: "+$mylocal; $mylocal="something new"
Magine:    also add CallLocalTest3, and in that put:
Magine:    $mylocal="something or other"; FTN "LocalTest3"; REPORT "AFTER LocalTest3: "+$mylocal
Magine:    FTN not CLICKBTN this time
Guri Lady:    okay :)
Magine:    now once you do that, click CallLocalTest3 ....don't be alarmed if there is an error :)
Magine:    so why is there an error? LocalTest3 is (so far) the same as LocalTest2, and CallLocalTest3 is the same as CallLocalTest2, except that CallLocalTest3 uses FTN instead of CLICKBTN
Draco.:    have not passed variable
Magine:    exactly
Magine:    FTN doesn't pass any variables unless you pass them explicitly, and i will show you how to do that next
Magine:    everyone keeping up so far?
Keshi:    yes
Sohraiyah:    yes
Magine:    ok, so in order to pass a variable in, or actually, to pass a value in, we just add the variable to the FTN command
Guri Lady:    yep
Magine:    so we can change CallLocalTest3 to be:
Magine:    $mylocal="something or other"; FTN "LocalTest3" $mylocal; REPORT "AFTER LocalTest3: "+$mylocal
Magine:    you see i added $mylocal to the FTN call
Magine:    now FTN will pass $mylocal into LocalTest3, or actually, it will pass the VALUE of $mylocal
Draco.:    hehe
Keshi:    hmm
Magine:    the variable itself isn't really passed in, just whatever the variable holds
Magine:    and LocalTest3 won't really get the $mylocal variable, it will just get the value
Magine:    so you need to assign that value to a new variable for use within the LocalTest3 button
Magine:    so, we also change LocalTest3 to be:
Magine:    ARGS $mylocal; REPORT "IN LocalTest3: "+$mylocal; $mylocal="something new"
Draco.:    is it bad 'technique' to use different variable names?
Magine:    not necessarily [in fact it's usually necessary; you don't want to have to remember the variable names everytime you call a function]
Keshi:    i am  still getting errors
Magine:    yes keshi, you will still get errors when clicking CallLocalTest3
Magine:    because we are only passing the value of $mylocal to LocalTest3, and not the $mylocal variable itself
Sylsea:     but calllocaltest3 still works...
Keshi:    Ahh works now no errors
Magine:    we have to assign that value to a new variable within LocalTest3
Magine:    that is what the ARGS command does
Draco.:    not putting a semicolon after the ARGS statement will cause one to pull all their hair out
Magine:    right, don't forget them semicolons :D
Sylsea:    hey
Sylsea:    and don't forget NOT to use "REPORT" where you shouldn't
Sylsea:    <--
Magine:    the ARGS $mylocal takes the value that was passed to LocalTest3 and assigns it to a new variable that exists only within LocalTest3, and gives it (by mere coincidence) the name $mylocal
Sylsea:    that was my problem with my calllocaltest buttons
Magine:    i see, sylsea :)
Magine:    to summarize, you should now have:
Magine:    LocalTest3:
Magine:    ARGS $mylocal; REPORT "IN LocalTest3: "+$mylocal; $mylocal="something new"
Magine:    and CallLocalTest3:
Magine:    $mylocal="something or other"; FTN "LocalTest3" $mylocal; REPORT "AFTER LocalTest3: "+$mylocal
Magine:    so now the CallLocalTest3 button should work.....kind of
Magine:    but you will see a difference between the result of CallLocalTest2 and CallLocalTest3
Magine:    can you see what it is?
Guri Lady:    I got errors only.. darn.. reads the chat again
Sylsea:    3 gives you both error and answer
Magine:    um, 3 should not give an error after it is revised
Draco.:    return variable?
Guri Lady:    I have an error after revising it. :(
Guri Lady:    *trys again*
Keshi:    in 3 no error but  variable the same in and  out  but  two see  different in and out
Magine:    keshi, yes!
Keshi:    Grins big
Magine:    with CallLocalTest2, the result shows that the $mylocal variable was changed in LocalTest2
Sylsea:    hmm ok
Draco.:    wtg K!
Sylsea:    ok now
Magine:    but with CallLocalTest3, there is no change
Magine:    because LocalTest3 doesn't pass anything back, because it was called with FTN
Sylsea:    ok right
Magine:    is everyone okay with going overtime here? (we already have by 15 mins, oops)
Guri Lady:    okay it worked
Sylsea:    I'm fine
Draco.:    yep
Keshi:    Hanging in there
Sohraiyah:    im fine too
Guri Lady:    I'm okay fixed my prob :)
Magine:    let me show you something else, to clarify what i mean when i said that FTN only passes in the value, not the actual variable
Magine:    let's create LocalTest4, and in there put:
Sohraiyah:    yay mine is fixed too .... *jumps around*
Magine:    ARGS $x; REPORT "LocalTest4 received: "+$x;
Magine:    and add CallLocalTest4, with:
Magine:    $mylocal="something or other"; FTN "LocalTest4" $mylocal; REPORT "AFTER LocalTest4: "+$mylocal
Magine:    CallLocalTest4 is actually identical to CallLocalTest3, except for the button it calls
Magine:    when you add those, and click CallLocalTest4, you will get the same result as with CallLocalTest3
Magine:    the point here is that LocalTest4 assigned the name $x to the variable it was passed...not $mylocal. so that name given the variable within the button that is called, makes no difference
Sylsea:    ok
Magine:    ok....but what if you *want* to pass something back out of the button, and want to use FTN anyway so you can control what goes in?
Magine:    there are two methods, actually
Magine:    you can use the RETURNS command inside the button, to list the variables that you want to pass back out,
Magine:    or you can call the button with the @ftn or $ftn functions instead of with FTN
Magine:    should i save that til next time though? or continue now?
Guri Lady:    I'm okay to listen on..
Draco.:    me too
Magine:    ok, but brb
Guri Lady:    kk
Sylsea:    please continue
Keshi:    mee too
Sohraiyah:    *nods to agree*
Magine:    back
Guri Lady:    wb :)
Magine:    ok......more buttons :D
Magine:    i'm adding new ones instead of changing existing ones, so you'll have step-by-step examples to refer to
Keshi:    Magine?
Magine:    yes keshi?
Keshi:    I forgot  what the difference was   with  @ftn  $ftn  and  FTN
Magine:    well i haven't explained that in detail yet :)
Magine:    i'm going to show you
Keshi:    ok
Magine:    first let's see how you can simply return local variables from a button called with FTN
Magine:    so create LocalTest5 and put this in it:
Magine:    ARGS $x; REPORT "LocalTest5 received: "+$x; $z="some new string"; RETURNS $z
Magine:    and in CallLocalTest5, put
Magine:    $mylocal="something or other"; FTN "LocalTest5" $mylocal; REPORT "AFTER LocalTest5:"; report "  mylocal="+$mylocal;report "  z="+$z;
Magine:    everyone got that?
Keshi:    my buttons are working now
Sylsea:    yes
Sohraiyah:    mine works ,,, yep
Magine:    ok, one more...
Magine:    so far we've seen how to pass values in (you can pass more than one, btw) and how to pass them out (also you can pass  more than one back)
Magine:    but you can also use the $ftn and @ftn functions to call a button instead
Magine:    and return one value back
Magine:    so let's make LocalTest6 and put this in it:
Magine:    ARGS $x; REPORT "LocalTest6 received: "+$x; RETURN "some new string"
Magine:    you notice that this time, the command is RETURN and not RETURNS
Magine:    RETURNS passes back variables, but RETURN passes back a single value
Magine:    to show this, we will also create CallLocalTest6:
Magine:    $mylocal="something or other"; $r=$ftn["LocalTest6",$mylocal]; REPORT "AFTER LocalTest6:"; REPORT "  mylocal="+$mylocal;REPORT "  result="+$r
Magine:    you see it uses the $ftn function instead of FTN
Magine:    as with FTN, it passes the value of $mylocal in
Sylsea:    cool
Magine:    but the value returned by LocalTest6 is assigned here to $r
Magine:    everyone see how that works?
Guri Lady:    I think so :)
Sylsea:    yes
Sohraiyah:    yuup
Keshi:    ok
Magine:    LocalTest6 uses the RETURN command to pass back the string "some new string", which is received by CallLocalTest6 as the result of the $ftn function
Magine:    ok, just one more example for today
Guri Lady:    okay :)
Sohraiyah:    kk
Magine:    $ftn and RETURN are used for strings, but if you want to get a number, then you would use @ftn instead
Magine:    so let's add LocalTest7 and in it put:
Magine:    ARGS $x; REPORT "LocalTest7 received: "+$x; RETURN_ @len[$x]
Magine:    notice it uses RETURN_ instead of RETURN, because it passes back a number instead of a string
Magine:    the @len function = the length of a string, in this case the $x string
Magine:    then for CallLocalTest7, put
Magine:    $mylocal="something or other"; @r=@ftn["LocalTest7",$mylocal]; REPORT $fmt["LocalTest7 returned %s",@r]
Magine:    you can see it uses @ftn and assigned the value returned from LocalTest7 to @r
Magine:    the $fmt (format) function is something i haven't mentioned yet, but it is used to format strings
Magine:    the  $fmt function takes a format string ("LocalTest7 returned %s") and inserts the values of variables where ever there is a %s
Magine:    so in this case the %s will be replaced with the value of @r
Magine:    if that's confusing, we could just put this instead:
Magine:    $mylocal="something or other"; @r=@ftn["LocalTest7",$mylocal]; REPORT "LocalTest7 returned "+$str[@r]
Draco.:    need a REPORT_ :p
Magine:    well REPORT only deals with strings, so you have to convert @r to a string somehow
Magine:    in order to print it out in the log window
Magine:    either using $fmt or using $str to convert @r to a string
Magine:    any questions there?
Keshi:    nope
Magine:    anyone?
Sylsea:    now to find some practical application for these in-world haha
Guri Lady:    yea
Guri Lady:    It's soaking in hehe
Magine:    well those are very simple examples, next time we can see some more practical applications
Guri Lady:    phone call interupped me  lol
Sylsea:    ok
Draco.:    are you going to learn us how to do the equivalent of array variables someday?
Magine:    so it looks like that is it for today...i will try to get the log up by tomorrow
Keshi:    thank you Magine
Guri Lady:    Thank you so much, Magine :)   *hugs*
Magine:    draco, if you ask about it next time, i'll tell you how you can do the equivalent in magsbot
Draco.:    ok... ty :)
Sylsea:    definitely thanks...next time I'll have my coffee first...
Sohraiyah:    Thanks Magine ... this has helped some ... next time i know ill get more~~
Magine:    enjoy the rest of the day folks...hope that was not too confusing for everyone :)
Sylsea:    very helpful, thanks
Guri Lady:    You too, Magine *hugs*


Immigration Officer:    Welcome to Mags, Pop. 1
Immigration Officer:    Welcome to Mags, Pop. 2
[Pete]:    Howdy, Magine. What'll ya have?
Magine:    just water pete, thanks
[Pete]:    Coming right up, Magine.