IncludeBinary

Just starting out? Need help? Post your questions and find answers here.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by TronDoc.

.

Edited by - TronDoc on 25 January 2002 17:38:03
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by PB.
does anyone have a working example of the IncludeBinary command?
Read the topic called "Extracting IncludeBinary files to disk" in
the Beginner's forum...


PB - Registered PureBasic Coder
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by PB.
I could not get the example to work [...] Have you used the IncludeBinary command?
The example that I referred you to is the exact code that I use myself to include binaries, so yes, it works 100% fine for me. Are you a registered PureBasic user? It probably doesn't work with the demo version.


PB - Registered PureBasic Coder
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Danilo.

Hello !!

;----------
r=OpenFile(1,"c:\nasm2.exe")
If r0
WriteData(?MyFile,208928) ; xxx = File size (in bytes) of included binary.
CloseFile(1)
endif
end
MyFile:
IncludeBinary "c:\nasm.exe"
;----------

Works great for me.

IF the WriteData is on the same line as
the "If" ( "If r0 WriteData(.." )
it does NOT work here !!
(Error: "WRITEDATA is not a valid operator")

** MAYBE a bug ?? **

cya,
...Danilo
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by PB.

Not a bug... WriteData is not intended to take arguments.

You cannot use "If r0 WriteData(.." because you have to use WriteData
alone, as per the docs. In my example, the "if r0" is a test to ensure
that the FILE was opened for writing, NOT to check if the WriteData command
worked.


PB - Registered PureBasic Coder

Edited by - PB on 11 December 2001 11:48:20
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Danilo.


