Network Automation Software We are currently migrating this forum
over to our HelpSystems domain. Please
post all new threads in our new
HelpSystems Community Portal.
Post to the HelpSystems Forum
You are not currently logged on. You must be logged on in order to post. Log on
Or Create a new account
AutoMate Discussion
Decrease font size
Increase font size
Topic Title: Read number from File
Topic Summary: Unable to set numeric variable from number read from file
Created On: 10/21/2014 02:42 PM
Status: Read Only
Linear : Threading : Single : Branch
Search Topic Search Topic
Topic Tools Topic Tools
View similar topics View similar topics
View topic in raw text format. Print this topic.
 10/21/2014 02:42 PM
User is offline View Users Profile Print this message

Author Icon
WayneOrndorff
Student (5-19 posts)

Posts: 16
Joined: 10/21/2014

I am having trouble creating a numeric variable from data read from a text file.  If I try to read it directly to a numeric variable it fails.  If I read the data to a variable configured as "Auto" the data is read (and appears to be a number) but I can't do a calculation on it.  If I take the read data and try to set it to a numeric variable by then performing a Val(varname) function it still fails.  Any suggestions?



 Category Survey
AutoMate 7 version: 7.1.3
Windows version: Windows 2008 R2
 10/21/2014 02:46 PM
User is offline View Users Profile Print this message

Author Icon
Ricardo Castaneda
HelpSystems

Posts: 3424
Joined: 01/11/2008

Hi Wayne,

Would it be possible to post the file and task you are running?

 Category Survey


-------------------------

Ricardo Castaneda | Principal Support Analyst
AutoMate | Division of HelpSystems
HelpSystems, LLC | T: +1.213.738.1700
 10/22/2014 05:08 AM
User is offline View Users Profile Print this message

Author Icon
WayneOrndorff
Student (5-19 posts)

Posts: 16
Joined: 10/21/2014

Here is the code and two files which contain only a number.  I try to read them into a variable.  If I format the variable as a number it doesn't read.  If I set it to Auto and read the file it goes to the variable, then I try to take the val of the original variable and set it into a numeric variable and it doesn't work either.



 Category Survey
AutoMate 7 version: 7.1.3
Windows version: Windows 2008 R2



Task Steps: (Right click, Select All, Copy to copy to the clipboard. Steps can then be pasted into the AutoMate Task Builder)
 10/22/2014 05:10 AM
User is offline View Users Profile Print this message

Author Icon
WayneOrndorff
Student (5-19 posts)

Posts: 16
Joined: 10/21/2014

it doesn't look like the files attached, I'll try again.  As I mentioned they are just text files with a 10 digit number in them.



 Category Survey
AutoMate 7 version: 7.1.3
Windows version: Windows 2008 R2


start.txt
start.txt  (0 KB)
stop.txt
stop.txt  (0 KB)

 10/22/2014 03:58 PM
User is offline View Users Profile Print this message

Author Icon
Ricardo Castaneda
HelpSystems

Posts: 3424
Joined: 01/11/2008

Hi Wayne,

Can you please provide some information on what you are attempting to do with the "Set Variable" actions?

 Category Survey


-------------------------

Ricardo Castaneda | Principal Support Analyst
AutoMate | Division of HelpSystems
HelpSystems, LLC | T: +1.213.738.1700
 10/23/2014 12:37 AM
User is offline View Users Profile Print this message

Author Icon
Gijsberth de Ruiter
Artisan (200-499)

Posts: 455
Joined: 03/30/2005

Can you add the attache code to your task (after step 8). Just to test if it reads zero's or o's. It should return true if the value is a number.

 Category Survey



Task Steps: (Right click, Select All, Copy to copy to the clipboard. Steps can then be pasted into the AutoMate Task Builder)


-------------------------
I am an A-Team Member
 10/23/2014 05:26 AM
User is offline View Users Profile Print this message

Author Icon
Gijsberth de Ruiter
Artisan (200-499)

Posts: 455
Joined: 03/30/2005

Another issue that can happen with the read from file action is that it reads more than only the number, things you might not see e.g. a return or an EOF sign.

Maybe you should use the option to partial read the file and only read the first 10 positions (which is equal to your number)

 Category Survey


-------------------------
I am an A-Team Member
 10/23/2014 05:55 AM
User is offline View Users Profile Print this message

Author Icon
WayneOrndorff
Student (5-19 posts)

Posts: 16
Joined: 10/21/2014

Regarding the questions above:

