Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[TCL] Strings
06-08-2010, 11:58 AM (This post was last modified: 06-08-2010 11:59 AM by Back_track.)
Post: #1
[TCL] Strings
Strings, an Introduction

Strings in Tcl are easy , yet powerful. Defining a String is easy as
Code:
set Str "String here!"

Tcl , like many other scripting languages doesn't require a type to declare your
variables in. So, you dont have to do something like this:
String Str = "String here!"; - Java

String Functions

String Length

If you're already familiar with TCL, you know that inside string you can use
[ ] for escape characters. So to display a Strings length you can do this:

Code:
set Str "String here!"
puts "Length of Str [string length $Str]"

The Syntax goes:

type , function, variable

Variables MUST have the scalar symbol before it to show it is a variable.

[Image: 64504_screenshot.png]

To Upper & To Lower

Very simple in TCl

Code:
set Str "RaNdOm StUfF HeRe"
puts "[string toupper $Str]"
=>RANDOM STUFF HERE
puts "[string tolower $Str]"
=> random stuff here

Byte-length

Code:
set Str "String Here!"
=> String Here!
puts "[string bytelength $Str]"
=> 12
May be different than length due to encoding.

"Character is determined more by the lack of certain experiences than by those one has had."
Friedrich Nietzsche
Visit this user's website Find all posts by this user
Quote this message in a reply
06-09-2010, 03:27 AM
Post: #2
RE: [TCL] Strings
Very good tut. I understand strings in almost every language !

There's a fine line between genius and insanity. I have erased this line.
Oscar Levant
There's a fine line between an administrator and black hat hacker. I have erased this line.
Dr DEBCOL
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


 Quick Theme: