Finding a value in a file

Ranorex Spy, Recorder, and Studio.
damien
Posts: 17
Joined: Wed Jun 24, 2020 8:17 am

Finding a value in a file

Post by damien » Wed Apr 14, 2021 2:06 pm

Version used: Ranorex 9.3.0
At the moment I'm using your defined function (in UserCode Collection): ValidateFileContainsText.
This helps me to find if a specific string value is present in my file.
I would like now to have the possibility to find an integer value in that file and check if that value is bigger than a defined value.
I have no idea how I could do that and hope you can help me and give different solutions to solve my problem !

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 6544
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Finding a value in a file

Post by odklizec » Wed Apr 14, 2021 2:16 pm

Hi,

Search in file will be always using "string". So any numeric operation you want to do over it must be done on numeric variable. And therefore, you must convert your string variable to integer (long, any other). You can do this, for example, via Int32.TryParse method. Then you can perform numeric comparison on it.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

damien
Posts: 17
Joined: Wed Jun 24, 2020 8:17 am

Re: Finding a value in a file

Post by damien » Thu Apr 15, 2021 7:29 pm

Thanks a lot for your reply, that's what I was thinking. I will try to implement that