MACE
(Starting to like KiXtart)
2015-02-10 11:55 PM
Wildcard Globbing

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


AllenAdministrator
(KiX Supporter)
2015-02-11 02:05 AM
Re: Wildcard Globbing

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


MACE
(Starting to like KiXtart)
2015-02-11 10:29 AM
Re: Wildcard Globbing

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 !


LonkeroAdministrator
(KiX Master Guru)
2015-02-11 02:12 PM
Re: Wildcard Globbing

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.


AllenAdministrator
(KiX Supporter)
2015-02-11 02:16 PM
Re: Wildcard Globbing

This worked well for my reading unicode needs...

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


NTDOCAdministrator
(KiX Master)
2015-02-13 07:56 PM
Re: Wildcard Globbing

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


LonkeroAdministrator
(KiX Master Guru)
2015-02-14 12:52 AM
Re: Wildcard Globbing

Microsoft is or Unicode is?

MACE
(Starting to like KiXtart)
2015-02-16 01:47 PM
Re: Wildcard Globbing

ALL because they have introduced MAC's into our windows world... Hummm

Thanks all


MACE
(Starting to like KiXtart)
2015-05-01 04:19 PM
Re: Wildcard Globbing

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...


AllenAdministrator
(KiX Supporter)
2015-05-01 05:40 PM
Re: Wildcard Globbing

Be sure to check out Dirplus() before you get to far into using FSO...

MACE
(Starting to like KiXtart)
2015-05-05 12:39 PM
Re: Wildcard Globbing

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.


LonkeroAdministrator
(KiX Master Guru)
2015-05-05 01:30 PM
Re: Wildcard Globbing

http://superuser.com/questions/636247/how-do-i-remove-non-ascii-characters-from-filenames