Page 1 of 1 1
Topic Options
#58508 - 2001-08-23 05:59 PM How do I enumerate a rasphone.pbk heading?
Anonymous
Unregistered


I want to use kix to parse a dialup heading name e.g. [xxxxx] based on a specific tel no i.e. 1877 1231234 from a rasphone.pbk entry into a variable, and then assign the heading name as a value name to a registry setting on my ISA server to force the specific tel no. users to receive use the ISA proxy settings when they dialin. My problem is I am not sure how to parse the entry heading based on this tel no., since the rasphone.pbk contains more than one heading for other tel nos. I know the phone no, but not the name heading which could be anything and that is what I want to use. Any help will be smashing.
Thanks

Top
#58509 - 2001-08-23 07:46 PM Re: How do I enumerate a rasphone.pbk heading?
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
So, let me get this straight. You want to:

1. Parse through RASPhone.pbk
2. Capture the heading inside [brackets] to a $var
3. Parse for 'PhoneNumber=' line and test for a match on phone number
4. If no match, capture next heading to $var
5. If match found, keep header it was found under
6. Bob's your uncle

Possible problem I forsee is the format of phone number. Some may include hyphens, some spaces, some fewer digits, etc. Can you search on subset (ie. last four digits) of number and ensure you have correct entry?

I'm not promising to write the code, just flowcharting to get an understanding.

[ 23 August 2001: Message edited by: LLigetfa ]

_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#58510 - 2001-08-23 08:41 PM Re: How do I enumerate a rasphone.pbk heading?
Anonymous
Unregistered


Your understanding is perfect !!! more than perfect. I am glad you pointed out the last 4 digits, that would make it easier to search since some users might have the space, dashes etc. You have it straight to the gun, understood.
Thanks

[ 23 August 2001: Message edited by: Ntjazzed ]

Top
#58511 - 2001-08-23 09:05 PM Re: How do I enumerate a rasphone.pbk heading?
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
So, with the outline pegged, are you going to carve the code or are you still looking for sample code?

My programming prowess is pretty pathetic. Not so good at string manipulation. I suspect though, it would be a combination of ReadLine() and ReadProfileString(). The latter I have never used.

_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#58512 - 2001-08-23 09:29 PM Re: How do I enumerate a rasphone.pbk heading?
Anonymous
Unregistered


LLigetfa,
Regardless, I think your kix skills definitely beats me. If you can dish me a sample code I can take it from there. I usually struggle when starting a script. The starting points is what kills me.
Thanks

Top
#58513 - 2001-08-23 10:15 PM Re: How do I enumerate a rasphone.pbk heading?
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
"Better to keep my mouth shut and have others think I'm a fool than to open my mouth and remove all doubt." -author unknown

Don't hold your breath, remember my sig.

Hey someone, help me out here! I've risen to my level of incompetence!

_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#58514 - 2001-08-23 10:20 PM Re: How do I enumerate a rasphone.pbk heading?
Anonymous
Unregistered


Don't beat yourself too much, I am gearing myself with a skeleton code and then I will post here and see if anyone can help me polish it. You gave your best shot.. remember is the effort that counts, your efforts has given me some input already. Thnx Lligetfa for trying.
Peace.

Top
#58515 - 2001-08-24 03:28 AM Re: How do I enumerate a rasphone.pbk heading?
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
OK, so you got my confidence up... well just a little. The way I look at it, this is what needs to be done:
1. With readline() parse for all the headings. That part's not too tough.
code:

IF OPEN(1, "C:\kix\rasphone.pbk") = 0
$cl = ReadLine(1)
WHILE @ERROR = 0
if SUBSTR($cl, 1, 1) = "["
? "$cl =" $cl ;put your code here
ENDIF
$cl = ReadLine(1)

LOOP
ENDIF
$ = CLOSE(1)
get $



2. You've got to put these headings into variables. Since there are likely to be more than one heading, I'm thinking a two dimensional array is needed. The first dimension for the header name and the second for the instance (loop count). This is where my limit is reached. I don't know how to do the two dimensional array.

3. Once you're there, you query each header section for 'PhoneNumber' with ReadProfileString().

code:

$header = "NameOfHeader" ;put your code here
$dev = ReadProfileString("C:\kix\rasphone.pbk", $header, "PhoneNumber")
If @ERROR = 0
? "PhoneNumber = " + $dev " ;put your code here

Endif
get $



4. Now do a SUBSTR() function to test for the number. Hey, wait a minute, I'm lazy. It'd be the same as my first example, only different.

5. G O T ... T O ... F I G H T ... T H E ... U R G E ... T O ... P R O G R A M ...

The rest I leave to you or someone else.

This is a slight departure from my first outline because I realized there may be more than one heading with the same base number. On my PC, there were several. One from the office, one from home, one from out-of-town, etc., all with a different dialing prefix.

Actually, I maybe over-simplified it just a bit. The very first thing you need to do is locate the rasphone.pbk file. Depending on OS and design, they could be per user or 'All Users'. On my Win2k, it resides in C:\Documents and Settings\All Users\Application Data\Microsoft\Network\Connections\Pbk\. But then again, what you intend to do with the results is probaably no cake walk either.

[ 24 August 2001: Message edited by: LLigetfa ]

[ 24 August 2001: Message edited by: LLigetfa ]

_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#58516 - 2001-08-25 08:18 AM Re: How do I enumerate a rasphone.pbk heading?
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Couldn't fight the urge. Just had to figure out this array thing. Here goes:
code:

break on
DIM $array[10] ;assuming fewer than 12 entries
$x = 0
; Find headers in .pbk file

IF OPEN(1, "C:\kix\rasphone.pbk") = 0
$cl = ReadLine(1)
WHILE @ERROR = 0
if SUBSTR($cl, 1, 1) = "["
$array[$x] = SUBSTR($cl, 2, LEN($cl)-2)
? "Header $x = " $array[$x]
$x = $x + 1
ENDIF
$cl = ReadLine(1)
LOOP
ENDIF
$ = CLOSE(1)
get $

; Find phone number in each section

$x = 0
WHILE $array[$x] <> ""
$dev = ReadProfileString("C:\kix\rasphone.pbk", $array[$x], "PhoneNumber")
If @ERROR = 0
? "PhoneNumber = " + $dev
Endif
$x = $x + 1
LOOP
get $



I'm still lazy, so I left some for you.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#58517 - 2001-08-26 11:07 AM Re: How do I enumerate a rasphone.pbk heading?
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11631
Loc: CA
Did you say ARRAY...

Where is that Array Boy of The Northern Hemisphere when you need him

Bill - here is your chance to increase ego again

Top
#58518 - 2001-08-27 05:42 PM Re: How do I enumerate a rasphone.pbk heading?
Anonymous
Unregistered


LLigetfa,
you are the MAN. I know I owe you a big pint of lager(beer) for your endeavour. You are great and persistent. Thank you once again.
DoUntil

Top
Page 1 of 1 1


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

Who's Online
1 registered (DaveLipman) and 623 anonymous users online.
Newest Members
ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder, M_Moore
17887 Registered Users

Generated in 0.062 seconds in which 0.024 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