Extremely noobish question(s)

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
YenTex
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 31
Joined: Sun Mar 01, 2009 9:38 pm

Extremely noobish question(s)

Post by YenTex »

Im learning BlitzPlus, and I keep getting an error "expecting end of file"
should I post my code?
Where can I get Blitz+ tutorials?
CODE FOR MAP EDITOR (incomplete)

Code: Select all

;Platform Map editor
AppTitle "ShadowX Map Editor"
gwidth=800
gheight=600
tsize=40
numtiles=4

Timer = CreateTimer(30) 

Graphics gwidth,gheight,16,2

scr_left = 0
scr_top = 0 
infile = OpenFile("map1.map");Assign infile to loading the map 
imgSprite = LoadImage("graphics\sprite.bmp") ;assign the variable imgSprite to loading a sprite 
If infile <> 0 Then 
	mapx = ReadInt(infile)
	mapy = ReadInt(infile)
Else 
	mapx = 50
	mapy = 20 
EndIf 

Dim map$(mapx,mapy)

If infile <> 0 Then 
	For y = 0 To mapy-1
		For x = 0 To mapx-1
			map(x,y) = 0
		Next 
	Next
EndIf 

CloseFile infile

img_tiles = LoadAnimImage("Graphics\tileset.bmp") ,tsize,tsize,0,numtiles) ; Assign the variable imgTile to loading the tilesets. 

seltile = 2

SetBuffer BackBuffer()

Color 0,255,255

While Not KeyHit(1)

Cls 

For y = 0 To mapy 
	For x = 0 To mapx 
		tilenum = Int(map(x,y))-1
		If (x*tsize)-scr_left > -tsize And (x*tsize)-scr_left < gwidth And (y*tsize)-scr_top > -tsize And (y*tsize)-scr_top < gheight Then
			;draw tile
			If tilenum > -1 Then DrawImage img_tiles,(x*tsize)-scr_left,(y*tsize)-scr_top,tilenum
		EndIf
	Next
Next
;Scrolling around map w/ keys
If KeyDown(208) And scr_top < (mapy*tsize-gheight) Then scr_top = scr_top+15
If KeyDown(205) And scr_left < (mapx*tsize-gheight Then scr_left = scr_left+15
If KeyDown(203) And scr_left > -menuwidth Then scr_left = scr_left-15
If KeyDown(200) And scr_top > 0 Then scr_top = scr_top-15

Rect (((MouseX()+scr_left)/tsize)*tsize)-scr_left-1,(((MouseY()+scr_top)/tsize)*tsize)-scr_top-1,tsize+2,tsize+2,0

If seltile > 0 DrawImage img_tiles,(((MouseX()+scr_left)/tsize)*tsize)-scr_left,(((MouseY()+scr_top)/tsize)*tsize)-scr_top,seltile-1
If MouseDown(1)
	map((MouseX()+scr_left)/tsize,(MouseY()+scr_top)/tsize) = seltile
EndIf 
If selmouse < MouseZ() Then seltile = seltile + 1
If selmouse > MouseZ() Then seltile = seltile - 1
selmouse = MouseZ()
I'm so sorry for being a noob. :bow: :bow: :bow:
Last edited by YenTex on Sun Mar 01, 2009 11:42 pm, edited 2 times in total.
User avatar
Kros
Chaos Rift Regular
Chaos Rift Regular
Posts: 136
Joined: Tue Feb 24, 2009 4:01 pm
Current Project: N/A
Favorite Gaming Platforms: PC, Playstation/2/3
Programming Language of Choice: C++
Location: Oregon,USA
Contact:

Re: Extremely noobish question(s)

Post by Kros »

Post your code in code brackets please. And I suggest using google to find tutorials. :)
Isaac Asimov wrote:Part of the inhumanity of the computer is that, once it is competently programmed and working smoothly, it is completely honest.
YouTube Channel
YenTex
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 31
Joined: Sun Mar 01, 2009 9:38 pm

