Creating Functions

code này biểu diễn cách phổ biến nhất của việc tạo ra một chức năng, cũng như cú pháp của chúng tôi sẽ sử dụng thường xuyên nhất trong bài học này. Bạn sẽ thấy rằng việc khai báo chức năng bắt đầu với chức năng từ, theo sau là tên của hàm (mà có thể được bất cứ điều gì bạn chọn, miễn là nó sau điển hình ước đặt tên). | Creating Functions Before you use a function you must create or define it. You can do this by using one of two possible syntaxes. Syntax 1 This code describes the first syntax function myFunction parameter1 DataType parameter2 DataType etc. actions go here The code represents the most common way of creating a function as well as the syntax we ll use most frequently in this lesson. You ll see that the function declaration begins with the word function followed by the name of the function which can be anything you choose as long as it follows typical naming conventions . Following the function name is an area enclosed by parentheses. You can leave this area blank or you can fill it with information parameter data that the function can use. By leaving the area within the parentheses blank you create a generic function that is one that performs the same way whenever it s called used . If your function contains parameters it will perform in a unique way each time it s called based on the parameter information it receives. Giving the function information in this way is called passing in arguments or passing in parameters. You can use as many parameters as you want. We ll tell you how to use parameter data a bit later in this lesson. Following the optional parameter area is an open curly brace followed by a carriage return and then some actions before the curly brace that concludes the function. In the space between the curly braces you write the actions that you want your function to perform. These actions can also make use of any parameter information passed to the function as you will see soon . TIP You can create a function skeleton that is a function that does not yet contain any actions in the Actions panel by clicking Statements User-Defined Functions then double-clicking the function command. Syntax 2 This code represents the second syntax for creating functions myFunction function parameter1 DataType parameter2 DataType etc. actions go here You would use this .

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
125    155    1    29-04-2024
94    57    2    29-04-2024
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.