# Manipulate code creates error messages when file is opened

When I open the file containing the following code I get a series of error messages. Once I evaluate the cell with the code the error messages disappear. What is Mathematica doing when it opens a file, or how can avoid creating this problem for myself in the future?

 econmagic1[ ds_, di_, ss_, si_  ] := (
(* begin equilibrium calculation *)

A = { { 1, - 1 ds }, { 1, - ss } };
CC = Inverse[ A ].{ di, si };

Manipulate[
(* begin grid layout*)
Grid[{

(* begin first row *)
{Show[

(* begin initial supply curve *)

Plot[ ( 1 / ss ) ( x - si ), {x, 0, Part[ CC, 1] },
PlotStyle -> { Red, Dashed },
PlotLegends -> { "Initial Supply Set"}],

(* begin initial demand curve *)

Plot[ ( 1 / ds ) x + (  - di / ds) , {x, 0, di },
PlotStyle -> Dashed,  PlotLegends -> { "Initial Demand Set"} ],

(* begin demand curve *)

Plot[ ( 1 / ds ) ( x - et ) + (  - di / ds) , {x, 0,
di + et},  PlotLegends -> { "Demand Set"} ],

(* begin supply curve *)

Plot[ ( 1 / ss ) ( x - si ), {x, 0,
Part[ Inverse[{ { 1, - 1 ds }, { 1, - ss } } ].{ di + et,
si }, 1 ]}, PlotStyle -> Red,
PlotLegends -> { "Supply Set"}],

(* begin horizontal for equilibrium *)

Plot[Part[
Inverse[{ { 1, - 1 ds }, { 1, - ss } } ].{ di + et, si },
2 ],  {x, 0,
Part[ Inverse[{ { 1, - 1 ds }, { 1, - ss } } ].{ di + et,
si }, 1 ]},  PlotStyle -> { Dashed, Thick } ],

(* begin filling for consumer surplus *)

Plot[{  ( 1 / ds ) ( x - et ) + (  - di / ds),
Part[ Inverse[{ { 1, - 1 ds }, { 1, - ss } } ].{ di + et,
si }, 2 ] }, {x, 0,
Part[ Inverse[{ { 1, - 1 ds }, { 1, - ss } } ].{ di + et,
si }, 1 ]}, Filling -> 1 -> {2},
FillingStyle -> Directive[ Opacity[ 0.1 ], Blue ] ],

(* begin filling for producer surplus *)

Plot[{  Part[
Inverse[{ { 1, - 1 ds }, { 1, - ss } } ].{ di + et, si },
2 ],  ( 1 / ss ) ( x - si ) }, {x, 0,
Part[ Inverse[{ { 1, - 1 ds }, { 1, - ss } } ].{ di + et,
si }, 1 ] }, Filling -> 1 -> {2},
FillingStyle -> Directive[ Opacity[ 0.1 ], Red ] ],

(* begin equilibrium point *)

ListPlot[{ {
Part[ Inverse[{ { 1, - 1 ds }, { 1, - ss } } ].{ di + et,
si }, 1 ],
Part[ Inverse[{ { 1, - 1 ds }, { 1, - ss } } ].{ di + et,
si }, 2 ] } }, PlotStyle -> Black,
PlotLegends -> { "Equilibrium Point" }],

(* begin dashed lines for market equilibrium *)

Graphics[{ Dashed,
Line[{ {
Part[ Inverse[{ { 1, - 1 ds }, { 1, - ss } } ].{ di + et,
si }, 1 ], 0 }, {
Part[ Inverse[{ { 1, - 1 ds }, { 1, - ss } } ].{ di + et,
si }, 1 ],
Part[ Inverse[{ { 1, - 1 ds }, { 1, - ss } } ].{ di + et,
si }, 2 ]}}] }],

AxesOrigin -> { 0, 0 },
PlotRange -> { { 0, di + 10 }, { 0, (  - di / ds) + 10 }},
AxesLabel -> { "Quantity", "Price"}, ImageSize -> Large
]}, (* End Show *)

(* begin second row *)
{ Grid[{

(*
second row first column *)
{"QD Price Intercept:" TraditionalForm[ - ( di + et ) / ds ],

(* second row second column *)

"QD Quantity Intercept:" TraditionalForm[ di + et ] },

(*
third row first column *)
{"QS Price Intercept:" TraditionalForm[ - si / ss ],

(* third row second column *)

"The equilibrium point is:"     TraditionalForm[ {
Part[ Inverse[{ { 1, - 1 ds }, { 1, - ss } } ].{ di + et,
si }, 1 ],
Part[ Inverse[{ { 1, - 1 ds }, { 1, - ss } } ].{ di + et,
si }, 2 ] } ] },

(*  fourth row first column *)
1 / 2 ) ( (- di / ds ) -
Part[ Inverse[{ { 1, - 1 ds }, { 1, - ss } } ].{
di + et, si }, 2 ])  Part[
Inverse[{ { 1, - 1 ds }, { 1, - ss } } ].{ di + et,
si }, 1 ] ],

(* fourth row second column *)

"Producer Surplus:" If[

(*  Does the Supply Curve Intersect the Price Axis *)
( - si / ss ) >= 0,

(*  Supply Curve Intersects Price Axis *)

Part[ Inverse[{ { 1, - 1 ds }, { 1, - ss } } ].{
di + et, si }, 2 ] - ( - si / ss  ) ) (
Part[ Inverse[{ { 1, - 1 ds }, { 1, - ss } } ].{
di + et, si }, 1 ] )],

(* Supply Curve Does Not Intersect Price Axis *)
Inverse[{ { 1, - 1 ds }, { 1, - ss } } ].{ di + et,
si }, 1 ] -  si  ) (
Part[ Inverse[{ { 1, - 1 ds }, { 1, - ss } } ].{
di + et, si }, 2 ] )]

] }
},
Alignment -> Left, Frame -> All, Spacings -> { 4, 1 } ]
}
}, Alignment -> Left],
{ { et, 0 },  -4.5, 25 } ]
)

-
If you indent every line of code by four or more spaces, the formatting of your question would be fixed. Also, you could post the error messages - perhaps these contain vital clues... – cormullion Jan 17 '13 at 12:56
Welcome to Mathematica.SE! It is not unusual for dynamic code to throw messages until evaluated / initialized. – Yves Klett Jan 17 '13 at 13:30
I suspect that at least some of the error messages will go away if the OP adds the option SaveDefinitions -> True to his Manipulate expression. – m_goldberg Jan 17 '13 at 15:36
Please do provide properly formatted code (see comment above) and also an appropriate function call. – Yves Klett Jan 17 '13 at 17:42
I'm learning thanks for the help. – Robert Kennedy Jan 20 '13 at 22:04