TIP: Click on subject to list as thread! ANSI
echo: qedit
to: ALL
from: `CHRIS ANTOS (EXCHANGE)`
date: 1997-12-16 07:16:00
subject: RE: GetToken() Bug??

From: "Chris Antos (Exchange)" 
i think what Kevin means is that for most compilers, anywhere in source
code where you can put one whitespace character, the compiler treats one
whitespace the same as a zillion whitespace: the number is irrelevent.
this is a common practice in general for text files, not just for
programming.
the GetToken command does treat whitespace and non-whitespace characters
differently, to mimic this.  this is a very useful feature.  GetToken
also understand quotes.  if you use GetToken('foo "a b c" bar', ' "', 2)
the result is not 'a', it is 'a b c'.  that is, the double quotes are
stripped, and everything between them is returned.
// chris
-----Original Message-----
From: Kevin A. Carr [mailto:kcarr@treb.com]
Sent: Monday, December 15, 1997 4:30 AM
To: 'tsepro@semware.com'
Subject: RE: GetToken() Bug??
Most compilers, SAL including, will compress any consecutive whitespace
(usually the tab and space) characters into one.  When using GetToken()
where you can specify token delimiters that are not whitespace (i.e. the
';') those are not compressed, because many times consecutive delimiters
like those are use to indicate and empty field.
If you wish to ignore those empty fields, then simply check the string
length of your token, and ignore it if is is 0.
Kevin A. Carr
----------
From:  Pieter de Ruiter[SMTP:ruiter@xs4all.nl]
Sent:  Sunday, December 14, 1997 4:00 PM
To:  tsepro@semware.com
Subject:  GetToken() Bug??
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)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.