You are here: Home DOCUMENTATION information SBASIC Manual - Page 51

Technological Arts Inc.

Your Shopping Cart

Your Cart is currently empty.

SBASIC Manual - Page 51

Article Index
SBASIC Manual
Page 2
Page 3
Page 4
Page 5
Page 6
Page 7
Page 8
Page 9
Page 10
Page 11
Page 12
Page 13
Page 14
Page 15
Page 16
Page 17
Page 18
Page 19
Page 20
Page 21
Page 22
Page 23
Page 24
Page 25
Page 26
Page 27
Page 28
Page 29
Page 30
Page 31
Page 32
Page 33
Page 34
Page 35
Page 36
Page 37
Page 38
Page 39
Page 40
Page 41
Page 42
Page 43
Page 44
Page 45
Page 46
Page 47
Page 48
Page 49
Page 50
Page 51
Page 52
Page 53
Page 54
Page 55
Page 56
Page 57
Page 58
Page 59
Page 60
Table of Contents
Index
All Pages

     SBasic User's Manual     SBasic Version 2.7             Page 51
     Printed:  December 5, 1999

     You can also use the PULL() function to remove items from the data
     stack.  PULL() works exactly the same was as the POP() function; it is
     simply a synonym for POP().

     You can copy a value from within the data stack by using the PICK()
     function.  PICK() locates a specific item within the data, and returns
     that value.

     Example:

          n = pick(2)

     copies the third item in the data stack into N.  The size of the data
     stack does not change, and the value in the third item does not
     change.

     Note that the item on the top of the stack is item 0; the second item
     is item 1.  SBasic does not check to see how many items are actually
     on the data stack.  If you supply an argument to PICK() that is larger
     than the current data stack, SBasic will return a bogus but legal
     value.

     You can alter a value within the data stack by using the PLACE
     statement.  PLACE stores a 16-bit value into a specified item in the
     data stack.

     Example:

          PLACE  2, n

     stores the value in N into the third item in the data stack.  The
     value in N does not change, and the size of the data stack does not
     change.

     SBasic does not test the actual size of the data stack before
     executing the PLACE statement.  Using PLACE to modify an item beyond
     the actual data stack will corrupt that location in memory and could
     crash your program.

     You can combine PICK() and PLACE to create 16-bit variables local to a
     section of code, such as a subroutine.  For example:

          foo:
          do
               place  0, pick(0) + 1    ' increment the item
          loop while pick(0) < 5        ' loop until it hits 5

     This code uses an item, already stored on the data stack by previous
     code, as a local variable.  Changes to this variable occur only in the
     data stack, not in a DECLAREd variable.