I had an array of structs, like this:



Constraints Constraint <offset PartsMustConnectStr,,offset Modeling,offset Magicad,,,,,,,,offset CheckNotConnectedParts,>,
<offset FlowNodesNeedPairStr,,offset Modeling,offset Magicad,,,,,,,,offset CheckFnodesWithDir,>,
<offset WaterPointsNeedSewerStr,,offset Design,offset WaterSeverSystems,offset CommonSense,,,,,,,,>,
<offset _7_3_1_3,,offset Design,offset NationalRegulations,offset Finland,offset SRAKMK,offset C2,,,,,,>


Then i added one more item in to the array and the line too long limitation occured.
So i changed the array to this:



Constraints Constraint <offset PartsMustConnectStr,,offset Modeling,offset Magicad,,,,,,,,offset CheckNotConnectedParts,>
Constraint <offset FlowNodesNeedPairStr,,offset Modeling,offset Magicad,,,,,,,,offset CheckFnodesWithDir,>
Constraint <offset WaterPointsNeedSewerStr,,offset Design,offset WaterSeverSystems,offset CommonSense,,,,,,,,>
Constraint <offset _7_3_1_3,,offset Design,offset NationalRegulations,offset Finland,offset SRAKMK,offset C2,,,,,,>


This introduced another problem, because i already had code that uses "LENGTHOF Constraints",
which will obviously be 1 in the latter case. So i replaced all "LENGTHOF Constraints" entries with
a constant
NUMOFRULES EQU 4

This works, but every time i add an entry to the array, i'll have to change the NUMOFRULES value also, and that feels stupid. Is there any other way around this?
Posted on 2003-11-10 09:56:39 by Janne
You can define the array like this, I have not used yours because it is a bit long to type ;)
rcts	RECT	<0,0,0,0>,

<1,0,0,0>,
<2,0,0,0>,
<3,0,0,0>

SIZEOF rcts will yeild the correct result (64 in this case)

There is a limitation to the number of bytes (440 I think) that you can declare this way.

You can also just do this:

rcts	RECT	<0,0,0,0>

RECT <1,0,0,0>
RECT <2,0,0,0>
RECT <3,0,0,0>
nmb dd ($-rcts)


nmb will be equal to the number of bytes in the array. If you wish to know the number of structures just devide by the size.

rcts	RECT	<0,0,0,0>

RECT <1,0,0,0>
RECT <2,0,0,0>
RECT <3,0,0,0>
nmbrcts dd ($-rcts)/SIZEOF RECT
Posted on 2003-11-10 10:11:49 by donkey
Thanks Donkey,


NUMOFRULES equ ($-Constraints)/SIZEOF Constraint


works perfect.
Posted on 2003-11-10 11:44:42 by Janne