James Russell Posted June 28, 2010 Share Posted June 28, 2010 Hey all, Just had a query related to the Case function. It has worked well for me when I've needed to do something number related, eg: Begin Case NUM of 1: FIELD:='A'; 2: FIELD:='B'; 3: FIELD:='C'; End; Where NUM is an integer and FIELD a string, I'm wondering if there is an equivalent where I can use a string as the case value. Begin Case FIELDA of 'AA': FIELDB:='A'; 'BB': FIELDB:='B'; 'SOMETHING: FIELDB:='OUTPUT'; End; Where FIELDA and FIELDB are both strings. Does that make sense? There might be a function that I'm not finding in my help guide. Cheers, J Quote Link to comment
MullinRJ Posted June 28, 2010 Share Posted June 28, 2010 You can use single characters, but not strings, in a case statement. CH :Char; case CH of ???'a' : begin end; ???'b' : begin end; ???'c' :begin end; ???'d' :begin end; ???'e' :begin end; ???'f' :begin end; ???'g' :begin end; ???'h', 'i', 'j', 'k' :begin end; ???'l' .. 'p' :begin end; ???'q', 'r', 's' :begin end; ???'t', 'u', 'v' :begin end; ???'w' :begin end; ???'x', 'y', 'z' :begin end; end;???{ case } As a rule, case statements only work with enumerated types, that is, variables that have an integer value. HTH, Raymond Quote Link to comment
James Russell Posted June 28, 2010 Author Share Posted June 28, 2010 That'll do it, thankyou Raymond. J Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.