2016년 11월 16일 수요일

Making the lines in a multiline text box the text in a list of buttons


I have three buttons, call them A, B, and C (their current text is nothing) a button (call it ADD) and a multiline text box OR every item in a comma separated list (1,2,3, etc). This is what I want:
When I press button ADD that buttons A, B, and C take the name of the lines in the list :
1
2
3

(or 1,2,3 if CSV)

So that button A is renamed 1, B = 2 and C = 3. 

Possible? Been sitting all afternoon.


-- 
It would really help if you provided a screenshot of your relevant blocks, so we can see what you are trying to do, and where the problem may be.

Taifun



So, what I'm trying to do is this:

1: When I add something (ONE LINE) in the text box, then press ADD, the first button gets that text. Second time (ONE LINE), the second button gets the text and the third time (again, one line) the third button gets the text. It works until the third button. What am I doing wrong? Is there an easier way?

2. If I copy MULTIPLE (3) lines in the textbox and press ADD I want the lines to get the text from the different lines. So if the textbox has the text:
1
2
3

If I then click ADD, I want the buttons to get the numbers 1, 2 and 3 in order. Do you understand?
 blocks.png
attached file: Texttobutton.aia


-- 
Change your 1,2,3 or 1\n2\n3 into a list by using a split block.
set buttonA.Text to select item 1 from list x
set buttonB.Text to select item 2 from list x
set buttonC.Text to select item 3 from list x

See Books and Tutorial section of this FAQ:

ABG


-- 
Can you please help me once more? I am a total beginner. So, I managed to do this: When ADD.longclick set button A,B,C text to a,b,c respectively (see picture)

What I have no clue about how to do is to make a new list x from the textbox with , or \n and select the index from the list. 
 blocks.png


-- 
See the How to Work with Lists section of the FAQ I mentioned.
ABG


--

Thanks! That was really helpful.

 So I've come this far now, any help would is appreciated. I still don't know how to make the split block list, can't find anything in the tutorials and I don't understand the built in help. See attached files.
 block(1).png
 Skärmbild_2016-11-17_06-52-16.png


attached file: Testtobutton.aia


--
use Do it to debug your blocks, see tip 4 here

it seems to be, you are working with a list of lists instead of a simple list
each bracket pair represents a list...


Taifun

-- 
Thank you for the DoIt help and I'm sorry for making another thread.

From the PDF you provided I got some answers. I still can't figure out how to make the multiline text different items in the list, but maybe someday I will.


-- 
you might want to provide a new screenshot of your relevant blocks including Do it results 
and a short description of the issue: how the result currently is and how it should be

Taifun


-- 
See attached for how to do the split.
You were wrapping the list that came out of the split block with an extra layer of list wrapping, that threw off the selects.

The Line Feed character is \n and you can do the same split as you did on a comma on a Line Feed to get a list.

ABG

-- 
See attached for how to do the split.
You were wrapping the list that came out of the split block with an extra layer of list wrapping, that threw off the selects.

The Line Feed character is \n and you can do the same split as you did on a comma on a Line Feed to get a list.

ABG

Skärmbild_2016-11-17_06-52-16.png 표시 중



-- 
Thank you sooo much, it works!


-- 
Is there any way I can have both , and \n? If I have both, neither work.


-- 
Is there any way I can have both , and \n? If I have both, neither work

There's a text block that can replace all \n with commas.
But think of a way to control your input better, so you don't have to deal with both.

On the other hand, is it possible you are being presented with a table when you get both , and \n ?
 If so, look at the csv-to-table block to turn it into a list of lists, if that's what is the shape of your data.

Maybe show us what the data looks like?

ABG


-- 
The app is supposed to be a grocery list, where the user puts a list of his/her groceries in the text box and the it generates buttons with each of the item as text. As I can't know if the user separates the items with commas or a new line, I want the option to be both :)

-- 
Use the replace all text block to change the Newlines to commas,
and run it thru a split at commas.

ABG

-- 
Oh, that's smart. Let me try!

--

댓글 없음:

댓글 쓰기