
-----------------------------------
KC 40oz
Tue Nov 15, 2005 10:03 am

Need help identifying a function
-----------------------------------
I'm making a binary -> decimal convertor and i need the function that counts the # of digits in a variable and also that can grab single digits
i am SURE i learned this last year, but the help file at my school isnt working right now
any help would be appreciated

-----------------------------------
ZeroPaladn
Tue Nov 15, 2005 10:20 am


-----------------------------------
lolz, i did this for extra credit this september, although i didnt know that there was a function for it  :cry: . What i did is that i used the number 256 (1 as the 9th digit of binary) and kept deviding it by 2, then checking to see if i could minus certain numbers from it. heres the post for it, and there are tons of other submissions for it too. study it.
http://www.compsci.ca/v2/viewtopic.php?t=9806

-----------------------------------
Albrecd
Tue Nov 15, 2005 10:40 am

length
-----------------------------------
Use "length (variable)"

Ex:
var a :string
put "Write something"
get a:*
put "The length of your writing masterpiece is ",length (a)," characters."

-----------------------------------
do_pete
Tue Nov 15, 2005 11:27 am


-----------------------------------
length(variable) is for strings. So in order to use that you would have to convert the interger into a string using intstr()

-----------------------------------
KC 40oz
Tue Nov 15, 2005 12:37 pm


-----------------------------------
ok thanks, i also need to be able to extract a certain char from the string, and i remember doing that yet cant remember for the life of me what the function was
i remember it including * s to signify the last char in the string

-----------------------------------
do_pete
Tue Nov 15, 2005 12:49 pm


-----------------------------------
i don't know about the *s but you just go something like this
Character:=String(number)
Character is the character you want to isolate. String is the string and number is the number of the character. for example this would print "r" becuase "r" is the third character in the string "turing"
var text:string:="turing"
put text(3)

-----------------------------------
codemage
Tue Nov 15, 2005 1:09 pm


-----------------------------------
Treat strings like you would arrays of characters.

var x : string := "abcdefghijklmn"
put x (3)
 -> puts out "c"

put x (5..*-2)
 - >puts out "efghijkl"

You can use index and length for more in-depth string manipulation.
