News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

error A2041: string or text literal too long

Started by tron, January 20, 2005, 11:48:25 AM

Previous topic - Next topic

tron

Quote from: Peterpan on January 21, 2005, 11:52:27 PM
Tron,

Another idea. How about using an offset/pointer in the structure ?
Something like this:

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

.486
.model flat, stdcall
option casemap :none   ; case sensitive

   include \masm32\include\windows.inc
   include \masm32\include\kernel32.inc
   include \masm32\include\user32.inc

   includelib \masm32\lib\kernel32.lib
   includelib \masm32\lib\user32.lib

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

PROFILE       STRUCT
  item1         LPSTR   ?
  item2         LPSTR   ?
PROFILE       ENDS

.Const
   Str1  db 'Header of the string2 1234567890 1234567890 1234568790 1234567890 ',13
         db 'This message is longer than 255 chars, this is the first line',13
         db 'This is the 2nd line, just testing',13
         db 'This is the 3rd line, just testing only',13
         db 'This is the 4th line, whatever ...........',13
         db 'This is the 5th line, sdfsd sdf ',13
         db 'This is the 6th line',13
         db 'This is the 7th line',13
         db 'string3 1234567890 1234567890 1234567890 1234567890 1234568790 1234567890 '
   Str2  db ' This is the caption. You can make this long longer than 500 bytes',0

.Data
   Profile001 PROFILE < offset Str1, offset Str2 >

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
.CODE
Start:
   invoke MessageBox, NULL, Profile001.item1, Profile001.item2, MB_OK
   invoke ExitProcess, 0

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

End Start


thanks for the reply

its funny you posted this :D, this is one of the first things i considered when i encountered the length error. basically its a code formatting issue i wanted to be able to define nice little organized structures and i did do a bunch of research on it before i posted. i kinda knew it was a limitation of masm i would just have to deal with.

Peterpan

Quote from: tron on January 22, 2005, 06:02:42 AM
its funny you posted this :D, this is one of the first things i considered when i encountered the length error. basically its a code formatting issue i wanted to be able to define nice little organized structures and i did do a bunch of research on it before i posted. i kinda knew it was a limitation of masm i would just have to deal with.

I already thought you know it.  :green  I offer it anyway because I think it is an easy way to work with long string in the structure, and you can also allocate the buffer in memory. Personally, I prefer this way
:U

Ratch

Peterpan,
     I like that method.  Map out the data structure with the STRUCT directive, and then either code the structure directly or MACRO it if a lot of structures are needed.  Ratch

sbrown

tron,

Dum-dum question... I know its a bit cumbersome, but instead of hard-coding this string data to inject into the structure, you instead add this string data as a resource to your executible? This would keep you from having to define multiple lines, and then 'pasting' them together, no? :wink

Your string (via lets say 'Notepad') could be as long as you want it. You then use a few Resource APIs, and you're in business. I have used this myself on occassion. :U

My two cents, ::)
Scott