Page 1 of 1

constant bugged?

Posted: Tue May 27, 2003 9:50 pm
by TheVelvetTeddyBear
Hi ive got a odd problem,

#libstart = 20
libcount = libstart
MessageRequester("",Str(libstart),0)

shouldnt libstart = 20? its shown as 0 in the message box,

edit: well i got what i wanted working with globals, also im wondering how i could read just one line in a txt file?

i have a file setout like

Divider
html
<hr>

id like to read in the first line into a string then the second leaveing it so the next read part will be after those 2 lines.

i normally use blitzbasic but tbh blitz+ aint really enuff yet:) lol but blitz3d is still my top prog for 3d apps, any help would be great.

ps. there was a odd bug earlier, i opened each file in a loop and closed after i opened them (before i opened the next) and they were copied to my programs root folder o_O.

Posted: Tue May 27, 2003 9:58 pm
by Henrik
Hi welcome

You forgot a #
try: MessageRequester("",Str(#libstart),0)

Bedst regards
Henrik

Posted: Tue May 27, 2003 9:59 pm
by TheVelvetTeddyBear
ahha! just tried that tnx worked nice,

Posted: Wed May 28, 2003 7:46 pm
by Henrik
Hi TVTB
Form the help. -(Press F1)- about File.
There is an example about stuff you maybe could use or modify for that purpose.

Code: Select all

;
; ------------------------------------------------------------
;
;   PureBasic - File example file
;
;    (c) 2001 - Fantaisie Software
;
; ------------------------------------------------------------
;

MessageRequester("PureBasic", "Welcome !"+Chr(13)+"PureBasic will write a file named: PureBasicTestFile.pb", 0)

If CreateFile(0, "PureBasicTestFile.txt")
  WriteStringN("         This is a PureBasic file test")
  WriteString("Now it's on ")
  WriteString("the same line.")

  CloseFile(0)
Else
  MessageRequester("PureBasic", "Error: can't write the file", 0)
  End
EndIf

If ReadFile(0, "PureBasicTestFile.txt")

  First$ =  Trim(ReadString())
  MessageRequester("PureBasic", "Line read: "+First$, 0)
  
  CloseFile(0)
Else
  MessageRequester("PureBasic", "Error: Can't read the file", 0)
EndIf

End 
Bedst regards
Henrik