Go Back   Cockos Incorporated Forums > Projects > Deprecated REAPER issue tracker > Closed Issue

JS: file_mem() unexpected results Issue Tools
issueid=4727 03-25-2013 06:04 AM
Human being with feelings
JS: file_mem() unexpected results
the file_mem() function sometimes fails to read the last value in the file.

I've found some odd behaviour with file_mem().

Test files:
test.txt
test2.txt

With "test.txt": count is correct (34) but mem[count - 1] is garbage, should be -2
Code:
desc: file test
filename:0,test.txt
@init
file = file_open(0);
count = file_mem(file, mem, 100);
file_close(file);
// count is correct (34) but mem[count - 1] is garbage, should be -2
With "test2.txt": count is 3 but should be 4, last value was not read
Code:
desc: file test
filename:0,test2.txt
@init
file = file_open(0);
count = file_mem(file, mem, 100);
file_close(file);
// count is 3 but should be 4, last value was not read
Using REAPER 4.32 on Win7 32bit
Issue Details
Issue Type Closed Issue
Project Deprecated REAPER issue tracker
Category Arcana
Status Fixed
Priority 5 - Medium
Affected Version 4.32
Closed Version 4.33
Yes votes 0
No votes 0
Assigned Users (none)
Tags (none)

03-25-2013 06:45 AM
Human being with feelings
 
Sorry, I just noticed an error in the file "test.txt". There's a typo in the constant used for the last value. It should be END_PAGE but is written ENDPAGE.

However, that being the case, I think the result is still wrong. The bad constant name should be ignored ie. count should be 33 and the last value written to memory should be -4, not a garbage value.

The problem where the last value is missed for "test2.txt" is unaffected by my stupidity.
Reply
03-25-2013 09:38 AM
Administrator
 
test2.txt doesn't have a newline at the end of its line.

I'll fix these, though who knows if it will break existing FX... :)
Reply
03-25-2013 12:28 PM
Human being with feelings
 
Thanks Justin :)

Quote:
Originally Posted by Justin
test2.txt doesn't have a newline at the end of its line.
I wouldn't mind if the docs said to leave a newline at the end of the files but I think it's better not to expect one.
Quote:
Originally Posted by Justin
I'll fix these, though who knows if it will break existing FX... :)
I don't think it will. It's unlikely anything relies on a bad constant and since data doesn't get loaded if there's no newline, existing data files probably all end with one. Some might even work better!
Reply
03-28-2013 12:07 PM
Human being with feelings
 
Thanks for fixing the EOF thing. :)

One thing though. Unknown variable names are read as zero now which is probably better than garbage values, but it wouldn't it be better if they were ignored altogether, like a blank line?
Reply
Reply

Issue Tools
Subscribe to this issue

All times are GMT -7. The time now is 07:59 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.