Page 1 of 1

Problem reading data section

Posted: Mon Dec 29, 2008 10:21 am
by Godai
I have a wierd problem.
After reading 6 lines of 24 I get an error that there is no more data?!
This is wierd, since the program worked in 4.20.
Did I miss something that was changed in 4.30? :)

Thanks in advance

Posted: Mon Dec 29, 2008 12:25 pm
by Mistrel
Did you remember to include a null byte after including your text?

Code: Select all

DataSection
	IncludeBinary "This.txt"
	Data.c 0
EndDataSection

Posted: Mon Dec 29, 2008 12:34 pm
by ts-soft
> - Changed: 'Read' keyword now requiers a type (Read.l, Read.q etc.) to avoid 64 bits migration problems

Posted: Mon Dec 29, 2008 12:34 pm
by Godai
It's not text. Simple byte lines.
I'm doing a proper purebasic raycasting example ala wolfenstein for the Tips'n'Tricks section :)

Initial code (which causes the compiler error)

Code: Select all

; Raycasting example 1 (Walls only)

; Some general stuff
Global mapWidth.l = 24
Global mapHeight.l = 24
Global screenWidth.l = 640
Global screenHeight.l = 480

; Map container
Global Dim worldMap.b(mapWidth, mapHeight)

; Read map
For y.l = 0 To mapHeight-1
  For x.l = 0 To mapWidth-1
    Read worldMap(x, y)
  Next x
Next y 



; Open screen
OpenWindow(0, 0, 0, screenWidth, screenHeight, "Raycast Example #1") 



; Map data
DataSection

Data.b  1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
Data.b  1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
Data.b  1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
Data.b  1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
Data.b  1,0,0,0,0,0,2,2,2,2,2,0,0,0,0,3,0,3,0,3,0,0,0,1
Data.b  1,0,0,0,0,0,2,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,1
Data.b  1,0,0,0,0,0,2,0,0,0,2,0,0,0,0,3,0,0,0,3,0,0,0,1
Data.b  1,0,0,0,0,0,2,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,1
Data.b  1,0,0,0,0,0,2,2,0,2,2,0,0,0,0,3,0,3,0,3,0,0,0,1
Data.b  1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
Data.b  1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
Data.b  1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
Data.b  1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
Data.b  1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
Data.b  1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
Data.b  1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
Data.b  1,4,4,4,4,4,4,4,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
Data.b  1,4,0,4,0,0,0,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
Data.b  1,4,0,0,0,0,5,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
Data.b  1,4,0,4,0,0,0,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
Data.b  1,4,0,4,4,4,4,4,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
Data.b  1,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
Data.b  1,4,4,4,4,4,4,4,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
Data.b  1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1

EndDataSection  

Posted: Mon Dec 29, 2008 12:36 pm
by ts-soft
You read the default (Integer) not a byte!
Read.b is required for PB4.30

Posted: Mon Dec 29, 2008 1:27 pm
by Godai
Ahh. Thought I was missing something, since it worked in 4.20. Thanks :)