Problem reading data section

Advanced game related topics
Godai
Enthusiast
Enthusiast
Posts: 171
Joined: Thu Oct 05, 2006 8:13 pm

Problem reading data section

Post 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
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Post 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
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

> - Changed: 'Read' keyword now requiers a type (Read.l, Read.q etc.) to avoid 64 bits migration problems
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
Godai
Enthusiast
Enthusiast
Posts: 171
Joined: Thu Oct 05, 2006 8:13 pm

Post 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,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,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  
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

You read the default (Integer) not a byte!
Read.b is required for PB4.30
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
Godai
Enthusiast
Enthusiast
Posts: 171
Joined: Thu Oct 05, 2006 8:13 pm

Post by Godai »

Ahh. Thought I was missing something, since it worked in 4.20. Thanks :)
Post Reply