0

I'm trying to to read from a TXT file and do some calculation and write it back to another TXT file but when I read the character it changes to ASCII number (ex : '1' convert to 50) and when I try to write it in another file it's the ASCII number. How can I change it to that character I want?

int wf=FileOpen("wf.txt",FILE_WRITE|FILE_ANSI|FILE_TXT);
int rf=FileOpen("rf.txt",FILE_READ|FILE_ANSI|FILE_TXT);
str_size=FileReadInteger(rf,INT_VALUE);  //the TXT I read is 1234
str=FileReadString(rf,str_size);
StringToCharArray(str,data1,0,StringLen(str));
RandonNum[0]= str[1];
RandonNum[1]= str[2];
RandonNum[2]= str[3];
FileWrite(wf,str[1],str[2],str[3]);     //the TXT I write is 505152
barbsan
  • 3,418
  • 11
  • 21
  • 28

1 Answers1

0

FileReadInteger() is reserved for binary type files.

Unfortunately this is not explicitly stated in the documentation.

Use FileReadNumber() to read a number from txt file. It will return the number as a double, but it can be cast to an integer using a type cast (int)double_value.

Palo
  • 974
  • 12
  • 27
  • My post was an answer, not a problem - problem was defined by OP. – Marcin Mądrzak May 28 '19 at 23:28
  • Hello Marcin. Yes, both the questions and answers are edited for improved readability, better clarification etc. This is a community site and we all try to contribute to the best experience for all the people visiting it. – Palo Jun 11 '19 at 11:26