Page 1 of 1 1
Topic Options
#211784 - 2016-07-12 09:00 PM DirPlus UDF and KiXtart 4.67 beta1 not playing nice
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
This afternoon I downloaded a copy of KiXtart 4.67 beta1 and started testing some things.

Using the DirPlus UDF and the code below I get:

 Quote:

ERROR : unknown command [weight]!
Script : C:\bla, bla, bla....
Line : 1


I tried with a local and remote folder and with or without the filter. All with the same result. I did the simple checks to see if somehow the UDF got messed up but it did not. Changed back to 4.66 and all was fine.

Can somebody test and confirm?

 Code:
Break on

$rc = RedirectOutput("d:\testoutput.txt")


$scripts = DirPlus("D:\testfolder\", "/a-d") ;returns only a list of files with .kix entension

Select
	Case UBound($scripts) < 0
		;nothing to do
	Case UBound($scripts) = 0
		;Call $scripts[0]
		? $scripts[0]
	Case UBound($scripts) > 0
		For Each $script in $scripts
			;Call $script
			? $script
		Next
EndSelect

$scripts = DirPlus("\\server\share\", "/a-d /f kix") ;returns only a list of files with .kix entension

Select
	Case UBound($scripts) < 0
		;nothing to do
	Case UBound($scripts) = 0
		;Call $scripts[0]
		?$scripts[0]
	Case UBound($scripts) > 0
		For Each $script in $scripts
			;Call $script
			?$script
		Next
EndSelect

Sleep 10


;Function		DIRPlus()
;
;Author		Bryce Lindsay bryce@isorg.net
;
;Action		Returns an array containing directory files and folders
;
;Syntax		DIRPLUS("PATH","OPTIONS")
;
;Version		2.34
;
;Date Revised	2-10-05
;			2005.09.20 2.34 Filed the file/folder option "d" to be non language dependent, thanks Jochen
;
;Parameters	Path
;		  Full path To To a folder that you want To Return information on.
;		  "c:\program files"
;
;		  OPTIONS
;		  /S          Displays files In specified directory and all subdirectories.
;                             Use a /S# where # is equal to the subfolder depth that you want to recurse.
;
;		  /A          Displays files with specified attributes.
;		  attributes   D  Directories                R  Read-only files
;		               H  Hidden files               A  Files ready For archiving
;		               S  System files               -  Prefix meaning not
;
;		  /M          Apply mask string To filter based on InSTR(), separate Each search string witha a |
;
;		  /F          Return a given File extension like exe log or txt Seperate each extension type with a space
;
;
;Remarks	Finaly fixed this UDF For To handle multiple recursions,
;		also should have a faster responce time since it is using the FSO
;
;		***Please note that the syntax For version 2.0 of this UDF has changed.***
;
;		made some tweeks using feedback from Les! thanks!  Also NTDOC!
;
;Returns	Returns and array of FSO objects that are equal the file and folder objects of
;		the given path.  Also returns a @ERROR code For event handling.
;
;Dependencies 	FSO
;
;KiXtart Ver	4.22
;
;Example(s)	$Dir = dirplus("c:\program files") ;returns all files and folders In the "c:\program files" folder
;		$Dir = dirplus("c:\program files","/s") ;all fiels and folders including subfolders
;		$Dir = dirplus("c:\","/a-d") ;returns only a list of files In the c:\
;		$Dir = dirplus("c:\","/ad") ;returns only a list of folders In the c:\
;		$Dir = dirplus("c:\program files","/ad /s") ;returns only the folders including all subfolders.
;
;		$Dir = dirplus("g:\kix\udf","/s /ad /m dir") ; recursive subfolder search, folders only, using a mask string of "dir"
;
;		$desktop = dirplus("%userprofile%\desktop","/a-d")
;		For Each $file In $desktop
;			? $file
;			? $file.size
;		Next
;
Function DirPlus($path,optional $Options, optional $f, optional $sfflag)
	If Not VarType($f)	Dim $f		EndIf
	If Not VarType($sfflag)	Dim $sfflag	EndIf

	Dim $file, $i, $temp, $item, $ex1, $mask,$mask1,$maskArray,$maskarray1,
	$ex2, $code, $CodeWeight, $targetWeight, $weight, $masktrue
	Dim $tarray[0]

	$ex1 = SetOption(Explicit,on)
	$ex2 = SetOption(NoVarsInStrings,on)
	$codeWeight = 0

	If Not Exist($path) 
		$temp = SetOption(Explicit,$ex1)
		$temp = SetOption(NoVarsInStrings,$ex2)
		Exit @ERROR
	EndIf

	If Not VarType($f)
		$f = CreateObject("Scripting.FileSystemObject").getfolder($path)
	EndIf
	If @ERROR 
		$temp = SetOption(Explicit,$ex1)
		$temp = SetOption(NoVarsInStrings,$ex2)
		Exit @ERROR
	EndIf

 	For Each $temp in Split($options,"/")
		$temp=Trim($temp)
		Select
		   Case Left($temp,1) = "s"
			If Not VarType($sfflag)
				If Val(Right($temp,-1)) = 0
					$sfflag = -1
				Else
					$sfflag = Val(Right($temp,-1))
				EndIf	
			EndIf
		   Case Left($temp,1) = "a"
			Select
			   Case Right($temp,-1)="d"
				$codeWeight = $codeWeight + 1
				$temp = "if $file.attributes & 16 " ;"if $file.type = 'File Folder' "
			   Case Right($temp,-1)="-d"
				$codeWeight = $codeWeight + 1
				$temp = "if ($file.attributes & 16)=0 " ;"if $file.type <> 'File Folder' "
			   Case Right($temp,-1)="s"
				$codeWeight = $codeWeight + 1
				$temp = "if $file.attributes & 4 "
			   Case Right($temp,-1)="-s"
				$codeWeight = $codeWeight + 1
				$temp = "if ($file.attributes & 4)=0 "
			   Case Right($temp,-1)="h"
				$codeWeight = $codeWeight + 1
				$temp = "if $file.attributes & 2 "
			   Case Right($temp,-1)="-h"
				$codeWeight = $codeWeight + 1
				$temp = "if ($file.attributes & 2)=0 "
			   Case Right($temp,-1)="r"
				$codeWeight = $codeWeight + 1
				$temp = "if $file.attributes & 1 "
			   Case Right($temp,-1)="-r"
				$codeWeight = $codeWeight + 1
				$temp = "if ($file.attributes & 1)=0 "
			   Case Right($temp,-1)="a"
				$codeWeight = $codeWeight + 1
				$temp = "if $file.attributes & 32 "
			   Case Right($temp,-1)="-a"
				$codeWeight = $codeWeight + 1
				$temp = "if ($file.attributes & 32)=0 "
			EndSelect
			$code = $temp + "$weight=$weight+1 endif" +@CRLF + $code

		   Case Left($temp,1) = "m"
			$maskarray = Split(Right($temp,-2),"|")
			$codeweight = $codeweight + 1
			$code = "$masktrue=0 for Each $mask in $maskarray if instr($file.name,$mask) $masktrue=1 " +
			"EndIf Next If $masktrue $weight=$weight+1 endif" + @CRLF +$code
		   Case Left($temp,1) = "f"
			$maskarray1 = Split(Right($temp,-2)," ")
			$codeweight = $codeweight + 1
			$code = "$masktrue=0 for Each $mask1 in $maskarray1 if substr($file.name,Instrrev($file.name,'.')+1)" +
			"=$mask1 $masktrue=1 EndIf Next If $masktrue $weight=$weight+1 endif" + @CRLF +$code

		EndSelect
	Next
	$code = "$weight = 0 $targetWeight = " + $codeweight + @CRLF + $code
	$code = $code + "if $weight = $targetweight Exit 1 endif"

	For Each $file in $f.subfolders
		If Execute($code)
			$tarray[$i] = $file
			$i = $i + 1
			ReDim preserve $tarray[$i]
		EndIf
		If $sfflag
			$temp = dirplus($file,$options,$file,$sfflag-1)
			For Each $item in $temp
				$tarray[$i] = $item
				$i = $i + 1
				ReDim preserve $tarray[$i]
			Next
		EndIf
	Next
	For Each $file in $f.files
		If Execute($code)
			$tarray[$i] = $file
			$i = $i + 1

			ReDim preserve $tarray[$i]
		EndIf
	Next

	If $i
		ReDim preserve $tarray[$i-1]
		$i=0
	Else
		$tarray = 0
	EndIf

	$dirplus = $tarray
	$temp = SetOption(Explicit,$ex1)
	$temp = SetOption(NoVarsInStrings,$ex2)
	Exit @ERROR
EndFunction


Could this be because of...
 Originally Posted By: Ruud van Velsen

....
Just one change/fix: KiXtart's string handling has been enhanced so it should now be able to deal with large (32000+) strings.
....\
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#211785 - 2016-07-12 09:37 PM Re: DirPlus UDF and KiXtart 4.67 beta1 not playing nice [Re: Mart]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4549
Loc: USA
It probably has something to do with the execute and variables inside strings he's using with $weight

You might try $RC=setoption("NoVarsinStrings","on")

$ex2 = SetOption(NoVarsInStrings,on)
Nope he has that in his UDF... except they are missing the quotes around the values.


Edited by Allen (2016-07-12 09:40 PM)

Top
#211787 - 2016-07-13 01:01 AM Re: DirPlus UDF and KiXtart 4.67 beta1 not playing nice [Re: Allen]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
Yea. You could try quoting those strings. Either unquoted strings or novarsinstrings no longer works. Should be easy enough to test
_________________________
!

download KiXnet

Top
#211798 - 2016-07-14 03:39 PM Re: DirPlus UDF and KiXtart 4.67 beta1 not playing nice [Re: Lonkero]
Ruud van Velsen Moderator Offline
Developer
*****

Registered: 1999-05-06
Posts: 391
Loc: Amsterdam, The Netherlands
Excellent find! Yep, I broke the novarsinstrings option.

I'll investigate and send out an update asap.

Ruud

Top
#211799 - 2016-07-14 03:48 PM Re: DirPlus UDF and KiXtart 4.67 beta1 not playing nice [Re: Ruud van Velsen]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
 Originally Posted By: Ruud van Velsen
Excellent find! Yep, I broke the novarsinstrings option.

I'll investigate and send out an update asap.

Ruud


Pfieuw... thanks. I was thinking I lost my mind somehow. Did several tests and did not succeed yet.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#211800 - 2016-07-14 04:13 PM Re: DirPlus UDF and KiXtart 4.67 beta1 not playing nice [Re: Mart]
Ruud van Velsen Moderator Offline
Developer
*****

Registered: 1999-05-06
Posts: 391
Loc: Amsterdam, The Netherlands
And here's an update that fixes this:


KiXtart 4.67 BETA 2


Thanks very much for the report, and keep up the good work!

Ruud

Top
#211801 - 2016-07-14 04:59 PM Re: DirPlus UDF and KiXtart 4.67 beta1 not playing nice [Re: Ruud van Velsen]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
4.67 Beta 2 works fine with the code posted in the top post. Thanks for checking and fixing Ruud.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#211806 - 2016-07-17 10:03 PM Re: DirPlus UDF and KiXtart 4.67 beta1 not playing nice [Re: Mart]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Hmmm ... will run that Beta against all my golf codes. Might gain some strokes there
_________________________



Top
#211808 - 2016-07-18 03:02 AM Re: DirPlus UDF and KiXtart 4.67 beta1 not playing nice [Re: Jochen]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
Really? For the string limit? That most likely will give you a weeks headache and still no winning score ;\)
_________________________
!

download KiXnet

Top
#211811 - 2016-07-18 08:56 PM Re: DirPlus UDF and KiXtart 4.67 beta1 not playing nice [Re: Lonkero]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
to gain sth. [increase, raise]
.. is what dict.cc has to say to this special noun (amongst many other entries).
So yeah, it will not only add strokes but break most of what we have written so far.

Hope the next course will be held before this is out of Beta :p
_________________________



Top
#211812 - 2016-07-19 04:19 AM Re: DirPlus UDF and KiXtart 4.67 beta1 not playing nice [Re: Jochen]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
Cambridge: "to obtain something useful, advantageous, or positive"
_________________________
!

download KiXnet

Top
#211815 - 2016-07-19 01:54 PM Re: DirPlus UDF and KiXtart 4.67 beta1 not playing nice [Re: Lonkero]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
hm,
let's rephrase: Might gain Will add some strokes there

Better Professor? ;\)
_________________________



Top
#211816 - 2016-07-19 02:44 PM Re: DirPlus UDF and KiXtart 4.67 beta1 not playing nice [Re: Jochen]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
{Shakes Head} {Chuckles}
A guy with a sig like yours referencing a dictionary... Your spell checker must love you! \:D
_________________________
Actually I am a Rocket Scientist! \:D

Top
Page 1 of 1 1


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

Who's Online
0 registered and 370 anonymous users online.
Newest Members
Timothy, Jojo67, MaikSimon, kvn317, kixtarts2025
17874 Registered Users

Generated in 0.068 seconds in which 0.025 seconds were spent on a total of 13 queries. Zlib compression enabled.