lang • comp

Comp

Result = Comp ( String1 AS String , String2 AS String [ , Mode AS Integer ] ) AS Integer

Compares two strings, and returns:

  • 0 if the two strings are equal.

  • 1 if String1 is strictly greater than String2.

  • -1 if String1 is strictly lower than String2.

The Mode parameter can be any combination defined in the Comparison methods page.

Examples

Dim command as string = "open"
If Comp(command, "open") = 0 Then Print "open_file"
DIM UserName AS String

PRINT "Please Enter Your User Name:";
INPUT UserName

IF Comp(UserName, "Akiti") = 0 THEN
  PRINT "You Can Enter"
ELSE
  PRINT "Sorry, You Cannot Enter"
ENDIF
' This is illustrative example only.
' To actually delete the file you will need to write the proper code.

Dim answer As String

Print "Do you want to delete the file? [y/n]"
Input answer

If Comp(answer, "y", gb.IgnoreCase) = 0 Then

  '...... (code to delete the file)
  '......
  '......

  ' If succesfull we print the following message
  Print "File Deleted"

Else
  Print "File Not Deleted"
Endif

See also