Problem coding a selcase

Discussions about CSEntry
Post Reply
Nevillefc
Posts: 10
Joined: February 1st, 2013, 10:37 am
Location: CSO Trinidad and Tobago

Problem coding a selcase

Post by Nevillefc »

I am having some problems coding a selcase. A users ID code is generated when they are added to my system and I want to check for duplicates. The code I have been trying is

Code: Select all

ok = selcase(oper_folder_dict,"") where operf_cd  = opr_code;
     if ok = 1 then
       errmsg("This code %s has already been used. !!PLEASE REENTER AND CHANGE !!",$);
       REENTER;
     endif;
operf_cd is the operator code in the external dictionary - 3 alpha char
opr_code is the field that I use to capture the operator code in this application. 3 alpha char

I have tested using codes that are in the external file but ok is always 0. Am I coding this correctly. I would like to use this one external dictionary to check several things.

Neville
Gregory Martin
Posts: 1793
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: Problem coding a selcase

Post by Gregory Martin »

This works for me. Run the attached application and enter either AAA, BBB, or ZZZ. You'll get the selcase window and then your error message. Is the problem that your string comparison is not taking into account the case of the string? In that case, you might want to write code like this:
ok = selcase(oper_folder_dict,"") where tolower(operf_cd) = tolower(opr_code);
For this kind of check, though, you probably don't want to use the selcase function because that introduces an unnecessary dialog box to your application. Write something like this instead:
ok = find(oper_folder_dict,=,tolower(opr_code));
In this case, however, all of the operf_cd codes in your external file will have to be in lower case because you cannot convert them dynamically (like you can with the selcase function).
Attachments
selcase.zip
(2.92 KiB) Downloaded 395 times
Post Reply