passing numeric variable in a file name

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
theonex
Junior Coder
Posts: 44
Joined: Thu May 10, 2012 12:32 pm

passing numeric variable in a file name

Post by theonex » Mon Mar 09, 2020 8:57 pm

Hello,

I have a problem which i need some assistance in.. basically i have an OCR code that captures some random numbers from the web "OCRArea>694,184,793,218,strText" works perfect it always does the job the captured numbers are stored in a variable "strText" if i use Message>%strText% the numbers in the veriable is displayed correctly.

what i want to do is create a txt file and i need the above variable data in the file name. like the example bellow

Year>yyyy
Midstr>yyyy,3,2,yy
Month>mm
Day>dd

Let>FileName=%profilePath%\Desktop\sample_%strText%_%dd%-%mm%-%yyyy%.txt
WriteLn>FileName,result,strText

for some reason the .txt create option does not work, any assistance is appreciated.

thank you

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1380
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: passing numeric variable in a file name

Post by Dorian (MJT support) » Tue Mar 10, 2020 10:47 am

Use Desktop_dir, like this :

Code: Select all

OCRArea>694,184,793,218,strText
Year>yyyy
Midstr>yyyy,3,2,yy
Month>mm
Day>dd
Let>FileName=%desktop_dir%\sample_%strText%_%dd%-%mm%-%yy%.txt
WriteLn>FileName,result,strText

//Will create ..._10-03-2020.txt
Let>FileName=%desktop_dir%\sample_%strText%_%dd%-%mm%-%yyyy%.txt

//Will create ..._10-03-20.txt
Let>FileName=%desktop_dir%\sample_%strText%_%dd%-%mm%-%yy%.txt
Note that in your example you're using %yyyy% instead of the yy you created with MidStr. So you either don't need the Midstr, or you need to use %yy% instead.
Yes, we have a Custom Scripting Service. Message me or go here

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts