lovromirnik Posted May 24, 2015 Share Posted May 24, 2015 (edited) Hello, I am trying to get separate parts of a random number, example, 12345, and then send it into an external input window via KeyDown and KeyUp, one char at a time. I'm having some difficulties with it. Please take a look at the Code below: program GetPartsOfString; var Number : Integer; ConvertedToString : String; LengthOfString : Integer; CountFrom : Integer; CurrentChar : Char; begin Number := 12345; ConvertedToString := IntToStr(Number); LengthOfString := Length(ConvertedToString); for CountFrom := 1 to LengthOfString do begin CurrentChar := StrGet(ConvertedToString, CountFrom); Write(CountFrom); Write(': '); Writeln(CurrentChar); end; end. This is the outcome: Successfully compiled (45.2964 ms) 1: 1 2: 3: 2 4: 5: 3 Successfully executed (201.781 ms) Why is every second number ignored and then recognized the next time? And more importantly, how do I fix this? Any help is much appreciated! Edited May 24, 2015 by lovromirnik Quote Link to comment Share on other sites More sharing options...
TroisVerites Posted May 25, 2015 Share Posted May 25, 2015 Hi, this is always the same story Unicode String and Ansi String if you make this change : "ConvertedToString : AnsiString;" the result is what you want. Quote Link to comment Share on other sites More sharing options...
lovromirnik Posted May 25, 2015 Author Share Posted May 25, 2015 Awesome man, this fixed it. Thanks a bunch! Quote Link to comment Share on other sites More sharing options...