Home AMX User Forum NetLinx Studio

Help separate characters

In this program the varaible nDay obtains the value of the date of the current day. I need to separate the value obtained by the variable nDay ff the following way.

Integer nDay

nDay = DATE_TO_DAY (DATE) //example nDay =23
Day1 = MID_STRING (nDay, 1, 1) // example Day1 = 2
Day2 = MID_STRING (nDay, 2, 1) //example Day2 =3

I test with this code but it does not work, Please help me

Comments

  • mpullinmpullin Posts: 949
    You can't pass MID_STRING an integer. I'm suprised the compiler let you do this.

    Try: Day1 = MID_STRING (itoa(nDay), 1, 1)
  • Spire_JeffSpire_Jeff Posts: 1,917
    Are you wanting DAY1 and DAY2 to be strings or integers?

    Also, do you want DAY1 to be the tens digit of the day?

    You could use:

    DAY1 = nDAY/10;
    DAY2 = nDAY%10;

    or

    DAY1 = ITOA(nDAY/10);
    DAY2 = ITOA(nDAY%10);

    if you need strings


    Jeff
Sign In or Register to comment.