This shows you the differences between the selected revision and the current version of the page.
| ptpscript:commands:data 2006/05/29 13:12 | ptpscript:commands:data 1970/01/01 00:00 current | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ======Data Command====== | ||
| - | The ''Data'' command allows areas of text to be marked as data, and therefore ignored by the PTP engine. These areas can contain PTPScript code, [[PTPScript:Basic Syntax:Placeholders|Placeholder]] symbols, etc. without being processed as PTPScript code. For instance, one use would be to mark an area of CSS or JavaScript in a webpage, so that the PTP engine would not try to evaluate it. | ||
| - | |||
| - | There is just one command in to the ''Data'' family - the ''Data'' command itself. It consists of the command followed by a set of characters that will be used to signal the end of the data sequence. These characters can be any characters except curly braces - ''{ }'' - as these are used to denote PTP placeholders. | ||
| - | |||
| - | For example: | ||
| - | |||
| - | <code ptpscript> | ||
| - | { data !!!END_OF_DATA!!! } | ||
| - | // Handy JavaScript function to pad numbers | ||
| - | function pad(number, places) { | ||
| - | if (number.toString().length > places) { | ||
| - | return number.toPrecision(places); | ||
| - | } else { | ||
| - | var str = number.toString(); | ||
| - | while (str.length < places) { | ||
| - | str = '0' + str; | ||
| - | } | ||
| - | return str; | ||
| - | } | ||
| - | } | ||
| - | !!!END_OF_DATA!!! | ||
| - | </code> | ||
| - | |||
| - | <output><code> | ||
| - | // Handy JavaScript function to pad numbers | ||
| - | function pad(number, places) { | ||
| - | if (number.toString().length > places) { | ||
| - | return number.toPrecision(places); | ||
| - | } else { | ||
| - | var str = number.toString(); | ||
| - | while (str.length < places) { | ||
| - | str = '0' + str; | ||
| - | } | ||
| - | return str; | ||
| - | } | ||
| - | } | ||
| - | </code></output> | ||
| - | |||
| - | In the example above, a section of JavaScript code is marked as a data sequence, and is correspondingly left as-is by the PTP engine. | ||
| - | |||
| - | ''Data'' commands can appear within other command structures, but cannot be nested within other ''Data'' sequences. | ||
| - | |||
| - | ~~DISCUSSION~~ | ||