Sequences - Xref - Types - pull


App: manual Page: fragments/page_4
PHP
HTML
fragments/page_4.pad
Result
{data 'fruit'}["apple","pear"]{/data}
<p>A clean pass sees the store: {code clean}{fruit}{$fruit} {/fruit}{/code}</p>
{code}{sequence '7;8;9', push='nums'/}{/code}
<p>A plain pass pushed nums, and it survived: {pull:nums}{$sequence} {/pull:nums}</p>

App: manual Page: pages/page
PHP
HTML
pages/page.pad
Result
{meta title='Nested Passes - {code} and {page}'}

<p>A nested pass is the engine run inside itself: the content of a <code>{code}</code>
pair, or the page a <code>{page}</code> tag names, is rendered as a complete PAD run
of its own, and what it produced lands in the surrounding page. The pass sees the request it
runs in - its variables, its stores - unless it asks for isolation.</p>

<h2>A pass and what it leaves behind</h2>

<p>A plain <code>{code}</code> shares everything. What the pass creates is still
there when it returns:</p>

{example 'fragments/page_1'}

<h2>The four isolation forms</h2>

<p>Three options decide how much of the request a pass sees, and how much of the pass the
request keeps. They differ on both sides of the boundary:</p>

<table border="1" cellpadding="8" cellspacing="0" style="border-collapse: collapse;">
<tr><th>form</th><th>sees the outer state</th><th>what it created afterwards</th></tr>
<tr><td><code>{code}</code></td> <td>yes</td><td>still there</td></tr>
<tr><td><code>{code reset}</code></td> <td>no - a blank slate going in</td><td>still there</td></tr>
<tr><td><code>{code clean}</code></td> <td>yes</td><td>taken back out</td></tr>
<tr><td><code>{code sandbox}</code></td> <td>no</td><td>taken back out</td></tr>
</table>

<p>&nbsp;</p>

{example 'fragments/page_2'}

<h2>Another page as a pass</h2>

<p><code>{page 'name'}</code> runs that page - its .php and its .pad - as a pass,
with the same isolation options. A <code>function</code> option runs the pass inside a PHP
function body, but it still starts from the caller's variables and what it sets comes back
out - a page whose .php half must not touch the caller's variables wants <code>clean</code>
or <code>sandbox</code>:</p>

{example 'fragments/page_3'}

<h2>Stores cross the boundary by the same rules</h2>

<p>The data, content, bool and sequence stores follow the isolation form. A
<code>clean</code> pass reads the request's stores; a <code>sandbox</code> or
<code>reset</code> pass starts without them. On the way out, only a plain pass's pushes
stay: each of the three isolated forms puts the request's stores back exactly as they
were, its own pushes included:</p>

{example 'fragments/page_4'}

<h2>Engine state is always put back</h2>

<p>Whatever the isolation form, the engine itself returns to where it was: a loop the pass
ran inside continues from the same row, and a request-lived counter such as
<code>{switch}</code>'s rotation is rolled back with the rest - a pass takes its
counting with it:</p>

{example 'fragments/page_5'}

<p>Both calls answer the first value: the rotation the pass advanced was restored when the
pass returned.</p>

App: regression/framework Page: lenient/a_count_that_is_no_whole_number_leaves_the_sequence_alone
PHP
lenient/a_count_that_is_no_whole_number_leaves_the_sequence_alone.php
HTML
lenient/a_count_that_is_no_whole_number_leaves_the_sequence_alone.pad
Result
<?php

// The lenient walk under test: with the syntax check off, what cannot run passes the
// value through or yields empty, and the walk carries on.

$padCheckSyntax = FALSE;

?>
[{sequence '1..6', first=2.5}{$sequence} {/sequence}][{sequence '1..6', last=-1}{$sequence} {/sequence}][{sequence '1..6', push='p'}{pull:p pop='x'}{$sequence} {/pull:p}][{pull:p}{$sequence} {/pull:p}][{sequence '1..6', maximum=1.5}{$sequence} {/sequence}]

App: regression/framework Page: lenient/a_resume_prefix_is_no_type_and_leaves_the_store_alone
PHP
lenient/a_resume_prefix_is_no_type_and_leaves_the_store_alone.php
HTML
lenient/a_resume_prefix_is_no_type_and_leaves_the_store_alone.pad
Result
<?php

