reading Pokeys pins
Re: reading Pokeys pins
Gary:
As a general guide, if you look in the scripters command list
youll see many file functions. To access them you use this syntax..
myfile = system.File();
myfile.Open("*"); //using a * will open a search dialog. A name will open that file.
you may then use the other file primitives on the myfile object.
Art
As a general guide, if you look in the scripters command list
youll see many file functions. To access them you use this syntax..
myfile = system.File();
myfile.Open("*"); //using a * will open a search dialog. A name will open that file.
you may then use the other file primitives on the myfile object.
Art
Re: reading Pokeys pins
Gary:
Here is a sample script using the file system for spirals.
It is written by YaNvrNo awhile back during development.
Art
Here is a sample script using the file system for spirals.
It is written by YaNvrNo awhile back during development.
Art
- Attachments
-
[The extension txt has been deactivated and can no longer be displayed.]
Re: reading Pokeys pins
OK thanks ART
at the moment I just wanted to save text file or read text files..
I am attaching another g code file its pretty busy has pocketing peck drilling and engraving, I did a dry run in auggie and it seemed to run fine but still calls the first m6 twice, maybe you can see something in this one you couldn't see in the other g code file I sent you..
Thanks gary
at the moment I just wanted to save text file or read text files..
I am attaching another g code file its pretty busy has pocketing peck drilling and engraving, I did a dry run in auggie and it seemed to run fine but still calls the first m6 twice, maybe you can see something in this one you couldn't see in the other g code file I sent you..
Thanks gary
- Attachments
-
- CaseBack.zip
- (23.93 KiB) Downloaded 197 times
Re: reading Pokeys pins
Art
Is this a good way to read a file or do you suggest a different approach ?
global next_line = table();
myfile = system.File();
myfile.Open("*");
line = 0;
next_line[line] = myfile.ReadLine();
while (next_line[line] != EOF)
{
line = line + 1;
next_line[line] = myfile.ReadLine();
if (next_line[line] == null)
{
exit();
}
print(next_line[line]);
};
Gary
Is this a good way to read a file or do you suggest a different approach ?
global next_line = table();
myfile = system.File();
myfile.Open("*");
line = 0;
next_line[line] = myfile.ReadLine();
while (next_line[line] != EOF)
{
line = line + 1;
next_line[line] = myfile.ReadLine();
if (next_line[line] == null)
{
exit();
}
print(next_line[line]);
};
Gary
Re: reading Pokeys pins
Gary:
Looks as efficient as any script ID write. Good job.
Art
Looks as efficient as any script ID write. Good job.
Art
Re: reading Pokeys pins
Art
One problem on large files it seems to read the EOF before its read the whole file at least it exits the loop and stops printing
small files its good, don't see any errors popping up is there a buffer limit to a table ?..
Gary
One problem on large files it seems to read the EOF before its read the whole file at least it exits the loop and stops printing
small files its good, don't see any errors popping up is there a buffer limit to a table ?..
Gary
Re: reading Pokeys pins
Gary:
Im sure a limit may exist, but I dont think in this case, unless one line gets too
large it shouldnt run into memory problems.
Your routine will skip the first line though... Id suggest the following change.
I might add the the null check may not be necessary as the print routine shouldn't
fail on a print(null) and it is possible for readline to return null without being at
the end of a file.
line = 0;
next_line[line] = myfile.ReadLine();
while (next_line[line] != EOF)
{
print(next_line[line]);
line = line + 1;
next_line[line] = myfile.ReadLine();
if (next_line[line] == null)
{
print("Null line found before end of file"); //can be ignored in many cases..
exit();
}
};
Art
]
Im sure a limit may exist, but I dont think in this case, unless one line gets too
large it shouldnt run into memory problems.
Your routine will skip the first line though... Id suggest the following change.
I might add the the null check may not be necessary as the print routine shouldn't
fail on a print(null) and it is possible for readline to return null without being at
the end of a file.
line = 0;
next_line[line] = myfile.ReadLine();
while (next_line[line] != EOF)
{
print(next_line[line]);
line = line + 1;
next_line[line] = myfile.ReadLine();
if (next_line[line] == null)
{
print("Null line found before end of file"); //can be ignored in many cases..
exit();
}
};
Art
]
Re: reading Pokeys pins
Art
I gave it a try same results, it seems its reading the end of file early...
It printed part of the file then quit, I assume it thought it read EOF, because it didn't print the null line..
it seems to run for a few second before it starts to print, I have no delays in there.. do you think its looping faster that it can print to screen..?
I will try looping with no print just storing the text lines in the table then print out the table in a loop worth a try..
Gary
I gave it a try same results, it seems its reading the end of file early...
It printed part of the file then quit, I assume it thought it read EOF, because it didn't print the null line..
it seems to run for a few second before it starts to print, I have no delays in there.. do you think its looping faster that it can print to screen..?
I will try looping with no print just storing the text lines in the table then print out the table in a loop worth a try..
Gary
Re: reading Pokeys pins
Gary:
There shouldnt be any buffer limit for the file, but the table may have a
line limit. Try replacing the same table line each time and see if it reads
the entire file. Im not sure the error, I havent played with files much, just
scripting tests early on for putting out point clouds and such.
Art
There shouldnt be any buffer limit for the file, but the table may have a
line limit. Try replacing the same table line each time and see if it reads
the entire file. Im not sure the error, I havent played with files much, just
scripting tests early on for putting out point clouds and such.
Art
Re: reading Pokeys pins
Art
Will give that a shot, I added line numbers to the print, one file reaches line 48 before it thinks it is reading a null and the other file stopped at line 46 before nulling out of the loop..
so could be table does have a limit and one file has more char's per line than the other so reads a couple more lines..
tried printing the file and only using a var next_line no table clearing the var each loop but did the same thing..
I wouldn't think there is some sort of looping limit going on?. just a thought
Update I have tried a few different txt files now and seems to make it to line 50 then exits the loop no print output so its not getting the null check just quits looping at or just under 50 lines of text..
Thanks gary
Will give that a shot, I added line numbers to the print, one file reaches line 48 before it thinks it is reading a null and the other file stopped at line 46 before nulling out of the loop..
so could be table does have a limit and one file has more char's per line than the other so reads a couple more lines..
tried printing the file and only using a var next_line no table clearing the var each loop but did the same thing..
I wouldn't think there is some sort of looping limit going on?. just a thought
Update I have tried a few different txt files now and seems to make it to line 50 then exits the loop no print output so its not getting the null check just quits looping at or just under 50 lines of text..
Thanks gary
Last edited by gburk on Wed Jul 24, 2019 9:27 am, edited 1 time in total.
Re: reading Pokeys pins
Art
I tried a loop that should loop 200 times and reading the file but it seems after 50 line read it exits the loop it doesn't print any of my messages like it hit a null or EOF or file closed just exits the loop.. here is a sample..
global next_line = table();
fileload = function()
{
myfile = system.File();
myfile.Open("*");
line = 0;
next_line[line] = myfile.ReadLine();
dowhile (line !=200)
{
print("Line # "+line+" "+next_line[line]);
line = line + 1;
next_line[line] = myfile.ReadLine();
if (next_line[line] == EOF)
{
print("EOF Reached");
myfile.Close();
print("File Closed");
return;
}
if (next_line[line] == null)
{
print("Line = Null");
myfile.Close();
print("File Closed");
exit();
}
};
myfile.Close();
print("File Closed");
};
fileload();
this script also only print 49 or 50 lines
x = 0;
dowhile( x < 400)
{
x = x + 1;
print("X = "+x);
};
gary
I tried a loop that should loop 200 times and reading the file but it seems after 50 line read it exits the loop it doesn't print any of my messages like it hit a null or EOF or file closed just exits the loop.. here is a sample..
global next_line = table();
fileload = function()
{
myfile = system.File();
myfile.Open("*");
line = 0;
next_line[line] = myfile.ReadLine();
dowhile (line !=200)
{
print("Line # "+line+" "+next_line[line]);
line = line + 1;
next_line[line] = myfile.ReadLine();
if (next_line[line] == EOF)
{
print("EOF Reached");
myfile.Close();
print("File Closed");
return;
}
if (next_line[line] == null)
{
print("Line = Null");
myfile.Close();
print("File Closed");
exit();
}
};
myfile.Close();
print("File Closed");
};
fileload();
this script also only print 49 or 50 lines
x = 0;
dowhile( x < 400)
{
x = x + 1;
print("X = "+x);
};
gary
Last edited by gburk on Thu Jul 25, 2019 1:29 pm, edited 1 time in total.
Re: reading Pokeys pins
Art
I removed the print during the loops, and only printed the last line read and line number when exiting the loop.
Its seems to finish looping this way, so it does seem that the print() is doing something to the loops if printing every line in the loop..
then it doesn't finish the loop or give an error either..
but read a 5000 plus line file not printing the lines only printed the last line on exit of the loop and it printed line 5082..
Gary
I removed the print during the loops, and only printed the last line read and line number when exiting the loop.
Its seems to finish looping this way, so it does seem that the print() is doing something to the loops if printing every line in the loop..
then it doesn't finish the loop or give an error either..
but read a 5000 plus line file not printing the lines only printed the last line on exit of the loop and it printed line 5082..
Gary
Re: reading Pokeys pins
have you tried a
sleep(.04); //of some micro second
after or before a line read?
sounds like reading of the file or printing is causing a buffer spooling/overload/limit of some kind.
I believe Art is off cruising on vacation.
sleep(.04); //of some micro second
after or before a line read?
sounds like reading of the file or printing is causing a buffer spooling/overload/limit of some kind.
I believe Art is off cruising on vacation.
Re: reading Pokeys pins
Ya-Nvr-No
Thanks that seemed to fix it I thought there was a buffer problem but had no errors, I wouldn't use the print while loading a file normally but was testing to make sure the entire file was loaded, and it is..
Thanks gary
Thanks that seemed to fix it I thought there was a buffer problem but had no errors, I wouldn't use the print while loading a file normally but was testing to make sure the entire file was loaded, and it is..
Thanks gary
Re: reading Pokeys pins
Hi Gary:
Sorry I missed that one, luckily YaNvrNo was around, he knows Auggie
pretty much as well as I and somewhat better in scripting. He was instrumental
in its development. Im deep into serious math learning for an upcoming (perhaps)
module Im writing so Im a bit intermittant. When the math gets too deep
for me I tend to lose track and hadnt checked in a few days to see how this
thread was doing (for some reason it no longer sends me notifications on this
thread.).
Glad the fix helped, probably the print buffer was filled and waiting for a sleep or
yield to get time to finish its work.
Art
Sorry I missed that one, luckily YaNvrNo was around, he knows Auggie
pretty much as well as I and somewhat better in scripting. He was instrumental
in its development. Im deep into serious math learning for an upcoming (perhaps)
module Im writing so Im a bit intermittant. When the math gets too deep
for me I tend to lose track and hadnt checked in a few days to see how this
thread was doing (for some reason it no longer sends me notifications on this
thread.).
Glad the fix helped, probably the print buffer was filled and waiting for a sleep or
yield to get time to finish its work.
Art
Who is online
Users browsing this forum: No registered users and 4 guests