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.

Tabulations

Help for those learning Tcl or writing their own scripts.
Post Reply
j
juanamores
Master
Posts: 317
Joined: Sun Mar 15, 2015 9:59 am

Tabulations

Post by juanamores »

How can I tabulate the rr,name and rank variables so that they are all in the same column?

Code: Select all

foreach pair $results {
	  scan $pair {%s%d} name rank 
	  incr rr
	  if {$rr == 1} { putmsg $chan_owners "\002\0034 $rr. $name  $rank"}
	  if {$rr == 2} { putmsg $chan_owners "\0032 $rr. $name $rank"}
	  if {($rr != 1) && ($rr != 2) && ($rr <= 5)} { putmsg $chan_owners "\0031 $rr. $name $rank"}
	  if {$rr > 5} {continue}
	} 
If you do not understand my ideas is because I can not think in English, I help me with Google Translate. I only speak Spanish. Bear with me. Thanks :)
User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

What do you mean by in the same column? Give an example.

Edit: If you want to have a TAB between the results then make the line like:

Code: Select all

$var1\t$var2\t$var3
Once the game is over, the king and the pawn go back in the same box.
j
juanamores
Master
Posts: 317
Joined: Sun Mar 15, 2015 9:59 am

Post by juanamores »

This I had already tried but it did not work for me.
What I want is that the names and points are aligned in the same column.
I can not put an example here, because I do not see the tool to tabulate the forum.
With the code that I shared you above it out like this:
1. Ana 12
2. Federico 11
3. Pedro 9
4. Manuel 5
5. The_best_of_the_world 2
If I use \t as the example:

Code: Select all

$var1\t$var2\t$var3
Result:
1.Ana12
2.Federico11
3.Pedro9
4.Manuel5
5.The_best_of_the_world2
If you do not understand my ideas is because I can not think in English, I help me with Google Translate. I only speak Spanish. Bear with me. Thanks :)
User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

I take it this is from the Sort file data code so i got the same code I posted and instead of what you posted above I used:

Code: Select all

foreach pair $results { 
	incr x
	scan $pair {%s%d} name rank
	puthelp "PRIVMSG $chan :$x. $name $rank"
}
And the result is:
[19:35] <@cez> !avgs
[19:35] <@bot> 1. Maria 12
[19:35] <@bot> 2. Jose 10
[19:35] <@bot> 3. Ana 9
[19:35] <@bot> 4. Pedro 7
[19:35] <@bot> 5. Luis 3
I even used your code with a small change to post into the current channel:

Code: Select all

foreach pair $results {
	scan $pair {%s%d} name rank
	incr rr
	if {$rr == 1} { puthelp "PRIVMSG $chan :\002\0034 $rr. $name  $rank"}
	if {$rr == 2} { puthelp "PRIVMSG $chan :\0032 $rr. $name $rank"}
	if {($rr != 1) && ($rr != 2) && ($rr <= 5)} { puthelp "PRIVMSG $chan :\0031 $rr. $name $rank"}
	if {$rr > 5} {continue}
} 
and the output is also ok:
[19:41] <@cez> !avgs
[19:41] <@bot> 1. Maria 12
[19:41] <@bot> 2. Jose 10
[19:41] <@bot> 3. Ana 9
[19:41] <@bot> 4. Pedro 7
[19:41] <@bot> 5. Luis 3
with only difference that first line is with red.

Are you sure isn't something with your irc client displaying info wrong or perhaps something wrong with your putmsg function?
Once the game is over, the king and the pawn go back in the same box.
j
juanamores
Master
Posts: 317
Joined: Sun Mar 15, 2015 9:59 am

Post by juanamores »

I replaced the putmsg with for the puthelp "PRIVMSG... and the results are still not tabulated.
If you look at the result that you have shared, you will see that the numbers are not aligned.

I want the point (numbers) to all begin in the same column, regardless of the number of characters in the name.
EDIT: View this image created with an excel sheet
Image
That's what I want to get with the tcl code.
It's possible?
If you do not understand my ideas is because I can not think in English, I help me with Google Translate. I only speak Spanish. Bear with me. Thanks :)
User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

It should work with the \t

Code: Select all

% foreach line $result { scan $line {%s%s} name rank; puts "$name \t$rank" }
bla     123
moo     23
like I said first time.
Once the game is over, the king and the pawn go back in the same box.
j
juanamores
Master
Posts: 317
Joined: Sun Mar 15, 2015 9:59 am

Post by juanamores »

As I mentioned before, BoT does not respond to \t
I do not know if it's because of the eggdrop version I use or because the librarys are old. :?

I tried to update the libraries, but when recompiling I did not work parts of my codes.
I also tried to update the eggdrop to the latest version, but I do not recognize the ascii characters (BoT symbols).
Now I will open a new thread for this.
If you do not understand my ideas is because I can not think in English, I help me with Google Translate. I only speak Spanish. Bear with me. Thanks :)
w
willyw
Revered One
Posts: 1196
Joined: Thu Jan 15, 2009 12:55 am

Post by willyw »

juanamores wrote:As I mentioned before, BoT does not respond to \t
...
Try it with a space before and after the \t .

I seem to remember that is what I had to do.
For a fun (and popular) Trivia game, visit us at: irc.librairc.net #science-fiction . Over 300K Q & A to play in BogusTrivia !
j
juanamores
Master
Posts: 317
Joined: Sun Mar 15, 2015 9:59 am

Post by juanamores »

willyw wrote:
juanamores wrote:As I mentioned before, BoT does not respond to \t
...
Try it with a space before and after the \t .

I seem to remember that is what I had to do.
I have tried what you advised me and it does not work, the BoT ignores the \t is as if they did not exist, nor does it give error.

The tabulator (\ t) assume them as simple white spaces

Code: Select all

foreach pair $results {
     scan $pair {%s%d} name rank
     incr rr
     if {$rr == 1} { putmsg $canal_owners "\002\0034 \t $rr. \t $name \t $rank"}
     if {$rr == 2} { putmsg $canal_owners "\0032 \t $rr. \t $name \t $rank"}
     if {($rr != 1) && ($rr != 2) && ($rr <= 5)} { putmsg $canal_owners "\0031 \t $rr. \t $name \t $rank"}
     if {$rr > 5} {continue}
   } 
Result:
1. Maria 12
2. Jose 10
3. Ana 9
4. Pedro 7
5. Luis 3
Here's what I want to get, regardless of the length in characters of the nicks that precede the score:
Image
As you see, the units go under the units and the tens under the tens, and ordinal numbers and names are also aligned in the corresponding column.
If you do not understand my ideas is because I can not think in English, I help me with Google Translate. I only speak Spanish. Bear with me. Thanks :)
Post Reply