# Using Output buffer S later in same Script

**URL:** https://community.mp3tag.de/t/using-output-buffer-s-later-in-same-script/62238
**Category:** Web Sources Discussion
**Created:** [September 28, 2023, 7:09pm UTC](https://community.mp3tag.de/t/using-output-buffer-s-later-in-same-script/62238 "2023-09-28T19:09:29Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![bugzero](https://community.mp3tag.de/user_avatar/community.mp3tag.de/bugzero/32/10350_2.png) [@bugzero](https://community.mp3tag.de/u/bugzero)
#### Post date: [September 28, 2023, 7:09pm UTC](https://community.mp3tag.de/t/using-output-buffer-s-later-in-same-script/62238/1 "2023-09-28T19:09:29Z")

</div>

Although I've seen similar but not same Topics:

> [@Variables in Source Scripts](https://community.mp3tag.de/t/variables-in-source-scripts/51644):
>
> Is there a way to set a variable in a source script so that when an include file is called the variable can either be evaluated (ie T/F) or written to a tag (ie itunes country searched = and language=)? some psudeo code: %country%="us" %language%="gb\_en" ... call include file output to "COUNTRY" If %country tag% does not exist say %country% End If output to "SUPPORTED LANGS" append %language% to "SUPPORTED LANGS" Thanks

and

> [@Use existing tag data in script](https://community.mp3tag.de/t/use-existing-tag-data-in-script/61745):
>
> Hey all, I was looking for some advice on how to do a thing. I was trying to build a script for [TMDB.org](http://TMDB.org) that would pull TV episode info and ran into a snag since all the info is down behind season and episode subdirectories. I know there should be a way to have the script grab the season and episode numbers from the existing tag, but I can't seem to find it in the documentation. f someone could direct me to the right part of the documentation or has some advice that would be great.

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:

```js
{
  ...
  "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:

```auto
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.

---

<div class="post-metadata">

### Author: ![Florian](https://community.mp3tag.de/user_avatar/community.mp3tag.de/florian/32/5759_2.png) [@Florian](https://community.mp3tag.de/u/Florian)
#### Post date: [October 13, 2023, 7:06pm UTC](https://community.mp3tag.de/t/using-output-buffer-s-later-in-same-script/62238/2 "2023-10-13T19:06:25Z")

</div>

I've added the option to reference contents of output buffers via `%output%` in string parameters of functions with [Mp3tag v3.22e](https://community.mp3tag.de/t/455).

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

---

<div class="post-metadata">

### Author: ![bugzero](https://community.mp3tag.de/user_avatar/community.mp3tag.de/bugzero/32/10350_2.png) [@bugzero](https://community.mp3tag.de/u/bugzero)
#### Post date: [October 26, 2023, 7:51pm UTC](https://community.mp3tag.de/t/using-output-buffer-s-later-in-same-script/62238/3 "2023-10-26T19:51:27Z")

</div>

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.
