Using a simple Array of Variables with [interpret]

The [interpret] context is very powerful command in the hands of a skilled WebDNA programmer.

numero = 127
interpreted = N
texte = Let's suppose you have need a simple array of eight variables. We could name them sequentially like this: variable1 variable2 variable3 ... variable8 If we wanted to preset all these variables to null, you would use the [text] context like so:
[text]variable1=[/text][text]variable2=[/text][text]variable3=[/text]...[text]variable8=[/text]
However, there is an easier way to set them all using the [loop] context.
[loop start=1&end=8][text]variable[index]=[/text][/loop]
Later in your code you could call the variables individually by simply placing the [variable1], [variable2], [variable3] ... [variable8] where needed. But if you need to display them all at once you can use the [loop] again.
[loop start=1&end=8]  [interpret][variable[index]][/interpret][/loop]
The [interpret] context is a vary powerful way of processing code inside code, and you need to be extra careful with your usage of the brackets when using [interpret] because it's easy to forget one of the ]. Understanding this is tricky for new programmers so let's break down the above example step by step: WebDNA will always process from the inside out as explained here: In this example the [index] provides the numbers 1 through 8. Take the numbers and insert them where you see [index] [variable[index]] becomes [variable1] Expanding outward we then have [interpret][variable1][/interpret] When WebDNA sees this it will return the information stored in the variable. The [interpret] context is very powerful command in the hands of a skilled WebDNA programmer. It allows you to create truly dynamic code. Let's suppose you have need a simple array of eight variables. We could name them sequentially like this:
variable1
variable2
variable3
...
variable8

If we wanted to preset all these variables to null, you would use the [text] context like so:
[text]variable1=[/text]
[text]variable2=[/text]
[text]variable3=[/text]
...
[text]variable8=[/text]

However, there is an easier way to set them all using the [loop] context.
[loop start=1&end=8]
[text]variable[index]=[/text]
[/loop]

Later in your code you could call the variables individually by simply placing the [variable1], [variable2], [variable3] ... [variable8] where needed. But if you need to display them all at once you can use the [loop] again.
[loop start=1&end=8]
[interpret][variable[index]][/interpret]
[/loop]

The [interpret] context is a vary powerful way of processing code inside code, and you need to be extra careful with your usage of the brackets when using [interpret] because it's easy to forget one of the ]. Understanding this is tricky for new programmers so let's break down the above example step by step:

WebDNA will always process from the inside out as explained here:

In this example the [index] provides the numbers 1 through 8.

Take the numbers and insert them where you see [index]
[variable[index]] becomes [variable1]

Expanding outward we then have [interpret][variable1][/interpret]
When WebDNA sees this it will return the information stored in the variable.

The [interpret] context is very powerful command in the hands of a skilled WebDNA programmer. It allows you to create truly dynamic code. Matthew Perosi - Psi Prime

DOWNLOAD WEBDNA NOW!

Top Articles:

AWS Raw WebDNA LAMP-Plus WebServer

Amazon Web Services (AWS) README for Machine Image ID...

F.A.Q

A compilation of some user's questions...

[biotype]

BioType is a behavioral biometrics WebDNA function based on ADGS research and development (from version 8...

Tips and Tricks

A list of user-submitted tips ...

Technical Change History

This Technical Change History provides a reverse chronological list of WebDNA changes...

WebDNA Libraries

A list of available libraries for WebDNA...

Related Readings:

Removing whitespace

How can I remove all whitespace entered by a user from an input box (ie card number)...

reCAPTCHA code

reCAPTCHA helps prevent automated abuse of your site (such as comment spam or bogus registrations) by using a CAPTCHA to ensure that only humans perform certain actions...

Spaghetti code

How to get rid of very long search strings...

Check the Federal Government's Social Security database

The script on the page will check the federal government's social security database...

Write Once Use Many

Reuse the same code over and over again on your site with the [include] context...

How to create a RSS feed

How to create a RSS feed from yourdatabase on formation...