Using Output buffer S later in same Script

Although I've seen similar but not same Topics:

and

I would like to ask for what I think is a new feature that may be useful for me and for others.

Sometimes we need to get some information from the source and use the value as we continue analysing the rest of the source.

Here is the partial example of a JSON:

{
  ...
  "songid": 8526743,
  ...
  "entities" : {      # not an array
    "7680981" : { ...},
    "8526743" : { "some": "data", "to" : "read"  },
    "8526876" : { ... },
    ...
    },
  ...
}

In the previous JSON we need to read the Song ID from the key 'songid', as a text, and use it to access an object named as the same id, inside 'entities' object.

The script could be something like this:

outputto  "TEMP_SongId"
json_select "songid"
sayrest

...  # Later in the same script

json_select_object "entities"
json_select_object $TEMP_SongId$    # maybe using a dollar sign to identify 
                                    # the contents of a tag value?

# Or It could be used also to check a value
json_select "songid"
If $TEMP_SongId$
   # Correct value
EndIf

It is just an idea.

I've added the option to reference contents of output buffers via %output% in string parameters of functions with Mp3tag v3.22e.

This is very experimental and needs testing. It would be great if you could try the new functionality and give feedback.

Thanks Florian.

I've just tested json_select_object %S% and it works as expected.
I've published a new beta version of my script.

Great work.

1 Like