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 

Character hiding and showing

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


Joined: 24 Jun 2005
Posts: 310
Location: Constanta, Romania

PostPosted: Fri Jan 04, 2019 12:46 pm    Post subject: Character hiding and showing Reply with quote

Evening.
I have a small problem with the following code, meaning that it works 97% Smile

I cannot make it show
'
`
and
?


Code:
proc hideword {word} {

   set newword "";
   foreach letter [split $word {}] {
      if {$letter ne " " && $letter ne "-" && $letter ne "," && $letter ne "." && $letter ne "(" && $letter ne ")" && $letter ne "'" && $letter ne "`" && $letter ne "?"} {set letter "*";}
      append newword $letter;
   }
   return $newword;
}

_________________
https://github.com/MadaliNTCL - To chat with me: https://tawk.to/MadaliNTCL
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3584
Location: Mint Factory

PostPosted: Fri Jan 04, 2019 2:53 pm    Post subject: Reply with quote

Have you tried string map like:
Code:

string map [list " " "" "-" "" "," "" "." "" "\(" "" "\)" "" "\'" "" "`" "" "?" "" "*" ""] [split $text]

that basically removes the characters leaving everything else?
_________________
I tawt I taw a puddy tat!
Back to top
View user's profile Send private message
Madalin
Master


Joined: 24 Jun 2005
Posts: 310
Location: Constanta, Romania

PostPosted: Sun Jan 06, 2019 12:50 pm    Post subject: Reply with quote

I want to show does characters not hide them.
_________________
https://github.com/MadaliNTCL - To chat with me: https://tawk.to/MadaliNTCL
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3584
Location: Mint Factory

PostPosted: Mon Jan 07, 2019 2:08 am    Post subject: Reply with quote

Ah, sorry, my bad. Loop and lsearch then?
Code:

proc hideword word {
   set chars {" " "-" "," "." "\("  "\)" "\'" "`" "?" "*"}
   foreach c [split $word ""] {
      if {[lsearch $chars $c] > -1} {
         append nw $c
      } else {
         append nw "*"
      }
   }
   return $nw
}

and a "compact" version:
Code:

proc hideword word {
   set chars {" " "-" "," "." "\("  "\)" "\'" "`" "?" "*"}
   foreach c [split $word ""] {
      append nw [expr {[lsearch $chars $c] > -1 ? $c : "*"}]
   }
   return $nw
}

_________________
I tawt I taw a puddy tat!
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