#C-hunks?
9 messages in this thread
help.
here's what I have..
I have a 300 k ascii file that I need to put in a string (one, BIG string) I
don't want to have it in the code of the main program (takes forever to scroll
through it all) so I wanted to have it in a separte file (hunk or otherwise)
and link it to the program during compiling..I have tried using MCS (make C
string) and bin2hk (both from the libs here) but can't get it to work
correctly..
any and all help appreciated,
Alex —
it's been a long time since
for i=1 to 10 print i next i
Alex
Why not just alloc some memory and load it in at run-time? You can use a
pointer of type char to point to the string, and can use this variable as you
would an array, or string in all the C string functions. This approach allows
you to change the ascii text without recompiling.
Mal
I can't have 2 files..only one.
Thanks for responding..
Alex
One file eh? If nothing else works, and you have an assembler, you could turn
the file into a linkable object by using a file such as this:
XDEF _stringname
_stringname incbin "string_file_path_&_name"
end
Assembling this will produce a linkable file that you can combine with your
main program. Make sure your assembler is set to produce a linkable rather
than executable file. To access the data, just have the line
extern far char *stringname;
somewhere in your C header file. I don't know which compiler and assembler you
have, but I know SAS/C and Devpac produce compatible object files.
I hope this helps.
Mal
Make a separate file, str.c, put in :
. char BigString[] = " <your string here>";
compile this, then link the str.o to your main program. Declare the
string there as
. extern char *BigString;
should work fine, and your compiler woun't have to re-compile the string
each time.
I tried that.. I get an error 11: string too large or not terminated
sigh…
Alex (thanks for responding!)
hmmm..
maybe you have to terminate each line with a 'line continuation char '\'
for the string to carry over the CR. Another thing I've resorted to was
an ARexx script to take a text file, and convert it to something like:
. ULONG Str[] = 0x414e5239, 0x3336445A, …
or even:
. UBYTE 0x41,0x4e,…
the byte version would make a bigger source, due to added '0x' and ','.
Well, I don't see any problems using MCS with SAS as long as you declare
the text as __far and don't use the small data options (don't use the
usual SD during linking!). I haven't tried it yet with 300dkb but I surely
used that scheme with my program above the usual small data hunk size…
— Wolf Faust, Am Dorfgarten 10, 60435 Frankfurt, Germany —
I am not sure if I am using the correct linking commands..I thought it would
work as well..going to try again.
Thanks
Alex