Skip to main content

[archive] Wildcards search

  • March 24, 2009
  • 2 replies
  • 0 views

[Migrated content. Thread originally posted on 23 March 2009]

I am using AcuCOBOL & VisionFile.

When I create a search functionality in my codes, I use the file's keys. If the users search by the keys, I will do like this:
For example, search a name "zigby" in a file FILENAME.
FILENAME has key F-NAME.

MOVE "zigby" TO F-NAME.
START FILENAME KEY IS NOT LESS THAN F-NAME
READ FILENAME NEXT
IF F-NAME = "zigby" THEN
PERFORM I-FIND-IT
END-IF


But now the user want to advanced search function such as "wildcards '*'" search, I don't think only AcuCOBOL & VsionFiles could do that by keys.
For example, the user wants searching "*igby".
What can I do now?


Is there any other way to do that?

Thanks for any ideas and suggestions.

2 replies

[Migrated content. Thread originally posted on 23 March 2009]

I am using AcuCOBOL & VisionFile.

When I create a search functionality in my codes, I use the file's keys. If the users search by the keys, I will do like this:
For example, search a name "zigby" in a file FILENAME.
FILENAME has key F-NAME.

MOVE "zigby" TO F-NAME.
START FILENAME KEY IS NOT LESS THAN F-NAME
READ FILENAME NEXT
IF F-NAME = "zigby" THEN
PERFORM I-FIND-IT
END-IF


But now the user want to advanced search function such as "wildcards '*'" search, I don't think only AcuCOBOL & VsionFiles could do that by keys.
For example, the user wants searching "*igby".
What can I do now?


Is there any other way to do that?

Thanks for any ideas and suggestions.
This is easy to code if the wild card is one character such as "?ine" which matches to 'pine' and 'line' but not with 'spine'. But as you have shown a "*" for the wild card I presume you mean that you want "*ine" to match to 'pine' 'line' and 'spine' and so on. This probably means searching through the entire file - as the "*" card can be anywhere and of any length I can see no way of using any KEY attributes in the file to assist. A combination of "?" and "*" wildcards in the same search may allow a combination of KEY usage as well as a sequential run thru the file.

[Migrated content. Thread originally posted on 23 March 2009]

I am using AcuCOBOL & VisionFile.

When I create a search functionality in my codes, I use the file's keys. If the users search by the keys, I will do like this:
For example, search a name "zigby" in a file FILENAME.
FILENAME has key F-NAME.

MOVE "zigby" TO F-NAME.
START FILENAME KEY IS NOT LESS THAN F-NAME
READ FILENAME NEXT
IF F-NAME = "zigby" THEN
PERFORM I-FIND-IT
END-IF


But now the user want to advanced search function such as "wildcards '*'" search, I don't think only AcuCOBOL & VsionFiles could do that by keys.
For example, the user wants searching "*igby".
What can I do now?


Is there any other way to do that?

Thanks for any ideas and suggestions.
Sounds like you need to use C$REGEXP (look in book 4 of the manual set under Appendix I - Library Routines).

If the wildcard is at the start of the file, your search will be slow because you will need to process every record in your file to determine a match or not.

Ian