Page 1 of 1 1
Topic Options
#209938 - 2015-02-10 11:55 PM Wildcard Globbing
MACE Offline
Starting to like KiXtart

Registered: 2004-09-07
Posts: 150
Loc: Manchester UK
I have tried numerous methods for wildcard to string enumeration and never quite get the desired result.
I broadened the net and came across this C# code example.
The basics tests I can see but I am at a loss why the increment var++ when its applied to a string.
A loop through the chars in the wildcard string compared to the test sting is required so if anyone is a C# coder I really would like to understand these parts translated to kix !
Equally confusing is the definition or an array and value for stopstring !
 Code:
break on
$A=strWildCmp("He??o W*d","Hello World")
? 'Result = '+$A
get $

;http:;www.codeproject.com/Articles/1088/Wildcard-string-compare-globbing  12-Aug-09 4:35 

strWildCmp($wildstring,$matchstring)

   dim $stopstring[1],$wildstringNew
   $stopstring = '\0'
   $wildstringNew=$wildstring

   while($matchstring <> '\0')
    if ($wildstring = '*')
     do
      $wildstring++;
     EndIf
     while ($wildstring = '*');  ; if a dork entered two or more * in a row
                                 ; ignore them and go ahead
      if ($wildstring = '\0')   ; if * was the last char, the strings are equal
       $strWildCmp=$matchstring
      else
       $stopstring = $wildstring; ; the next char to check after the *
      EndIf
     Loop
    EndIf

    if($stopstring <> '\0')
     if(($stopstring = $matchstring) or ($stopstring = '?') )
      $wildstring++;
      $stopstring = '\0';
     EndIf
     matchstring++;
    else
     if(($wildstring = $matchstring) or ($wildstring = '?'))
      $wildstring++;
      $matchstring++;
     else
      if(*$wildstring <> '\0')
       $wildstring=$wildstringNew;
      else
	$strWildCmp=''
      EndIf
     EndIf

     if( ($matchstring = '\0') and ($wildstring <> '\0') )
      ; matchstring seems to be too short. Check if $wildstring has any more chars except '*'
      while ($wildstring = '*') ; ignore following '*'
       $wildstring++;
      Loop

      if ($wildstring = '\0') ; if $wildstring endet after '*', strings are equal
       $strWildCmp=$matchstring
      else
       $strWildCmp=''
      EndIf
     EndIf
   Loop
EndFunction

Top
#209939 - 2015-02-11 02:05 AM Re: Wildcard Globbing [Re: MACE]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4545
Loc: USA
What are you trying to accomplish? This maybe?

StringMatch() - do a pattern match against a string
http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=132819

How to use UDFs -
http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=81943#Post81943

The rest of the UDFs are here -
http://www.kixtart.org/forums/ubbthreads.php?ubb=postlist&Board=7&page=1

Top
#209940 - 2015-02-11 10:29 AM Re: Wildcard Globbing [Re: Allen]
MACE Offline
Starting to like KiXtart

Registered: 2004-09-07
Posts: 150
Loc: Manchester UK
Yes Lokernos StringMatch is good however I am dealing with Unicode not necessarily ASCII and am looking for mechanisms and algorithms I can expand into my particular need.
I would like to keep it in kixtart or VBS if I can before needing to write EXE or DLL com components which would then need distributing and installing....I appreciate KIX by default uses ASCII.
What Intrigues me from a coding perspective is HOW to interpret the VAR++ in a KIX environment rather than just the substitutions of wildcards !

Top
#209941 - 2015-02-11 02:12 PM Re: Wildcard Globbing [Re: MACE]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
I didn't even remember writing that.

The ++ functionality equivalent for kixtart should be substr()

Now, dealing with Unicode is a bit trickier. I remember something like, you can read and write Unicode with some trickery but manipulation I don't remember trying. Or maybe it's easier than I remember.

In any case, that code is not directly translatable to kixtart.
_________________________
!

download KiXnet

Top
#209942 - 2015-02-11 02:16 PM Re: Wildcard Globbing [Re: Lonkero]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4545
Loc: USA
This worked well for my reading unicode needs...

ReadUnicodeFile -
http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=207309#Post207309

Top
#209962 - 2015-02-13 07:56 PM Re: Wildcard Globbing [Re: Allen]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
Don't forget this too. Microsoft is sometimes different depending on the tool used.

Comparison of Unicode encodings
http://en.wikipedia.org/wiki/Comparison_of_Unicode_encodings

Top
#209964 - 2015-02-14 12:52 AM Re: Wildcard Globbing [Re: NTDOC]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
Microsoft is or Unicode is?
_________________________
!

download KiXnet

Top
#209965 - 2015-02-16 01:47 PM Re: Wildcard Globbing [Re: Lonkero]
MACE Offline
Starting to like KiXtart

Registered: 2004-09-07
Posts: 150
Loc: Manchester UK
ALL because they have introduced MAC's into our windows world... Hummm

Thanks all

Top
#210226 - 2015-05-01 04:19 PM Re: Wildcard Globbing [Re: MACE]
MACE Offline
Starting to like KiXtart

Registered: 2004-09-07
Posts: 150
Loc: Manchester UK
Having to look outside of kix because Dir("Foldername") fails when the folder or file has Unicode in the name - array has text with ? imbedded. !
FSO...

Top
#210227 - 2015-05-01 05:40 PM Re: Wildcard Globbing [Re: MACE]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4545
Loc: USA
Be sure to check out Dirplus() before you get to far into using FSO...
Top
#210233 - 2015-05-05 12:39 PM Re: Wildcard Globbing [Re: Allen]
MACE Offline
Starting to like KiXtart

Registered: 2004-09-07
Posts: 150
Loc: Manchester UK
Lindsay bryce did a great job with DirPlus however using it give upto a 10% CPU hit compared to Dir alone, that said the moment you view the collection with KIX the unicode seems to get taken as a ? so the array still contains un-useable file and folder names.
I need to be able to rename the items containing unicode text to ASCII before KIX gets to read them.
The problem is HOW as thus far I have not located a scripting method capable of doing this.
If when I identify in kix such an entry a script/app could be executed to deal with it in ANO language then I should be able to get past this.

Top
#210234 - 2015-05-05 01:30 PM Re: Wildcard Globbing [Re: MACE]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
http://superuser.com/questions/636247/how-do-i-remove-non-ascii-characters-from-filenames
_________________________
!

download KiXnet

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
2 registered (morganw, mole) and 414 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.061 seconds in which 0.023 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