Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
blocks:app-note:textfile [2021-05-10 14:59] mattias [The Block] |
blocks:app-note:textfile [2021-05-10 15:18] (current) mattias [The text file] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | Work In Progress | ||
====== Use a text file to provide some text data to Blocks ====== | ====== Use a text file to provide some text data to Blocks ====== | ||
Line 41: | Line 40: | ||
===== The Tasks ===== | ===== The Tasks ===== | ||
- | Open the task manager and take a look at the example tasks. | + | Open the task manager and look at the example tasks. |
- | The LogTexts task will log the whole list of items one by one. This is done wit a loop that loops though the index one by one and logs the lines value of all index positions. | + | The LogTexts task will log the whole list of items one by one. This is done with a loop that loops though the index one by one and logs the lines value of all index positions. |
{{: | {{: | ||
- | The Shuffle task will just trigger the callable // | + | The Shuffle task will just trigger the callable // |
{{: | {{: | ||
- | The last task is just picking a random item and logging it, like it would in a raffel | + | The last task is just picking a random item and logging it, like it would in a raffle |
{{: | {{: | ||
+ | |||
+ | ===== The text file ===== | ||
+ | |||
+ | The file we use as source is a plain text file with a carriage return in between every data entry, the file is located at the Blocks default file location / | ||
+ | If a SimpleFile is used to read a text file and the file is kept at the default location only the filename must be specified. If you want to user some other folder the full file path must be used. | ||
+ | |||
+ | :!: This user script can only access files stored locally | ||
+ | |||
+ | {{: | ||
+ | |||
===== The user script ===== | ===== The user script ===== | ||
Line 64: | Line 73: | ||
If you would want to run two instances of the same user script you would have to duplicate the .ts file and change the name of the copy to something unique. The name of a user script and the name of the export class must be identical since blocks will find the export class based on filename. | If you would want to run two instances of the same user script you would have to duplicate the .ts file and change the name of the copy to something unique. The name of a user script and the name of the export class must be identical since blocks will find the export class based on filename. | ||
+ | |||
+ | {{: | ||