Comments and answers for "Generic writer - set at runtime" https://knowledge.safe.com/questions/5038/generic-writer-set-at-runtime.html The latest comments and answers for the question "Generic writer - set at runtime" Answer by jdh https://knowledge.safe.com/answers/76807/view.html

Yes, if you have a generic reader and expose the fme_basename, fme_format_short_name and fme_basename, then use a FeatureWriter, in the Writer Parameters set the Output Format to fme_format_short_name and the Base filename to fme_basename (unless you want a different output file name, in which case set it to an attribute containing that name)

In the feature type parameters set the Feature Type Name to fme_feature_type, Geometry from Schema Definition, Check off Dynamic Schema, and set the Schema Sources to your generic reader.

If you would like a different Feature Type Name, then set that to whatever attribute contains the name, but the Schema Definition Name must be set to the fme_feature_type.

Tue, 21 Aug 2018 14:56:31 GMT jdh
Comment by geographer https://knowledge.safe.com/comments/76789/view.html Hi All,
is there a way to get the FORMAT from the generic reader and pass it to the generic writer automatically in newer versions of FME somehow?
Tue, 21 Aug 2018 14:37:04 GMT geographer
Comment by takashi https://knowledge.safe.com/comments/16710/view.html 我的话是短缺。< br > @Evaluate仍然伊娃luates Tcl script in FME 2015. But it will return <null> if the result was non-numeric. So you cannot perform any string operation through @Evaluate+Tcl. Thu, 19 Feb 2015 09:00:13 GMT takashi Comment by gio https://knowledge.safe.com/comments/16596/view.html Actually in the Evaluates are to Evaluate the tcl functions. And they do work in for instance a creator or a tester. The tcl bit i posted works exactly as intneded when used in a creator &co. And it does return the extension.

This is not the problem though in the scripted parameter. The problem is it can't reach the parameter "$(SourceDataset_SHAPE)" : "ParamFuncinvoked from within" error

That is what Jonathan is trying to do. Set output filetype to same as inputfiletype.
( i think he has to either use a workspacerunner, or use extension to select one writer using a testfilter wich boils down to basicaly entering writers for all expected possibel filetypes.)

When fme2015 is rolled out here (next week or so; i accepted and tested the instalation) we will see if i can do away with the @Evaluate. But if u use nested tcl bits, u need to use @Evaluate(). At least in and up to fme 2014sp2. Nesting is common practice.

This does not apply however to using tcl in script in a tcl caller; no need for the @Eval there.

So in a start-up i would not need to use the @Evaluate. This is only needed when used in the transformers.

(i do hope i can still use tcl in transformers though...if not that would be a big drawback)
Thu, 19 Feb 2015 08:38:42 GMT gio
Comment by takashi https://knowledge.safe.com/comments/16570/view.html Gio, a Scripted (Tcl) Parameter with this script returns the extension of the source dataset, for example.
-----
return [lindex [split $FME_MacroValues(SourceDataset_GENERIC) {.}] end]
-----

FME Functions such as @Evaluate don't work in a Tcl script.
And also, in FME 2015, the @Evaluate function will not evaluate Tcl script and string expressions no longer. The function is now only for evaluating a math expression.
Thu, 19 Feb 2015 04:50:00 GMT takashi
Comment by gio https://knowledge.safe.com/comments/17381/view.html yes i did try that Takashi, using tcl scripted parameter :

[string range $(SourceDataset_SHAPE) @Evaluate(@Evaluate([string length $(SourceDataset_SHAPE)])- 3) @Evaluate([string length $(SourceDataset_SHAPE)])]
to get the extention and then somehow pass it to set the "$(GENERIC_OUT_FORMAT_GENERIC)" parameter.

..but all attemtps ended in "ParamFuncinvoked from within" error.


Maybe a startUp script to set it?
Wed, 18 Feb 2015 17:30:25 GMT gio
Comment by gio https://knowledge.safe.com/comments/15709/view.html 啊,我认为你必须阅读扩展到美元(GENERIC_OUT_FORMAT_GENERIC) using a script.

I think a start-up script would do.

I tried creating a tcl to do that in a scripted parameter, but run into "ParamFuncinvoked from within" error.
Wed, 18 Feb 2015 17:13:06 GMT gio
Comment by takashi https://knowledge.safe.com/comments/15150/view.html Hi Jonathan,

Just an idea.
If the input format could be determined by the file extention of specified source dataset, it might be possible to define a scripted parameter that returns appropriate output format name based on the input format.

Takashi
Wed, 18 Feb 2015 16:44:03 GMT takashi
Comment by jonathan https://knowledge.safe.com/comments/15335/view.html Gio - Sorry, that's not what I want to do. What I want is to be able to set the output format itself.

David - Ok. It seems odd that it's not possible as it's a simple use-case.
Thanks
Wed, 18 Feb 2015 15:54:37 GMT jonathan
Comment by david_r https://knowledge.safe.com/comments/17382/view.html Hi,

I not think it is possible to set the Generic writer format at run-time. Your closest bet is using a published or private parameter (those are evaluated just before run-time).

David
Wed, 18 Feb 2015 15:45:23 GMT david_r
Comment by gio https://knowledge.safe.com/comments/17357/view.html I used tst as filename, but you can make this a parameter as well of course.
AttributeCreator becomes:
outformat =
$(DestDataset_GENERIC)$(FileOut).$(GENERIC_OUT_FORMAT_GENERIC)
Wed, 18 Feb 2015 15:40:37 GMT gio
Comment by jonathan https://knowledge.safe.com/comments/15724/view.html I'm afraid not. I don't want to set it via a parameter because I don't want the user to have to set it. It'd be easy if I could do that. :-) Wed, 18 Feb 2015 15:25:57 GMT jonathan Comment by gio https://knowledge.safe.com/comments/16857/view.html User-added image

This works.
Any help?

Greetzz.
Wed, 18 Feb 2015 15:22:12 GMT gio