EduardoS Posted June 12, 2008 Share Posted June 12, 2008 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? Quote Link to comment
PeterT Posted June 12, 2008 Share Posted June 12, 2008 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? Quote Link to comment
EduardoS Posted June 12, 2008 Author Share Posted June 12, 2008 I'm using version 12.5. I changed the HArea to ObjArea and still have the same error. Can it be cause by units? The Area1:= HArea(Shape)/10000 to change the value from square centimeters to meters? Quote Link to comment
maarten. Posted June 13, 2008 Share Posted June 13, 2008 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); Quote Link to comment
EduardoS Posted June 13, 2008 Author Share Posted June 13, 2008 It works just fine. Thanks a lot!!! Quote Link to comment
Recommended Posts
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.