www.digitalmars.com         C & C++   DMDScript  

D - [help] property error

reply Lewis <dethbomb hotmail.com> writes:
ok, i have the following enumeration:

enum CompareMethod {
	BinaryCompare	= 0,
	TextCompare	= 1
}

and the following function for comparing two char[] strings, (AString is an 
alias for char[]) and it gives me a
-no property 'CompareText' for type 'int'
compile eror...

public int StrComp(AString Value1,AString Value2,CompareMethod Compare) {
         int len1 = Value1.length;
         int len2 = Value2.length;
         int result = 0;

   try {
	if (len1 == len2) {
		if (Compare == CompareMethod.CompareText)
			{ result = memcmp((char*)Value1,(char*)Value2,len1); }
		else
			{result = memicmp((char*)Value1,(char*)Value2,len1);}
		return result; }
	else
		{ return result; }
	}
    catch
	{ return result; }

}

would somebody be able to posibly tell me what im doing wrong, im thinking im 
using the enum incorectly, but i dont know how...

thanks
Jan 07 2004
next sibling parent Lewis <dethbomb hotmail.com> writes:
Lewis wrote:

 ok, i have the following enumeration:
 
 enum CompareMethod {
     BinaryCompare    = 0,
     TextCompare    = 1
 }
 
 and the following function for comparing two char[] strings, (AString is 
 an alias for char[]) and it gives me a
 -no property 'CompareText' for type 'int'
 compile eror...
 
 public int StrComp(AString Value1,AString Value2,CompareMethod Compare) {
         int len1 = Value1.length;
         int len2 = Value2.length;
         int result = 0;
 
   try {
     if (len1 == len2) {
         if (Compare == CompareMethod.CompareText)
             { result = memcmp((char*)Value1,(char*)Value2,len1); }
         else
             {result = memicmp((char*)Value1,(char*)Value2,len1);}
         return result; }
     else
         { return result; }
     }
    catch
     { return result; }
 
 }
 
 would somebody be able to posibly tell me what im doing wrong, im 
 thinking im using the enum incorectly, but i dont know how...
 
 thanks
woops nm, mistyped it :( boy i feel stupid now
Jan 07 2004
prev sibling parent reply "Matthew" <matthew.hat stlsoft.dot.org> writes:
Can you bit a bit clearer about what you're trying to achieve and, since you
said you made a typo, post again, after having converted tabs to spaces, so
we can see your code in its formatted state?

:)

"Lewis" <dethbomb hotmail.com> wrote in message
news:bthpup$2nh6$1 digitaldaemon.com...
 ok, i have the following enumeration:

 enum CompareMethod {
 BinaryCompare = 0,
 TextCompare = 1
 }

 and the following function for comparing two char[] strings, (AString is
an
 alias for char[]) and it gives me a
 -no property 'CompareText' for type 'int'
 compile eror...

 public int StrComp(AString Value1,AString Value2,CompareMethod Compare) {
          int len1 = Value1.length;
          int len2 = Value2.length;
          int result = 0;

    try {
 if (len1 == len2) {
 if (Compare == CompareMethod.CompareText)
 { result = memcmp((char*)Value1,(char*)Value2,len1); }
 else
 {result = memicmp((char*)Value1,(char*)Value2,len1);}
 return result; }
 else
 { return result; }
 }
     catch
 { return result; }

 }

 would somebody be able to posibly tell me what im doing wrong, im thinking
im
 using the enum incorectly, but i dont know how...

 thanks
Jan 07 2004
parent reply Lewis <dethbomb hotmail.com> writes:
Matthew wrote:
 Can you bit a bit clearer about what you're trying to achieve and, since you
 said you made a typo, post again, after having converted tabs to spaces, so
 we can see your code in its formatted state?
 
 :)
 
 "Lewis" <dethbomb hotmail.com> wrote in message
 news:bthpup$2nh6$1 digitaldaemon.com...
*reformatted* //enum of compare methods enum CompareMethod { BinaryCompare = 0, TextCompare = 1 } and the following function for comparing two char[] strings, (AString is an alias for char[]) and it gives me a: -no property 'CompareText' for type 'int' compile eror... public int StrComp(AString Value1, AString Value2, CompareMethod Compare) { int len1 = Value1.length; int len2 = Value2.length; int result = 0; //assume failure try { if (len1 == len2) { if (Compare == CompareMethod.CompareText) //check compare method desired { result = memcmp((char*)Value1,(char*)Value2,len1); } else {result = memicmp((char*)Value1,(char*)Value2,len1);} return result; } else { return result; } //failed, unequal length } catch { return result; } //error }
would somebody be able to posibly tell me what im doing wrong, im thinking
im using the enum incorectly, but i dont know how...
thanks
after looking at it after i posted i seen the error this line > Compare == CompareMethod.CompareText should be > Compare == CompareMethod.TextCompare basically its a function for comparing two strings either case sensitive or non case sensitive, i dont even know if it works yet lol regards lewis
Jan 08 2004
parent Lewis <dethbomb hotmail.com> writes:
Lewis wrote:

 Matthew wrote:
 
 Can you bit a bit clearer about what you're trying to achieve and, 
 since you
 said you made a typo, post again, after having converted tabs to 
 spaces, so
 we can see your code in its formatted state?

 :)

 "Lewis" <dethbomb hotmail.com> wrote in message
 news:bthpup$2nh6$1 digitaldaemon.com...
*reformatted* //enum of compare methods enum CompareMethod { BinaryCompare = 0, TextCompare = 1 } and the following function for comparing two char[] strings, (AString is an alias for char[]) and it gives me a: -no property 'CompareText' for type 'int' compile eror... public int StrComp(AString Value1, AString Value2, CompareMethod Compare) { int len1 = Value1.length; int len2 = Value2.length; int result = 0; //assume failure try { if (len1 == len2) { if (Compare == CompareMethod.CompareText) //check compare method desired { result = memcmp((char*)Value1,(char*)Value2,len1); } else {result = memicmp((char*)Value1,(char*)Value2,len1);} return result; } else { return result; } //failed, unequal length } catch { return result; } //error }
 would somebody be able to posibly tell me what im doing wrong, im 
 thinking
 im using the enum incorectly, but i dont know how...
 thanks
after looking at it after i posted i seen the error this line > Compare == CompareMethod.CompareText should be > Compare == CompareMethod.TextCompare basically its a function for comparing two strings either case sensitive or non case sensitive, i dont even know if it works yet lol regards lewis
another bug i found in this code int result = 0; //assume failure should be int result = 1; //assume failure
Jan 10 2004