Search Tutorials
More Functions The example movie also contains 3 additional functions on Frame 1. They are simply variations on what you have already learned, but should prove useful in their own right. Please look at the source file for more details. function formatnumber (the_num): string_out = formatnumber(-24242424.2424); This function takes a single argument, the_num, which may be a number or a string. The appropriate commas are incorporated into the number so that the variable string_out now equals "-24,242,424.2424". Negative, decimal, and exponential numbers are all handled correctly. function trimstring (the_string, characters, from_start, from_end): string_out = trimstring('***Hurray***', '*');
This functions takes a minimum of 2 arguments. The arguments from_start and from_end are optional. The variable string_out now equals "Hurray". string_out = trimstring('***Hurray***', '*', false, true);
The variable string_out now equals "***Hurray". function trimlines (the_string, characters, from_start, from_end): string_out = trimlines(string_from_file, ' '); This function takes a minimum of 2 arguments. The arguments from_start and from_end are optional. This function works similar to how the trimstring function works, but trims each line. It handles every return character situation, including newline, "\n", "\r", and even the dreaded "\n\r". This function is most useful for handling dynamically loaded text. In the above example, whitespaces are trimmed from the front and end of each line.
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|