Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / ReadLine failing to read a line? Sporadic bug?

Author
Message
DavidAGK
AGK Developer
10
Years of Service
User Offline
Joined: 1st Jan 2014
Location:
Posted: 24th Dec 2015 15:33
I've traced a bug in my program to a ReadLine statement. It appears that the ReadLine command is failing to read a line of my data file...very occasionally. I report to screen the contents and at a set line, the command returns a blank string rather than the actual contents of the file. I've taken a careful look at the data file for double carriage returns (which would absolutely explain it) but cannot see any....so, I'm wondering if anyone else has had an issue with the ReadLine command not reading a line? If I force another read-line (when a blank string is returned) then all is fine...but it's a dodgy work-around!

Anyone got any clues?

AGK V2.14
Using Tier 1 AppGameKit V2
Started coding with AMOS (Thanks Francois Lionet)
BatVink
Moderator
20
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 24th Dec 2015 17:04
Is it an issue with Carriage Returns (CHR 13) and Line Feeds (CHR 10)?
Windows adds both by default. Linux uses only Line Feeds.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
DavidAGK
AGK Developer
10
Years of Service
User Offline
Joined: 1st Jan 2014
Location:
Posted: 24th Dec 2015 17:12
Hi,

I've had a look and can, as you say, see both CR and LF at the end of each line. Odd thing is that every line has both of these and all work except for the erroneous one. I've searched carefully for duplicate CRs but all lines end with the same.....which is why it feels odd.
Using Tier 1 AppGameKit V2
Started coding with AMOS (Thanks Francois Lionet)
Markus
Valued Member
19
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 24th Dec 2015 21:33
are you sure u open the correct file?
it is possible that one exists in project media folder (template) and maybe one file in app data ?
normal windows linebreak is 13 10
AGK (Steam) V2.0.16 : Windows 10 Pro 64 Bit : AMD (15.30.1025) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
Digital Awakening
AGK Developer
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 24th Dec 2015 21:44
Try using strings instead of lines.
DavidAGK
AGK Developer
10
Years of Service
User Offline
Joined: 1st Jan 2014
Location:
Posted: 25th Dec 2015 16:42
Hi Markus - yep, checked for that one! I've fallen for that one in the past.

Hi DA - Hmmmm I've based most of the file loading using ReadLine commands so would prefer to go that way. It should technically work...

So you guys haven't experienced anything like this?
Using Tier 1 AppGameKit V2
Started coding with AMOS (Thanks Francois Lionet)
Digital Awakening
AGK Developer
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 25th Dec 2015 17:42
I have had problems with lines. Which is why I use strings instead.
DavidAGK
AGK Developer
10
Years of Service
User Offline
Joined: 1st Jan 2014
Location:
Posted: 25th Dec 2015 19:03
Ah, ok. I'll have to have another read of the read-string commands to se how I might use them as a potential replacement.
Using Tier 1 AppGameKit V2
Started coding with AMOS (Thanks Francois Lionet)
Digital Awakening
AGK Developer
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 25th Dec 2015 20:50
I use both strings and integers with no problems.
Cybermind
Valued Member
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 26th Dec 2015 10:26
If you are going to re-write code anyway, why don't you copy the file into memory and read it line for line from there? HDD's like reading big chunks of data in one go instead of picking in a file multiple times.
The byte chrunchers are coming...
DIVIDING BY ZERO/BECAUSE I SUCK...
DavidAGK
AGK Developer
10
Years of Service
User Offline
Joined: 1st Jan 2014
Location:
Posted: 26th Dec 2015 15:53
Into a memblock?
Using Tier 1 AppGameKit V2
Started coding with AMOS (Thanks Francois Lionet)
BatVink
Moderator
20
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 26th Dec 2015 22:50
I use parameter files a lot, and never had this issue.
Have you tried rewriting the file from scratch (no copying and pasting?)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
DavidAGK
AGK Developer
10
Years of Service
User Offline
Joined: 1st Jan 2014
Location:
Posted: 30th Dec 2015 08:17
I'll attach it when at my pc. See if you detect the blank line. That would be interesting.
Using Tier 1 AppGameKit V2
Started coding with AMOS (Thanks Francois Lionet)
DavidAGK
AGK Developer
10
Years of Service
User Offline
Joined: 1st Jan 2014
Location:
Posted: 30th Dec 2015 10:00
OK, here it is....this file seems to have a mystery blank string returned at line 27 when I use the ReadLine command to read through the file . It's a text file.
Using Tier 1 AppGameKit V2
Started coding with AMOS (Thanks Francois Lionet)

