Re: Using Mathematica to create body of switch() statement



On Jun 6, 3:49 pm, Robert Buchanan <j.robert.bucha...@xxxxxxxxxxx>
wrote:
Hello,

I am writing some MathLink routines, which make use of some switch
statements in C which have a lot of cases. I have written a function
in Mathematica which automatically generates the lines in the body of
the switch statement. I thought I would use Splice[] to have
Mathematica insert those lines into the appropriate C source file. My
first naive attempt had my Mathematica function loop through a bunch
of Print[] statements, but Splice[] places Null in the C file since
the output of Print[] is Null. I could create a long string of the
case statements for the switch body, but then Splice[] would include
them in the C file as a literal string.

If you have managed to use Splice[] or some other technique to insert
Mathematica-generated C language statements  into a C source code
file, please outline the procedure for doing so.

Thanks,
Bob Buchanan

If you can create strings, I would do that and then use

Splice[sourcefile, FormatType -> OutputForm]

...to prevent the string marks being inserted into the target file.
.



Relevant Pages

  • Re: Using Mathematica to create body of switch() statement
    ... Robert Buchanan schrieb: ... I am writing some MathLink routines, which make use of some switch ... I thought I would use Splice[] to have ... Mathematica insert those lines into the appropriate C source file. ...
    (sci.math.symbolic)
  • Re: Using Mathematica to create body of switch() statement
    ... Robert Buchanan wrote: ... I am writing some MathLink routines, which make use of some switch ... I thought I would use Splice[] to have ... Mathematica insert those lines into the appropriate C source file. ...
    (sci.math.symbolic)
  • Using Mathematica to create body of switch() statement
    ... I am writing some MathLink routines, which make use of some switch ... I thought I would use Splice[] to have ... Mathematica insert those lines into the appropriate C source file. ... them in the C file as a literal string. ...
    (sci.math.symbolic)
  • Re: Change Text to Memo
    ... Switch a given table field to Memo ... Function SwitchFieldType(sDb As String, sTableName As String, sFieldName ... Dim sSQL As String ... If Err.Number = 0 Then Exit Function ...
    (microsoft.public.access.modulesdaovba)
  • Re: proposal: reswitch
    ... > which levels of loops and/or switches and/or ... socket -server command ?-myaddr addr? ... You've got the quick-exit (break, no string), the fall-through to next ... -switch option), then it'd be the nth switch. ...
    (comp.lang.tcl)