The loadStrings() function is used to read the contents of a file and create an array of strings with each of the lines of the file. The file to be read must be located at the sketch directory if the file name is used, otherwise, a URL to the file can be specified.
This function is recommended to be called in the preload() function to ensure that the function is executed before the other functions.
loadStrings( filename, callback, errorCallback )
Parameters: This function accept three parameter as mentioned above and described below:
- filename: This is a string which denotes the name of the file or the url to load the file from.
- callback: This is a function which is called after the function is successfully executed. The first argument for this function is the strings array.
- errorCallback: This is a function which is called if there is any error in executing the function. The first argument for this function is the error response.
Below examples illustrate the loadStrings() function in p5.js:
Online editor: https://editor.p5js.org/
- How to get the function name inside a function in PHP ?
- PHP | min( ) Function
- p5.js | int() function
- PHP | sin( ) Function
- PHP | abs() Function
- p5.js | log() function
- p5.js | sin() function
- p5.js | tan() function
- p5.js | cos() function
- CSS | rgb() Function
- PHP | max( ) Function
- PHP | ord() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.