0.9.0.4, Generate text file, functions not working

Here you can submit bugreports
Post Reply
User avatar
kibi
Posts: 106
Joined: Mon Feb 29, 2016 12:57 pm
Contact:

0.9.0.4, Generate text file, functions not working

Post 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?
Alexander Sorkin
admin
Site Admin
Posts: 1680
Joined: Sat Feb 08, 2014 10:39 pm

Re: 0.9.0.4, Generate text file, functions not working

Post 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
User avatar
kibi
Posts: 106
Joined: Mon Feb 29, 2016 12:57 pm
Contact:

Re: 0.9.0.4, Generate text file, functions not working

Post 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%", "\","\\")
Alexander Sorkin
admin
Site Admin
Posts: 1680
Joined: Sat Feb 08, 2014 10:39 pm

Re: 0.9.0.4, Generate text file, functions not working

Post by admin »

Yes of course. My mistake ;-)

-steinar
Post Reply