// The lenient walk under test: with the syntax check off, what cannot run passes the
// value through or yields empty, and the walk carries on.

$padCheckSyntax = FALSE;

?>
[{sequence 5, push='x'}{resume:x add=1}][{pull:x}{$sequence} {/pull:x}]

App: regression/framework Page: passes/a_plain_pass_leaves_its_push_behind
PHP
HTML
passes/a_plain_pass_leaves_its_push_behind.pad
Result
{code}{sequence '7;8', push='psOut'/}in{/code}
[{pull:psOut}{$sequence},{/pull:psOut}]

App: regression/framework Page: prefixes/pull_names_a_stored_sequence
PHP
HTML
prefixes/pull_names_a_stored_sequence.pad
Result
{sequence '1..3', push='p'/}
{pull:p}
{$sequence},
{/pull:p}

App: regression/framework Page: sequence/a_fraction_is_one_value_wherever_it_prints_alike
PHP
HTML
sequence/a_fraction_is_one_value_wherever_it_prints_alike.pad
Result
{sequence '0.3;1', push='b'/}[{sequence '0.1;0.2', make, add=0.1, merge='b'}{$sequence} {/sequence}][{sequence '1;1.0;2;2', dedup}{$sequence} {/sequence}][{sequence '1;1.0;2;x;x', distinct}{$sequence} {/sequence}][{sequence '0.1;0.2', make, add=0.1, push='c'/}{pull:c dedup='b'}{$sequence} {/pull:c}][{sequence '0.30000000000000004;0.3', unique}{$sequence} {/sequence}][{sequence '3;1;3;2;1', dedup}{$sequence} {/sequence}]

App: regression/framework Page: sequence/a_list_beside_a_store_pulled_plays_over_it_as_a_semicolon_list_does_or_is_the_parameter_of_an_action_option
PHP
HTML
sequence/a_list_beside_a_store_pulled_plays_over_it_as_a_semicolon_list_does_or_is_the_parameter_of_an_action_option.pad
Result
{sequence '1..6', push='a'/}[{keep:a [2,3,9]}{$sequence} {/keep:a}][{remove:a [2,3,9]}{$sequence} {/remove:a}][{flag:a [2,3,9]}{$sequence} {/flag:a}][{make:a [2,3,9]}{$sequence} {/make:a}][{pull:a keep, [2,3,9]}{$sequence} {/pull:a}][{pull:a [7, 8]}{$sequence} {/pull:a}|{pull:a '7;8'}{$sequence} {/pull:a}][{sequence '7;8', push='b'/}{pull:b append, [9]}{$sequence} {/pull:b}][{pull:b [9], append}{$sequence} {/pull:b}][{sequence b, prepend, [9]}{$sequence} {/sequence}]

App: regression/framework Page: sequence/a_list_for_an_action_that_takes_stores_is_one
PHP
HTML
sequence/a_list_for_an_action_that_takes_stores_is_one.pad
Result
[{echo php:implode(',', sequence:merge([1,2], [4]))}][{sequence '1..5', push='a'/}{sequence '4..8', push='b'/}{pull:a intersection=b}{$sequence} {/pull:a}][{echo php:implode(',', sequence:sum([1,2,3]))}][{sequence '1..3', append=[7,8]}{$sequence} {/sequence}]

App: regression/framework Page: sequence/a_list_is_the_values_of_a_sequence_and_of_an_action
PHP
HTML
sequence/a_list_is_the_values_of_a_sequence_and_of_an_action.pad
Result
[{sequence [3,1,2], sort}{$sequence} {/sequence}][{sequence list=[5,'a',2]}{$sequence} {/sequence}]{sequence '1..5', push='a'}{/sequence}{sequence '4..8', push='b'}{/sequence}[{pull:a intersection=b}{$sequence} {/pull:a}][{pull:a append=[9,8]}{$sequence} {/pull:a}][{pull:a difference=[2,3,9]}{$sequence} {/pull:a}]

