Pushing items up and down

There are two very handy functions in Tables Library, they are:

  • TB.PushUp(table, position)
  • TB.PushDown(table, position)

These functions take the item at the given position and move it, respectively, to the top of the table or to the bottom of the table.

Here is a brief exaple that comes with the library within the function TB.TEST_Push()

Function TB.TEST_Push()
  
  Local items = { "Jhonny", 
                  "Michael", 
                  "Henry", 
                  "Mark", 
                  "Ryan", 
                  "Cody", 
                  "Fred", 
                  "Jim", 
                  "Paul", 
                  "Sam" }  
  
  Local drawScreen = Function()
                        Cls
                        Locate(0, 0)
                        NPrint("TESTING TB.Item.PushUp(), TB.Item.PushDown()\n")
                        NPrint("TABLE CONTENTS:")
                        For Local i = 0 To 9 Do NPrint(i, items[i])
                        
                        NPrint("\nType your choice and hit ENTER:")
                        NPrint("1) PushUp, 2) PushDown, Q) Quit")
                        
                        Local command = InKeyStr(#ALL)
                        
                        If command = "Q"
                          End
                          
                        ElseIf command = "1"
                          NPrint("\n   Type item number and hit ENTER:")
                          Local i = ToNumber(InKeyStr(#ALL))
                          TB.PushUp(items, i)
                          
                        ElseIf command = "2"
                          NPrint("\n   Type item number and hit ENTER:")
                          Local i = ToNumber(InKeyStr(#ALL))
                          TB.PushDown(items, i)
                          
                        EndIf
                      EndFunction
                      
  Repeat
    drawScreen()
  Forever
  
EndFunction
hollywoodlibs/tables/testpushpull.txt · Ultima modifica: 2016/10/21 08:54 da admin
CC Attribution-Noncommercial 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0