![]() |
![]() |
We are currently migrating this forum over to our HelpSystems domain. Please post all new threads in our new HelpSystems Community Portal. |
![]() |
|
![]() |
AutoMate Discussion | ![]() |
help :
faq :
home
|
||
Latest News:
|
latest topics : statistics |
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 |
![]() |
![]()
|
![]() |
||||||||||
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?
|
||||||||||
|
||||||||||
![]() |
||||||||||
Hi Wayne,
Would it be possible to post the file and task you are running?
------------------------- ![]() Ricardo Castaneda | Principal Support Analyst AutoMate | Division of HelpSystems HelpSystems, LLC | T: +1.213.738.1700 |
||||||||||
|
||||||||||
![]() |
||||||||||
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.
Task Steps: (Right click, Select All, Copy to copy to the clipboard. Steps can then be pasted into the AutoMate Task Builder) |
||||||||||
|
||||||||||
![]() |
||||||||||
|
||||||||||
![]() |
||||||||||
Hi Wayne,
Can you please provide some information on what you are attempting to do with the "Set Variable" actions?
------------------------- ![]() Ricardo Castaneda | Principal Support Analyst AutoMate | Division of HelpSystems HelpSystems, LLC | T: +1.213.738.1700 |
||||||||||
|
||||||||||
![]() |
||||||||||
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.
Task Steps: (Right click, Select All, Copy to copy to the clipboard. Steps can then be pasted into the AutoMate Task Builder) ------------------------- ![]() |
||||||||||
|
||||||||||
![]() |
||||||||||
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)
------------------------- ![]() |
||||||||||
|
||||||||||
![]() |
||||||||||
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
|
||||||||||
|
||||||||||
![]() |
||||||||||
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
Task Steps: (Right click, Select All, Copy to copy to the clipboard. Steps can then be pasted into the AutoMate Task Builder) |
||||||||||
|
||||||||||
![]() |
||||||||||
Is there any reason that you want to read these numbers from a file?
------------------------- ![]() |
||||||||||
|
||||||||||
![]() |
||||||||||
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.
|
||||||||||
|
||||||||||
![]() |
||||||||||
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)
Task Steps: (Right click, Select All, Copy to copy to the clipboard. Steps can then be pasted into the AutoMate Task Builder) ------------------------- ![]() |
||||||||||
|
||||||||||
![]() |
||||||||||
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.
|
||||||||||
|
||||||||||
![]() |
||||||||||
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
|
||||||||||
|
||||||||||
![]() |
||||||||||
Wayne,
I missed indeed the step size to adjust. I add the 10000 back in the folder name, which should work for each loop.
------------------------- ![]() |
||||||||||
|
AutoMate Discussion
» AUTOMATE » AutoMate 7
»
Read number from File
|
![]() |
FuseTalk Enterprise Edition v4.0 - © 1999-2021 FuseTalk Inc. All rights reserved.