# I/O on Swish

**URL:** <https://swi-prolog.discourse.group/t/i-o-on-swish/4308>\
**Category:** Tools\
**Tags:** swish\
**Created:** [August 18, 2021, 9:15am UTC](https://swi-prolog.discourse.group/t/i-o-on-swish/4308 "2021-08-18T09:15:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![LucaX8](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/lucax8/32/3160_2.png) [@LucaX8](https://swi-prolog.discourse.group/u/LucaX8)\
**Post date:** [August 18, 2021, 9:15am UTC](https://swi-prolog.discourse.group/t/i-o-on-swish/4308/1 "2021-08-18T09:15:27Z")

</div>

I tryed to publish my work on the Swish platform, but all the main procedures require to write the output in a file, but here it’s not allowed.  
This is the latest version of an expert system for automated rule-based generation of music. The program works in time lapsed and produce as output a playable standard MIDI file. If I can’t open an output stream the program is unusable.  
How can I do?

---

<div class="post-metadata">

**Author:** ![EricGT](https://avatars.discourse-cdn.com/v4/letter/e/f1d935/32.png) [@EricGT](https://swi-prolog.discourse.group/u/EricGT)\
**Post date:** [August 18, 2021, 9:36am UTC](https://swi-prolog.discourse.group/t/i-o-on-swish/4308/2 "2021-08-18T09:36:49Z")

</div>

> [@LucaX8](#):
>
> I tryed to publish my work

In a previous [topic](https://swi-prolog.discourse.group/t/music-in-prolog/3466) you made your code available for download. Is this still the same code or similar enough that it represents your problem?

[music\_eng.pl](https://swi-prolog.discourse.group/uploads/short-url/1vBlmU9tj1gIrTebAi1QpiWlH8n.pl) (31,1 KB) ([SWI-Prolog](https://www.swi-prolog.org/pldoc/doc_for?object=manual) 64 bit release 8.0.3)

* * *

As I do not use SWISH other than for checking out existing work published there I can not help.

* * *

Have you considered publishing your work as an SWI-Prolog [pack](https://www.swi-prolog.org/pack/list)?

Note: SWI-Prolog [packs](https://www.swi-prolog.org/pack/list) should not be confused with SWI-Prolog [packages](https://www.swi-prolog.org/pldoc/doc_for?object=packages). Be aware that the wrong word (pack or package) may be used and then the correct word has to be derived from context.

---

<div class="post-metadata">

**Author:** ![LucaX8](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/lucax8/32/3160_2.png) [@LucaX8](https://swi-prolog.discourse.group/u/LucaX8)\
**Post date:** [August 18, 2021, 9:46am UTC](https://swi-prolog.discourse.group/t/i-o-on-swish/4308/3 "2021-08-18T09:46:36Z")

</div>

Yes. My previous code represent the problem, although the current code is much better than the previous one.

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [August 18, 2021, 12:43pm UTC](https://swi-prolog.discourse.group/t/i-o-on-swish/4308/4 "2021-08-18T12:43:57Z")

</div>

Writing to a file won’t help too much as it would end up on the server … SWISH isn’t really designed to generate arbitrary files. It can generate CSV and image files, but that is about it. There may be a way. The idea would be to use its HTML output capabilities and generate a button with a _data URL_ as `href`.

The idea would be to use with\_output\_to/2 to generate a string containing the wiki document and then encode it to form a data url. Not sure it works as-is given the various limitations of SWISH. Would it be enough for you?
