Created
October 22, 2020 16:30
-
-
Save antipole2/c0d79c081115098a49d442aebd24a6ee to your computer and use it in GitHub Desktop.
Example of script using dialogues
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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