News:

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

string too long

Started by chipbug, May 07, 2011, 08:02:25 PM

Previous topic - Next topic

chipbug

.data

lpText   db   "1) To calculate the amount your BG level goes up per gram of carbs take a BG reading before each meal then 2 hours after each meal. Record in a log the date, time, the amount of carbs you ate in grams, and BG level. Accumulate a weeks worth of data. Take only Lantus during this time.",13,10,13,10,"2) Calculate the amount your BG level goes up per gram of carbs by using the following formula for each meal: (2nd BG reading - 1st BG reading) / amount of carbs in grams. Then add the results and divide by the number of meals to get the average. Put this number in the calculator variable BG UP PER GRAM OF CARB.",13,10,13,10,"3) Decide your target BG level. Enter target in the calculator variable TARGET BG LEVEL.",13,10,13,10,"4)To calculate BG drop per unit of Humalog take a BG reading before each meal (Meals have to be exact same meals in the same order as the week you calculated BG UP PER GRAM OF CARB). Inject 20 units humalog before the meal. Then take a BG reading 2 hours after each meal. Record in a log the date, time, the amount of carbs you ate in grams, and BG level. Accumulate a weeks worth of data. Continue to take Lantus during this time.",13,10,13,10,"5) Calculate your BG drop per unit of Humalog by using the following formula for each meal: ((week 1 2nd BG reading - week 1 1st BG reading) -(week 2 2nd BG reading - week 2 1st BG reading)) / 20. Then add the results and divide by the number of meals in 1 week to get the average. Put this number in the calculator variable BG DROP PER UNIT.",13,10,13,10,"6) Now you can calculate your humalog dose to get you to your target BG based on the amount of carbs you are about to eat and your current BG level by entering your current BG level in the field labeled CURRENT BG and entering the number of carbs your about to eat in the field labeled NUMBER OF CARBS YOUR ABOUT TO EAT IN GRAMS. Click the calculate button or hit enter on the keyboard and the dose is displayed in the field UNITS HUMALOG BEFORE MEAL.",13,10,13,10,13,10,"All variables are stored in a file called bgcalc.ini in the same folder the program is in. If bgcalc.ini is missing the program will create a new one and default to BG UP PER GRAM OF CARB 2.5 and BG DROP PER UNIT 5.64 and TARGET 85.",13,10,13,10,"If you want to calculate a bolus just put 0 in the NUMBER OF CARBS YOUR ABOUT TO EAT IN GRAMS field and your current BG in the CURRENT BG field and click the calculate button or hit enter on the keyboard and the dose is displayed in the field UNITS HUMALOG BEFORE MEAL.",13,10,13,10,13,10,0

The assembler gives me:

C:\Users\Dave\my programs\BGCalc\BGcalc.asm(52) : error A2041: string or text literal too long
C:\Users\Dave\my programs\BGCalc\BGcalc.asm(52) : fatal error A1009: line too long

How long is too long?

vanjast

My brain gives me...
Error 1001: "More paragraphs needed in post - cannot read squashed writing"

I'll check my version.  :bg

dedndave

i'd say, "that long is too long"   :bg
that is an assembly error - not a runtime error
break the line up...
lpText   db   "1) To calculate the amount your BG level goes '
         db   'up per gram of carbs take a BG reading before each '
;
;and so on
;

MichaelW

In my test just now I get  "error A2039: line too long" starting at 359 bytes, but I seem to recall that the limit varies somewhat. As Dave demonstrated you can break the string up into individual DB statements, each of which is shorter than the limit. And if you need to size of the entire string, since the SIZEOF operator returns the size for a single statement, you can calculate the size from the value of the location counter.

;==============================================================================
   include \masm32\include\masm32rt.inc
;==============================================================================
   .data
       s db "01234567890123456789012345678901234567890123456789", \
            "01234567890123456789012345678901234567890123456789", \
            "01234567890123456789012345678901234567890123456789", \
            "01234567890123456789012345678901234567890123456789", \
            "01234567890123456789012345678901234567890123456789", \
            "01234567890123456789012345678901234567890123456789", \
            "01234567890123456789012345678901234567890123456789",
            "01234567"
       sz dd $-s
   .code
;==============================================================================
start:
;==============================================================================
   print str$(SIZEOF s),13,10
   print str$(sz),13,10

   inkey "Press any key to exit..."
   exit
;==============================================================================
end start


358
358
eschew obfuscation

dedndave

i think he has too much text to use the "\" method

redskull

Use a resource file.  You get unicode, easy multi-language support, and less cluttered code.  :U

-r
Strange women, lying in ponds, distributing swords, is no basis for a system of government

chipbug

I went with dedndave's suggestion and split it into individual db lines. I didn't know I could do it.

Thanks for your help! Now I feed that into:

        .elseif wParam == 601
            szText lpCaption,"How to use Dave's Dose Calculator"
            invoke MessageBox,0,ADDR lpText,ADDR lpCaption,MB_OK

And I have a help screen for my calculator.

Thanks for the advice!

MichaelW

Quote from: dedndave on May 07, 2011, 08:37:06 PM
i think he has too much text to use the "\" method

Sorry if I was not clear, I was not suggesting that he use that method (although I think it would eliminate the error A2041). I used it for my test, and I posted the code to demonstrate how to get the total length.
eschew obfuscation

dedndave

for message boxes, as well as a few other places (like about dialogs), you can use linefeed only - no cr needed

Vortex

Hi chipbug,

I would suggest you to try Hutch's file data assembler fda.exe It converts any binary file to an MS COFF object module :

\masm32\fda.exe
\masm32\fda2.exe