Editing file assignment lists


When using files inside of your project, you need to reference the file(s) you want to use inside of your code. There can be static, direct references to files, but in many cases, this might not fulfill your needs. In order to solve this problem, the GetWrite Builder allows you to define file assignment lists that are known ahead-of-runtime, but can be used in your code to query files dynamically. For example, you may want to display a random image from a list of images.

In this article, you will learn how to create and edit file assignment lists and how to use them in your code.


How to edit your project's assignment lists

To edit your project's assignment lists, click on the "Assign to lists" button in the file management system. This will open a new tab that allows you to edit your assignment lists.

An image of the file assignment list editor

To create a new assignment list, click on the "Add new list" button. This will open a dialog that prompts you to enter a name for the new list. For portability reasons, it is required to use ASCII (english alphabet + numbers) characters. After entering a name, click on the "Create" button to create the new list.

To add files to that list, first make sure it is selected. You can see whether a list is currently selected by looking at the title of the large, middle panel. If it says "Files in selected list appear below", you need to select a list first, otherwise, the described list is selected. To select a list, click on it in the list of lists on the left side of the screen. After selecting a list, you can add files to it by clicking on the arrow symbol next to each file in the file palette located at the right side of the screen.

Removing files is just as easy; simply click on the file you want to remove from the list in the list of files (located at the large center panel)

Lists can be deleted by clicking on the trashcan icon next to the list's name in the list of lists.

Important! When you're done editing your lists, make sure to click on the "Save and exit" button at the top left of the screen. The editor tab might tell you that a reload is recommended. You should accept this whenever you just CREATED or DELETED a list, but you can ignore it when you just edited an existing list.


How to use assignment lists inside of your code

Assignment lists can be used inside of your code by using the "from list ... get element # ..." block or the "pick random file from list ..." block. The former block allows you to get a specific file from a list, while the latter block allows you to get a random file from a list.

Good to know: The "pick random file from list ..." block tries to avoid picking the same file multiple times in a row. This means that if you have a list with 3 files and you pick a random file from that list 3 times, you will get all 3 files in a random order. If you pick a random file from that list a 4th time, you will get one of the 3 files twice. You do not need to worry about the same file appearing twice in a project's execution as long as the random function is never called more often than the number of files in the list.

Different list reference blocks inside of the block editor.