home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 9 / 09.iso / e / e031 / 3.ddi / MATHZIP2 / STARTUP / OBSOLETE.M < prev    next >
Encoding:
Text File  |  1991-09-23  |  7.3 KB  |  237 lines

  1.  
  2. (* Obsolete.m *)
  3. (* Generate warning messages and install certain functionality *)
  4. (* for symbols which are obsolete or superseded with this version. *)
  5.  
  6. Begin["System`"]
  7.  
  8. Unprotect[Message]
  9.  
  10. General::obsopt = "`1` is an obsolete graphics option, superseded by `2`."
  11.  
  12. ContourLevels::usage =
  13. "ContourLevels is an obsolete graphics option, superseded by Contours."
  14. Message[_, HoldForm[ContourLevels], _] :=
  15.     Message[ContourLevels::obsopt, ContourLevels, Contours]
  16.  
  17. ContourSpacing::usage =
  18. "ContourSpacing is an obsolete graphics option, superseded by Contours."
  19. Message[_, HoldForm[ContourSpacing], _] :=
  20.     Message[ContourSpacing::obsopt, ContourSpacing, Contours]
  21.  
  22. PlotColor::usage =
  23. "PlotColor is an obsolete graphics option, superseded by ColorOutput."
  24. Message[_, HoldForm[PlotColor], _] :=
  25.     Message[PlotColor::obsopt, PlotColor, ColorOutput]
  26.  
  27. Framed::usage =
  28. "Framed is an obsolete graphics option, superseded by Frame."
  29. Message[_, HoldForm[Framed], _] :=
  30.     Message[Framed::obsopt, Framed, Frame]
  31.  
  32. Plot3Matrix::usage =
  33. "Plot3Matrix is an obsolete graphics option, superseded by
  34. ViewCenter and ViewVertical."
  35. Message[_, HoldForm[Plot3Matrix], _] :=
  36.     Message[Plot3Matrix::obsopt, Plot3Matrix, {ViewCenter, ViewVertical}]
  37.  
  38. Protect[Message]
  39.  
  40. General::obsfn = "`1` is an obsolete function, superseded by `2`."
  41.  
  42. Unprotect[Accumulate]
  43. Accumulate::usage =
  44. "Accumulate is an obsolete function, superseded by FoldList.\n
  45. Accumulate[f, g[e1, e2, ...]] gives g[e1, f[e1, e2], f[f[e1, e2], e3], ...]."
  46. Begin["Obsolete`"]
  47. Accumulate[x___] :=
  48.     With[{result = oAccumulate[x]}, result /; result =!= $Failed]
  49. oAccumulate[x___] := Module[{f,g,len=Length[{x}], result},
  50.     Message[Accumulate::obsfn, Accumulate, FoldList];
  51.     Return[$Failed]; (* remove this line if the internal code is removed *)
  52.     Which[
  53.         len === 2,
  54.             {f, g} = {x};
  55.             Which[
  56.                 Length[g] > 0,
  57.                     result = Hold[Evaluate[FoldList[f, First[g], Rest[g]]]];
  58.                     If[result[[1,0]]===FoldList, $Failed, result[[1]]],
  59.                 MemberQ[{Symbol,Real,Complex,Integer,String}, Head[g]],
  60.                     Message[Accumulate::accnorm, g]; $Failed,
  61.                 True, g
  62.             ],
  63.         len === 1,
  64.             Message[Accumulate::argr, Accumulate, 2]; $Failed,
  65.         True,
  66.             Message[Accumulate::argrx, Accumulate, len, 2]; $Failed
  67.     ]
  68. ]
  69. Accumulate::accnorm = "Argument `1` should be a normal expression."
  70. End[]
  71. Protect[Accumulate]
  72.  
  73. Unprotect[Alias]
  74. Alias::usage =
  75. "Alias is an obsolete function, superseded by $Pre and $PreRead."
  76. Alias[___] := $Failed /;
  77.     (If[!$Remote, Message[Alias::obsfn, Alias, {$Pre, $PreRead}]]; False)
  78. Protect[Alias]
  79.  
  80. (* CellArray *)
  81. Unprotect[CellArray]
  82. CellArray::usage =
  83. "CellArray[{{a11, a12, ...}, ...}] is a two-dimensional graphics
  84.  primitive which represents a rectangular array of gray cells."
  85.  
  86. Begin["Obsolete`"]
  87.  
  88. CellArray[x_] :=
  89. (Message[CellArray::obsfn, CellArray, {Raster, RasterArray}];
  90. Raster[x, {{0,0}, {1,1}}])
  91.  
  92. CellArray[x___] :=
  93. (Message[CellArray::obsfn, CellArray, {Raster, RasterArray}]; Raster[x])
  94.  
  95. SetAttributes[ CellArray, {Protected, ReadProtected}]
  96.  
  97. End[]
  98.  
  99. Protect[CellArray]
  100.  
  101. Unprotect[Compose]
  102. Compose::usage =
  103. "Compose is an obsolete function, superseded by Composition.\n
  104. Compose[a,b,c,d] gives a[b[c[d]]]."
  105. Compose[___] := $Failed /; Message[Compose::obsfn, Compose, Composition]
  106. Protect[Compose]
  107.  
  108. Unprotect[Debug]
  109. Debug[___] := $Failed /; (Message[Debug::obsfn, Debug, Trace]; False)
  110. Protect[Debug]
  111.  
  112. Unprotect[DownValue]
  113. Attributes[DownValue] = HoldAll
  114. DownValue::usage =
  115. "DownValue is an obsolete function, superseded by DownValues.\n
  116. DownValues[f] gives a list of transformation rules corresponding to all
  117. downvalues (values for f[x,..], etc.) defined for the symbol f."
  118. Begin["Obsolete`"]
  119. DownValue[args___] := (
  120.     Message[DownValue::obsfn, DownValue, DownValues];
  121.     DownValues[args] )
  122. End[]
  123. Protect[DownValue]
  124.  
  125. (* FontForm *)
  126. Unprotect[FontForm]
  127.  
  128. FontForm::obsff =
  129. "FontForm[expr, font, size] is an obsolete use of FontForm, \
  130. superseded by FontForm[expr, {font, size}]." 
  131.  
  132. Begin["Obsolete`"]
  133.  
  134. FontForm[ expr_, font_String, size_] :=
  135. (Message[FontForm::obsff]; FontForm[ expr, {font, size}])
  136.  
  137. SetAttributes[ FontForm, {Protected, ReadProtected}]
  138.  
  139. End[]
  140.  
  141. Protect[ FontForm]
  142.  
  143. Unprotect[ Axes]
  144.  
  145. Axes::obaxes = "This is an obsolete use of Axes, superseded by AxesOrigin."
  146.  
  147. Begin["Obsolete`"]
  148.  
  149. Axes /:
  150. Axes -> {x_,y_} /; ((NumberQ[x] && NumberQ[y]) && (Message[Axes::obaxes]; True)) :=
  151. Sequence[ Axes -> Automatic, AxesOrigin -> {x,y}]
  152.  
  153. Axes /:
  154. Axes -> {x_,y_} /; ((NumberQ[x] && ! NumberQ[y]) && (Message[Axes::obaxes]; True)) :=
  155. Sequence[ Axes -> {Automatic,y} , AxesOrigin -> {x,y}]
  156.  
  157. Axes /:
  158. Axes -> {x_,y_} /; ((!NumberQ[x] && NumberQ[y]) && (Message[Axes::obaxes]; True)) :=
  159. Sequence[ Axes -> {x,Automatic}, AxesOrigin -> {x,y}]
  160.  
  161. End[]
  162.  
  163. Protect[ Axes]
  164.  
  165. Unprotect[FromASCII]
  166. FromASCII::usage =
  167. "FromASCII is an obsolete function, superseded by FromCharacterCode.\n
  168. FromASCII[\"c\"] gives the ASCII integer code corresponding to the character c."
  169. Begin["Obsolete`"] 
  170. FromASCII[x___] := With[{result = oFromASCII[x]}, result /; result =!= $Failed]
  171. oFromASCII[x___] := (
  172.     Message[FromASCII::obsfn, FromASCII, FromCharacterCode];
  173.     If[Length[{x}] === 1,
  174.         If[IntegerQ[x] && 0 <= x && x <= 255,
  175.             Check[FromCharacterCode[x], $Failed], 
  176.             Message[FromASCII::fromascii, x]; $Failed
  177.         ],  
  178.         Message[FromASCII::argx, FromASCII, Length[{x}]]; $Failed,
  179.     ])
  180. FromASCII::fromascii =
  181. "Argument `1` is not an 8-bit ASCII code (integer in the range 0 to 255)."
  182. End[]
  183. Protect[FromASCII]
  184.  
  185. Unprotect[ToASCII]
  186. ToASCII::usage =
  187. "ToASCII is an obsolete function, superseded by ToCharacterCode.\n
  188. ToASCII[\"c\"] gives the ASCII integer code corresponding to the character c."
  189. Begin["Obsolete`"] 
  190. ToASCII[x___] := With[{result = oToASCII[x]}, result /; result =!= $Failed]
  191. oToASCII[x___] := (
  192.     Message[ToASCII::obsfn, ToASCII, ToCharacterCode];
  193.     If[Length[{x}] === 1,
  194.         If[StringLength[x] === 1,
  195.             Check[First[ToCharacterCode[x]], $Failed],
  196.             Message[ToASCII::toascii, x]; $Failed
  197.         ],
  198.         Message[ToASCII::argx, ToASCII, Length[{x}]]; $Failed,
  199.     ])   
  200. ToASCII::toascii = "Argument `1` is not a single-character string." 
  201. End[]
  202. Protect[ToASCII]
  203.  
  204. (*
  205. Release is an obsolete function.
  206. Messages for Release can be found in msg.m.
  207. *)
  208.  
  209. Unprotect[ResetMedium]
  210. ResetMedium[___] := $Failed /;
  211.     (If[!$Remote, Message[ResetMedium::obsfn, ResetMedium, SetOptions]]; False)
  212. Protect[ResetMedium]
  213.  
  214. Unprotect[StartProcess]
  215. StartProcess[___] :=
  216.     $Failed /; (Message[StartProcess::obsfn, StartProcess,"MathLink"]; False)
  217. Protect[StartProcess]
  218.  
  219. Unprotect[CallProcess]
  220. CallProcess[___] :=
  221.     $Failed /; (Message[CallProcess::obsfn, CallProcess, "MathLink"]; False)
  222. Protect[CallProcess]
  223.  
  224. Unprotect[EndProcess]
  225. EndProcess[___] :=
  226.     $Failed /; (Message[EndProcess::obsfn, EndProcess, "MathLink"]; False)
  227. Protect[EndProcess]
  228.  
  229. Unprotect[$$Media]
  230. $$Media::usage = $$Media::obsym =
  231. "$$Media is an obsolete symbol, superseded by Streams[ ]."
  232. $$Media := (Message[$$Media::obsym]; Streams[])
  233. Protect[$$Media]
  234.  
  235. End[]
  236.  
  237.