From: Pieter de Ruiter
Hi,
Using GetToken() in SAL (TSE 2.5) I detected a unexpected effect.
Can anybody explain the output of this test-macro?
In my opinion the output of each mTestToken() call should be equal (as the
first call)!
The GetToken() function seem to treat a non-blank character different from a
blank.
Can't figure out what I'm doing wrong...
----------------------------------------------------------------------------
------------------
proc mTestToken(string sSearch, string sDelim)
integer i, nNum = NumTokens(sSearch,sDelim )
addline("Number of tokens: " + str(nNum))
for i=1 to nNum
addline(str(i) + " " + GetToken(sSearch, sDelim,i))
endfor
end
proc mTest()
mTestToken("How many tokens?", " ;")
mTestToken("How many;;;;tokens?", " ;")
mTestToken("How many ; tokens?", " ;")
end
mTest()
----------------------------------------------------------------------------
------------------
Output:
-------
Number of tokens: 3
1 How
2 many
3 tokens?
Number of tokens: 6
1 How
2 many
3
4
5
6 tokens?
Number of tokens: 5
1 How
2 many
3
4
5 tokens?
----------------------------------------------------------------------------
------------------
Thanks
Pieter de Ruiter,
Utrecht, Nederland
---
---------------
* Origin: apana>>>>>fidonet [sawasdi.apana.org.au] (3:800/846.13)
|