1) I have attempted to "read entire file" and "read set # of bytes" and set it to the length 10.  In both cases is still either errors out or doesn't let me do a calculation on it

 

2) I have a large number of folders that are named with a number.  Examples of the folder names are what are in the Start.txt and Stop.txt files.  The folder names increment by 10000.  I'm trying to do a loop starting at the start number with the loop incrementing by 10000, then loop through the files in each folder.  I'll follow this note with the full code



 Category Survey
AutoMate 7 version: 7.1.3
Windows version: Windows 2008 R2
 10/23/2014 05:59 AM
User is offline View Users Profile Print this message

Author Icon
WayneOrndorff
Student (5-19 posts)

Posts: 16
Joined: 10/21/2014

Here is the code I am trying to execute.  Maybe I'm going about this the wrong way.  Any assistance would be greatly appreciated.  Thanks



 Category Survey
AutoMate 7 version: 7.1.3
Windows version: Windows 2008 R2



Task Steps: (Right click, Select All, Copy to copy to the clipboard. Steps can then be pasted into the AutoMate Task Builder)
 10/23/2014 06:17 AM
User is offline View Users Profile Print this message

Author Icon
Gijsberth de Ruiter
Artisan (200-499)

Posts: 455
Joined: 03/30/2005

Is there any reason that you want to read these numbers from a file?

 Category Survey


-------------------------
I am an A-Team Member
 10/23/2014 08:23 AM
User is offline View Users Profile Print this message

Author Icon
WayneOrndorff
Student (5-19 posts)

Posts: 16
Joined: 10/21/2014

I'm open for suggestion.  These aren't numbers that I have, they come from another department.  I'm trying to automate the process as much as possible.  When the other department has the information needed and their processes can identify the number(s) they create the files which will then trigger my job.  I'd prefer to have no manual steps involved.



 Category Survey
AutoMate 7 version: 7.1.3
Windows version: Windows 2008 R2
 10/23/2014 09:06 AM
User is offline View Users Profile Print this message

Author Icon
Gijsberth de Ruiter
Artisan (200-499)

Posts: 455
Joined: 03/30/2005

Wayne,
I did some testing and found the issue. The loop cannot handle such number. If you divide the numbers bu 10000 it works fine.

I have attached the updated steps (work arround)

 Category Survey



Task Steps: (Right click, Select All, Copy to copy to the clipboard. Steps can then be pasted into the AutoMate Task Builder)


-------------------------
I am an A-Team Member
 10/23/2014 10:43 AM
User is offline View Users Profile Print this message

Author Icon
WayneOrndorff
Student (5-19 posts)

Posts: 16
Joined: 10/21/2014

Thank you for this follow up.  Your suggestion works for the first pass through, but not any subsequent folders as it doesn't increment the loop by 10000 each time.  Here's a scenario:

I have folders with the following names:

1234560000

1234570000

1234580000

1234590000

1234600000

In each of those folders, I will have many files that are named such as:

######????.txt  Where ###### = the first six digits of the folder name and ???? is a unique 4 digit number.

I'm trying to read through each folder and write the name of each file within each folder out to a text file.  Your suggestion will get it through the first folder but not any subsequent folders.  One day that could be as few as four folders while other days it could be as many as 45 folders.



 Category Survey
AutoMate 7 version: 7.1.3
Windows version: Windows 2008 R2
 10/23/2014 10:53 AM
User is offline View Users Profile Print this message

Author Icon
WayneOrndorff
Student (5-19 posts)

Posts: 16
Joined: 10/21/2014

OK, I've changed my loop to increment by 1 and use the divided values in the loop but multiply by 10000 the folder value.  That appears to work.

Thanks for the help

 



 Category Survey
AutoMate 7 version: 7.1.3
Windows version: Windows 2008 R2
 10/23/2014 11:10 AM
User is offline View Users Profile Print this message

Author Icon
Gijsberth de Ruiter
Artisan (200-499)

Posts: 455
Joined: 03/30/2005

Wayne,
I missed indeed the step size to adjust. I add the 10000 back in the folder name, which should work for each loop.

 Category Survey


-------------------------
I am an A-Team Member
Statistics
18258 users are registered to the AutoMate Discussion forum.
There are currently 0 users logged in.
The most users ever online was 5551 on 01/08/2018 at 11:11 AM.
There are currently 1810 guests browsing this forum, which makes a total of 1810 users using this forum.

FuseTalk Enterprise Edition v4.0 - © 1999-2020 FuseTalk Inc. All rights reserved.

Sitemap Network Automation Software Blog