Page 1 of 1 1
Topic Options
#116876 - 2004-03-26 12:12 AM Cutting off login name at 8 characters
Warren Offline
Lurker

Registered: 2004-03-26
Posts: 1
In order to map some Windows users to Unix drives, I need to be able to user the @USERID macro, but only have it output the first 8 characters of the username.. is this possible?

thanks

-Warren

Top
#116877 - 2004-03-26 12:43 AM Re: Cutting off login name at 8 characters
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11631
Loc: CA
Hello Warren and welcome to the board.

Yes, it is very easy to do. Make sure you're using KiXtart 4.22 if possible.


In the manual it says this.

Quote:

Left( )

Action: Returns a specified number of characters from the left side of a string.

Syntax: LEFT ("string", length)

Parameters: String
String expression from which the leftmost characters are returned.

Length

Numeric expression indicating how many characters to return. If 0, a zero-length string is returned. If greater than or equal to the number of characters in string, the entire string is returned. Specifying a negative value will cause Left( ) to return the number of characters equal to the total length of the string minus the value specified.

Returns: The substring requested.

See Also: InStr( ), InStrRev( ), Right( ), SubStr( )

Example: ; get the first 2 chars of the user's ID
$x = LEFT(@USERID, 2)





If you need further assistance please don't hesitate to ask.

Top
#116878 - 2004-03-26 12:44 AM Re: Cutting off login name at 8 characters
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
The following line will take the first 8 chars from the left end of the @UserID macro and assign it to the $username variable.

Code:
$username = Left(@UserID,8)


Top
#116879 - 2004-03-26 12:45 AM Re: Cutting off login name at 8 characters
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
dohh...Doc beat me to it..
Top
#116880 - 2004-03-26 01:34 AM Re: Cutting off login name at 8 characters
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
WHat if several users have the same first 8?
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#116881 - 2004-03-26 01:44 AM Re: Cutting off login name at 8 characters
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11631
Loc: CA
First one's the WINNER
Top
#116882 - 2004-03-26 02:57 AM Re: Cutting off login name at 8 characters
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
All of our user IDs are only 7 chars to begin with
Top
Page 1 of 1 1


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

Who's Online
0 registered and 302 anonymous users online.
Newest Members
Sir_Barrington, batdk82, StuTheCoder, M_Moore, BeeEm
17886 Registered Users

Generated in 0.053 seconds in which 0.023 seconds were spent on a total of 12 queries. Zlib compression enabled.

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