Text Blocks

" "

Block này dùng để chứa đựng những chuỗi văn bản. Những chuỗi này có thể chứa bất kỳ ký tự nào mà bạn muốn (số, chữ hoặc bất kỳ ký tự đặc biệt nào). Trong App Inventor, block này có thể được xem như là 1 đối tượng văn bản (Text Object).

join

Ghép nối tất cả các đầu vào thành 1 chuỗi ký tự duy nhất. Nếu như không có đầu vào, sẽ trả về 1 ký tự trắng.

length

Trả về kết quả là số ký tự trong chuỗi ký tự mà ta nhập vào (Tính luôn cả khoảng trắng). ( Ví dụ : length("Dang Van Hao") = 12 )

is empty

Kiểm tra xem đầu vào có chứa ký tự nào không (nếu nhập vào khoảng trắng vẫn sẽ tính là 1 ký tự). Khi Số ký tự nhập vào là 0 thì kết quả sẽ trả về "True", ngược lại, nếu có ký tự nhập vào thì sẽ trả về kết quả là "false".


compare texts < > =

Returns whether or not the first string is lexicographically <, >, or = the second string depending on which dropdown is selected.
A string a considered lexicographically greater than another if it is alphabetically greater than the other string. Essentially, it would come after it in the dictionary. All uppercase letters are considered smaller or to occur before lowercase letters. cat would be > Cat.

trim

Loại bỏ tất cả khoảng trắng nằm ở đầu và cuối của chuỗi văn bản.

upcase

Chuyển đổi toàn bộ chuỗi văn bản nhập vào thành chữ in hoa.

downcase

Ngược lại với upcase, downcase sẽ chuyển đổi toàn bộ chuỗi văn bả sang chữ thường.

starts at

Trả về giá trị là vị trí ký tự đầu tiên của "piece" xuất hiện đầu tiên trong chuỗi văn bản, hoặc trả về giá trị bằng 0 nếu như chuỗi văn bản nhập vào không chứa những ký tự trong "piece".
Ví dụ, vị trí của "ana" trong chuỗi văn bản "havean banana" là 4.


contains

Trả về giá trị "true" nếu như "piece" xuất hiện trong chuỗi văn bản, ngược lại trả về giá trị "false".


split at first

Divides the given text into two pieces using the location of the first occurrence of at as the dividing point, and returns a two-item list consisting of the piece before the dividing point and the piece after the dividing point. Splitting apple,banana,cherry,dogfood with a comma as the splitting point returns a list of two items: the first is the text apple and the second is the text banana,cherry,dogfood. Notice that the comma after apple doesn't appear in the result, because that is the dividing point.

split at first of any

Divides the given text into a two-item list, using the first location of any item in the list at as the dividing point.
Splitting i love apples bananas apples grapes by the list [ba,ap] would result in a list of two items the first being i love and the second ples bananas apples grapes.

split

Divides text into pieces using at as the dividing points and produces a list of the results. Splitting one,two,three,four at , (comma) returns the list one two three four. Splitting one-potato,two-potato,three-potato,four at -potato, returns the list one two three four.

split at any


/sites/all/files/UserGuide/blocks/text/splitAtAny.png"
Divides the given text into a list, using any of the items in at as the dividing point, and returns a list of the results.
Splitting appleberry,banana,cherry,dogfood with at as the two-element list whose first item is a comma and whose second item is rry returns a list of four items: [applebe, banana, che, dogfood,]

split at spaces

Divides the given text at any occurrence of a space, producing a list of the pieces.

segment

Extracts part of the text starting at start position and continuing for length characters.

replace all

Returns a new text string obtained by replacing all occurrences of the substring with the replacement.
Replace all with She loves eating. She loves writing. She loves coding as the text, She as the segment, and Hannah as the replacement would result inHannah loves eating. Hannah loves writing. Hannah loves coding.

Không có nhận xét nào:

Đăng nhận xét