Jump to content
UBot Underground

How to Create Text from a List


Recommended Posts

Hello All,

 

Okay...I'm trying to take a list of items and format them into spin ready format.

 

So if for example the list was...

 

blue

red

green

yellow

 

 

I'm trying to have it take the list, put everything on one line, separated by pipes with brackets at beginning and end. So final output would look like this

 

{blue|red|green|yellow}

 

Currently I'm creating a list from a file that contain all the words. But that's as far as I can get. I'm not sure how to have it write each element to a line as well as place the pipes and brackets.

 

Anyone have any ideas?

 

Thanks!

Link to post
Share on other sites

read file to list

set #str = {

loop listotal

set #item to nextListItem

set #str = #str|

 

after loop use javascript (lib_string) to return a substring of #str (0, length -1), so you remove the last |

set #str = #str}

 

 

Thanks for your reply. The above code is a bit beyond me but I tried to use it as far as I could... I've attached the bot I created minus the java portion as I know nothing about javascript.

I am getting an output of a list without any {'s or |'s. Sorry for my ignorance...

 

Obviously this bot is set to open a file on my system...that would have be be changed with your own...

joiner.ubot

Link to post
Share on other sites

This should do it.

 

If your .txt file doesn't end in a "new line"

your text might be missing the last character

since it's replacing "new line" with "|"

 

In this case just remove the node with the

javascript that strips the last character.

 

Have fun

spin text.ubot

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...