App Inventor 指令集详解:内置函数与副程序

需积分: 9 3 下载量 183 浏览量 更新于2024-07-26 收藏 1.73MB PDF 举报
"App Inventor 是一个用于创建 Android 应用的可视化编程工具,尤其适合初学者。这个文档是Google App Inventor的中文说明文档的一部分,涵盖了App Inventor的内置指令集,包括定义、文本、列表、数学、逻辑、控制和颜色等不同类型的指令。这些指令是构建App Inventor应用程序的基础,用户可以通过它们来实现各种功能和操作。" 在App Inventor中,`Definition`指令区主要涉及的是创建和使用**副程式**(即子程序或函数)。副程式允许你将一组指令封装在一起,以便在需要时通过调用它的名字来执行。你可以通过`procedure`指令定义一个没有返回值的副程式,而`procedureWithResult`则用于定义一个有返回结果的副程式。在创建副程式时,可以使用`name`指令来命名参数,这使得你可以在调用副程式时传递参数。App Inventor会自动为副程式生成一个`call`指令,用于在程序中调用它。 **Text**指令区涉及到对文本的操作,如拼接字符串、提取子串、检查文本是否包含特定字符等。这对于创建用户界面和处理用户输入的文本信息非常重要。 **List**指令区则与数组或列表操作相关,包括创建列表、添加或删除元素、查找元素位置、获取列表长度等,这些功能在处理数据集合时非常实用。 **Math**指令区提供了基本的数学运算,如加减乘除、取余数、平方根等,以及比较运算,支持进行数值计算和逻辑判断。 **Logic**指令区包含逻辑操作,如AND、OR、NOT等,用于组合条件判断和逻辑表达式。 **Control**指令区是关于流程控制的,比如`if`、`for each`循环、`while`循环、`do...while`等,它们决定了程序的执行顺序和条件。 **Color**指令区涉及颜色相关的操作,可以用于设置组件的颜色属性或者进行颜色的混合和比较。 通过这些指令,用户可以构建出复杂的Android应用,实现各种功能。在App Inventor中,所有这些指令都是图形化的,用户可以通过拖放方式构建程序逻辑,降低了编程的门槛,非常适合初学者学习和实践。

优化这条sql: select distinct (select product_name from t_product from where id = #{productId} and mark = 1 and status = 1) as productName, (select count(0) from t_clue a where a.distribution_status != 4 and a.mark = 1 and a.product_id = #{productId} and a.status in(1,2,3,31,32,33)) as clueCount, (select count(0) from t_clue a left join t_clue_appendix b on a.clue_code = b.clue_code where a.distribution_status != 4 and a.mark = 1 and b.file_url is not null and a.product_id = #{productId} and a.status in (3,31,32,33)) as intentionCount, (select count(0) from t_clue a where a.status in (4,5,7,8) and a.distribution_status != 4 and a.mark = 1 and a.product_id = #{productId} and a.status = 4) as incomingCount, (select count(0) from t_clue a where a.status in (5,7,8) and a.distribution_status != 4 and a.mark = 1 and a.product_id = #{productId} and a.status in (5,7,8)) as approvedCount, (select count(0) from t_clue a where a.status = 6 and a.distribution_status != 4 and a.mark = 1 and a.product_id = #{productId} and a.status = 6) as rejectionCount, (select count(0) from t_clue a where a.status in (7,8) and a.distribution_status != 4 and a.mark = 1 and a.product_id = #{productId}) as loanCount, (select count(0) from t_clue a where a.status = 8 and a.distribution_status != 4 and a.mark = 1 and a.product_id = #{productId}) as swipeCount, (select sum(a.loan_amount) from t_clue a where a.distribution_status != 4 and a.mark = 1 and a.product_id = #{productId}) as loanMoney, (select sum(a.use_amount) from t_clue a where a.distribution_status != 4 and a.mark = 1 and a.product_id = #{productId}) as swipeMoney

2023-06-06 上传