This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

how to convert sting to int.

Old posts that have not been replied to for several years.
Locked
Z
Zygomaticum

Post by Zygomaticum »

Hi.

I'm making a script that checks some thing in a log file and compare it with $arg.
The comparing **** is working perfectly, only each line in the log is timestamped in 'unix' time (only a row of numbers, like 1017854413). I want to convert that time to DD/MM/YY and hh:mm:ss. I know hot to do it (clock format .....), but when i use this function, it says that it expects an int, not a sting, so i need to convert this piece of the string (it's split already in f_time) to an int value, but afaik there is no function for it (like string toint or somehint like that).
And i'm not fealing like writing a function like:
switch $<vartoconverttostring> {
"0" : { return 0 }
"1" : { return 1}
and so on.
}

Can someone help me plz, or perhaps ther already IS a function for this...

Greejtz, Zygo.
P
Petersen
Owner
Posts: 685
Joined: Thu Sep 27, 2001 8:00 pm
Location: Blackpool, UK

Post by Petersen »

technically there is no int in tcl. what its requesting is that whatever string you're passing to it consists only of the characters 0-9. I suspect that you may have some leading/trailing spaces in whatever string you're passing to it, or possibly its in a list format (in which case you may have some {} in it).
Z
Zygomaticum

Post by Zygomaticum »

it's not in a list and it's only numbers

the timestamp in the log file looks like this:
<10numbersfordate>, <restoflogline>
example>
101122334455, <Rest>

to 'catch' the time i use this:
set _time [lindex [split $line ","] 0]
P
Petersen
Owner
Posts: 685
Joined: Thu Sep 27, 2001 8:00 pm
Location: Blackpool, UK

Post by Petersen »

well that looks ok to me (except that 101122334455 is a larger than 32 bit number, and since clock format is a 32 bit function it will fail).

you sure you're specifing the arguments to clock format corectly?
Locked