Post Reply 
Template for a table editor [▣=▣ ].
04-27-2019, 02:36 AM (This post was last modified: 05-20-2019 11:52 PM by compsystems.)
Post: #6
RE: Template for a table editor [▣=▣ ].
Another example of how to use the data in the table.

PHP Code:
phonebook := table("John":0"Jack":0"Jill":
[enter]
PHP Code:
table(
"Jack" 0,
"Jill" 0,
"John" 0


PHP Code:
phonebook["John"],phonebook["Jack"],phonebook["Jill"
[enter]
PHP Code:
0,0,

PHP Code:
phonebook["John"] := 938477566
phonebook
["Jack"] := 938377264
phonebook
["Jill"] := 947662781 
[enter]
"Done","Done","Done"

PHP Code:
phonebook 
[enter]
PHP Code:
table(
"Jack" 938377264,
"Jill" 947662781,
"John" 938477566


PHP Code:
phonebook["John"],phonebook["Jack"],phonebook["Jill"
[enter]
PHP Code:
938477566938377264947662781 

Alternatively, a table can be initialized with the same values in the following notation:

PHP Code:
phonebook := table("John" 938477566,"Jack" 938377264,"Jill" 947662781
[enter]
PHP Code:
table(
"Jack" 938377264,
"Jill" 947662781,
"John" 938477566


Adhere to a new member.
phonebook["jaime"] := 3187935015

Iterating over tables

Tables can be iterated over, just like a list. However, a table, unlike a list, does not keep the order of the values stored in it. To iterate over key value pairs, use the following syntax:


PHP Code:
for name in phonebook:
    print( 
"Phone number of " name " is " phonebook[name]) 
[enter]

PHP Code:
Phone number of Jack is 938377264
Phone number of Jill is 947662781
Phone number of John is 938477566 

Removing a value
To remove a specified index, use either one of the following notations:

PHP Code:
del phonebook["John"
[enter]

phonebook [enter]
PHP Code:
table(
"Jack" 938377264,
"Jill" 947662781


or
PHP Code:
phonebook.pop("Jill"
[enter]


phonebook [enter]
PHP Code:
table(
"Jack" 938377264

Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Template for a table editor [▣=▣ ]. - compsystems - 04-27-2019 02:36 AM



User(s) browsing this thread: 1 Guest(s)