Skip to main content
Question

String concatenator not writing correct string


bubblebeb
Contributor
Forum|alt.badge.img+6

I am using a string concatenator to
write batch files for me.

I am entering a windows path in the string concatenator (see
below).

%SendKeys% "E:\FME\Development Work\Timesheet
Analysis\Output\@Value(HomeTeamFP)\@Value(Name) @Value(DateFrom) to @Value(DateTo){ENTER}"

But the string it writes out is 

%SendKeys"E:\FME\Development Work\Timesheet
Analysis/Output\RUR370\Amy Hutsby 2018-01-01 to 2018-01-31{ENTER}"

I.e. it changes to ...Analysis\Output... to
...Analysis/Output... 

This then leads the batchfile to fail to work. 

It has happened several times and I dont know what is
causing it or how to fix it. 

Any ideas from anyone? 

Thanks

3 replies

davideagle
Contributor
Forum|alt.badge.img+21
  • Contributor
  • February 9, 2018

Hi Seb, An absolute hack is to follow it with a StringReplacer that swaps / to \\, it's a hack that solves the problem short term. Slashes are definitely a challenge frequently and its because they are a bit "special" especially as they sometimes need to be reversed for Linux. I suspect someone else has a much more slid explanation of why this might be happening though.


bubblebeb
Contributor
Forum|alt.badge.img+6
  • Author
  • Contributor
  • February 9, 2018
davideagle wrote:

Hi Seb, An absolute hack is to follow it with a StringReplacer that swaps / to \\, it's a hack that solves the problem short term. Slashes are definitely a challenge frequently and its because they are a bit "special" especially as they sometimes need to be reversed for Linux. I suspect someone else has a much more slid explanation of why this might be happening though.

Thanks Dave. I hadnt thought of that. Good short term fix.

 

Cheers

 

 

 


Forum|alt.badge.img
  • February 10, 2018

I tend not to use string transformers as I use python callers

HomeTeamFP = feature.getAttribute('HomeTeamFP')
DateFrom= feature.getAttribute('DateFrom')
DateTo= feature.getAttribute('DateTo')

#or if parameter 
Name = FME_MacroValues['Name']

fullstring = '%SendKeys% "E:\FME\Development Work\TimesheetAnalysis\Output\{}\{} {} to {}{{ENTER}}"'.format(HomeTeamFP,Name,DateFrom,DateFrom)

feature.setAttribute('BatFile',fullstring)

could in fact write the bat files in python too


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings