How can you increase the FileRead function limitation of 4096 bytes for length of the data string?
How does when the end of the file is reached, the string *EOF* will be returned, Am I suppose to use a While loop?
Everything works but the string length is killing me please help?
I know it says IntControl 65 but I cant seem to increase the size beyond 4096 bytes, The example in the consolidated help I dont seem to understand how? :'(
Im reading the string in to a variable then pulling the string in to an array but can only read in about 500 elements at a shot, not sure what to do?
The string is like this 1,2,3,4,4,5,6,7
;Get VendorNumbers from VendorNumber.txt
DirChange( DirScript())
fileVendorNumberstrList1=FileLocate ("VendorNumber.txt")
fileVendorNumberstrList2=FileOpen(fileVendorNumberstrList1,"READ")
fileVendorNumberstrList=FileRead(fileVendorNumberstrList2)
FileClose(fileVendorNumberstrList2)
;Convert list to an array
arrA = ObjectType ("ARRAY", Arrayize (fileVendorNumberstrList, ","))
intElements1 = ArrInfo (arrA, 1)
;
If intElements1
intItem1 = 0
;Access each element in the array
ForEach arrElement1 In arrA
VendorNumber = arrA[intItem1]
intItem1 = intItem1 + 1
;Use SendKey with Variable element from array
cSetFocus(hWnd)
TimeDelay(1)
SendKey(VendorNumber)
Next ;loop next element
End If
Exit
You can go to the FileRead topic in the Consolidated WIL Help file and look at the example. The example answers your question. Or you can use FileGet after you read about it in the Consolidated WIL Help file. Once you get that figured out, you can take a look at the Arrayize function in the Consolidated WIL Help file. It is very handy for converting delimited lists to arrays and you can make your script much simpler.
Sorry I have looked in to the consolidated help but dont understand the example for IntControl 65?
How would you expand the string length with this control, would it be like IntControl (65, 8192, 0, 0, 0) ?
IntControl (65, p1, 0, 0, 0)
Sets maximum line length for FileRead.
p1 Meaning
-1 Don't change (just return current setting)
-2 Smart size (default)
0 Don't buffer file reads - max line length limited by generic
buffer (currently 1280 bytes)
## Any other positive value specifies the actual buffer size. (default is 4096).
First, it is not clear that you even need to change the buffer size. Your problem may have more to do with not understanding the basic function of FileRead for some reason. Also, you apparently have not bothered to look at any of the suggested alternative solutions which would eliminate the need to use FileRead and simplify your script.
With respect to IntControl 65, the line "Any other positive value specifies the actual buffer size" in the description of the p1 parameters explains how to change the buffer size. The first line in the description of the function explains the side-effect of the change induced by the p1 parameter, "This function specifies the maximum length of a line which can be read using the FileRead function, in bytes". It is not that complicated.
Just to clarify, about how many lines of text are in "VendorNumber.txt" ?
Just my $0.02
-Kirby
More information please...
My understanding is that you have a file in which each line has eight comma delimited items. One of those items is the "Vendor Number".
My further understanding is that you want to extract the vendor number from each line and then "SendKey" them somewhere, then move on to the next line and do the same until you reach the end of the file.
Can you provide a sample line (or two) from your input file?
The idea of sending thousands of numbers to an application using the SendKey function seems inefficient and very prone to errors. However, not knowing the application(s) involved and the details of the source file make suggesting alternatives close to impossible.
Quote from: td on January 30, 2020, 09:05:58 AM
The idea of sending thousands of numbers to an application using the SendKey function seems inefficient and very prone to errors. However, not knowing the application(s) involved and the details of the source file make suggesting alternatives close to impossible.
+1
1000 ;)
Changing the IntControl (65, p1, 0, 0, 0) to IntControl(65,51200,0,0,0) solved the string length issue reading in to the array from a text file, tested with 10,000 comma separated values, thanks.
Interesting. Are you saying that each individual "line" in your input file contains 10,000 comma separated values?