Issue with format

I have this function

GetMonth(month : Text) ris : Text

ArrayMonth[1] := 'A';
ArrayMonth[2] := 'B';
ArrayMonth[3] := 'C';
ArrayMonth[4] := 'D';
ArrayMonth[5] := 'E';
ArrayMonth[6] := 'F';
ArrayMonth[7] := 'G';
ArrayMonth[8] := 'H';
ArrayMonth[9] := 'I';
ArrayMonth[10] := 'J';
ArrayMonth[11] := 'K';
ArrayMonth[12] := 'L';

IF month[1] = '0' THEN
i := FORMAT(month[2]);

ris := ArrayMonth[month];

the parameter of the function is a text. I have to transform this into an integer to search the array... can anyone help me? thanks

Best Answers

  • KishormKishorm Member Posts: 921
    edited 2016-11-21 Answer ✓
    Try this...
    GetMonth(month : Text) ris : Text
    
    IF NOT EVALUATE(MonthAsInt,month) THEN
      EXIT('');
    
    IF MonthAsInt IN [1..12] THEN BEGIN
      ris :='?';
      ris[1] := 64 + MonthAsInt;
    END;
    
    ... where MonthAsInt is a local variable of type Integer

Answers

  • KishormKishorm Member Posts: 921
    The above code looks odd - what is it exactly you want to achieve?
  • sharon95sharon95 Member Posts: 183
    I have to get a letter from a number... the problem is that the parameter is a text and it gives me an error beacuse it tries to assign a text to an integer...
  • KishormKishorm Member Posts: 921
    edited 2016-11-21 Answer ✓
    Try this...
    GetMonth(month : Text) ris : Text
    
    IF NOT EVALUATE(MonthAsInt,month) THEN
      EXIT('');
    
    IF MonthAsInt IN [1..12] THEN BEGIN
      ris :='?';
      ris[1] := 64 + MonthAsInt;
    END;
    
    ... where MonthAsInt is a local variable of type Integer
  • sharon95sharon95 Member Posts: 183
    wooooooooooo!!! great!!! Thank you!!!
  • sharon95sharon95 Member Posts: 183
    and similarly, if I have DATE2DMY(TableFiscal.DOB,1) that returns "3" and I want to print "03", how can I do this?
Sign In or Register to comment.