Page 1 of 1

0.9.0.4, Generate text file, functions not working

Posted: Wed Jun 06, 2018 4:17 pm
by kibi
Hi, Steinar!
I tried to use functions in "Generate text node" template without success. Maybe it's not implemented yet?
I need to replace (escape) "\" with "\\" in order to generate valid JSON. Here is the test template:

Code: Select all

{
   "source_avs": "$replace(%s_original_full%, "\","\\")",
   "target_video": "F:\\Pipeline\\U-$replace(%s_original_name%,"\","\\").mp4",
   "frame_size": "%i_width%x%i_height%",
   "duration": %f_duration%,
   "error_message": "OK",
   "error_code": 200
}
And the resulting text:

Code: Select all

{
   "source_avs": "$replace(F:\Pipeline\In-AviSynth\UTV\TEST_203732370.avs, "\","\\")",
   "target_video": "F:\\Pipeline\\U-$replace(TEST_203732370,"\","\\").mp4",
   "frame_size": "768x576",
   "duration": 119.36,
   "error_message": "OK",
   "error_code": 200
}
What do you think?

Re: 0.9.0.4, Generate text file, functions not working

Posted: Wed Jun 06, 2018 8:40 pm
by admin
I think it's not a bug, it's just not a feature either. Functions are only supported in the "Conditional" and "Populate variables" nodes. That's why you see an "F" button on only those nodes. So you need to create your own user variables that should be populated with the processed strings you need in your json file. F.ex. in the "Populate variables" node:

%s_my_string% = $replace(%s_original_full%, "\","\\")

Then your json should look like:
{
"source_avs": "%s_my_string%",

...

-steinar

Re: 0.9.0.4, Generate text file, functions not working

Posted: Thu Jun 21, 2018 11:09 am
by kibi
Thanks for the workaround!

Just a note: the populate variable expression should be with quotes around %s_original_full%, or else it generates wrong result:

Code: Select all

%s_my_string% = $replace("%s_original_full%", "\","\\")

Re: 0.9.0.4, Generate text file, functions not working

Posted: Thu Jun 21, 2018 4:46 pm
by admin
Yes of course. My mistake ;-)

-steinar