Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Alphabetical sort in ISTringMap array
#1
In the example which follows I cannot understand why the 3 first lines in file .txt are sorted at the end of the IStringMap list. Any advice will be much appreciated.

Function tempf05
Code:
Copy      Help
IStringMap+ QMT=CreateStringMap(1|8) ;; QM Topics
OpenISMFile(QMT "C:\tmp\IS\QMTopics.txt" ":") ;;Help - QM Topics
str sl
QMT.GetList(sl)
out sl
ARRAY(str) ak av
QMT.GetAll(ak av)
for int'i 0 ak.len
,out ak[i]
,


Attached Files
.txt   QMTopics.txt (Size: 21.88 KB / Downloads: 417)
#2
Macro Macro2840
Code:
Copy      Help
;normal A
outb "A" 2 ;;41 00

;your A is preceded by UTF8 BOM
outb "A" 5 ;;EF BB BF 41 00
#3
Dear Gintaras, thank you for your invaluable advice, as always !

It seems that the input .txt file contains some rubbish characters in its beginning. In routine "OpenISMFile" which reads this file I changed "str s.getfile(fPath)" to str s.getfile(fPath 3) and everything worked perfectly. However, I hesitate to use this workaround as a matter of principle, since there could be cases that I could use useful characters. Could I use a "ltrim" statement on string "s" to eliminate this rubbish ? Thanks for your advice, in advance.
#4
I wrote this short routine to detect BOM at the beginning of a file. Any advice most welcome.

Function BOM_Det
Code:
Copy      Help
function# str's
if s[0]=239 and    s[1]=187 and s[2]=191
,ret 1
else
,ret 0
#5
str s
s.LoadUnicodeFile("path")


Forum Jump:


Users browsing this thread: 1 Guest(s)