Re: MathLink Q: Not working anymore!!

*To*: mathgroup at smc.vnet.net*Subject*: [mg3280] Re: MathLink Q: Not working anymore!!*From*: wagner at bullwinkle.cs.Colorado.EDU (Dave Wagner)*Date*: Fri, 23 Feb 1996 02:12:36 -0500*Organization*: University of Colorado, Boulder*Sender*: owner-wri-mathgroup at wolfram.com

In article <4gbvpc$mqo at dragonfly.wolfram.com>, Chang-Hyeon Song <song at cs.purdue.edu> wrote: >---------------- >:Begin: >:Function: m2c >:Pattern: M2C[exp_] >:Arguments: {exp} >:ArgumentTypes: {Manual} >:ReturnType: Manual >:End: >:Evaluate: Attributes[M2C] = {HoldAll} >----------- > >??M2C says > >---------------- >M2C[exp] will convert given mathematica an expression or > a compound expression into a correspoding C program > >Attributes[M2C] = {HoldAll} > >M2C[exp_] := > ExternalCall[LinkObject["m2c", 2, 2], > CallPacket[0, {exp}]] > >----------------- > >Putting the Evalauate line in different line doesn't make any difference. >Can anybody help? First of all, the SetAttributes command should precede the definition of the function. This doesn't always matter, but sometimes it does. Second, even with the HoldAll attributes, "exp" is being evaluated when the body of M2C is evaluated. Try re-defining M2C as: ClearAll[M2C] SetAttributes[M2C, HoldAll] M2C[exp_] := ExternalCall[LinkObject[.....], CallPacket[0, {Unevaluated[exp]}]] This ought to work, but you don't want to have to do that every time you load the package. Try using the following line in your template file: :Arguments: {Unevaluated[exp]} I'd be curious to know if that causes mprep to generate the correct code or not. Dave Wagner Principia Consulting (303) 786-8371 dbwagner at princon.com http://www.princon.com/princon ==== [MESSAGE SEPARATOR] ====