Attachments

Login to view attachments
Markus
Valued Member
19
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 30th Dec 2015 10:39 Edited at: 30th Dec 2015 11:19
... emmm
AGK (Steam) V2.0.16 : Windows 10 Pro 64 Bit : AMD (15.30.1025) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 30th Dec 2015 10:39
I'm only seeing a single CR LF at the end of each line. It appears to insert an extra blank row if the line length exactly matches 2561 characters (not including CR LF). Try it! Try making line 26 the same length as line 27 (by adding some random characters to the end of the line)... The same thing happens! Very odd. Looks like a bug to me.

made a quick reader to show the prob...
V2 T1 (Mostly)
Phone Tap!
Uzmadesign
Markus
Valued Member
19
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 30th Dec 2015 11:22
that is special, waiting for paul's statement
AGK (Steam) V2.0.16 : Windows 10 Pro 64 Bit : AMD (15.30.1025) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
DavidAGK
AGK Developer
10
Years of Service
User Offline
Joined: 1st Jan 2014
Location:
Posted: 3rd Jan 2016 08:25
Interesting! Was fairly sure I wasn't going mad....

Paul....
Using Tier 1 AppGameKit V2
Started coding with AMOS (Thanks Francois Lionet)
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 3rd Jan 2016 18:54
I've seen odd things like this pop up in a variety of programming situations.

It might have something to do with memory boundaries when memory is allocated to handle the line read in. Or just hitting a certain size.

I once had a Borland C++ application that I had to put a dummy function in as the 10th one in a file being compiled. Otherwise, any attempt to call the function that was the 10th one in that file crashed the application.
Cheers,
Ancient Lady
DavidAGK
AGK Developer
10
Years of Service
User Offline
Joined: 1st Jan 2014
Location:
Posted: 4th Jan 2016 19:47 Edited at: 4th Jan 2016 19:49
Hmmm, that's interesting! Would be cool if Paul could take a look and see if there is something that can be done. For now I just check for blank strings returned from the function and if I get one when I shouldn't I just read another line. Fine for my situation where I know what the file being read should contain (ie number of lines that contain actual data) but for other situations I can see this being an issue so would be great if it can be resolved.

Edit: Especially given that there is a file and a piece of code (thanks CJB) that demonstrates the bug in action.
Using Tier 1 AppGameKit V2
Started coding with AMOS (Thanks Francois Lionet)
Yodaman Jer
User Banned
Posted: 4th Jan 2016 21:13
David - have you tried using either 2.15 or 2.16 yet to see if this issue pops up there as well? Just a suggestion. I would, of course, back up your project and then try the new version of AGK. I haven't had any issues with readLine and I have used it quite a bit already for my project. I am currently using 2.15!

Sign up for NaGaCreMo!
DavidAGK
AGK Developer
10
Years of Service
User Offline
Joined: 1st Jan 2014
Location:
Posted: 4th Jan 2016 22:04
I'm on 2.14 so yes...I should upgrade and see if that fixes it and report back.... just want to ensure I'm working with a stable version for development so....are 2.15 /2.16 stable?
Using Tier 1 AppGameKit V2
Started coding with AMOS (Thanks Francois Lionet)
Yodaman Jer
User Banned
Posted: 4th Jan 2016 22:15
They don't appear to be any less stable than 2.14, and many issues with 2.14 were fixed in 2.15, so I'm hoping your issue was one of them

Sign up for NaGaCreMo!
Paul Johnston
TGC Developer
21
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 5th Jan 2016 17:00
Thanks, fixed for the next version. For those interested AppGameKit reads lines in chunks of 256, so if a \r\n combination got split across two chunks then it would interpret it as two separate lines. It will now treat this properly as a single new line.
Markus
Valued Member
19
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 5th Jan 2016 18:01
@paul
ahh, interesting case
AGK (Steam) V2.0.16 : Windows 10 Pro 64 Bit : AMD (15.30.1025) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
DavidAGK
AGK Developer
10
Years of Service
User Offline
Joined: 1st Jan 2014
Location:
Posted: 5th Jan 2016 19:22
Woohoo! Good to hear it's fixed and good to know I wasn't just going mad. Not sure which is more important to me...

Thanks Paul.
Using Tier 1 AppGameKit V2
Started coding with AMOS (Thanks Francois Lionet)

Login to post a reply

Server time is: 2024-03-29 12:57:00
Your offset time is: 2024-03-29 12:57:00