Page 1 of 1 1
Topic Options
#36884 - 2003-02-25 06:10 PM Compound InStr.....
ArchAngel96 Offline
Getting the hang of it

Registered: 2002-10-20
Posts: 70
When people logon at work, I need to see what machine name it is and then do or don't run a scan base on the computer name. My real problem is that I need to check for a varity of varibles in the computer name...

Each computer is named for its location and then its function at that location: S0100N01. The first four numbers changer per location and of course the last three characters, both the letter and the two numbers change.

I know what I don't want to scan for, so everything else I do. the problem is the variables
Example:
Locations 0002 - 0598 with:
S01
R01
V01
H01 - H10
N01 - N24
I don't want to scan, but any thing at location 0800 I want to scan. And lastly, nothing at location 0900 should be scanned.

I'm looking at having to write something like:
code:
 If NOT (InStr(@WKSTA,'0002') AND InStr(@WKSTA,'S01')) OR InStr(@WKSTA,'0900')
OR (InStr(@WKSTA,'0425') AND InStr(@WKSTA,'R01'))

but with all the variables in there, which will make a very long line....

Is there a better way of doing this, or am I going to need to write out this line for every combination? and can that even be done?

[ 25. February 2003, 18:11: Message edited by: ArchAngel96 ]
_________________________
penny = the target the playing field = three football fields side by side you = only allowed to stand on the outside of the playing field tool you get to use to find the penny = a ONE INCH LAWN DART get the level of difficulty?

Top
#36885 - 2003-02-25 06:14 PM Re: Compound InStr.....
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
you gave example what you don't want but could you give some info more what you want.

else than just location 0800?
_________________________
!

download KiXnet

Top
#36886 - 2003-02-25 06:15 PM Re: Compound InStr.....
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Look at using ASCAN() and rethink your logic. Create an array containing the two digit codes and a second one contianing the four-digit codes. Then check the first two digits of the computername and then the four-digit ones.
code:
$two='S01','R01'
$four='0425','0900'
if ascan($two,left(@WKSTA,2))=-1 and ascan($four,left((@WKSTA,4))=-1
; not in either array
else
; in at least one fo the arrays
endif



[ 26. February 2003, 15:48: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.

Top
#36887 - 2003-02-25 06:16 PM Re: Compound InStr.....
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Have you considered a solution based on logical subnet instead of the computer name?
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#36888 - 2003-02-25 06:18 PM Re: Compound InStr.....
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
See for example TCP/IP Primer, Part I - IP Addresses
_________________________
There are two types of vessels, submarines and targets.

Top
#36889 - 2003-02-25 07:43 PM Re: Compound InStr.....
ArchAngel96 Offline
Getting the hang of it

Registered: 2002-10-20
Posts: 70
To answer Lonkero: Basically, we want to scan everything else... We know exactly what we don't want to scan, but we also want to check to make sure our field techs are naming computers correctly, no one is Brining in their own computers and some how getting them on our network. And as far as the 'want to scan' not all the machine names exist at each location. Therefore the easiest solution is to 'not scan' my list, then everything else will get scanned.

To answer Howard Bullock: No actually, I didn't consider that. But we already have a way to separate certain machines in our enviornment within the logon.bat(kix) and so I was simply attempting to follow the same path... Oh, and as new locations are added, 'Someone' (most likely me) would have to update that list every time... [Frown]

AS for sealeopard: I think an array, as you gave an example, would be the easiest. Thou, I would still have to update the array info, but I wouldn't have to worry about the IP chaning at the location... sometimes this does happen for all the right reasons... By using the array, I can simply adjust the location numbers to include the new locations, or remove them as they fall off.

I haven't used an array before, can anyone recommend some good examples that could help....? Thanx
_________________________
penny = the target the playing field = three football fields side by side you = only allowed to stand on the outside of the playing field tool you get to use to find the penny = a ONE INCH LAWN DART get the level of difficulty?

Top
#36890 - 2003-02-25 07:45 PM Re: Compound InStr.....
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Just give it a try. Learning by doing!
_________________________
There are two types of vessels, submarines and targets.

Top
#36891 - 2003-02-26 01:39 AM Re: Compound InStr.....
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11631
Loc: CA
Haven't seen Bill around for awhile. He used to list himself as the ArrayBoy

Lonkero seems to be one of the reigning champions of Arrays. His Application. BBS Checker using it, the PostPrep uses the heck out of it, etc...

There are other people here that know it fairly well also. Unfortunately I'm not yet one of them. I can only do very simple ones.

Perhaps one of these good folks that do understand Arrays will write an EASY TO UNDERSTAND FAQ/Guide to ARRAYS.

Top
#36892 - 2003-02-26 11:02 AM Re: Compound InStr.....
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
If you want to keep it simple this should do it for you:
code:
$sLocation=SubStr(@WKSTA,1,5)
$sFunction=SubStr(@WKSTA,6,3)

$iScan=0 ; Default is to not scan.

Select
Case $sLocation >= "S0002" AND $sLocation <= "S0598"
Select
Case $sFunction = "S01"
Case $sFunction = "R01"
Case $sFunction = "V01"
Case $sFunction >= "H01" AND $sFunction <= "H10"
Case $sFunction >= "N01" AND $sFunction <= "N24"
Case "true"
$iScan=1 ; None of the above? Then scan
EndSelect
Case $sLocation = "S0800"
$iScan=1 ; Scan all 0800 locations
Case $sLocation = "S0900"
$iScan=0 ; Don't scan 0900 locations
Case "true"
$iScan=1 ; Scan unknowns.
"***WARNING*** Badly formed workstation name '" + @WKSTA + "'" + @CRLF
EndSelect

If $iScan
; *** YOUR SCANNING CODE HERE ***
EndIf


Top
#36893 - 2003-02-27 09:36 PM Re: Compound InStr.....
ArchAngel96 Offline
Getting the hang of it

Registered: 2002-10-20
Posts: 70
Richard's solution looks pretty simple, actually.... [Smile] [Big Grin]

I'm going to try this first, thank you.. my 16 hour project may have just became 16 minutes...
_________________________
penny = the target the playing field = three football fields side by side you = only allowed to stand on the outside of the playing field tool you get to use to find the penny = a ONE INCH LAWN DART get the level of difficulty?

Top
#36894 - 2003-03-01 04:19 AM Re: Compound InStr.....
ArchAngel96 Offline
Getting the hang of it

Registered: 2002-10-20
Posts: 70
I've used Richard's sample, with a real minor change... And its working perfectly!!! Thanx all for the help
_________________________
penny = the target the playing field = three football fields side by side you = only allowed to stand on the outside of the playing field tool you get to use to find the penny = a ONE INCH LAWN DART get the level of difficulty?

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 1057 anonymous users online.
Newest Members
ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder, M_Moore
17887 Registered Users

Generated in 0.066 seconds in which 0.029 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