Jump to content
lovromirnik

Function StrGet - Help Needed

Recommended Posts

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 by lovromirnik
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
  • Create New...