Q&A

  • in case문에서..
if (FormatDateTime('HHNNSS', now) = '090000') or

(FormatDateTime('HHNNSS', now) = '100000') or

(FormatDateTime('HHNNSS', now) = '110000') or

(FormatDateTime('HHNNSS', now) = '120000') or

(FormatDateTime('HHNNSS', now) = '130000') or

(FormatDateTime('HHNNSS', now) = '140000') or

(FormatDateTime('HHNNSS', now) = '150000') or

(FormatDateTime('HHNNSS', now) = '160000') or

(FormatDateTime('HHNNSS', now) = '170000') or

(FormatDateTime('HHNNSS', now) = '180000') or

(FormatDateTime('HHNNSS', now) = '190000') or

(FormatDateTime('HHNNSS', now) = '200000') or

(FormatDateTime('HHNNSS', now) = '210000') then

위의 문장을 다음과 갇이 바꿀수는 없는 것인가요..

if (FormatDateTime('HHNNSS', now) in ['090000','100000','110000','120000','130000','140000','150000','160000','170000','180000','190000','200000','210000']) then







1  COMMENTS
  • Profile
    최용일 2001.05.16 04:34
    안녕하세요. 최용일입니다.



    case문이나 집합에서는 서수형만 사용가능합니다. 그러니까 그러한 방법은 불가능하구요. 배열이나 TStrgingList를 이용해서 하시는 것이 좋을거 같네요...



    Ex1)

    cosnt

    TimeArray: array[0..12 of string =

    ('090000', '100000', '110000', '120000', '130000', '140000',

    '150000', '160000', '170000', '180000', '190000', '200000', '210000');

    var

    I: Integer;

    S: string;

    begin

    S := FormatDateTime('HHNNSS', now);

    for I := 0 to 12 do

    begin

    if S = TimeArray[I] then

    begin

    DoSomething;

    Break;

    end;

    end;

    end;



    Ex2)

    var

    StrList: TStringList;

    begin

    StrList := TStringList.Create;

    StrList.Add('090000');

    StrList.Add('100000');

    StrList.Add('110000');

    StrList.Add('120000');

    StrList.Add('130000');

    StrList.Add('140000');

    StrList.Add('150000');

    StrList.Add('160000');

    StrList.Add('170000');

    StrList.Add('180000');

    StrList.Add('190000');

    StrList.Add('200000');

    StrList.Add('210000');



    if StrList.IndexOf( FormatDateTime('HHNNSS', now) ) <> -1 then

    DoSomeThing;

    StrList.Free;

    end;



    Ex3)

    const

    TimeStr = '090000' + #13#10 + '100000' + #13#10 + '110000' + #13#10 +

    '120000' + #13#10 + '130000' + #13#10 + '140000' + #13#10 +

    '150000' + #13#10 + '160000' + #13#10 + '170000' + #13#10 +

    '180000' + #13#10 + '190000' + #13#10 + '200000' + #13#10 +'210000';

    var

    StrList: TStringList;

    begin

    StrList := TStringList.Create;

    StrList.Text := TimeStr;

    if StrList.IndexOf( FormatDateTime('HHNNSS', now) ) <> -1 then

    DoSomeThing;

    StrList.Free;

    end;



    ^^ 항상 즐코하세요...



    장 wrote:

    > if (FormatDateTime('HHNNSS', now) = '090000') or

    > (FormatDateTime('HHNNSS', now) = '100000') or

    > (FormatDateTime('HHNNSS', now) = '110000') or

    > (FormatDateTime('HHNNSS', now) = '120000') or

    > (FormatDateTime('HHNNSS', now) = '130000') or

    > (FormatDateTime('HHNNSS', now) = '140000') or

    > (FormatDateTime('HHNNSS', now) = '150000') or

    > (FormatDateTime('HHNNSS', now) = '160000') or

    > (FormatDateTime('HHNNSS', now) = '170000') or

    > (FormatDateTime('HHNNSS', now) = '180000') or

    > (FormatDateTime('HHNNSS', now) = '190000') or

    > (FormatDateTime('HHNNSS', now) = '200000') or

    > (FormatDateTime('HHNNSS', now) = '210000') then

    > 위의 문장을 다음과 갇이 바꿀수는 없는 것인가요..

    > if (FormatDateTime('HHNNSS', now) in ['090000','100000','110000','120000','130000','140000','150000','160000','170000','180000','190000','200000','210000']) then

    >

    >

    >