Re: Extremely noobish question(s)

Post by YenTex »

Kros wrote:Post your code in code brackets please. And I suggest using google to find tutorials. :)
I tried google, i came up empty
User avatar
aamesxdavid
ES Beta Backer
ES Beta Backer
Posts: 347
Joined: Wed Jan 07, 2009 8:49 pm
Location: Bellevue, WA
Contact:

Re: Extremely noobish question(s)

Post by aamesxdavid »

End of line errors usually mean you didn't close something off, such as an "if" statement. I'm familiar with Blitz3D, but not BlitzPlus. The only thing I noticed was this inconsistency:

Code: Select all

If MouseDown(1)
   map((MouseX()+scr_left)/tsize,(MouseY()+scr_top)/tsize) = seltile
EndIf 
Every other "if" statement has a "Then" at the end of the line except this one, your last in the code you posted. I'm not sure if those are necessary for multi-line "if" statements, but it's best to keep things like that consistent. Keep your code as clean as possible, and errors like this will be easier to find.
YenTex
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 31
Joined: Sun Mar 01, 2009 9:38 pm

Re: Extremely noobish question(s)

Post by YenTex »

Code: Select all

;Platform Map editor
AppTitle "ShadowX Map Editor"
gwidth=800
gheight=600
tsize=40
numtiles=4

Timer = CreateTimer(30) 

Graphics gwidth,gheight,16,2

scr_left = 0
scr_top = 0 
infile = OpenFile("map1.map");Assign infile to loading the map 
imgSprite = LoadImage("graphics\sprite.bmp") ;assign the variable imgSprite to loading a sprite 
If infile <> 0 Then 
	mapx = ReadInt(infile)
	mapy = ReadInt(infile)
Else 
	mapx = 50
	mapy = 20 
EndIf 

Dim map$(mapx,mapy)

If infile <> 0 Then 
	For y = 0 To mapy-1
		For x = 0 To mapx-1
			map(x,y) = 0
		Next 
	Next
EndIf 

CloseFile infile


img_tiles = LoadAnimImage("tileset.bmp",tsize,tsize,0,numtiles) 

;LOL
;LOL
seltile = 2

SetBuffer BackBuffer()

Color 0,255,255

While Not KeyHit(1)

Cls 

For y = 0 To mapy 
	For x = 0 To mapx 
		tilenum = Int(map(x,y))-1
		If (x*tsize)-scr_left > -tsize And (x*tsize)-scr_left < gwidth And (y*tsize)-scr_top > -tsize And (y*tsize)-scr_top < gheight Then
			;draw tile
			If tilenum > -1 Then DrawImage img_tiles,(x*tsize)-scr_left,(y*tsize)-scr_top,tilenum
		EndIf
	Next
Next
;Scrolling around map w/ keys
If KeyDown(208) And scr_top < (mapy*tsize-gheight) Then scr_top = scr_top+15
If KeyDown(205) And scr_left < (mapx*tsize-gheight )Then scr_left = scr_left+15
If KeyDown(203) And scr_left > -menuwidth Then scr_left = scr_left-15
If KeyDown(200) And scr_top > 0 Then scr_top = scr_top-15

Rect (((MouseX()+scr_left)/tsize)*tsize)-scr_left-1,(((MouseY()+scr_top)/tsize)*tsize)-scr_top-1,tsize+2,tsize+2,0

If seltile > 0 DrawImage img_tiles,(((MouseX()+scr_left)/tsize)*tsize)-scr_left,(((MouseY()+scr_top)/tsize)*tsize)-scr_top,seltile-1
If MouseDown(1)
	map((MouseX()+scr_left)/tsize,(MouseY()+scr_top)/tsize) = seltile
EndIf 
If selmouse < MouseZ() Then seltile = seltile + 1
If selmouse > MouseZ() Then seltile = seltile - 1
selmouse = MouseZ()
If MouseHit(2) Then seltile = seltile + 1
If seltile > numtiles Then seltile = 0
If seltile = -1 Then seltile = numtiles 

;Clear map w/C key 
If KeyHit(46) Then
For y = 0 To mapy-1
	For x = 0 To mapx-1
		map(x,y) = 0
	Next 
Next
EndIf

 
;Save with S
;------------------------
If KeyHit(31) Then 

;Open outpu in write mode
fileout = WriteFile("map1.map")

WriteInt fileout,mapx
WriteInt fileout,mapy


For y = 0 To mapy-1
	For x = 0 To mapx-1
		WriteInt fileout,map(x,y)
	Next
Next

CloseFile fileout

EndIf



Flip
Wend

EndGraphics 
End

Now it says I have an invalid file stream handle
Last edited by YenTex on Sun Mar 01, 2009 11:49 pm, edited 1 time in total.
User avatar
LuciDreamTheater
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 39
Joined: Tue Jan 20, 2009 2:18 am
Location: Southern CA
Contact:

Re: Extremely noobish question(s)

Post by LuciDreamTheater »

Raiden wrote:
Something gives me the impression that I have to to an end of file here

Code: Select all

img_tiles = LoadAnimImage("tileset.bmp"),tsize,tsize,0,numtiles) 
Looks like you're missing a parenthesis. In all the languages I know, closing parenthesis have a matching opening parenthesis.
YenTex
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 31
Joined: Sun Mar 01, 2009 9:38 pm

Re: Extremely noobish question(s)

Post by YenTex »

anothrguitarist wrote:
Raiden wrote:
Something gives me the impression that I have to to an end of file here

Code: Select all

img_tiles = LoadAnimImage("tileset.bmp"),tsize,tsize,0,numtiles) 
Looks like you're missing a parenthesis. In all the languages I know, closing parenthesis have a matching opening parenthesis.
Yeah, I think i caught my mistake right when you were posting
Now it says invalid file stream handle
User avatar
LuciDreamTheater
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 39
Joined: Tue Jan 20, 2009 2:18 am
Location: Southern CA
Contact:

Re: Extremely noobish question(s)

Post by LuciDreamTheater »

Although I nothing about the language you are using (even its name slips my mind), I would assume it's having trouble finding a file you are trying to load. Similar problems can occur in C++. If a file name or path is incorrect, for instance, then the debugger might say something like, "invalid file pointer."


EDIT: Whoops, I left off the advice: Try moving the bitmap image to different folders and see if your program starts to work.

EDIT2: Could be your map file too.
YenTex
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 31
Joined: Sun Mar 01, 2009 9:38 pm

Re: Extremely noobish question(s)

Post by YenTex »

anothrguitarist wrote:Although I nothing about the language you are using (even its name slips my mind), I would assume it's having trouble finding a file you are trying to load. Similar problems can occur in C++. If a file name or path is incorrect, for instance, then the debugger might say something like, "invalid file pointer."


EDIT: Whoops, I left off the advice: Try moving the bitmap image to different folders and see if your program starts to work.

EDIT2: Could be your map file too.
It was my map file, I can't save now for some reason.
Meh, I'll figure it out tomorrow...
Thanks for the advice :) :)
User avatar
LuciDreamTheater
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 39
Joined: Tue Jan 20, 2009 2:18 am
Location: Southern CA
Contact:

Re: Extremely noobish question(s)

Post by LuciDreamTheater »

Raiden wrote:
anothrguitarist wrote:Although I nothing about the language you are using (even its name slips my mind), I would assume it's having trouble finding a file you are trying to load. Similar problems can occur in C++. If a file name or path is incorrect, for instance, then the debugger might say something like, "invalid file pointer."


EDIT: Whoops, I left off the advice: Try moving the bitmap image to different folders and see if your program starts to work.

EDIT2: Could be your map file too.
It was my map file, I can't save now for some reason.
Meh, I'll figure it out tomorrow...
Thanks for the advice :) :)
Glad I could help.
Post Reply