enumerating an collection

Post

Posted
Rating:
#1 (In Topic #207)
Avatar
Enthusiast
GrayGhost is in the usergroup ‘Enthusiast’
 this code runs fine :

Dim Dict As New Collection
Dim Element As String

Dict["Blue"] = 3
Dict["Red"] = 1
Dict["Green"] = 2

For Each Element In Dict
  Print Element;
Next

but if I substutite a json.Decode …. I get the results in the attachment

Image

(Click to enlarge)

Online now: No Back to the top

Post

Posted
Rating:
#2
Avatar
Guru
cogier is in the usergroup ‘Guru’
cogier is in the usergroup ‘GambOS Contributor’
 Hi grayghost4,

Can you tell us what it is you are trying to achieve and please upload the 'conssendo_s.srm' file so we can see what you see.
Online now: No Back to the top

Post

Posted
Rating:
#3
Avatar
Enthusiast
GrayGhost is in the usergroup ‘Enthusiast’
thanks for the response.

 I want to load the file from the disk, make modifications to it and then write it back to the disk.  I can accomplish that without enumerating the file but when I write it back with Json.encode, the file is compressed without tabs and linefeeds. If I enumerate it to a string, or string[] then I can add tabs and line feeds where I want them, and write the string back to a file.

Also, I am learning the language and want to understand the commands and understand why that one does not work. It seems like that is a useful command to know.

I believe I found the problem … the file I am working with has two collections within it.
So the first element is a collection and the second element is a string. So it will generate a type mismatch no matter what you try to assign it to. :(

Attachment
Online now: No Back to the top

Post

Posted
Rating:
#4
Avatar
Guru
cogier is in the usergroup ‘Guru’
cogier is in the usergroup ‘GambOS Contributor’
I think that you can do what you want with a simpler edit structure.
I have taken your file opened it and split it by line, then created a new array without all the indentation. You can edit the data then replace the old data with the new. This leaves the indentation as it was.

I hope it helps.

Attachment
Online now: No Back to the top
1 guest and 0 members have just viewed this.