test part of fixed legnth string

stampestampe Member Posts: 48
edited 2001-12-15 in Navision Financials
Is there any way to test only part of a fixed length string

example :

myvar = text

test = copystr(myvar,1,8)

case test of
'ABC*****' :
'ABCD****' :
'ABCDE***' :

end

i'am looking for some sort of "joker" sign to use in a textstring '*' do not work

Regards

Peter

Comments

  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    I'm afraid you can't do this in a CASE-statement.

    Therefore, you have to use:

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">code:</font><HR><pre>
    IF COPYSTR(test,1,3) = 'ABC' THEN BEGIN
    END;

    IF COPYSTR(test,1,4) = 'ABCD' THEN BEGIN
    END;

    IF COPYSTR(test,1,5) = 'ABCDE' THEN BEGIN
    END;

    </pre><HR></BLOCKQUOTE>

    If necessary, you need to put ELSE's between the IF's, otherwise the other code gets executed also when COPYSTR(test,1,3) = 'ABC'.

    Hope this helps.
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • stampestampe Member Posts: 48
    Hi Luc

    I'll use the solution you suggest

    Thanks for your help and a merry crismas

    Peter
  • John_TegelaarJohn_Tegelaar Member Posts: 159
    You should reverse the order of the CASE checks. As shown, COPYSTR(test,1,3) = 'ABC' will be giving a match always before the other ones. So, start with the longest and work down to the shortest.

    John
Sign In or Register to comment.