If r0 WriteData(..
Endif

is the same as

If r0
WriteData(..
Endif

thats the BASIC programming language.
What you meant is "IF WriteData(..",
but the above example *should* work
in every BASIC.

Fred himself wrote the example and he
knew it works because you can do it
in BASIC.
You cant do it in PureBasic, so i
would call it a BUG in the Syntax
Interpreter (parser).
(The parser has to interpret the line as
"If r is not 0, then WriteData(..",
but it looks like the parser only checks
"´IF´ and ´WriteData´ on the same line ?? No Way !!")

cya,
...Danilo
(registered PureBasic user)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Franco.
If r0 WriteData(..
Endif

is the same as

If r0
WriteData(..
Endif

thats the BASIC programming language.
Hi Danilo,
well I never used QuickBasic or PowerBasic (and the last time I used GW-Basic was 1987 I think, so I can't exactly remember how it act...)
but in BCX-Basic it has to be:

Code: Select all

IF r0 THEN
 WriteData(..
ENDIF
In PureBasic you are able to code:

Code: Select all

If r0 : WriteData(...)
Endif
or

Code: Select all

If r0 : WriteData(...) : Endif
So I suppose every Basic seams to be different and with PureBasic you don't have to use:

Code: Select all

IF r0 THEN
and I appreciate it very much!
Have Fun!



Have a nice day...
Franco
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by PB.
If r0 WriteData(..
Endif

is the same as

If r0
WriteData(..
Endif
No it isn't, actually. The second example has WriteData on a new line, and hence
the checking done with if r0 is complete. To make the first example
match the second, you need to add a colon like so:

If r0 : WriteData(..
Endif

Otherwise, if you don't use the colon or new line, then the editor correctly
assumes that if r0 WriteData(.. is all one command, because there's no
colon or new line to separate the two parts [ if r0 and WriteData(.. ].

But that's not even what my code example is doing. Read it carefully again.
My code is using if r0 to check that the file was opened -- it's not
checking to see if WriteData worked.

To make it clearer:

Code: Select all

r=OpenFile(1,"c:\nasm2.exe")
If r0 ; This checks if OpenFile worked and has nothing to do with WriteData.
  WriteData(?MyFile,208928) ; This is a standalone command with no checking.
  CloseFile(1)
endif ; This relates to the OpenFile check above.
end
MyFile:
IncludeBinary "c:\nasm.exe"
Edited by - PB on 12 December 2001 06:57:59
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by PB.
PB, it's a little annoying asking someone if they aren't a registered user just because a command doesn't work and I feel more than a little insulting.
I asked if they were registered simply because I was curious as to whether they
were using the demo version or not; not because I thought they were
stupid or a newbie or anything. I've seen some questions here by people using
the demo version and that's simply why I asked.

If I caused any offence to anyone, then I sincerely apologise.
I seem to remember someone telling me they thought my code was way
beyond them???
That was because I have zero knowledge of IncrediMail, that's all. There's no
way you can expect me to know what your code is supposed to be doing when I have
no understanding of how IncrediMail works...

(BTW, is this the forum's first flame war? ).

Edited by - PB on 12 December 2001 07:07:33
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by PB.
HAHA ROFL, not at all. I nearly choked on a ginger biscuit there.
Hehehe. Good, I'm glad you didn't take it the wrong way.
I don't want this to go the way of the PowerBasic conference with "Go here", "There it is", "Search for this here", "you will find examples there" etc. Repeat as much code as you can stand, the beginners will learn faster (I did).
You do have a good point there.

Just to clear something up: I'm a permanent shift worker (midnight to dawn)
so many of my posts here are done after work, when I'm not 100% -- hence I can
sometimes come across as a little gruff or rude, although I truly don't mean
to be when posting. I'll try to be more considerate with my answers in future
and again, I'm sorry if any newbies have been offended by my rough posts.

Edited by - PB on 12 December 2001 11:36:36
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Danilo.

Hello PB !!

I know how your example works,
but you dont get my point.

Its not a problem for me because
i use a clean prog-style (you have
to write clean code in Assembly).

I only said "it should work".

Newbies dont know the reason why
it doesnt work, because it looks
like BASIC...

Dont care about it anymore...

Anyway: happy programming

cya,
...Danilo


(registered PureBasic user)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by PB.
IncludeBinary re-visited.
I finally got it to work.
I now know why it wouldn't work before.
The file to be included MUST include the FULL PATHNAME!
Wrong... I don't need to include the full pathname with it.


PB - Registered PureBasic Coder
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by MrVainSCL.

Hi Trondoc
I repoted about this problem and told that you need to use the complete path in PB2.70 -
Check: "Bug Reports" - "PB-Editor/Compiler and Include files..."

In PB2.80 i must use the complete path too but i think that is no problem :wink:

PIII450, 256MB Ram, 6GB HD, RivaTNT, DirectX8.1, SB AWE64, Win98SE + Updates...

greetz
MrVainSCL! aka Thorsten
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by PB.
In PB2.80 i must use the complete path too but i think that is no problem :wink:
I don't need to use the full path with v2.80 and my apps compile just fine.
Even my vis2pure app (v0.11) used IncludeBinary as one of its conversion
options with no problems without full paths.


PB - Registered PureBasic Coder
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by TronDoc.

I don't understand the differences,
but at least I can use the command for now.
I hope somebody can figure it out because
I'd rather not have to use the whole path.

btw: I have Windoze98 dated 4.10.1998
and Franco's version of GetOSversion.pb
reports Windows 98 version 4.10 build 1998.1034
Although I don't know why that should matter.
Thank you all for your input.
*************************************************
O.K. Now! back to one of my very first questions
before I had all of the trouble trying to include
a file within my executable.

just suppose that here is my code so far:

Code: Select all

end
MyMapIndex:
    IncludeBinary "c:\myProj\map.indx"
MyMapData:
    IncludeBinary "c:\myProj\map.data"
That will compile just fine into an executable file
which contains an accurate copy of the binary information
in the files map.indx and map.data (I know because I have done so.)

I now need to access that data
WITHOUT writing it to any disk drive.

Can I use the "labels" MyMapIndex: and MyMapData:
as pointers to the start of that information?

Ultimately to keep the filesize of my program
small I will try to compress my binary data
files into the executable and when the
executable is run I will uncompress
the data to another part of
memory. There are commands to do
this part of my project, but I cannot
seem to find any to directly access the
binary data in memory other than the peek and
poke commands.

Please read this thoughtfully if you intend to reply.

Thanks for everyone's help in other issues.

Joe


Edited by - TronDoc on 14 January 2002 10:29:27
Post Reply