App: regression/framework Page: sequence/a_list_the_request_or_a_row_brings_under_a_store_name_leaves_the_store_to_the_sequence
PHP
sequence/a_list_the_request_or_a_row_brings_under_a_store_name_leaves_the_store_to_the_sequence.php
HTML
sequence/a_list_the_request_or_a_row_brings_under_a_store_name_leaves_the_store_to_the_sequence.pad
Result
<?php

// The visitor sends ?primes[]=1&orders[]=7 - lists, under the names of the stores the page
// pushes and names - which become variables as every request value does. They are no array
// the page made: the stores are kept as without them, where the first ended the page on
// "the store name 'primes' is already an array of the page" and the second kept no store.

$_GET ['primes'] = [ '1' ];
$_GET ['orders'] = [ '7' ];

padGetParms ( 'GET', [ 'primes' => [ '1' ], 'orders' => [ '7' ] ] );

?>
[{sequence '1..3', push='primes'/}{pull:primes}{$primes} {/pull:primes}]
[{sequence 3, name='orders'}{$orders}{/sequence}|{pull:orders}{$orders}{/pull:orders}]
{data 'o'}[{"id":1,"kids":[{"k":1}]}]{/data}[{o}{sequence '1..2', push='kids'/}{pull:kids}{$kids}{/pull:kids}{/o}]

App: regression/framework Page: sequence/a_loop_named_like_a_page_array_or_a_store_keeps_no_store_under_that_name
PHP
sequence/a_loop_named_like_a_page_array_or_a_store_keeps_no_store_under_that_name.php
HTML
sequence/a_loop_named_like_a_page_array_or_a_store_keeps_no_store_under_that_name.pad
Result
<?php

$orders
= [ [ 'id' => 'A1' ], [ 'id' => 'B2' ] ];

?>
before:[{orders}{$id} {/orders}] loop:[{sequence 3, name='orders'}{$orders} {/sequence}] after:[{orders}{$id} {/orders}]
{data 'x'}[{"a":7},{"a":8}]{/data}[{sequence '1..3', name='x'}{$x} {/sequence}][{x}{$a} {/x}]
{content 'c'}CONTENT{/content}[{sequence 2, name='c'}{$c}{/sequence}][{c}]
[{sequence 2, name='free'}{$free}{/sequence}][{free}{$free}{/free}]

App: regression/framework Page: sequence/a_named_pair_and_a_resume_keep_the_columns_of_their_terms
PHP
HTML
sequence/a_named_pair_and_a_resume_keep_the_columns_of_their_terms.pad
Result
[{sequence '1..3', add=10, name='s'}{/sequence}{pull:s}{$sequence}:{$range}:{$add} {/pull:s}]{sequence '1..6', add=10, push='nums'}{/sequence}[{resume reverse}{pull:nums}{$sequence}:{$range}:{$add} {/pull:nums}]{sequence '1..6', add=10, push='nums'}{/sequence}[{resume shift=2}{pull:nums}{$sequence}:{$range}:{$add} {/pull:nums}]

App: regression/framework Page: sequence/a_named_pair_is_a_loop_first_and_leaves_the_last_push
PHP
HTML
sequence/a_named_pair_is_a_loop_first_and_leaves_the_last_push.pad
Result
[{sequence 3, name='step'}{$step} {/sequence}][{sequence 3, name='count'}{$count} {/sequence}][{sequence 2, name='first'}{$first}{/sequence}][{sequence '1..5', push='s'}{/sequence}{sequence 3, name='i'}{$i}{/sequence}|{resume reverse}{pull:s}{$s} {/pull:s}][{pull:i}{$i}{/pull:i}]

App: regression/framework Page: sequence/a_number_right_after_an_option_naming_a_type_or_an_action_that_counts_is_its_value
PHP
HTML
sequence/a_number_right_after_an_option_naming_a_type_or_an_action_that_counts_is_its_value.pad
Result
{sequence '1..9', push='a'/}[{pull:a first, 2}{$sequence} {/pull:a}][{pull:a add, 2}{$sequence} {/pull:a}][{sequence '1..3', add, 2}{$sequence} {/sequence}][{sequence '1..3', first, 2}{$sequence} {/sequence}][{prime first, 3}{$sequence} {/prime}][{sequence add, 3, rows=3}{$sequence} {/sequence}]