split string variable into array? 
Author Message
 split string variable into array?

Is there any way to split a string variable (In this case the
currently logged on user) into an array of each letter?

In short, I'm trying to edit a hex entry in the registry. to do that I
need to take the users name, and turn it into hex then apply that
change to the registry entry.

Alternate to manipulating the logon name, if anyone could suggest a
way to do this that would be great.

Thanks!
--Gene



Mon, 01 Aug 2005 03:56:45 GMT  
 split string variable into array?


Quote:
> Is there any way to split a string variable (In this case the
> currently logged on user) into an array of each letter?

> In short, I'm trying to edit a hex entry in the registry. to do that I
> need to take the users name, and turn it into hex then apply that
> change to the registry entry.

> Alternate to manipulating the logon name, if anyone could suggest a
> way to do this that would be great.

> Thanks!
> --Gene

Function ToCharArray(ByVal strString)
  Dim lngCtr
  Dim strArray

  ReDim strArray(Len(strString))

  For lngCtr = 1 To Len(strString)
    strArray(lngCtr) = Mid(strString, lngCtr, 1)
  Next

  ToCharArray = strArray
End Function

Please note, I haven't tested it, and I am really tired, but it should
work...

Hope this helps!

Mythran



Mon, 01 Aug 2005 04:18:30 GMT  
 split string variable into array?
am 12.02.03 20:56 sprach GeneL dieses:

Quote:
> Is there any way to split a string variable (In this case the
> currently logged on user) into an array of each letter?

with JScript:

var i =-1, s = "test_user", a = new Array();
while(i++<s.length) {
   a.push(s.substr(i,1));

Quote:
}

WScript.Echo (a.join('\n'));

mfg
Christoph



Mon, 01 Aug 2005 07:50:38 GMT  
 split string variable into array?
Quote:
> Is there any way to split a string variable (In this case the
> currently logged on user) into an array of each letter?

yet another solution

var user = "abcdefghijk";

String.prototype.toHex = function()
    {
    var hex = this.charCodeAt(0).toString(16);
    return hex.length < 2 ? "0"+hex: hex;
    }

Array.prototype.toHex = function()
    {
    var hexarr = [];
    for(var i=0; i<this.length; i++)
        {
        hexarr.push(this[i].toHex());
        }
    return hexarr;
    }

WScript.echo(user.split("").toHex().join("\n"));

zwetan



Tue, 02 Aug 2005 07:32:59 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Splitting Session Variable into several variables (array?)

2. Splitting a string into an array

3. string splitting and arrays

4. how to split a split string

5. BinaryRead - howto convert binary string back to string array

6. Passing Array to Session Variable Then back to Array

7. Split string by regular expression (ie. date)

8. Splitting Strings

9. String Split

10. Newbie wants to split up strings

11. Splitting a string into each character..

12. SPLIT A LONG STRING TO PUT IN A MULTILINE BOX

 

 
Powered by phpBB® Forum Software