@ desga2
The "$Arg" is not being used a an argument. It is the caption of a popup menu item. I have been running this in 1.5.2 RC for testing, but I needed to test in 1.1.6 to check the code you provided for KM versions.
There are two kmm files now with more to come as I complete them. All the testing for prompt is not complete.
Training.kmm
# K-Meleon Macros (http://kmeleon.sourceforge.net/wiki/index.php?id=MacroLanguage)
#
# ---------- Training.kmm
# ---------- K-Meleon Macro Language Training/Example ---------------
#
# Dependencies : main.kmm K-Meleon ver 1.1 or later
# Resources : -
# Preferences : -
# Version : - 0.5 2008-12-17
# --------------------------------------------------------------------------------
#
#### PUBLIC MACROS ----------
Training_ArgCode{
$_Training_ArgVal = $ARG ;
$_Training_ArgVal == "menu" ? &_Training_ArgCodeA : 0 ;
$_Training_ArgVal == "F8" ? &_Training_ArgCodeB : 0 ;
}
#### PRIVATE MACROS ---------
_Training_OverView{
$_Training_Text01 = "This 'Training' macro is provided to help users understand some statements";
$_Training_Text02 = "in the Macro Language which is a part of K-Meleon.";
$_Training_Text03 = "This macro file controls additional macro files designated as 'Training1[2][3]'.";
$_Training_Text04 = "Not all files are available yet. They will be added as they become available. ";
alert($_Training_Text01."\n".$_Training_Text02."\n\n".$_Training_Text03."\n".$_Training_Text04, "Overview of 'Training'", "INFO");
$_Training_Text01 = "Each macro statement or concept will be reachable from the Training popup menu. ";
$_Training_Text02 = "Individual units do not follow each other. You must choose an item from the menu. ";
$_Training_Text03 = "The additional macro files may each be made inactive via the Macro Extension ";
$_Training_Text04 = "in preferences. You can do this for units on which you no longer need help. ";
alert($_Training_Text01."\n".$_Training_Text02."\n\n".$_Training_Text03."\n".$_Training_Text04, "Overview of 'Training' (2)", "INFO");
$_Training_Version_Pref="general.useragent.vendorSub";
$_Training_User_Ver=getpref(STRING, $_Training_Version_Pref);
## $_Training_User_Ver=substr(getpref(STRING, $Training_Version_Pref), 0, 3);
## double conditional ==> _KMVersion=="1.5"?$kSessions==true?&_Sessions_BuildMenu_15:0:0;
$_Training_Text01 = "The Macro Language has evolved through each new version of K-Meleon.";
$_Training_Text02 = "Some current language statements may not be not available to the version" ;
$_Training_Text03 = "of the browser that you are using. Training will tell you if the version" ;
$_Training_Text04 = "you are using does not support a particular statement.";
$_Training_Text05 = "You are current using K-Meleon ";
alert($_Training_Text01."\n".$_Training_Text02."n\n".$_Training_Text03."\n".$_Training_Text04."\n\n".$_Training_Text05.$_Training_User_Ver, "Overview of 'Training' (3)", "INFO");
}
_Training_FolderCode{
alert("Allow user to select folder. \n\n No initial folder \n No programed requirement", "Using promptforfolder") ;
$_Training_SubFolder=promptforfolder("Select a folder for use") ;
alert( $_Training_SubFolder, "Folder user selected", "INFO") ;
alert("Allow user to select folder. \n\n Set initial folder to originating folder \n No programed requirement", "Using promptforfolder") ;
$_Training_SubFolder=promptforfolder("Select a folder for use", $_Training_Path) ;
alert( $_Training_SubFolder, "Folder user selected", "INFO") ;
macros(_Training_FolderCode2) ;
}
_Training_FolderCode2{
alert("Allow user to select folder. \n\n Set initial folder to Favorites \n Require Favorites or subfolder", "Using promptforfolder") ;
#### look three places for the favorites directory
$_Training_FavFolder=getpref(STRING,"kmeleon.plugins.favorites.directory");
$_Training_FavFolder==""?$_Training_FavFolder=readreg("HKCU","Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders\\Favorites"):0;
$_Training_FavFolder==""?$_Training_FavFolder=readreg("HKLM","Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders\\Favorites"):0;
#### $_Training_FavFolder should have the path for the favorites folder c:\something\favorites
#### call _Training_RnameTrue_loop until $_Training_SubFolder is no longer a "?"
$_Training_SubFolder="?"; while($_Training_SubFolder=="?") &_Training_NameTrue_loop;
$_Training_SubFolder == "" ? alert($_Training_FavFolder, "The selected folder", "INFO") : alert($_Training_FavFolder."\\".$_Training_SubFolder, "The selected folder", "INFO") ;
}
_Training_NameTrue_loop{
$_Training_SubFolder=promptforfolder (_("Specify where to add the new shortcut. Select your Favorites folder or one of its subfolders:"),$_Training_FavFolder);
$_Training_SubFolder=$_Training_SubFolder=="" ? "" : index($_Training_SubFolder,$_Training_FavFolder) == 0 ? substr($_Training_SubFolder,length($_Training_FavFolder)+1) : "?";
}
_Training_GensubCode{
$_Training_Text01 = "$SUB = gensub( r, s, h, t );" ;
$_Training_Text02 = "Searches the target string t for matches of the string r." ;
$_Training_Text03 = "If h is a string beginning with 'g' or 'G', then all matches" ;
$_Training_Text04 = "of r are replaced with s. Otherwise, h is a number indicating" ;
$_Training_Text05 = "which match of r to replace. The modified string is returned." ;
alert($_Training_Text01."\n".$_Training_Text02."\n".$_Training_Text03."\n".$_Training_Text04."\n".$_Training_Text05, "gensub statement", "INFO");
$_Training_Target = "copper is a color for corporate" ;
alert($_Training_Target, "The target string (t)") ;
$_Training_Match = "co" ;
$_Training_Replace = "To" ;
alert("The match string (r) is '".$_Training_Match."'\n\n The replacement string (s) is '".$_Training_Replace."'", "The match and replace strings", "INFO");
$_Training_GOut = gensub($_Training_Match, $_Training_Replace, "G" ,$_Training_Target) ;
$_Training_Text01 = "$_Training_GOut = gensub($_Training_Match, $_Training_Replace, 'G' ,$_Training_Target) ;" ;
alert($_Training_GOut."\n\n".$_Training_Text01, "Global replacement", "INFO") ;
$_Training_GOut = gensub($_Training_Match, $_Training_Replace, "1" ,$_Training_Target) ;
$_Training_Text02 = "$_Training_GOut = gensub($_Training_Match, $_Training_Replace, '1' ,$_Training_Target) ;" ;
alert($_Training_GOut."\n\n".$_Training_Text02, "First replacement only", "INFO") ;
}
_Training_ArgCodeA{
$_Training_Text01 = "setmenu($_Training_Popm,'macro','$Arg','Training_ArgCode(menu)');" ;
alert("A choice was made within the Training_ArgCode macro \n based on the argument passed from the setmenu statement. \n\n The argument was 'menu'.\n\n" . $_Training_Text01 , " $ARG - argument in setmenu statement", "INFO");
alert("After you click OK for this message, \n\n please press the CTRL + SHIFT + F8 together.", "To test another method", "INFO");
}
_Training_ArgCodeB{
$_Training_Text01 = "setaccel( 'CTRL SHIFT VK_F8' ,'macros(Training_ArgCode(F8))');";
alert("A choice was made within the Training_ArgCode macro \n based on the argument passed from the setaccel statement. \n\n The argument was 'F8'.\n\n" . $_Training_Text01, " $ARG - argument in setaccel statement", "INFO");
alert("Training actually finished running before you pressed CTRL + SHIFT + F8. \n Your keypresses restarted Training_ArgCode and and passed 'F8' \n as an argument.", "$ARG examples finished", "INFO");
}
_Training_BuildMenu{
$_Training_Num = 1 ;
# add another option to Help menu
$Training_Popm = "Training" ;
setmenu("KMDocs",popup,$Training_Popm,2);
setmenu($Training_Popm,"macro","Overview","_Training_OverView");
setmenu($Training_Popm,"macro","PromptForFolder","_Training_FolderCode");
setmenu($Training_Popm,"macro","Gensub","_Training_GensubCode");
setmenu($Training_Popm,"macro","$Arg","Training_ArgCode(menu)");
macros(Training_Chapters) ;
macros(_Training_accelerators) ;
}
_Training_accelerators{
setaccel( "CTRL SHIFT VK_F8" ,"macros(Training_ArgCode(F8))");
}
Training_Chapters{
while($_Training_Num < 20) &_Training_Chapters_Loop ;
}
_Training_Chapters_Loop{
$_Training_File = "Training". $_Training_Num . ".kmm" ;
$_Training_ChapExist = readfile($_Training_Path."\\".$_Training_File );
$_Training_File_Menu = "Training". $_Training_Num . "_BuildMenu" ;
$_Training_ChapExist != "" ? macros($_Training_File_Menu) : 0 ;
$_Training_Num = $_Training_Num + 1 ;
}
_Training_GetPath{
## Training.kmm will be located in one of two possible locations
## If readfile finds nothing at MacroFolder then the location is UserMacroFolder
$_Training_Data=readfile(getfolder(MacroFolder)."\\Training.kmm");
$_Training_Path=getfolder($_Training_Data==""?UserMacroFolder:MacroFolder);
}
# ------- Startup Order of Precedence
# ------- Init
# ------- Setup
## $_Training_Path is required to execute _Training_Chapters
## which is called from _Training_BuildMenu
$OnInit=$OnInit."_Training_GetPath;";
$OnStartup=$OnStartup."_Training_BuildMenu;";
$macroModules=$macroModules."Training;";
################ END OF TRAINING.KMM ###############################
Training1.kmm
# K-Meleon Macros (http://kmeleon.sourceforge.net/wiki/index.php?id=MacroLanguage)
#
# ---------- Training1.kmm
# ---------- K-Meleon Macro Language Training/Example ---------------
# ---------- CHAPTER 1
#
# Dependencies : main.kmm Training.kmm K-Meleon ver 1.1 or later
# Resources : -
# Preferences : -
# Version : - 0.1 2008-12-17
# --------------------------------------------------------------------------------
Training1_PromptCode{
#-- $VALUE = prompt( MESSAGE [, TITLE [, DEFAULT]] );
#$_Training1_Result_Bounds = 0 ;
$_Training1_Result = prompt("Select a whole number from zero to ten", "prompt example", 5);
$_Training1_Result != "" ? alert($_Training1_Result, "Your answer from prompt") : alert("Cancel", "Your answer from prompt");
macros(_Training1_PromptValid) ;
$_Training1_Text01 = "The prompt statement is used to send a message to the user. \n" ;
$_Training1_Text02 = "The user must interact with the message display box in order \n" ;
$_Training1_Text03 = "for the macro to continue. \n The user's interaction is returned " ;
$_Training1_Text04 = "to the macro where the results \n can be acted upon. \n\n ";
$_Training1_Text05 = "$VALUE = prompt( MESSAGE [, TITLE [, DEFAULT]] ); \n\n ";
$_Training1_Text06 = "The prompt requesting a number looks like this: \n\n Result = prompt('Select a number between zero and ten', 'prompt example', 5);";
alert($_Training1_Text01.$_Training1_Text02.$_Training1_Text03.$_Training1_Text04.$_Training1_Text05.$_Training1_Text06,"prompt example", "INFO");
}
_Training1_PromptValid{
$_Training1_Version_Pref="general.useragent.vendorSub";
$_Training1_User_Ver=substr(getpref(STRING, $_Training1_Version_Pref), 0, 3);
# choice 1.5 series = later version while other = early version
$_Training1_User_Ver == "1.5" ? &_Training1_PromptValidL : &_Training1_PromptValidE ;
}
_Training1_PromptValidL{
$_Training1_RCnt = 0 ;
$_Training1_Result > 10 ? $_Training1_RBI = 1 : 0;
$_Training1_RCnt = $_Training1_RCnt + $_Training1_RBI ;
$_Training1_Result < 0 ? $_Training1_RBI = 1 : 0;
$_Training1_RCnt = $_Training1_RCnt + $_Training1_RBI ;
$_Training1_RCnt >= 1 ? alert($_Training1_Result, "Your answer was not an integer within the range.", "EXCLAIM"):0;
}
_Training1_PromptValidE{
alert("we are running _Training1_PromptValidE");
$_Training1_RCnt = 0 ;
$_Training1_ResultLength = length($_Training1_Result);
$_Training1_ResultLength == 1 ? &_Training1_PVE_CaseZero : 0;
$_Training1_RCnt == 1 ? 0 : &_Training1_PVE_CaseZero ;
$_Training1_RCnt >= 1 ? alert($_Training1_Result, "Your answer was not an integer within the range.", "EXCLAIM"):0;
}
_Training1_PVE_CaseNonZero{
$_Training1_RBI = 0 ;
$_Training1_ResultLength == 1 ? $_Training1_Result = "0" . $_Training1_Result :0;
#alert($_Training1_Result. " is the value") ;
$_Training1_RBI = $_Training1_Result > "10" ? 1 : 0;
$_Training1_RCnt = $_Training1_RCnt + $_Training1_RBI ;
$_Training1_RBI = 0 ;
$_Training1_RBI = $_Training1_Result < "0" ? 1 : 0;
$_Training1_RCnt = $_Training1_RCnt + $_Training1_RBI ;
#alert($_Training1_RCnt, "RCnt value", "EXCLAIM");
$_Training1_RBI = 0 ;
$_Training1_Result_First = substr($_Training1_Result,0,1);
## Does it sort > 0 and less than 11 ?
$_Training1_RBI=$_Training1_Result_First > "0" ? $_Training1_Result_First < "11" ? 0:1:1 ;
$_Training1_RCnt = $_Training1_RCnt + $_Training1_RBI ;
alert($_Training1_RCnt, "RCnt value", "EXCLAIM");
}
_Training1_PVE_CaseZero{
$_Training1_Result == "0" ? 0 : $_Training1_RCnt = 1 ;
macros(_Training1_PVE_NonZero);
}
Training1_ConfirmCode{
#-- $RESULT = confirm( MESSAGE [, TITLE [, BUTTONS [, ICON]]] );
#-- BUTTONS = RETRYCANCEL | YESNO | YESNOCANCEL | ABORTRETRYIGNORE
#-- ICON = EXCLAIM | INFO | STOP | QUESTION
#-- RESULT = OK | YES | NO |ABORT | RETRY | IGNORE | 0
$_Training1_Text01 = "The confirm statement is used to send a message to the user. \n" ;
$_Training1_Text02 = "The user must interact with the message display box in order \n" ;
$_Training1_Text03 = "for the macro to continue. \n The user's interaction is returned " ;
$_Training1_Text04 = "to the macro where the results \n can be acted upon. \n\n Can you see this message?";
$_Training1_Result = confirm($_Training1_Text01.$_Training1_Text02.$_Training1_Text03.$_Training1_Text04,"confirm statement","YESNO",QUESTION) ;
$_Training1_Result == "NO" ? $_Training1_Result=confirm("You could not see prior message?", "received 'NO' from previous", "YESNO",EXCLAIM) :0 ;
$_Training1_Result == "YES" ? $_Training1_Result=confirm("Good, you did see it.", "received 'YES' from previous", "YESNO","EXCLAIM") :0 ;
$_Training1_Text01 = "are shown below. Some shortning of text was done so they would fit \n\n" ;
$_Training1_Text02 = "Result=confirm('Bunch of text','confirm statement','YESNO','QUESTION'); \n" ;
$_Training1_Text03 = "Result=confirm('You could not see prior message?', 'received 'NO' from previous', 'YESNO','EXCLAIM'); \n" ;
$_Training1_Text04 = "Result=confirm('Good, you did see it.', 'received 'YES' from previous', 'YESNO','EXCLAIM'); \n" ;
$_Training1_Text05 = "Bye the way, your last answer was ".$_Training1_Result. "." ;
alert($_Training1_Text01.$_Training1_Text02.$_Training1_Text03.$_Training1_Text04.$_Training1_Text05, "The previous confirm statements");
$_Training1_Text01 = "$RESULT = confirm( MESSAGE [, TITLE [, BUTTONS [, ICON]]] ); \n" ;
$_Training1_Text02 = "BUTTONS = RETRYCANCEL | YESNO | YESNOCANCEL | ABORTRETRYIGNORE \n" ;
$_Training1_Text03 = "ICON = EXCLAIM | INFO | STOP | QUESTION \n " ;
$_Training1_Text04 = "RESULT = OK | YES | NO |ABORT | RETRY | IGNORE | 0 \n\n";
$_Training1_Text05 = "Do you need to view other combinations of buttons and icons? ";
$_Training1_Result = confirm($_Training1_Text01.$_Training1_Text02.$_Training1_Text03.$_Training1_Text04.$_Training1_Text05, "confirm message box", "YESNO");
$_Training1_Result == "YES" ? macros(_Training1_ConfirmCodeA) : 0 ;
}
_Training1_ConfirmCodeA{
#alert("the user wants more");
$_Training1_Result = confirm("Choose an action", "The process stopped", "ABORTRETRYIGNORE", "STOP");
$_Training1_Text01 = "Result = confirm('Choose an action', 'The process stopped', 'ABORTRETRYIGNORE', 'STOP');";
alert("Your reply generated this answer " . $_Training1_Result. "\n\n The code was as follows \n\n". $_Training1_Text01, "confirm with buttons 'ABORTRETRYIGNORE'");
$_Training1_Result = confirm("Do you want to try another answer?", "Replay previous", "YESNOCANCEL");
$_Training1_Text01 = "Result = confirm('Do you want to try another answer?', 'Replay previous', 'YESNOCANCEL');" ;
$_Training1_Result == "YES" ? $_Training1_Text02 = "Other possible answers were NO or 0." :0;
$_Training1_Result == "NO" ? $_Training1_Text02 = "Other possible answers were YES or 0." :0;
$_Training1_Result == 0 ? $_Training1_Text02 = "Other possible answers were NO or YES." :0;
alert("Your reply generated this answer " . $_Training1_Result. "\n\n". $_Training1_Text02."\n\n The code was as follows \n\n". $_Training1_Text01, "confirm - replay previous");
$_Training1_Result == "YES" ? &_Training1_ConfirmCodeA : 0;
}
Training1_AlertCode{
#-- alert( MESSAGE [, TITLE [, ICON]] );
#-- ICON = EXCLAIM | INFO | STOP | QUESTION
$_Training1_Text01 = "The alert statement is used to send a message to the user. \n" ;
$_Training1_Text02 = "The user must interact with the message display box in order \n" ;
$_Training1_Text03 = "for the macro to continue. \n\n This is an alert message." ;
alert($_Training1_Text01.$_Training1_Text02.$_Training1_Text03, "alert message box", "INFO");
$_Training1_Text01 = "alert( MESSAGE [, TITLE [, ICON]] ); \n\n TITLE and ICON are optional. \n" ;
$_Training1_Text02 = "ICON can have one of the following values \n" ;
$_Training1_Text03 = "EXCLAIM | INFO | STOP | QUESTION \n\n EXCLAIM was used in this alert." ;
alert($_Training1_Text01.$_Training1_Text02.$_Training1_Text03, "form of the alert statement", "EXCLAIM");
alert("Neither TITLE nor ICON is used in this alert");
}
Training1_BuildMenu{
# add additional lines to the training menu
setmenu($Training_Popm,"macro","[1] Prompt","Training1_PromptCode");
setmenu($Training_Popm,"macro","[1] Confirm","Training1_ConfirmCode");
setmenu($Training_Popm,"macro","[1] Alert","Training1_AlertCode");
}
$macroModules=$macroModules."Training1;";
################ END OF TRAINING1.KMM ###############################