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.

string range

Old posts that have not been replied to for several years.
Locked
c
cvanmeer
Halfop
Posts: 40
Joined: Tue Dec 02, 2003 1:00 pm
Location: The Netherlands
Contact:

string range

Post by cvanmeer »

Hi all, just a small question

let's say I have a string: "xxxxxx.xxx"
and I want to loose the .xxx (always the last 4 characters) and I want to make the first x of the string an uppercase X so you would have:

"Xxxxxx"

I've tried it with string range but it didn't work out.

Could somebody write me the line I need?
thx.

Chrizz
c
cvanmeer
Halfop
Posts: 40
Joined: Tue Dec 02, 2003 1:00 pm
Location: The Netherlands
Contact:

Post by cvanmeer »

solved it already :)

Code: Select all

     set mapvol [lindex $row 4]
     set mapstrip [string range $mapvol 0 [expr [strlen $mapvol]-5]]
     set map1 [string toupper [string range $mapstrip 0 0]]
     set map2 [string range $mapstrip 1 end]
     set map $map1$map2
User avatar
arcane
Master
Posts: 280
Joined: Thu Jan 30, 2003 9:18 am
Location: Germany
Contact:

Post by arcane »

2 remarks:
1. you are using list commands on a string
2. you could just split on "."

like:

Code: Select all

set string [lindex [split $input "."] 0]
to get your first xxxxx
then make the first x upper case (don't know a better way than the one you are using :))
aVote page back online!
Check out the most popular voting script for eggdrop bots.

Join the metal tavern!
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

or string trim to remove the .xxxx :)
Once the game is over, the king and the pawn go back in the same box.
Locked