From 1183ec7bb9fd3b0b614c7c9eb621b146968e5ea0 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Sat, 30 Jul 2022 15:18:56 +0300 Subject: [PATCH] info on how to check the availability of the API function --- README.md | 11 +++++++++++ samples/check-new-api-sample.lua | 7 +++++++ 2 files changed, 18 insertions(+) create mode 100644 samples/check-new-api-sample.lua diff --git a/README.md b/README.md index dc53f7e..c63e25a 100644 --- a/README.md +++ b/README.md @@ -532,6 +532,17 @@ For example, let's say you want to use the `weather` module that appeared in ver -- aio_version = "4.1.3" ``` +You can also check the presence of a particular API function this way (note the use of a dot instead of a colon): + +``` +if ui.show_list_dialog then + ui:show_text("list dialog supported") +else + ui:show_text("list dialog is not supported") +end + +``` + # Debugging Some tips on writing and debugging scripts: diff --git a/samples/check-new-api-sample.lua b/samples/check-new-api-sample.lua new file mode 100644 index 0000000..30092dd --- /dev/null +++ b/samples/check-new-api-sample.lua @@ -0,0 +1,7 @@ +function on_resume() + if ui.show_list_dialog then + ui:show_text("list dialog supported") + else + ui:show_text("list dialog is not supported") + end +end