wifinigel.MikrotikScripting/scripts/v6/ch9-07-use-str-module.rsc

32 lines
902 B
Text
Raw Normal View History

2023-01-19 21:27:15 +00:00
# filename: ch9-07-use-str-module.rsc
2023-03-06 20:56:48 +00:00
# import the functions we need and declare the functions
2023-02-19 13:53:15 +00:00
# names we wish to use
2023-01-19 21:27:15 +00:00
/import "ch9-06-str-funcs-mod.rsc"
:global RemoveSpaceFunc;
:global ChopStrFunc;
# check our function names are valid
if ([:typeof $RemoveSpaceFunc] != "array") do={
:error "RemoveSpaceFunc is wrong data type or does not exist.";
}
if ([:typeof $ChopStrFunc] != "array") do={
:error "ChopStrFunc is wrong data type or does not exist.";
}
# create a string to use with the functions
:local StringToModify "txBroadcast = 201,";
# print original string
:put ("Orignal string: $StringToModify");
# use both functions to modify the string
:local ModifiedString [$RemoveSpaceFunc $StringToModify];
:set ModifiedString [$ChopStrFunc $ModifiedString];
:put ("Modified string: $ModifiedString");
# tidy up the global namespace (optional)
:set RemoveSpaceFunc;
:set ChopStrFunc;