Talk:Update a configuration file: Difference between revisions
Content added Content deleted
(→A generic solution for the problem: new section) |
|||
Line 49: | Line 49: | ||
== A generic solution for the problem == |
== A generic solution for the problem == |
||
Well, as I saw in the previous comments, the task was really complex. And it could be, so I did a generic solution for the problem: |
Well, as I saw in the previous comments, the task was really complex. And it could be, so I did a generic solution for the problem: |
||
# The solution in BASIC (QB45) reads ANY configuration file and shows what it found. |
|||
# If there is an array (FAMILY John Smith, Lisa Smith, Charles Smith) the program will create an array of elements FAMILY. |
|||
# If FAMILY variable is repeated in another part of the configuration file, will simply add the found elements to the existing array. |
|||
# The main procedure can toggle the comment status of a variable in the configuration file as per User request. |
|||
# The main procedure will save all the elements of an array in just one line. This way, if you have a situation like this: |
|||
#: |
|||
FAMILY John Smith, Lisa Smith, Charles Smith |
#:FAMILY John Smith, Lisa Smith, Charles Smith |
||
FRUITSILIKE banana |
#:FRUITSILIKE banana |
||
FAMILY Donna Smith |
#:FAMILY Donna Smith |
||
FAMILY Rachel Smith |
#:FAMILY Rachel Smith |
||
#: |
|||
Will end as follows: |
#:Will end as follows: |
||
#: |
|||
FAMILY John Smith, Lisa Smith, Charles Smith, Donna Smith, Rachel Smith |
#:FAMILY John Smith, Lisa Smith, Charles Smith, Donna Smith, Rachel Smith |
||
FRUITSILIKE banana |
#:FRUITSILIKE banana |
||
#: |
|||
# The main procedure is able, when saving, to record the variables and values with a "=" or with a space (" ") in between. The configuration file reader can identify both of them. |
|||
# The program can identify if a variable name is an array or not, and, if so, to return the number of elements in the array. |
|||
# The above explained functionality lead to a very large program. Nevertheless, as per my understanding, it amply meets the requirements of the task. |