Filling form from file

I like to fill in a web form with data from a text file and can't figure out how to do that in Text blaze
Maybe someone can point me in the right direction

example:
content of input text file
Field 1 data
Field 2 data
Field 3 data

The form has 3 fields (moving in between with tab)
so the txt blaze macro would look like this

Field 1 data
{key:tab; trim=yes}
Field 2 data
{key:tab; trim=yes}
Field 3 data

I looked at the import/export function but that is a bit too long winded to use frequently.
Is there a way a snippet (generated by some external script) could be loaded from another snippet?

Hi, and welcome to the forum! :slight_smile:

Text Blaze doesn't provide any mechanism to access files on your computer.

An alternative that might work for you is to copy the contents of file and then use the {clipboard} command. Here's some more info on that:

Thanks for that tip. I had a try but the problem is the dynamic command don't work with the clipboard.
I want to fill in data in a field and then tab to the next and fill in again etc.
The {tab} on the clipboard does not get executed as a tab key on the form.
Or is there a way to make this work?

Hi @Andreas_Hagele,

Actually, you can manipulate the {clipboard} contents in many ways.

Here's an example. I've got the following sample data:

Name: Cedric Debono
Profession: Copywriter
Favorite Hobby: Deep-diving into Text Blaze

Now here's how the snippet would work:

{note}
{line1={=split({clipboard},"\n")[1]}} << splits clipboard contents by line break, picks the first bit and assigns it to the variable line1
{line2={=split({clipboard},"\n")[2]}} << splits clipboard contents by line break, picks the second bit and assigns it to the variable line2
{line3={=split({clipboard},"\n")[3]}} << splits clipboard contents by line break, picks the third bit and assigns it to the variable line3

{endnote: trim=right}

{=line1}{key:tab; trim=yes}
{=line2}{key:tab; trim=yes}
{=line3}{key:tab; trim=yes}

You can do it with spreadsheet data too. If it's on the same row, split the data by tabs using \t instead of \n

Hope this helps :slight_smile:

P.S. {clipboard} doesn't preview on the forums. Copy my snippet sample into your text blaze dashboard and test it there to be able to see it at work.

Thanks for that idea.
But this works only if I have a fixed length of fields (lines) to process.
I would like to have my snippet a bit more flexible to deal with variable number of fields. For my current form it's about 40 fields.

Why doesn't it work to have commands in the clipboard like {key:tab}
All that seems to happen is the text gets pasted as is instead of executed.
It would be easy for me to generate the whole snippet externally and then load it with a {clipboard} command. Of course it would even be easier to load the external file directly.

So you basically want to execute a piece of text as if it were snippet? If so, unfortunately that is not possible.

You can extend what Cedric showed using the {repeat} command which would allow you to handle any number of lines. Here is more info on that command: