Gadget Blues Again - [FIXED]

Just starting out? Need help? Post your questions and find answers here.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

kinglestat wrote:and
how do you do those data stuff from a file? Is there an automatic way to do this?
Just write a small utility which dumps a file to a PB program etc.

I just happen to have one lying around the floor!

Code: Select all

;This small utility creates a data section in raw binary format out of an external file.
;Useful for embedding small images directly within a source program etc,

;No error checking.

#linelength=40

inputfile$="back.ico"
outputfile$="data.pbi"

;Main program.
If CreateFile(1, outputfile$)
  WriteStringN(1, ";"+inputfile$)
  WriteStringN(1,"")
  WriteStringN(1,"DataSection")
  ReadFile(2, inputfile$)
  line$="  Data.b "
  While Eof(2) = 0
    count+1
    byte.c=ReadByte(2)
    line$+Str(byte)
    If count=#linelength
      WriteStringN(1, line$)
      line$="  Data.b "
      count=0
    Else
      line$+", "
    EndIf
  Wend
  If line$<> "  Data.b "
    WriteStringN(1, Left(line$, Len(line$)-2))
  EndIf
  CloseFile(2)
  WriteStringN(1,"EndDataSection")
  CloseFile(1)
Else
  MessageRequester("Error!", "Problem creating output file!")
EndIf
I may look like a mule, but I'm not a complete ass.
kinglestat
Enthusiast
Enthusiast
Posts: 746
Joined: Fri Jul 14, 2006 8:53 pm
Location: Malta
Contact:

Post by kinglestat »

clever
thanks srod once again
I guess I have to upgrade from a couple of beers to a couple of champagne bottles next time I'm in England.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

I only drink out of barrels these days! :wink:
I may look like a mule, but I'm not a complete ass.
kinglestat
Enthusiast
Enthusiast
Posts: 746
Joined: Fri Jul 14, 2006 8:53 pm
Location: Malta
Contact:

Post by kinglestat »

a barrel it is then :!:
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Post by Rook Zimbabwe »

sRod,
If that is a sample of whats just laying around on the floor... I would LOVE to see whats tossed haphazardly on your desk!

Great tool! Thanks! 8)
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
kinglestat
Enthusiast
Enthusiast
Posts: 746
Joined: Fri Jul 14, 2006 8:53 pm
Location: Malta
Contact:

Post by kinglestat »

moot point rook
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Rook Zimbabwe wrote:sRod,
If that is a sample of whats just laying around on the floor... I would LOVE to see whats tossed haphazardly on your desk!

Great tool! Thanks! 8)
Trust me, you really don't want to know what's lying on top of and underneath my desk! I really should get a cleaner I guess!

:)
I may look like a mule, but I'm not a complete ass.
Baldrick
Addict
Addict
Posts: 860
Joined: Fri Jul 02, 2004 6:49 pm
Location: Australia

Post by Baldrick »

srod wrote:
Trust me, you really don't want to know what's lying on top of and underneath my desk! I really should get a cleaner I guess!

:)
Good to know I am not the only 1 who suffers from this affliction :lol:

( Besides, ..... a clean desk is a sign of a sick mind so they tell me!! )
kinglestat
Enthusiast
Enthusiast
Posts: 746
Joined: Fri Jul 14, 2006 8:53 pm
Location: Malta
Contact:

Post by kinglestat »

well, I have 3 offices now at home......I try to choose the least messy...and avoid the ones where I see new life forms start to emerge...lets just say it my contibution to science!
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

My b*stard coffee mug has welded itself to the top of my desk and refuses to budge. I have to drink coffee from a straw now! Damn thing has an IQ in excess of my own now. Indeed, it's helping me debug some code here!

As for the bugs? Well they've moved into my laundry basket now and are busy creating a eutopian civilisation. The swines refuse to give me my socks back, -they were good for at least another 6 weeks or so!

Now who wins the slob of the year competition?

:)
I may look like a mule, but I'm not a complete ass.
kinglestat
Enthusiast
Enthusiast
Posts: 746
Joined: Fri Jul 14, 2006 8:53 pm
Location: Malta
Contact:

Post by kinglestat »

you always win!
Post Reply