home *** CD-ROM | disk | FTP | other *** search
- program Somebool;{Demonstration only: run Somebool.exe}
- USES SEABOOL, crt;
-
- {*********************************************************************}
- {sample for seabool.pas Turbo Pascal 5.5 search unit}
- {calls: bool_init any_bool}
- {see the file seabool.doc for detailed PROGRAMMER instructions for seabool}
-
-
-
- {THIS PROGRAM IS AN EXAMPLE OF THE SEABOOL IMPLEMENTATION.
- IT IS BY NO MEANS AN EXHAUSTIVE DEMONSTRATION, AND MAKES NO
- ATTEMPT TO PROVIDE THE USUAL AMENITIES OF USER EDITING KEYS
- OR DESIGN. IT IS NOT MEANT TO BE A USER PRODUCT}
-
- {THE USER IS ASKED TO TYPE IN A SENTENCE.}
- {THE USER IS ASKED FOR A TEXT CONDITION}
- {THE USER IS TOLD WHETHER HIS CONDITION IS FOUND IN THE ORIGINAL SENTENCE}
- {OR THE USER IS TOLD THE CONDITION IS ILLOGICAL OR TOO COMPLICATED}
- {OR THE USER IS TOLD THE CONDITION IS LOGICALLY ALWAYS FALSE}
- {CRITICAL VARIABLES ARE DISCLOSED}
- {**********************************************************}
-
- var {for this demo only: seabool provides other variables. see manual file
- Seabool.doc for information or read the beginning of Seabool.pas
- UNIT source file}
-
- source_string:string;{what you are searching}
- target_string:string;{the text condition the user is looking for}
- interface_source_string:string;{search source
- string for your search primitive}
-
- ch:char;{just used to read the keypress of the user in the demo}
- counter:letter_type{a seabool type variable};
- there_was_a_critical_one:boolean;{just used in this demo}
- {THIS IS THE USER DEFINED SEARCH PRIMITIVE "you" write}
- {NOT FAR CALL COMPILER OPTION!}
- {$F+}
- procedure my_search_procedure(var target:string;var valid:boolean);
- begin
- valid:= Pos(target,lowercase(interface_source_string))>0;
- end{procedure my_search...};
- {$F-}
-
-
-
- begin {MAIN DEMONSTRATION OF SEABOOL SEARCH CAPABILITY:}
- clrscr;
- {*************************}
- {MESSAGE}
- Writeln('This is a simple demonstration of Seabool Searcher');
- writeln
- ('It uses the identical unit provided with your programmers package');
- writeln;writeln('You type in any sentence of your choice,');
- writeln('then a text condition using');
- writeln('and or not operators. parentheses allowed');
- writeln
- ('THE PROGRAM TELLS WHETHER YOUR CONDITION WAS PRESENT IN THE SENTENCE');
- writeln;Writeln('(press any key to continue, esc to exit)');
- ch:=readkey;if ch=#0 then ch:=readkey;
- if ch=#27 then halt;
-
-
- {*********************DEMO DEMO DEMO DEMO of seabool.pas unit********}
- REPEAT
-
- clrscr;
- Writeln('DEMONSTRATION OF THE SEABOOL UNIT');
- Writeln('PLEASE NOTE YOU don''t get any fancy editing keys!');
- Writeln;
- Write('Please enter any sentence (ENTER=exit) ');
- Writeln('example: I want to phone up Mary tonight');
- Writeln;Writeln;
- Write('>');
-
-
-
- {EXAMPLE OF SEARCH SPACE:}
- Readln(source_string);
- IF source_string<>'' then
- BEGIN
- Writeln;
-
- {********************************}
- {GET BOOLEAN CONDITON FROM USER:}
- Write('Please type in a AND OR NOT condition. ');
- Writeln('example: phone and (mary or sue)');
- Writeln;Writeln;
- Write('>');
- Readln(target_string);
- Editstring(target_string);{Editstring is an tool of seabool}
- if ((target_string='') or (target_string='exit')) then halt;
- bool_init(target_string);
-
-
-
-
- {************************************}
- {NOW WE VALIDATE THIS target_string:}
- if bool_validation_sit=2 then
- Writeln('YOUR REQUEST IS TOO COMPLICATED OR NOT LOGICAL')
- else
- if bool_validation_sit=4 then
- Writeln('YOUR REQUEST WILL NEVER BE TRUE')
- ELSE {Valid user input}
-
- begin
- {******************}
- {******THE SEARCH:***********
- could be a loop for many source_strings or objects}
-
- interface_source_string:=source_string;
- if any_bool(my_search_procedure) then
- Writeln('THIS CONDITION IS TRUE IN YOUR SENTENCE')
- else
- Writeln('THIS CONDITION WAS NOT FOUND IN YOUR SENTENCE');
- end;
-
- {**********************************************************************}
- {DEMONSTRATION OF CRITICAL VARIABLE INFO}
- if ((bool_validation_sit<>2) and (bool_validation_sit<>4)) then
- begin
- There_was_a_critical_one:=false ;{default}
- for counter:='b' to length_object_hash_table_0 do
- if bool_crit_true[counter] then
- there_was_a_critical_one:=true;
- if There_was_a_critical_one then
- begin
- writeln;
- writeln('By the way, I knew that you were looking for:');
- for counter:='b' to length_object_hash_table_0 do
- if bool_crit_true[counter] then
- writeln(
- search_object_hash_table_0[counter]);
- Writeln('I could have checked those word(s) in my database INDEX!');
- end;
- end;{DEMO OF CRITICAL VARIABLE KNOWLEDGE}
-
-
- {*****************DEMO loop ENDING************}
- writeln(chr(7));
- Writeln;
- Writeln
- ('--------Please press any key to try it again, or Esc to END-------');
- ch:=readkey;if ch=#0 then ch:=readkey;if ch=#27 then
- source_string:='';
- {**********************************************************************}
-
- END;
-
- UNTIL source_string='';
- end.
-