Skip to content

Instantly share code, notes, and snippets.

@antipole2
Created October 22, 2020 16:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save antipole2/c0d79c081115098a49d442aebd24a6ee to your computer and use it in GitHub Desktop.
Save antipole2/c0d79c081115098a49d442aebd24a6ee to your computer and use it in GitHub Desktop.
Example of script using dialogues
dialogue = [
{type:"text", value:"Register your boat"},
{type:"field", label:"Name"},
{type:"field", label:"Length", suffix:"m", width:30},
{type:"radio", label:"type", value:["yacht", "motor cruiser", "keelboat", "dinghy"]},
{type:"tick", value:"share details?"},
{type:"button", label:["cancel", "register"]}
];
OCPNonDialogue(handle, dialogue);
function handle(response){
print (response, "\n", "response was: '", response[5].label, "'\n");
switch(response[5].label){
case "cancel":
print("Registration was cancelled\n");
break;
case "register":
if (response[4].value){
print("The ");
if (response[2].value != "") print(response[2].value, "m ");
print(response[3].value, " ", response[1].value, " has been registered\n");
}
else print("Registered\n");
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment