11.01.2013 Views

Oracle Forms Developer – Form Builder Reference, Volume 1

Oracle Forms Developer – Form Builder Reference, Volume 1

Oracle Forms Developer – Form Builder Reference, Volume 1

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

*/<br />

prefix := ’GLOBAL.’ || the_stackname;<br />

/*<br />

** This named stack’s pointer resides in<br />

** GLOBAL._PTR Remember that this is the *name*<br />

** of the pointer.<br />

*/<br />

ptr_name := prefix || ’_PTR’;<br />

/*<br />

** Force a default value of NULL so we can test if the<br />

** pointer exists (as a global variable). If it does not<br />

** exist, we can test in a moment for the NULL, and avoid<br />

** the typical error due to referencing non-existent<br />

** global variables.<br />

*/<br />

Default_Value( NULL, ptr_name );<br />

/*<br />

** If the *value* contained in the pointer is NULL, then<br />

** the pointer must not have existed prior to the<br />

** Default_Value statement above. Return the constant<br />

** NO_SUCH_STACK in this case and erase the global<br />

** variable that the Default_Value implicitly created.<br />

*/<br />

IF Name_In( ptr_name ) IS NULL THEN<br />

the_val := NO_SUCH_STACK;<br />

Erase( ptr_name );<br />

/*<br />

** Otherwise, the named stack already exists. Get the<br />

** index of the largest stack element from this stack’s<br />

** pointer.<br />

*/<br />

ELSE<br />

cur_idx := Name_In( ptr_name ) ;<br />

/*<br />

** If the index is zero, then the named stack is already<br />

** empty, so return the constant EMPTY_STACK, and leave<br />

** the stack’s pointer around for later use, ie don’t<br />

** ERASE it.<br />

**<br />

** Note that a stack can only be empty if some values<br />

** have been PUSH’ed and then all values subsequently<br />

** POP’ed. If no values were ever PUSH’ed on this named<br />

** stack, then no associated stack pointer would have<br />

** been created, and we would flag that error with the<br />

** NO_SUCH_STACK case above.<br />

*/<br />

IF cur_idx = ’0’ THEN<br />

the_val := EMPTY_STACK;<br />

/*<br />

** If the index is non-zero, then:<br />

** (1) Determine the name of the global variable in<br />

** which the value to be POP’ed is stored,<br />

** GLOBAL.<br />

** (2) Get the value of the (cur_idx)-th element to<br />

** return<br />

** (3) Decrement the stack pointer<br />

** (4) Erase the global variable which was used for<br />

** value storage<br />

*/<br />

ELSE<br />

elt_name:= prefix || cur_idx;<br />

the_val := Name_In( elt_name );<br />

new_idx := TO_CHAR( TO_NUMBER( Name_In(ptr_name) ) - 1 ) ;<br />

Copy( new_idx , ptr_name );<br />

Erase( elt_name );<br />

293

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!