Jump to content
Developer Wiki and Function Reference Links ×

Old MiniCad script


Recommended Posts

I get this error message:

"Error: TIPO_E_AREA N - String index or count must be from 1 to 255"

When I run this script:

{Selecione um objeto 2D e use o comando - Select a 2D object and run the

command}

Procedure Tipo_e_Area;

VAR

Shape: HANDLE;

Center,Area1,X,Y: REAL;

Area,Comodo: STRING;

n: INTEGER;

BEGIN

Shape := Nil;

Shape:= FSActLayer;

IF Shape <> NIL THEN BEGIN

Area1:= HArea(Shape)/10000;

Area:= Num2Str(2, Area1);

n := Pos('.', Area);

Delete(Area, n, 1);

Insert(',', Area, n);

HCenter(Shape,X,Y);

Comodo:= StrDialog('Nome do Comodo or Room name','Quarto');

IF NOT DidCancel THEN BEGIN

PushAttrs;

TextJust(2);

TextVerticalAlign(2);

TextSize(9);

TextOrigin(X,Y);

TextSize(12);

FillPat(0);

BeginText;

ConCat(Comodo, Chr(13), Area, ' m2')

EndText;

PopAttrs;

DSelectAll;

END;

END ELSE AlrtDialog('Select a solid 2D shape and try again.');

END;

Run(Tipo_e_Area);"

What am I doing wrong?

Link to comment

Your script runs O.K. in version 12.5. I do not have v.2008 to test it, but it appears that you variable n is not being assigned a value between 1 and 255 which would be needed for the Insert or Delete calls. Pos('.',Area); is probably returning a zero.

I know that the HArea function is obsolete as of v.12.5. Perhaps this is the problem?

Link to comment

I think it has to do something about the ".", it needs to be a ",".

Try this one, and see what you get in the message, if it's a ",", then you need to change it in your script:

Procedure Tipo_e_Area;

VAR

Shape: HANDLE;

Center,Area1,X,Y: REAL;

Area,Comodo: STRING;

n: INTEGER;

BEGIN

Shape := Nil;

Shape:= FSActLayer;

IF Shape <> NIL THEN BEGIN

Area1:= HArea(Shape)/10000;

Area:= Num2Str(2, Area1);

message(Area);

{

n := Pos(',', Area);

Delete(Area, n, 1);

Insert('.', Area, n);

}

HCenter(Shape,X,Y);

Comodo:= StrDialog('Nome do Comodo or Room name','Quarto');

IF NOT DidCancel THEN BEGIN

PushAttrs;

TextJust(2);

TextVerticalAlign(2);

TextSize(9);

TextOrigin(X,Y);

TextSize(12);

FillPat(0);

BeginText;

ConCat(Comodo, Chr(13), Area, ' m2')

EndText;

PopAttrs;

DSelectAll;

END;

END ELSE AlrtDialog('Select a solid 2D shape and try again.');

END;

Run(Tipo_e_Area);

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...