佳礼资讯网

 找回密码
 注册

ADVERTISEMENT

查看: 141|回复: 0

Programming control flow in DApp development

  [复制链接]
发表于 23-9-2022 07:06 PM | 显示全部楼层 |阅读模式
Code is run from the first line in the file to the last line unless the computer runs across the (extremely frequent) structures that change the control flow, such as conditionals and loops.
For example, imagine a script used to validate user data from a webpage form. The script submits validated data, but if the user leaves a required field empty, it prompts them to fill it in. To do this, the script uses a conditional structure or if...else, so that different code executes depending on whether the form is complete or not:

if (isEmpty(field)) {
  promoter();
} else {
  submitForm();
}
Copy to Clipboard
A typical script in JavaScript or PHP (and the like) includes many control structures, including conditionals, loops, and functions. Parts of a script may also be set to execute when events occur.
For example, the above excerpt might be inside a function that runs when the user clicks the Submit button for the form. The function could also include a loop, which iterates through all of the fields in the form, checking each one in turn. Looking back at the code in the if and else sections, the lines promptUser and submitForm could also be calls to other functions in the script. As you can see, control structures can dictate complex processing flows even with only a few lines of code.
Control flow Decentralized Application development services mean that when you read a script, you must read from start to finish and look at the program structure and how it affects the order of execution.

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

 

ADVERTISEMENT



ADVERTISEMENT




ADVERTISEMENT



ADVERTISEMENT


版权所有 © 1996-2022 Cari Internet Sdn Bhd (483575-W)|IPSERVERONE 提供云主机|广告刊登|私隐权|免控|投诉|联络|脸书|佳礼资讯网

GMT+8, 27-9-2022 04:23 AM , Processed in 0.088162 second(s), 20 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表