Home AMX Forum NetLinx Studio
Options

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 Obvious Troll Account, Marked for Deletion
    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 Formerly Caffeinated Programmer
    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.