C Cor Active Member Licensed User Longtime User Apr 18, 2011 #1 If key begins with space then space is automatically stripped off see key 024 Now i have to put dummy char at begin and strip it off when reading key Is this a feature of map? Code: Copy dim lickmap as map dim str1 as string bluesv1.dat contains 024= 0 0 2p0 4 4 2p058 025=- 0 0 2p0 4 4 2p058 lickMap=File.readmap(File.dirassets,"bluesv1.dat") str1=lickMap.Get("024") tabCanvas.DrawText(str1,18dip,48,tabFont,20,Colors.Blue,"LEFT")
If key begins with space then space is automatically stripped off see key 024 Now i have to put dummy char at begin and strip it off when reading key Is this a feature of map? Code: Copy dim lickmap as map dim str1 as string bluesv1.dat contains 024= 0 0 2p0 4 4 2p058 025=- 0 0 2p0 4 4 2p058 lickMap=File.readmap(File.dirassets,"bluesv1.dat") str1=lickMap.Get("024") tabCanvas.DrawText(str1,18dip,48,tabFont,20,Colors.Blue,"LEFT")
Erel B4X founder Staff member Licensed User Longtime User Apr 19, 2011 #2 I don't see this behavior. Check this code for example which works as expected: Code: Copy Dim s As String s = " 123" Dim m As Map m.Initialize m.Put(s,s) File.WriteMap(File.DirRootExternal, "1.txt", m) Log(m) m = File.ReadMap(File.DirRootExternal, "1.txt") Dim s2 As String s2 = m.Get(" 123") Log(s2.Length) Log(m) Upvote 0
I don't see this behavior. Check this code for example which works as expected: Code: Copy Dim s As String s = " 123" Dim m As Map m.Initialize m.Put(s,s) File.WriteMap(File.DirRootExternal, "1.txt", m) Log(m) m = File.ReadMap(File.DirRootExternal, "1.txt") Dim s2 As String s2 = m.Get(" 123") Log(s2.Length) Log(m)
C Cor Active Member Licensed User Longtime User Apr 19, 2011 #3 Don't create txt with map.put Just create with editor and save it as utf-8 then use only readmap attached is a utf-8 text file Attachments bluesv1.txt bluesv1.txt 708 bytes · Views: 432 Last edited: Apr 19, 2011 Upvote 0
Don't create txt with map.put Just create with editor and save it as utf-8 then use only readmap attached is a utf-8 text file
Erel B4X founder Staff member Licensed User Longtime User Apr 19, 2011 #4 The easiest way to see the required format (.properties - Wikipedia, the free encyclopedia) is to create the file by saving it with File.WriteMap and then read the text file. You need to escape the first space character with '\'. Upvote 0
The easiest way to see the required format (.properties - Wikipedia, the free encyclopedia) is to create the file by saving it with File.WriteMap and then read the text file. You need to escape the first space character with '\'.
C Cor Active Member Licensed User Longtime User Apr 19, 2011 #5 This is only needed when we have a key with spaces. I have values with spaces at front. Upvote 0
C Cor Active Member Licensed User Longtime User Apr 19, 2011 #6 after done several tests, map is unuseable for loading tab notation style \ = slide and space are stripped off I will find for another solution to read the text files like below Code: Copy 02u= |2 021= 022= 023= 0 0 024=/ 0 0 2p0 4 4 2p0 025= 0h3 3 3 /5 026=\3p2 02d= d u d u u d u d Upvote 0
after done several tests, map is unuseable for loading tab notation style \ = slide and space are stripped off I will find for another solution to read the text files like below Code: Copy 02u= |2 021= 022= 023= 0 0 024=/ 0 0 2p0 4 4 2p0 025= 0h3 3 3 /5 026=\3p2 02d= d u d u u d u d
stevel05 Expert Licensed User Longtime User Apr 19, 2011 #7 Hi Cor, Not sure if this will help, but you could use an arbitrary character at the beginning of each row and strip it out on reading. Also you would have to change the keys of the non strings to sort in the correct order if that's important. I attach an example. steve Attachments ta4.zip ta4.zip 5.8 KB · Views: 365 Last edited: Apr 19, 2011 Upvote 0
Hi Cor, Not sure if this will help, but you could use an arbitrary character at the beginning of each row and strip it out on reading. Also you would have to change the keys of the non strings to sort in the correct order if that's important. I attach an example. steve
C Cor Active Member Licensed User Longtime User Apr 19, 2011 #8 Hello Steve, Yes, i use that now, I use now . at the beginning and replace after reading the map e.g s to / and do a replace in my code Code: Copy 02u=. |2 021=. 022=. 023=. 0 0 024=. 01 0 2p0 4 4 2p0* 025=.0h3 3 3 /5 026=.s3p2 02d=. d u d u u d u d Upvote 0
Hello Steve, Yes, i use that now, I use now . at the beginning and replace after reading the map e.g s to / and do a replace in my code Code: Copy 02u=. |2 021=. 022=. 023=. 0 0 024=. 01 0 2p0 4 4 2p0* 025=.0h3 3 3 /5 026=.s3p2 02d=. d u d u u d u d