egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Tabulations

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
juanamores
Master


Joined: 15 Mar 2015
Posts: 317

PostPosted: Wed Apr 19, 2017 5:36 pm    Post subject: Tabulations Reply with quote

How can I tabulate the rr,name and rank variables so that they are all in the same column?
Code:
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 Smile
Back to top
View user's profile Send private message
caesar
Ass Kicker


Joined: 14 Oct 2001
Posts: 3403
Location: Area 51

PostPosted: Thu Apr 20, 2017 12:36 am    Post subject: Reply with quote

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:

$var1\t$var2\t$var3

_________________
You may say anything about me, but don't misspell my name.
Back to top
View user's profile Send private message
juanamores
Master


Joined: 15 Mar 2015
Posts: 317

PostPosted: Thu Apr 20, 2017 11:44 am    Post subject: Reply with quote

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:
Quote:
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:

$var1\t$var2\t$var3

Result:
Quote:
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 Smile
Back to top
View user's profile Send private message
caesar
Ass Kicker


Joined: 14 Oct 2001
Posts: 3403
Location: Area 51

PostPosted: Thu Apr 20, 2017 12:14 pm    Post subject: Reply with quote

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:

foreach pair $results {
   incr x
   scan $pair {%s%d} name rank
   puthelp "PRIVMSG $chan :$x. $name $rank"
}

And the result is:
Quote:

[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:

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:
Quote:

[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?
_________________
You may say anything about me, but don't misspell my name.
Back to top
View user's profile Send private message
juanamores
Master


Joined: 15 Mar 2015
Posts: 317

PostPosted: Thu Apr 20, 2017 1:01 pm    Post subject: Reply with quote

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

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 Smile
Back to top
View user's profile Send private message
caesar
Ass Kicker


Joined: 14 Oct 2001
Posts: 3403
Location: Area 51

PostPosted: Fri Apr 21, 2017 2:32 am    Post subject: Reply with quote

It should work with the \t
Code:

% foreach line $result { scan $line {%s%s} name rank; puts "$name \t$rank" }
bla     123
moo     23

like I said first time.
_________________
You may say anything about me, but don't misspell my name.
Back to top
View user's profile Send private message
juanamores
Master


Joined: 15 Mar 2015
Posts: 317

PostPosted: Sat Apr 22, 2017 5:37 am    Post subject: Reply with quote

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. Confused

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 Smile
Back to top
View user's profile Send private message
willyw
Owner


Joined: 15 Jan 2009
Posts: 925

PostPosted: Sat Apr 22, 2017 9:20 am    Post subject: Reply with quote

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 !
Back to top
View user's profile Send private message
juanamores
Master


Joined: 15 Mar 2015
Posts: 317

PostPosted: Sun Apr 23, 2017 1:39 pm    Post subject: Reply with quote

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:
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:
Quote:
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:

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 Smile
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber