Page 1 of 1 1
Topic Options
#131242 - 2004-12-13 11:19 PM Problem Emunerating directory
Fugazi Offline
Starting to like KiXtart

Registered: 2001-04-23
Posts: 142
Loc: Pace, Fl.
I am trying to do a simple enum of a directory and I am only returning a "." as the results. Can someone see what I am doing wrong.
Code:
  $username=Dir  ($nodepath)

While $username <> "" AND @ERROR = 0
?$username
If NOT InStr ($username,".")
decrypt()
Select
Case $cboUserSort.Text = "Name"
$fullname=ReadProfileString ($nodepath+$username,"Primary","Fullname")
If InStr($fullname,$txtFind.text)
$item=$listUsers.items.add
$Item.SubItems(0).Text = ($transuserid)
$Item.SubItems(1).Text = ($fullname)
Case $cboUserSort.Text = "User ID#"
If InStr($transuserid,$txtFind.text)
?"Find User ID ="$Find
$item=$listUsers.items.add
$Item.SubItems(0).Text = ($transuserid)
$Item.SubItems(1).Text = ReadProfileString ($nodepath+$username,"Primary","Fullname")
EndSelect
EndIf
$username = Dir("")
Loop




The Decrypt () function will translate a numeric file name to a valid Network ID ($transuserid).
_________________________
I haven't failed. I just found another way that did not work.

Top
#131243 - 2004-12-13 11:59 PM Re: Problem Emunerating directory
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
I would try changing:
$username = Dir("")

to:
$username = Dir()
_________________________
!

download KiXnet

Top
#131244 - 2004-12-14 03:29 PM Re: Problem Emunerating directory
Fugazi Offline
Starting to like KiXtart

Registered: 2001-04-23
Posts: 142
Loc: Pace, Fl.
Found the problem out forgot the endif for the instr statements.
_________________________
I haven't failed. I just found another way that did not work.

Top
#131245 - 2004-12-14 03:49 PM Re: Problem Emunerating directory
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Be careful when looping on not @error as it can sneak up on you.
Code:
$var = 0
While $var < 10 and not @Error
'var = '+ $var ?
$var = $var + 1
If $var = 5
$rc=MessageBox("snookered","Test")
EndIf
Loop



You may start out OK but then later embelish the code somewhere inside the loop that could throw @Error. BTDTGTTS
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#131246 - 2004-12-15 05:09 AM Re: Problem Emunerating directory
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
Why reinvent the wheel if there are already a couple of DIR...() UDFs posted in the UDF Forum?
_________________________
There are two types of vessels, submarines and targets.

Top
#131247 - 2004-12-15 01:06 PM Re: Problem Emunerating directory
MCA Offline
KiX Supporter
*****

Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
Dear,

We run our program kixstrip which you can find on our site and
which shows indeed you are missing two ENDIF statements:
The result of our call: kistrip input.kix output.kix /block_check /show_errors
shows
Code:

$username=Dir ($nodepath)
WHILE $username <> "" AND @error = 0
?$username
IF NOT InStr ($username,".")
decrypt()
SELECT
CASE
$cbousersort.text = "Name"
$fullname=ReadProfileString ($nodepath+$username,"Primary","Fullname")
IF InStr($fullname,$txtfind.text)
$item=$listusers.items.add
$item.subitems(0).text = ($transuserid)
$item.subitems(1).text = ($fullname)
CASE
$cbousersort.text = "User ID#"
IF InStr($transuserid,$txtfind.text)
?"Find User ID ="$Find
$item=$listusers.items.add
$item.subitems(0).text = ($transuserid)
$item.subitems(1).text = ReadProfileString ($nodepath+$username,"Primary","Fullname")
ENDSELECT
ENDIF
$username = Dir("")
LOOP


;($begin)
;
; kixstrip 4.03e - kixtart 4.22
;
; wed 15-dec-2004 12:58:15
;
;Informative KIXSTRIP: input=23 output=23 skip=0
;
;Warning KIXSTRIP: 2 errors in block structure(s). missing statement(s).
; - do:until [0:0]
; - for|each:in|to:step|next [0|0:0|0:0|0]
; - function:endfunction [0:0]
; -ERROR- - if:else:endif [3:0:1]
; - select:case:endselect [1:2:1]
; - while:loop [1:1]
;Warning KIXSTRIP: some lines contains errors or possible errors.
;Informative KIXSTRIP: 5 block_structures found.
;Informative KIXSTRIP: no UDF's found.
;Informative KIXSTRIP: no labels found.
;Summary KIXSTRIP: BREAK CALL DEBUG DISPLAY ENDFUNCTION EXECUTE EXIT FUNCTION GET GETS GOSUB GOTO OLExxx PLAY QUIT RETURN RUN SHELL SLEEP THEN USE
;
;($end)
;($begin)
;
;
;($end)


greetings.

_________________________
email scripting@wanadoo.nl homepage scripting@wanadoo.nl | Links | Summary of Site Site KiXforms FAQ kixtart.org library collection mirror MCA | FAQ & UDF help file UDF kixtart.org library collection mirror MCA | mirror USA | mirror europe UDF scriptlogic library collection UDFs | mirror MCA

Top
#131248 - 2004-12-15 02:46 PM Re: Problem Emunerating directory
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
MCA is correct to a point..

You are missing more than just a couple of ENDIFs

You can clean up your code to be -
Code:

WHILE $username <> "" AND @error = 0
?$username
IF NOT InStr ($username,".")
decrypt()
;SELECT ;<< IS THIS NEEDED?
;CASE ;<< IS THIS NEEDED?
$cbousersort.text = "Name"
$fullname=ReadProfileString ($nodepath+$username,"Primary","Fullname")
IF InStr($fullname,$txtfind.text)
$item=$listusers.items.add
$item.subitems(0).text = ($transuserid)
$item.subitems(1).text = ($fullname)
ELSE ;<< MISSING ELSE?
$cbousersort.text = "User ID#"
IF InStr($transuserid,$txtfind.text)
?"Find User ID ="$Find
$item=$listusers.items.add
$item.subitems(0).text = ($transuserid)
$item.subitems(1).text = ReadProfileString ($nodepath+$username,"Primary","Fullname")
ENDSELECT
ENDIF
$username = Dir("")
;ENDSELECT ;<< IS THIS NEEDED?
ENDIF ; MISSING ENDIF
LOOP



Thanks,

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#131249 - 2004-12-15 03:02 PM Re: Problem Emunerating directory
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
You are still looping on not @error. I would go with a more modularized method rather than in-line. Read in the works into an array with a UDF first and then iterate through the array.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#131250 - 2004-12-15 03:39 PM Re: Problem Emunerating directory
maciep Offline
Korg Regular
*****

Registered: 2002-06-14
Posts: 947
Loc: Pittsburgh
Kent, it looks like you have an ENDSELECT where you'd want an ENDIF. And i think you should also move that username=Dir() down a level, because it'll just keep looping if username = '.'

Les, what's the problem with looping on @error if the last statement, the Dir() assignment, sets @error? I've never had a problem with it in that situation.
_________________________
Eric

Top
#131251 - 2004-12-15 04:07 PM Re: Problem Emunerating directory
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Guess maybe you didn't read my post and run my example.
http://www.kixtart.org/ubbthreads/showthreaded.php?Cat=&Number=130405&page=&view=&sb=5&o=&vc=1

If after you read it and analyze it, you still have questions, post back.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#131252 - 2004-12-15 04:15 PM Re: Problem Emunerating directory
maciep Offline
Korg Regular
*****

Registered: 2002-06-14
Posts: 947
Loc: Pittsburgh
I did read it and i did test it. But still it has nothing to do with the Dir() function and its ability to set @error

Code:

$var = 0
$username = dir("c:\*.*")
While $var < 10 and not @Error
'var = '+ $var ?
$var = $var + 1
If $var = 5
MessageBox("snookered","Test")
EndIf
$userName = dir()
Loop
? @error

_________________________
Eric

Top
#131253 - 2004-12-16 07:08 PM Re: Problem Emunerating directory
Fugazi Offline
Starting to like KiXtart

Registered: 2001-04-23
Posts: 142
Loc: Pace, Fl.
The reason I left this as a Select Case is that I originally had the sort including location and computer name. The powers that be at that time did not see a use for it and I removed it. I did change it to an IF statement then reconsidered because I can almost gaurentee that they will have me put it back at the next meeting for this application (which is why I forgot to include the EndIf's).
_________________________
I haven't failed. I just found another way that did not work.

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
0 registered and 507 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

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