2 Single: Using ZeroLib; Introduction
8 In this chapter we will learn how to use the ZeroLib library.
12 pair: Using ZeroLib; Introduction
17 ZeroLib is a simple library written in Ring.
19 The library provideds classes for Lists and String where the index starts from 0.
23 pair: Using ZeroLib; Z() function
32 Z(String|List) ---> New Object (ZeroBasedString|ZeroBasedList)
35 pair: Using ZeroLib; ZeroBasedList Class
40 Simple class provide a List where the index starts from zero.
44 =========================== ======================================================================
45 Method Description/Output
46 =========================== ======================================================================
48 Add(Value) Add item to the list
49 Insert(nIndex,Value) Inset Item after nIndex
51 Delete(nIndex) Delete item from the list
52 Item(nIndex) Get item from the list
53 First() Get the first item in the list
54 Last() Get the last item in the list
55 Set(nIndex,Value) Set item value
56 FindInColumn(nCol,Value) Find item in a column
57 Sort() Sort items - return new list
58 Reverse() Reverse items - return new list
59 Swap(nIndex1,nIndex2) Swap two items
60 =========================== ======================================================================
69 ? "Using List - Index start from 0"
79 ? "Find(2) = " + nIndex
81 ? "After deleting the first item : List[0]"
82 ? "Now List[0] = " + List[0]
88 Using List - Index start from 0
95 After deleting the first item : List[0]
99 pair: Using ZeroLib; ZeroBasedString Class
101 ZeroBasedString Class
102 =====================
104 Simple class provide a String where the index starts from zero.
106 =========================== ======================================================================
107 Method Description/Output
108 =========================== ======================================================================
110 Lower() New String - Lower case characters
111 Upper() New String - Upper case characters
112 Left(x) New String - contains x characters from the left
113 Right(x) New String - contains x characters from the right
114 Lines() Number - Lines count
115 Trim() New String - Remove Spaces
116 Copy(x) New String - repeat string x times
117 strcmp(cString) Compare string with cString
118 tolist() List (String Lines to String Items)
119 tofile(cFileName) Write string to file
120 mid(nPos1,nPos2) New String - from nPos1 to nPos2
121 getfrom(nPos1) New String - from nPos1 to the end of the string
122 replace(cStr1,cStr2,lCase) New String - Replace cStr1 with cStr2 , lCase (True=Match Case)
123 split() List - Each Word as list item
124 startswith(substring) Return true if the start starts with a substring
125 endswith(substring) Return true if the start ends with a substring
126 =========================== ======================================================================
134 ? "Using String - Index start from 0"
135 String = Z( "Welcome" )
148 Using String - Index start from 0
158 pair: Using ZeroLib; Source Code
163 We can find the library source code in this folder
165 URL : https://github.com/ring-lang/ring/tree/master/ringlibs/zerolib