Page 1 of 2 12>
Topic Options
#143438 - 2005-07-12 07:41 PM How do I split a "word" into letter when no delimiter is defined?
JazzM Offline
Getting the hang of it

Registered: 2004-04-23
Posts: 91
now im dizzzzy...

How do I split a "word" into "letter" if no delimiter is defined?

e.g. input:

$W1 = "kixart"

output should be:

k
i
x
a
r
t

..........

_________________________
I will always look out from behind these eyes...

Top
#143439 - 2005-07-12 07:58 PM Re: How do I split a "word" into letter when no delimiter is defined?
oobnuker Offline
Getting the hang of it

Registered: 2003-12-09
Posts: 87
Loc: Oxford, CT
This is a really quick hack:

Code:

$W1 ="kixtart"
$count = Len($W1)
While $count <> 0
? Left($W1,1)
$count = $count - 1
$W1 = Right($W1,$count)
Loop



I'm sure one of the regulars will come in with a better way to do it shortly.
_________________________
-- oobnuker - .KIX hack - no really.

Top
#143440 - 2005-07-12 08:22 PM Re: How do I split a "word" into letter when no delimiter is defined?
JazzM Offline
Getting the hang of it

Registered: 2004-04-23
Posts: 91
cool... but I need each letter to be defined as global variables...
somthing like "for each $lvar" do this and that...
_________________________
I will always look out from behind these eyes...

Top
#143441 - 2005-07-12 08:48 PM Re: How do I split a "word" into letter when no delimiter is defined?
oobnuker Offline
Getting the hang of it

Registered: 2003-12-09
Posts: 87
Loc: Oxford, CT
Quote:

cool... but I need each letter to be defined as global variables...
somthing like "for each $lvar" do this and that...




I'm not really sure what you are asking for here.
_________________________
-- oobnuker - .KIX hack - no really.

Top
#143442 - 2005-07-12 08:53 PM Re: How do I split a "word" into letter when no delimiter is defined?
maciep Offline
Korg Regular
*****

Registered: 2002-06-14
Posts: 947
Loc: Pittsburgh
sounds like he's looking for an array of letters...

Code:

$word = 'testword'
dim $letters[len($word)-1]
for $j = 0 to ubound($letters)
$letters[$j] = substr($word,$j+1,1)
next

for each $letter in $letters
? $letter
next


Top
#143443 - 2005-07-12 08:54 PM Re: How do I split a "word" into letter when no delimiter is defined?
JazzM Offline
Getting the hang of it

Registered: 2004-04-23
Posts: 91
...once the "word" is "splited" into "letters" I need each letter defined in variable form...

e.g.

$l1 = "k"
$l2 = "i"
$l3 = "x"

and so on ...
_________________________
I will always look out from behind these eyes...

Top
#143444 - 2005-07-12 10:24 PM Re: How do I split a "word" into letter when no delimiter is defined?
Richie19Rich77 Offline
Seasoned Scripter
*****

Registered: 2002-08-16
Posts: 624
Loc: London, England
Here we go.

Code:

Break On

$word = 'testword'
Dim $letters[Len($word)-1]
For $j = 0 to Ubound($letters)
$=Execute("$$Letters$j = SubStr($word,$j+1,1)")
Next

? 'Letter 1: '+$Letters0
? 'Letter 2: '+$Letters1


Top
#143445 - 2005-07-12 10:35 PM Re: How do I split a "word" into letter when no delimiter is defined?
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
VarsInStrings EEK!
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#143446 - 2005-07-12 10:38 PM Re: How do I split a "word" into letter when no delimiter is defined?
Richie19Rich77 Offline
Seasoned Scripter
*****

Registered: 2002-08-16
Posts: 624
Loc: London, England
Les help me out here, what would be the best way, as I have alot of scripts that do this. Is there another way ??

Thanks

Top
#143447 - 2005-07-12 10:41 PM Re: How do I split a "word" into letter when no delimiter is defined?
Richie19Rich77 Offline
Seasoned Scripter
*****

Registered: 2002-08-16
Posts: 624
Loc: London, England
Hold on I am just reading up, I got it, this one will please you Les
Top
#143448 - 2005-07-12 10:56 PM Re: How do I split a "word" into letter when no delimiter is defined?
Richie19Rich77 Offline
Seasoned Scripter
*****

