|
1 |
| -# Dictionary in Classic ASP |
| 1 | +# Dynamic array in Classic ASP |
2 | 2 |
|
3 |
| -[](https://app.codacy.com/gh/R0mb0/Dictionary_classic_asp/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade) |
| 3 | +[](https://app.codacy.com/gh/R0mb0/Dynamic_array_classic_asp/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade) |
4 | 4 |
|
5 |
| -[](https://github.com/R0mb0/Dictionary_classic_asp) |
6 |
| -[](https://github.com/R0mb0/Dictionary_classic_asp) |
| 5 | +[](https://github.com/R0mb0/Dynamic_array_classic_asp) |
| 6 | +[](https://github.com/R0mb0/Dynamic_array_classic_asp) |
7 | 7 | [](https://opensource.org/license/mit)
|
8 | 8 |
|
9 | 9 | [](http://paypal.me/R0mb0)
|
10 | 10 |
|
11 |
| -## Backgroud structure |
12 |
| - |
13 |
| -### Arrays structure. |
14 |
| -The dictionary is implemented as a multidimensional array, where the first dynamic array contains on every cell a fixed array of two cells. |
15 |
| -The first fixed array cell contains the unique key and the second one contains the value. |
16 |
| - |
17 |
| -#### Chart |
18 |
| -```mermaid |
19 |
| -flowchart LR; |
20 |
| - A[/0/] ==> B[/1/] |
21 |
| - B ==> C[/2/] |
22 |
| - C ==> D[/.../] |
23 |
| - A --> E[0: Unique Key] |
24 |
| - E --> F[1: Value] |
25 |
| - B --> G[0: Unique Key] |
26 |
| - G --> H[1: Value] |
27 |
| - C --> I[0: Unique Key] |
28 |
| - I --> J[1: Value] |
29 |
| - D --> K[0: Unique Key] |
30 |
| - K --> L[1: Value] |
31 |
| -``` |
32 | 11 |
|
33 | 12 | <details>
|
34 | 13 | <summary>
|
35 | 14 |
|
36 |
| - ## `Dictionary.asp`'s avaible Functions |
| 15 | +## `Dynamic_array.asp`'s avaible Functions |
37 | 16 |
|
38 |
| - </summary> |
39 |
| - |
40 |
| -- **Initialize an array as a dictionary** -> `get_initialized_dictionary()` |
41 |
| -- **Add an element into a dictionary** -> `add_element_to_dictionary(key,value)` |
42 |
| -- **Get value from key** -> `get_dictionary_value_from_key(key)` |
43 |
| -- **Set value from key** -> `set_dictionary_value_from_key(key,value)` |
44 |
| -- **Change a key into dictionary** -> `change_dictionary_key(old_key,new_key)` |
45 |
| -- **Remove dictionary element from key** -> `remove_dictionary_element_from_index(idx)` |
46 |
| -- **Remove dictionary element from index** -> `remove_dictionary_element_from_index(idx)` |
47 |
| -- **Remove last element from dictionary** -> `remove_last_element_from_dictionary()` |
48 |
| -- **Remove elements from dictionary using indices (pass to function an array with the indices)** -> `remove_dictionary_elements_from_indices(indices)` |
49 |
| -- **Remove all elements with the same value from dictionary** -> `remove_dictionary_elements_from_value(value)` |
50 |
| -- **Replace all value occurrences with a new value in dictionary** -> `replace_all_value_occurrences(old_value,new_value)` |
51 |
| -- **Get key index from dictionary** -> `get_key_index_from_dictionary(key)` |
52 |
| -- **Reset a dictionary** -> `get_initialized_dictionary()` |
53 |
| -- **Get dictionary key from index** -> `get_dictionary_key_from_index(idx)` |
54 |
| -- **Get first value index occurrence** -> `get_first_value_index_occurrence(value)` |
55 |
| -- **Get all indices of a value** -> `get_all_value_indices(value)` |
56 |
| -- **Check if a key has been used into dictionary** -> `check_if_key_has_been_used(key)` |
57 |
| -- **Check if a value is present in the dictionary** -> `check_if_value_is_present(value)` |
58 |
| -- **Get dictionary value from index** -> `get_dictionary_value_from_index(idx)` |
59 |
| -- **Get dictionary dimension** -> `get_dictionary_dimension()` |
60 |
| -- **Write a dictionary** -> `write_dictionary()` |
61 |
| - |
62 |
| -## How to use: |
63 |
| - |
64 |
| -> From `Test.asp` |
65 |
| -
|
66 |
| -1. Create array and initialize it as dictionary |
| 17 | +</summary> |
| 18 | + |
| 19 | +- **Initialize the array** -> `initialize_array()` |
| 20 | +- **Check if the array is initializated** -> `is_array_initializated()` |
| 21 | +- **Add an element into the array** -> `add_element_to_array(element)` |
| 22 | +- **Get element from index** -> `get_element_from_array(idx)` |
| 23 | +- **Remove last element from array** -> `remove_last_element_from_array()` |
| 24 | +- **Remove an element from array** -> `remove_all_occurences_from_array(element)` |
| 25 | +- **Remove the first element occurence from array** -> `remove_first_occurence_from_array(element)` |
| 26 | +- **Remove element from index** -> `remove_this_elements_from_array(idx)` |
| 27 | +- **Remove elements from indices** -> `remove_these_elements_from_array(indices_array)` |
| 28 | +- **Reset the array** -> `initialize_array()` |
| 29 | +- **Check if an element is in the array** -> `array_contains(element)` |
| 30 | +- **Retrieve the first index of an element in the array** -> `from_array_get_first_index_occurence_of(element)` |
| 31 | +- **Retrieve all indeces of an element inside the array (return an array)** -> `from_array_get_all_indeces_occurence_of(element)` |
| 32 | +- **Retrieve the entire array** -> `get_array()` |
| 33 | +- **Retrieve the array dimension** -> `get_array_dimension()` |
| 34 | +- **Write the entire array** -> `write_array()` |
| 35 | + |
| 36 | +## How to use |
| 37 | + |
| 38 | +> From `Test1.asp` |
| 39 | +
|
| 40 | +1. Initialize the array and check it's status |
67 | 41 | ```asp
|
68 |
| - <!--#include file="Dictionaries.asp"--> |
| 42 | + <%@LANGUAGE="VBSCRIPT"%> |
| 43 | + <!--#include file="Dynamic_array.asp"--> |
69 | 44 | <%
|
70 |
| - Dim dictionary |
71 |
| - dictionary = Array() |
72 |
| - dictionary = get_initialized_dictionary() |
| 45 | + initialize_array() |
| 46 | + Response.Write("Array status: ") |
| 47 | + Response.Write(is_array_initializated() & "<br>") |
73 | 48 | ```
|
74 |
| -2. Pass the dictionary to functions for manage |
| 49 | +2. Use the functions to manage the array |
75 | 50 | ```asp
|
76 |
| - add_element_to_dictionary_array "0001","Ice ice baby" |
77 |
| - add_element_to_dictionary_array "0002","Dove lo vuoi tu" |
78 |
| - add_element_to_dictionary_array "0003","Hot shot" |
79 |
| - write_dictionary |
| 51 | + add_element_to_array("A") |
| 52 | + add_element_to_array("B") |
| 53 | + add_element_to_array("C") |
| 54 | + add_element_to_array("D") |
| 55 | + Response.Write("Elements inside: ") |
| 56 | + write_array() |
80 | 57 | %>
|
81 | 58 | ```
|
| 59 | + |
82 | 60 | </details>
|
83 | 61 |
|
84 | 62 | <details>
|
85 | 63 | <summary>
|
86 | 64 |
|
87 |
| - ## `Dictionaries.asp`'s avaible Functions |
| 65 | +## `Dynamic_arrays.asp`'s avaible Functions |
88 | 66 |
|
89 |
| - </summary> |
90 |
| - |
91 |
| -- **Initialize an array as a dictionary** -> `get_initialized_dictionary()` |
92 |
| -- **Add an element into a dictionary** -> `add_element_to_dictionary(dictionary,key,value)` |
93 |
| -- **Get value from key** -> `get_dictionary_value_from_key(dictionary,key)` |
94 |
| -- **Set value from key** -> `set_dictionary_value_from_key(dictionary,key,value)` |
95 |
| -- **Change a key into dictionary** -> `change_dictionary_key(dictionary,old_key,new_key)` |
96 |
| -- **Remove dictionary element from key** -> `remove_dictionary_element_from_index(dictionary,idx)` |
97 |
| -- **Remove dictionary element from index** -> `remove_dictionary_element_from_index(dictionary,idx)` |
98 |
| -- **Remove last element from dictionary** -> `remove_last_element_from_dictionary(dictionary)` |
99 |
| -- **Remove elements from dictionary using indices (pass to function an array with the indices)** -> `remove_dictionary_elements_from_indices(dictionary,indices)` |
100 |
| -- **Remove all elements with the same value from dictionary** -> `remove_dictionary_elements_from_value(dictionary,value)` |
101 |
| -- **Replace all value occurrences with a new value in dictionary** -> `replace_all_value_occurrences(dictionary,old_value,new_value)` |
102 |
| -- **Get key index from dictionary** -> `get_key_index_from_dictionary(dictionary,key)` |
103 |
| -- **Reset a dictionary** -> `get_initialized_dictionary()` |
104 |
| -- **Get dictionary key from index** -> `get_dictionary_key_from_index(dictionary,idx)` |
105 |
| -- **Get first value index occurrence** -> `get_first_value_index_occurrence(dictionary,value)` |
106 |
| -- **Get all indices of a value** -> `get_all_value_indices(dictionary,value)` |
107 |
| -- **Check if a key has been used into dictionary** -> `check_if_key_has_been_used(dictionary,key)` |
108 |
| -- **Check if a value is present in the dictionary** -> `check_if_value_is_present(dictionary,value)` |
109 |
| -- **Get dictionary value from index** -> `get_dictionary_value_from_index(dictionary,idx)` |
110 |
| -- **Get dictionary dimension** -> `get_dictionary_dimension(dictionary)` |
111 |
| -- **Write a dictionary** -> `write_dictionary(dictionary)` |
112 |
| - |
113 |
| -## How to use: |
| 67 | +</summary> |
| 68 | + |
| 69 | +- **Initialize a dynamic array** -> `get_initializated_dynamic_array()` |
| 70 | +- **Add an element into a dynamic array** -> `add_element_to_dynamic_array(my_array,element)` |
| 71 | +- **Get element from index** -> `get_element_from_dynamic_array(my_array,idx)` |
| 72 | +- **Remove last element from a dynamic array** -> `remove_last_element_from_dynamic_array(my_array)` |
| 73 | +- **Remove all element occurences from a dyamic array** -> `remove_all_occurences_from_dynamic_array(my_array,element)` |
| 74 | +- **Remove first element occurence from a dynamic array** -> `remove_first_occurence_from_dynamic_array(my_array,element)` |
| 75 | +- **Remove element from index** -> `remove_this_elements_from_dynamic_array(my_array,idx)` |
| 76 | +- **Remove elements from indices** -> `remove_these_elements_from_dynamic_array(my_array,indices_array)` |
| 77 | +- **Reset a dynamic array** -> `get_initializated_dynamic_array()` |
| 78 | +- **Check if an element is in the dynamic array** -> `dynamic_array_contains(my_array,element)` |
| 79 | +- **Retrieve the first index of an element inside a dynamic array** -> `from_dynamic_array_get_first_index_occurence_of(my_array,element)` |
| 80 | +- **Retrieve all indeces of an element inside the dynamic array (return an array)** -> `from_dynamic_array_get_all_indeces_occurence_of(my_array,element)` |
| 81 | +- **Retrieve the dynamic array dimension** -> `get_dynamic_array_dimension(my_array)` |
| 82 | +- **Write an entire dynamic array** -> `write_dynamic_array(my_array)` |
| 83 | + |
| 84 | +## How to use |
114 | 85 |
|
115 | 86 | > From `Test.asp`
|
116 | 87 |
|
117 |
| -1. Create array and initialize it as dictionary |
| 88 | +1. Create array and initialize it |
118 | 89 | ```asp
|
119 |
| - <!--#include file="Dictionary.asp"--> |
| 90 | + <%@LANGUAGE="VBSCRIPT"%> |
| 91 | + <!--#include file="Dynamic_arrays.asp"--> |
120 | 92 | <%
|
121 |
| - Dim dictionary |
122 |
| - dictionary = Array() |
123 |
| - dictionary = get_initialized_dictionary() |
| 93 | + Dim test_array |
| 94 | + test_array = Array() |
| 95 | + test_array = get_initializated_dynamic_array() |
124 | 96 | ```
|
125 |
| -2. Pass the dictionary to functions for manage |
| 97 | +2. Pass the array to functions for manage |
126 | 98 | ```asp
|
127 |
| - add_element_to_dictionary_array dictionary,"0001","Ice ice baby" |
128 |
| - add_element_to_dictionary_array dictionary,"0002","Dove lo vuoi tu" |
129 |
| - add_element_to_dictionary_array dictionary,"0003","Hot shot" |
130 |
| - write_dictionary dictionary |
| 99 | + add_element_to_dynamic_array test_array,"A" |
| 100 | + add_element_to_dynamic_array test_array,"B" |
| 101 | + add_element_to_dynamic_array test_array,"C" |
| 102 | + write_dynamic_array(test_array) |
131 | 103 | %>
|
132 | 104 | ```
|
133 |
| - </details> |
| 105 | + |
| 106 | +</details> |
134 | 107 |
|
135 | 108 | <details>
|
136 | 109 | <summary>
|
137 | 110 |
|
138 |
| -## `dictionary.class.asp`'s avaible Functions |
| 111 | +## `dArray.class.asp`'s avaible Functions |
139 | 112 |
|
140 |
| - </summary> |
141 |
| - |
142 |
| -- **Add an element into a dictionary** -> `add_element(key,value)` |
143 |
| -- **Get value from key** -> `get_value_from_key(key)` |
144 |
| -- **Set value from key** -> `set_value_from_key(key,value)` |
145 |
| -- **Change a key into dictionary** -> `change_key(old_key,new_key)` |
146 |
| -- **Remove dictionary element from key** -> `remove_element_from_index(idx)` |
147 |
| -- **Remove dictionary element from index** -> `remove_element_from_index(idx)` |
148 |
| -- **Remove last element from dictionary** -> `remove_last_element(dictionary)` |
149 |
| -- **Remove elements from dictionary using indices (pass to function an array with the indices)** -> `remove_elements_from_indices(indices)` |
150 |
| -- **Remove all elements with the same value from dictionary** -> `remove_elements_from_value(value)` |
151 |
| -- **Replace all value occurrences with a new value in dictionary** -> `replace_all_value_occurrences(old_value,new_value)` |
152 |
| -- **Get key index from dictionary** -> `get_key_index(key)` |
153 |
| -- **Reset a dictionary** -> Re-initialize the object |
154 |
| -- **Get dictionary key from index** -> `get_key_from_index(idx)` |
155 |
| -- **Get first value index occurrence** -> `get_first_value_index_occurrence(value)` |
156 |
| -- **Get all indices of a value** -> `get_all_value_indices(value)` |
157 |
| -- **Check if a key has been used into dictionary** -> `check_if_key_has_been_used(key)` |
158 |
| -- **Check if a value is present in the dictionary** -> `check_if_value_is_present(value)` |
159 |
| -- **Get dictionary value from index** -> `get_value_from_index(idx)` |
160 |
| -- **Get dictionary dimension** -> `get_dimension()` |
161 |
| -- **Write a dictionary** -> `write()` |
162 |
| - |
163 |
| -## How to use: |
| 113 | +</summary> |
| 114 | + |
| 115 | +- **Initialize class** -> `sub class_initialize()` |
| 116 | +- **Terminate class** -> `sub class_terminate()` |
| 117 | +- **Add an element** -> `Public Function add_element(element)` |
| 118 | +- **Get element from index** -> `Public Function get_element(idx)` |
| 119 | +- **Get array dimension** -> `Public Function get_dimension()` |
| 120 | +- **Remove last element** -> `Public Function remove_last_element()` |
| 121 | +- **Remove all element occurences** -> `Public Function remove_all_occurences(element)` |
| 122 | +- **Remove first element occurence** -> `Public Function remove_first_occurence(element)` |
| 123 | +- **Remove element from index** -> `Public Function remove_this_element(idx)` |
| 124 | +- **Remove elements from indices** -> `Public Function remove_these_elements(indices_array)` |
| 125 | +- **Reset** -> Re-initialize the class |
| 126 | +- **Check if an element is present** -> `Public Function contains(element)` |
| 127 | +- **Retrieve the first index of an element** -> `Public Function get_first_index_occurence_of(element)` |
| 128 | +- **Retrieve all indeces of an element (return an array)** -> `Public Function get_all_indeces_occurence_of(element)` |
| 129 | +- **Write the entire array** -> `Public Function write_array()` |
| 130 | + |
| 131 | +## How to use |
164 | 132 |
|
165 | 133 | > From `Test.asp`
|
166 | 134 |
|
167 | 135 | 1. Initialize the class
|
168 | 136 | ```asp
|
169 | 137 | <%@LANGUAGE="VBSCRIPT"%>
|
170 |
| - <!--#include file="dictionary.class.asp"--> |
| 138 | + <!--#include file="dArray.class.asp"--> |
171 | 139 | <%
|
172 |
| - Dim dic |
173 |
| - Set dic = new dictionary |
| 140 | + Dim da |
| 141 | + Set da = new dArray |
174 | 142 | ```
|
175 | 143 | 2. Use the class
|
176 | 144 | ```asp
|
177 |
| - dic.add_element "0001","Ice ice baby" |
178 |
| - dic.add_element "0002","Dove lo vuoi tu" |
179 |
| - dic.add_element "0003","Hot shot" |
180 |
| - dic.add_element "0004","7 minuti in paradiso" |
181 |
| - dic.add_element "0005","Dimmi dove e quando" |
182 |
| - dic.add_element "0006","Balla per me" |
183 |
| - dic.add_element "0007","Nudi e crudi" |
184 |
| - dic.add_element "0008","Obbligo o verita'" |
185 |
| - dic.add_element "0009","Sotto il vestito, niente" |
186 |
| - dic.add_element "0010","Colazione a letto " |
187 |
| - dic.add_element "0011","Luce dei miei occhi" |
188 |
| - dic.add_element "0012","Comprami un giocattolo" |
189 |
| - dic.add_element "0013","Facciamo pace" |
190 |
| - dic.add_element "0014","Less is more" |
191 |
| - dic.add_element "0015","call me baby" |
192 |
| - dic.add_element "0016","Pensaci tu" |
193 |
| - dic.add_element "0017","Souvenir d'amour" |
194 |
| - dic.add_element "0018","Proca a prendermi" |
195 |
| - dic.add_element "0019","Meet me at the hotel" |
196 |
| - dic.add_element "0020","Sexy movie night" |
197 |
| - dic.add_element "0021","Doccia bollente" |
198 |
| - dic.add_element "0022","Blind date" |
199 |
| - dic.add_element "0023","Oggi voglio..." |
200 |
| - dic.add_element "0024","Nuovo blocchetto" |
201 |
| - dic.write() |
| 145 | + da.add_element("A") |
| 146 | + da.add_element("B") |
| 147 | + da.add_element("C") |
| 148 | + da.add_element("D") |
| 149 | + da.add_element("A") |
| 150 | + da.add_element("B") |
| 151 | + da.add_element("C") |
| 152 | + da.add_element("D") |
| 153 | + da.add_element("A") |
| 154 | + Response.Write("Elements inside: ") |
| 155 | + da.write_array() |
202 | 156 | %>
|
203 | 157 | ```
|
| 158 | + |
204 | 159 | </details>
|
0 commit comments