diff --git a/scripts/v6/ch5-01-no-semi-colons.rsc b/scripts/v6/ch5-01-no-semi-colons.rsc index a251629..9351aca 100644 --- a/scripts/v6/ch5-01-no-semi-colons.rsc +++ b/scripts/v6/ch5-01-no-semi-colons.rsc @@ -4,6 +4,6 @@ :for Number from=1 to=10 do={ :local Result ($Number * $MULTIPLIER) - :put ("This is an unusually long line. Here is the result $Number times \ - $MULTIPLIER is: $Result") + :put ("This is an unusually long line. Here is the result $Number \ + times $MULTIPLIER is: $Result") } diff --git a/scripts/v6/ch5-02-semi-colons.rsc b/scripts/v6/ch5-02-semi-colons.rsc index b1b71ae..24fe7fc 100644 --- a/scripts/v6/ch5-02-semi-colons.rsc +++ b/scripts/v6/ch5-02-semi-colons.rsc @@ -4,6 +4,6 @@ :for Number from=1 to=10 do={ :local Result ($Number * $MULTIPLIER); - :put ("This is an unusually long line. Here is the result $Number times \ - $MULTIPLIER is: $Result"); -} + :put ("This is an unusually long line. Here is the result $Number \ + times $MULTIPLIER is: $Result"); +} \ No newline at end of file diff --git a/scripts/v6/ch6-03-global-scope.rsc b/scripts/v6/ch6-03-global-scope.rsc index a6c5a8a..7d05eff 100644 --- a/scripts/v6/ch6-03-global-scope.rsc +++ b/scripts/v6/ch6-03-global-scope.rsc @@ -5,6 +5,6 @@ :local GlobalScopeVar "I'm in the global scope!"; # Let's print it out -:put ("Global variable contents = $GlobalScopeVar"); +:put ("Global scope variable contents = $GlobalScopeVar"); # ---- global scope end ---- \ No newline at end of file diff --git a/scripts/v6/ch6-12-global-vars3.rsc b/scripts/v6/ch6-12-global-vars3.rsc index a1c6838..a64ad47 100644 --- a/scripts/v6/ch6-12-global-vars3.rsc +++ b/scripts/v6/ch6-12-global-vars3.rsc @@ -22,10 +22,10 @@ if ( [:typeof $WanInterfaces] != "array") do={ # Let's step through the interfaces in the array # and print out their operation status :foreach WanInterface in=$WanInterfaces do={ - :local InterfaceIndex [/interface ethernet find name=$WanInterface]; + :local InterfaceId [/interface ethernet find name=$WanInterface]; :local UpDown "down"; - if ([:interface ethernet get $InterfaceIndex]->"running") do={ + if ([:interface ethernet get $InterfaceId]->"running") do={ :set UpDown "up" } diff --git a/scripts/v6/ch8-08-while-timer.rsc b/scripts/v6/ch8-08-while-timer.rsc index fbc0959..6e2fde8 100644 --- a/scripts/v6/ch8-08-while-timer.rsc +++ b/scripts/v6/ch8-08-while-timer.rsc @@ -11,24 +11,27 @@ # define a target web site :local WebSite "www.google.com"; -# run a while loop until one minute interval expired +# run a while loop until one minute interval has expired :while ( [/system clock get time] < $EndTime ) do={ :put "Getting web page from $WebSite"; # fetch a page from web site - :local FetchResult [/tool fetch url=("https://$WebSite") mode=https \ - http-method=get as-value keep-result=no]; + :local FetchResult; + :local TimeTaken [:time { + :set FetchResult [/tool fetch url=("https://$WebSite") \ + mode=https http-method=get as-value keep-result=no]; + }]; if ($FetchResult->"status" = "finished") do={ # print out how long page retrieval took (if successful) - :local FetchDuration ($FetchResult->"duration"); - :put "Web page fetch time: $FetchDuration secs"; + :put "Web page fetch time: $TimeTaken secs"; } else={ + # print failure message if fetch failed :put "Web page fetch failed"; } # pause for 5 seconds :delay 5; - } +:put "One minute period has ended!" diff --git a/scripts/v6/ch9-01-mac-fixer.rsc b/scripts/v6/ch9-01-mac-fixer.rsc index adb5fd2..7fd52f3 100644 --- a/scripts/v6/ch9-01-mac-fixer.rsc +++ b/scripts/v6/ch9-01-mac-fixer.rsc @@ -6,8 +6,8 @@ # --- start of function --- :global MacColonRemoveFunc do={ :local TidyMac ""; - for i from=0 to=([:len $1]-1) do={ - :local TmpValue [:pick $1 $i]; + for CharNumber from=0 to=([:len $1]-1) do={ + :local TmpValue [:pick $1 $CharNumber]; :if ($TmpValue !=":") do={ :set TidyMac "$TidyMac$TmpValue" } } :return $TidyMac; diff --git a/scripts/v6/ch9-02-mutiple-args-simple.rsc b/scripts/v6/ch9-02-mutiple-args-simple.rsc index 7448233..0d086cb 100644 --- a/scripts/v6/ch9-02-mutiple-args-simple.rsc +++ b/scripts/v6/ch9-02-mutiple-args-simple.rsc @@ -23,7 +23,8 @@ } # data type checks passed, print the interface data - :put "$InterfaceName: IP address = $InterfaceIp, speed = $InterfaceSpeed"; + :put "$InterfaceName: IP address = $InterfaceIp, speed = \ + $InterfaceSpeed"; } # --- end of function --- diff --git a/scripts/v6/ch9-03-mutiple-args-array.rsc b/scripts/v6/ch9-03-mutiple-args-array.rsc index 182e600..f10e315 100644 --- a/scripts/v6/ch9-03-mutiple-args-array.rsc +++ b/scripts/v6/ch9-03-mutiple-args-array.rsc @@ -5,10 +5,12 @@ # --- start of function --- :global PrintInterfaceAttrsFunc do={ + # verify arg is correct type if ([:typeof $1] != "array") do={ :error "Function argument is not an array!"; } + # extract values from array passed as arg :local Args $1; :local InterfaceName ($Args->"ifname"); :local InterfaceSpeed ($Args->"ifspeed"); @@ -34,12 +36,13 @@ # --- end of function --- # Let's call the function with some sample values in an array -:local Args { ifname="WAN1"; ifspeed="100Mbps"; +:local Args { ifname="WAN1"; ifspeed="100Mbps"; \ ifip="192.168.99.1/24" }; $PrintInterfaceAttrsFunc $Args; # Let's call the function with some other values in an array -:set Args { ifname="ether2-LAN"; ifspeed="1000Mbps"; ifip="172.16.1.254/24" }; +:set Args { ifname="ether2-LAN"; ifspeed="1000Mbps"; \ + ifip="172.16.1.254/24" }; $PrintInterfaceAttrsFunc $Args; # Cleanup global namespace diff --git a/scripts/v6/ch9-04-create-global-func.rsc b/scripts/v6/ch9-04-create-global-func.rsc index 0c31dbd..6fc997d 100644 --- a/scripts/v6/ch9-04-create-global-func.rsc +++ b/scripts/v6/ch9-04-create-global-func.rsc @@ -6,8 +6,8 @@ # :global RemoveSpaceFunc do={ :local NewName "" - for i from=0 to=([:len $1]-1) do={ - :local Tmp [:pick $1 $i] + for CharNumber from=0 to=([:len $1]-1) do={ + :local Tmp [:pick $1 $CharNumber] :if ($Tmp !=" ") do={ :set NewName "$NewName$Tmp" } } :return $NewName diff --git a/scripts/v6/ch9-06-str-funcs-mod.rsc b/scripts/v6/ch9-06-str-funcs-mod.rsc index 76a7b51..2ea7516 100644 --- a/scripts/v6/ch9-06-str-funcs-mod.rsc +++ b/scripts/v6/ch9-06-str-funcs-mod.rsc @@ -6,8 +6,8 @@ # :global RemoveSpaceFunc do={ :local NewName "" - for i from=0 to=([:len $1]-1) do={ - :local Tmp [:pick $1 $i] + for CharNumber from=0 to=([:len $1]-1) do={ + :local Tmp [:pick $1 $CharNumber] :if ($Tmp !=" ") do={ :set NewName "$NewName$Tmp" } } :return $NewName diff --git a/scripts/v6/ch9-07-use-str-module.rsc b/scripts/v6/ch9-07-use-str-module.rsc index 3664321..cce900c 100644 --- a/scripts/v6/ch9-07-use-str-module.rsc +++ b/scripts/v6/ch9-07-use-str-module.rsc @@ -1,6 +1,6 @@ # filename: ch9-07-use-str-module.rsc -# import the functions we need and declare the function +# import the functions we need and declare the functions # names we wish to use /import "ch9-06-str-funcs-mod.rsc" :global RemoveSpaceFunc; diff --git a/scripts/v7/ch5-01-no-semi-colons.rsc b/scripts/v7/ch5-01-no-semi-colons.rsc index a251629..5ecc92c 100644 --- a/scripts/v7/ch5-01-no-semi-colons.rsc +++ b/scripts/v7/ch5-01-no-semi-colons.rsc @@ -4,6 +4,6 @@ :for Number from=1 to=10 do={ :local Result ($Number * $MULTIPLIER) - :put ("This is an unusually long line. Here is the result $Number times \ - $MULTIPLIER is: $Result") + :put ("This is an unusually long line. Here is the result \ + $Number times $MULTIPLIER is: $Result") } diff --git a/scripts/v7/ch5-02-semi-colons.rsc b/scripts/v7/ch5-02-semi-colons.rsc index b1b71ae..a8ac26d 100644 --- a/scripts/v7/ch5-02-semi-colons.rsc +++ b/scripts/v7/ch5-02-semi-colons.rsc @@ -4,6 +4,6 @@ :for Number from=1 to=10 do={ :local Result ($Number * $MULTIPLIER); - :put ("This is an unusually long line. Here is the result $Number times \ - $MULTIPLIER is: $Result"); + :put ("This is an unusually long line. Here is the result $Number \ + times $MULTIPLIER is: $Result"); } diff --git a/scripts/v7/ch6-03-global-scope.rsc b/scripts/v7/ch6-03-global-scope.rsc index a6c5a8a..7d05eff 100644 --- a/scripts/v7/ch6-03-global-scope.rsc +++ b/scripts/v7/ch6-03-global-scope.rsc @@ -5,6 +5,6 @@ :local GlobalScopeVar "I'm in the global scope!"; # Let's print it out -:put ("Global variable contents = $GlobalScopeVar"); +:put ("Global scope variable contents = $GlobalScopeVar"); # ---- global scope end ---- \ No newline at end of file diff --git a/scripts/v7/ch6-12-global-vars3.rsc b/scripts/v7/ch6-12-global-vars3.rsc index 311c3b7..cd5bef0 100644 --- a/scripts/v7/ch6-12-global-vars3.rsc +++ b/scripts/v7/ch6-12-global-vars3.rsc @@ -22,10 +22,10 @@ if ( [:typeof $WanInterfaces] != "array") do={ # Let's step through the interfaces in the array # and print out their operation status :foreach WanInterface in=$WanInterfaces do={ - :local InterfaceIndex [/interface/ethernet find name=$WanInterface]; + :local InterfaceId [/interface/ethernet find name=$WanInterface]; :local UpDown "down"; - if ([:interface/ethernet get $InterfaceIndex]->"running") do={ + if ([:interface/ethernet get $InterfaceId]->"running") do={ :set UpDown "up" } diff --git a/scripts/v7/ch8-08-while-timer.rsc b/scripts/v7/ch8-08-while-timer.rsc index 899ffed..c63e5fb 100644 --- a/scripts/v7/ch8-08-while-timer.rsc +++ b/scripts/v7/ch8-08-while-timer.rsc @@ -3,7 +3,7 @@ # script to report page load time of google.com # get the current time -:local CurrentTime [/system/clock get time]; +:local CurrentTime [/system clock get time]; # calculate the time in 1 minute :local EndTime ($CurrentTime + 00:01:00); @@ -11,24 +11,28 @@ # define a target web site :local WebSite "www.google.com"; -# run a while loop until one minute interval expired +# run a while loop until one minute interval has expired :while ( [/system/clock get time] < $EndTime ) do={ :put "Getting web page from $WebSite"; # fetch a page from web site - :local FetchResult [/tool fetch url=("https://$WebSite") mode=https \ - http-method=get as-value keep-result=no]; + :local FetchResult; + :local TimeTaken [:time { + :set FetchResult [/tool fetch url=("https://$WebSite") \ + mode=https http-method=get as-value keep-result=no]; + }]; if ($FetchResult->"status" = "finished") do={ # print out how long page retrieval took (if successful) - :local FetchDuration ($FetchResult->"duration"); - :put "Web page fetch time: $FetchDuration secs"; + :put "Web page fetch time: $TimeTaken secs"; } else={ + # print failure message if fetch failed :put "Web page fetch failed"; } # pause for 5 seconds :delay 5; - } +:put "One minute period has ended!" + diff --git a/scripts/v7/ch9-01-mac-fixer.rsc b/scripts/v7/ch9-01-mac-fixer.rsc index adb5fd2..7fd52f3 100644 --- a/scripts/v7/ch9-01-mac-fixer.rsc +++ b/scripts/v7/ch9-01-mac-fixer.rsc @@ -6,8 +6,8 @@ # --- start of function --- :global MacColonRemoveFunc do={ :local TidyMac ""; - for i from=0 to=([:len $1]-1) do={ - :local TmpValue [:pick $1 $i]; + for CharNumber from=0 to=([:len $1]-1) do={ + :local TmpValue [:pick $1 $CharNumber]; :if ($TmpValue !=":") do={ :set TidyMac "$TidyMac$TmpValue" } } :return $TidyMac; diff --git a/scripts/v7/ch9-02-mutiple-args-simple.rsc b/scripts/v7/ch9-02-mutiple-args-simple.rsc index 7448233..0d086cb 100644 --- a/scripts/v7/ch9-02-mutiple-args-simple.rsc +++ b/scripts/v7/ch9-02-mutiple-args-simple.rsc @@ -23,7 +23,8 @@ } # data type checks passed, print the interface data - :put "$InterfaceName: IP address = $InterfaceIp, speed = $InterfaceSpeed"; + :put "$InterfaceName: IP address = $InterfaceIp, speed = \ + $InterfaceSpeed"; } # --- end of function --- diff --git a/scripts/v7/ch9-03-mutiple-args-array.rsc b/scripts/v7/ch9-03-mutiple-args-array.rsc index 8f47b9b..f10e315 100644 --- a/scripts/v7/ch9-03-mutiple-args-array.rsc +++ b/scripts/v7/ch9-03-mutiple-args-array.rsc @@ -5,10 +5,12 @@ # --- start of function --- :global PrintInterfaceAttrsFunc do={ + # verify arg is correct type if ([:typeof $1] != "array") do={ :error "Function argument is not an array!"; } + # extract values from array passed as arg :local Args $1; :local InterfaceName ($Args->"ifname"); :local InterfaceSpeed ($Args->"ifspeed"); @@ -34,11 +36,12 @@ # --- end of function --- # Let's call the function with some sample values in an array -:local Args { ifname="WAN1"; ifspeed="100Mbps"; ifip="192.168.99.1/24" }; +:local Args { ifname="WAN1"; ifspeed="100Mbps"; \ + ifip="192.168.99.1/24" }; $PrintInterfaceAttrsFunc $Args; # Let's call the function with some other values in an array -:set Args { ifname="ether2-LAN"; ifspeed="1000Mbps"; +:set Args { ifname="ether2-LAN"; ifspeed="1000Mbps"; \ ifip="172.16.1.254/24" }; $PrintInterfaceAttrsFunc $Args; diff --git a/scripts/v7/ch9-04-create-global-func.rsc b/scripts/v7/ch9-04-create-global-func.rsc index 0c31dbd..6fc997d 100644 --- a/scripts/v7/ch9-04-create-global-func.rsc +++ b/scripts/v7/ch9-04-create-global-func.rsc @@ -6,8 +6,8 @@ # :global RemoveSpaceFunc do={ :local NewName "" - for i from=0 to=([:len $1]-1) do={ - :local Tmp [:pick $1 $i] + for CharNumber from=0 to=([:len $1]-1) do={ + :local Tmp [:pick $1 $CharNumber] :if ($Tmp !=" ") do={ :set NewName "$NewName$Tmp" } } :return $NewName diff --git a/scripts/v7/ch9-06-str-funcs-mod.rsc b/scripts/v7/ch9-06-str-funcs-mod.rsc index 76a7b51..2ea7516 100644 --- a/scripts/v7/ch9-06-str-funcs-mod.rsc +++ b/scripts/v7/ch9-06-str-funcs-mod.rsc @@ -6,8 +6,8 @@ # :global RemoveSpaceFunc do={ :local NewName "" - for i from=0 to=([:len $1]-1) do={ - :local Tmp [:pick $1 $i] + for CharNumber from=0 to=([:len $1]-1) do={ + :local Tmp [:pick $1 $CharNumber] :if ($Tmp !=" ") do={ :set NewName "$NewName$Tmp" } } :return $NewName diff --git a/scripts/v7/ch9-07-use-str-module.rsc b/scripts/v7/ch9-07-use-str-module.rsc index 3664321..cce900c 100644 --- a/scripts/v7/ch9-07-use-str-module.rsc +++ b/scripts/v7/ch9-07-use-str-module.rsc @@ -1,6 +1,6 @@ # filename: ch9-07-use-str-module.rsc -# import the functions we need and declare the function +# import the functions we need and declare the functions # names we wish to use /import "ch9-06-str-funcs-mod.rsc" :global RemoveSpaceFunc;