Registered: 2002-08-16
Posts: 624
Loc: London, England
I give up, how can i make this code NOVarsInStrings Compliant.

Code:
$=Execute("$$Letters$j = SubStr($word,$j+1,1)")



Thanks


Edited by Richie19Rich77 (2005-07-12 10:59 PM)

Top
#143449 - 2005-07-12 11:45 PM Re: How do I split a "word" into letter when no delimiter is defined?
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
Untested...
Code:

$=Execute("$" + "Letters" + $j + " = SubStr(" + $word + "," + $j + "+1,1)")code]

Edited by Chris S. (2005-07-12 11:47 PM)

Top
#143450 - 2005-07-12 11:48 PM Re: How do I split a "word" into letter when no delimiter is defined?
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
It makes more sense if I use syntax highlighting...

$=Execute("$" + "Letters" + $j + " = SubStr(" + $word + "," + $j + "+1,1)")

Top
#143451 - 2005-07-13 12:08 AM Re: How do I split a "word" into letter when no delimiter is defined?
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
Quote:

...once the "word" is "splited" into "letters" I need each letter defined in variable form...

e.g.

$l1 = "k"
$l2 = "i"
$l3 = "x"

and so on ...




you don't have any idea what you asked, do you?
you want to have separate variables...
huh?

how do you think you are able to use if you can't even create variables on the fly like that?
_________________________
!

download KiXnet

Top
#143452 - 2005-07-13 12:16 AM Re: How do I split a "word" into letter when no delimiter is defined?
Richie19Rich77 Offline
Seasoned Scripter
*****

Registered: 2002-08-16
Posts: 624
Loc: London, England
Nice 1 Chris, I was close but I didn't wrap the Substr in quotes.

Thanks I have learnt something new.

Top
#143453 - 2005-07-13 05:38 PM Re: How do I split a "word" into letter when no delimiter is defined?
JazzM Offline
Getting the hang of it

Registered: 2004-04-23
Posts: 91
Well dear Lonkero ...ofcurse I dont have any clue... If I had, why should I ask U!?

However its always a gift/rewarding ask u guys out there to help dizzy damage brains like me.

So why stop now? lets play around with the letters...

Now when the "word" is "splited" using maciep code,
We join the letters back to a "word", but in a reverse form!
That way we make sure we keep talking in a reverse form
.
_________________________
I will always look out from behind these eyes...

Top
#143454 - 2005-07-13 06:25 PM Re: How do I split a "word" into letter when no delimiter is defined?
maciep Offline
Korg Regular
*****

Registered: 2002-06-14
Posts: 947
Loc: Pittsburgh
many ways to do it. And if that's all you wanted to do, then there's no need for an array at all.
Top
#143455 - 2005-07-13 06:36 PM Re: How do I split a "word" into letter when no delimiter is defined?
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Here's one:
Code:
Reverse("one") ?
Reverse("two") ?
Reverse("three") ?
Reverse("supercalifragilisticexpialidocious") ?

Function Reverse($s)
While $s<>""
$Reverse=Left($s,1)+$Reverse
$s=SubStr($s,2)
Loop
EndFunction


Top
#143456 - 2005-07-13 06:46 PM Re: How do I split a "word" into letter when no delimiter is defined?
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Following this topic is like following a moose through the bush...

First you imply an array with your "Split" analogy and follow it up with your "for each $lvar", then you say you want global vars, not an array, then you say you want it the other way...

Is this just a long running KiX 101 training course or is there some sort of objective you are trying to attain?
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#143457 - 2005-07-13 07:43 PM Re: How do I split a "word" into letter when no delimiter is defined?
JazzM Offline
Getting the hang of it

Registered: 2004-04-23
Posts: 91
oh dear, please dont take this to seriously... the confiusion is my lack of understanding the fundamental scripting, particulary in kix language. nor am I a developer, or for that matter have a logical mind...

However my confiusion was to break a part a word into its letters, then use the letters to rebuild or manipulate... that way I could play around with each letter in diffrent ways...

My apologize to u all, if I make u confiused.

-JM
_________________________
I will always look out from behind these eyes...

Top
Page 1 of 2 12>


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 1471 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.079 seconds in which 0.029 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org