Page 1 of 1 1
Topic Options
#179414 - 2007-08-17 08:07 AM Hyphen problem - Help
ping82 Offline
Lurker

Registered: 2007-08-17
Posts: 3
Hello,

I have some problem with the hyphen. I am trying to use the macro @wuserid
If the windows user id is without hypen it works perfectly fine. If the userid contains hyphen, it does not work, giving error LABEL [<label>] not found!

a similar example below does not work as well
----
goto mytest-av '<-Have tried added in "mytest-av"
goto end

:mytest-av 'added quotation mark, still not work
"testing"

:end
-----

I tried to add the double quotation to the userid label(eg. :"abc-d") but it does not work. Please help. Below is my script algorithm.

---------
goto @wuserid
..
..
..


:abc
..
goto end

:abc-d
..
..
goto end

:end

Top
#179415 - 2007-08-17 08:36 AM Re: Hyphen problem - Help [Re: ping82]
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1896
Loc: Hilversum, The Netherlands
Using "Goto" is generally considered bad practise but yeah, apparantly Labels cannot have hypens. However underscores are supported.
Top
#179418 - 2007-08-17 08:58 AM Re: Hyphen problem - Help [Re: Arend_]
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
I presume KiXtart will see the - as minus.
I don't think there is a way around.

Top
#179419 - 2007-08-17 09:01 AM Re: Hyphen problem - Help [Re: Arend_]
ping82 Offline
Lurker

Registered: 2007-08-17
Posts: 3
Hi,

I will need to change some registry entry based on each windows username.

Is there an alternate way to do this? Is there a function to remove the hyphen? i.e - user abc-d become abcd, user df-erfg becomes dferfg

Thanks.


Edited by ping82 (2007-08-17 09:03 AM)

Top
#179420 - 2007-08-17 09:18 AM Re: Hyphen problem - Help [Re: ping82]
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
"a-a" --> "aa"
 Code:
BREAK ON
Join(Split("a-a","-"),"") ?
Get $

Top
#179421 - 2007-08-17 09:25 AM Re: Hyphen problem - Help [Re: Witto]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
The issue is not the user name it's the use of the LABEL command like a batch file.

You should program around it and not use the LABEL

Can you show more of your script or a bigger picture of your environment so that maybe we can provide a better solution.

These quick snippets may work some but often users come back because as they move forward they find that something else isn't working right because the overall method or design needs rework instead of adding code on top of code that is problematic in the first place.

Top
#179422 - 2007-08-17 09:27 AM Re: Hyphen problem - Help [Re: ping82]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
 Originally Posted By: ping82
Is there a function to remove the hyphen


Yes, but I'd still advise that you don't use GoTo.

Better to use something like Select:
 Code:
Select
   Case @WUSERID="userA"
      ; Update Registry here
   Case @WUSERID="anotheruser"
      ; Update regsitry here
   Case @WUSERID="bill" OR @WUSERID="ben" OR @WUSERID="weed-little"
      ; Update registry here
EndSelect


Better still if there are common settings among the users is to use a parameter (INI) file. Read a profile from the parameter file and only set the registry if it is true.

To do this, create an INI file on your netlogon share that looks like this:
 Originally Posted By: PARAMETER.INI

[userA]
Office=1
RemoteUser=0
DevTeam=0
[Bill]
Office=1
RemoteUser=0
DevTeam=1

Now in your script you can do this:
 Code:
$sUserProfile=@LSERVER+"\netlogon\PARAMETER.INI"
If ReadProfileString($sUserProfile,@WUSERID,"Office")
   ; Do Office reg settings
EndIf
If ReadProfileString($sUserProfile,@WUSERID,"RemoteUser")
   ; Special login coding for remote users
EndIf
If ReadProfileString($sUserProfile,@WUSERID,"DevTeam")
   ; Install development tools for DevTeam members
EndIf


Still better again, use AD groups rather than the INI file.
 Code:
If InGroup("Office Users")
   ; Do Office reg settings
EndIf
If InGroup("Remote Users")
   ; Special login coding for remote users
EndIf
If InGroup("Engineering Dev Team", "Accounting Dev Team", "Sales Dev Team")
   ; Install development tools for DevTeam members
EndIf



Finally, if you must use dodgy GoTo the simplest way to remove the hyphen is to use the Join(Split()) replace trick:
 Code:
GoTo Join(Split(@WUSERID,"-"),"")

Top
#179423 - 2007-08-17 09:31 AM Re: Hyphen problem - Help [Re: NTDOC]
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
We all agree on that. apronk already said it:
 Originally Posted By: apronk
Using "Goto" is generally considered bad practise

Top
#179424 - 2007-08-17 09:59 AM Re: Hyphen problem - Help [Re: Witto]
ping82 Offline
Lurker

Registered: 2007-08-17
Posts: 3
Hi All,

Thanks. That solves the problem.

Since it is for individual users, I will just use the Select statement.


:-)

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 1894 anonymous users online.
Newest Members
fgarcia, Viginette, ManuvdWielNL, Sir_Barrington, batdk82
17889 Registered Users

Generated in 0.064 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