Help needed with form panels

Hello there!
I hope I'm botering nobody with this. But I tried myself out in coding a game. Now am I coding the chat input box.
I think I'm finished with this, though there are a lot of errors sadly. I have looked at the settings example send, and at another code, and combined it basically.
I would like to ask for help in that matter. I have been coding yesterday so much that my head did hurt - and that literally - :grinning:
I'll paste the code below, and I hope anyone could give me some tips. It's really difficult for me to understand the subforms and panels right now.

void chat_dialog()
{
	audio_form message;
	message.create_window("message",false,false,true);
	int message2=message.create_input_box("&Enter your message","","",5000,false,true,true);
	int send=message.create_button("&Send message",true,false,true);
	audio_form buffers;
	buffers.create_window("Reading through your buffers (every list showing the latest 10000 items)",false,false,false);
	int all=buffers.create_list("All &buffers",10000,false,false);
	int chats=buffers.create_list("&Chats",10000,false,false);
	for(uint i = 0; i < all.length(); i++) buffers.add_list_item(all,all[i]+" "+(i+1)+" of "+(all.length()-1),-1,false,true);
	for(uint i = 0; i < chats.length(); i++) buffers.add_list_item(all,chats[i]+" "+(i+1)+" of "+(chats.length()-1),-1,false,true);
// These are suposed to run async, though I have no idea how to aproach such right now, as async must return a type such as an int or string if I remember right.
	f.create_window("chat",false,true,false);
	int categories=f.create_tab_panel("&actions",2,false,false);
	int s1=f.create_subform("Chat message", @message);
	int s2=f.create_subform("Buffer", @buffers);
	int cancel=f.create_button("cancel",false,true,false);
	f.add_list_item(categories,"chat message", -1, false, true);
	f.add_item(categories, "buffers", -1, false, true);
	f.focus(categories);
	while(true)
	{
		wait(5);
		f.monitor();
		int current=f.get_list_position(categories);
		int old=0; // Just now noticed this, probably would end up being every time at tab 0 when the int is declaed all the time new in the loop.
		if(old!=categories)
		{
			if(current=0)
			{
				f.set_state(s1,true,true);
				f.set_state(s2, false, false);
				f.set_subform(s1,messages);
			}
			else if(current=1)
			{
				f.set_state(s1, false, false);
				f.set_state(s2, true, true);
				f.set_subform(s2,buffers);
			}
			else
			{
				alert("Error","Critical form error.");
				exit();
			}
		}
		if(f.is_pressed(cancel))
		{
			speak("Canceled");
			break;
		}
		if(chat.is_pressed(send))
		{
			speak("This works.");
			}
		}
	}
// I'm also not sure if I should monitor the other forms here as well.

Now the errors:

line: 1 (1)
INFO: Compiling void chat_dialog()

line: 11 (25)
ERROR: Illegal operation on 'int'

line: 1 (1)
INFO: Compiling void chat_dialog()

line: 11 (70)
ERROR: Type 'int' doesn't support the indexing operator

line: 1 (1)
INFO: Compiling void chat_dialog()

line: 12 (27)
ERROR: Illegal operation on 'int'

line: 1 (1)
INFO: Compiling void chat_dialog()

line: 12 (74)
ERROR: Type 'int' doesn't support the indexing operator

line: 1 (1)
INFO: Compiling void chat_dialog()

line: 14 (19)
ERROR: No matching signatures to 'audio_form::create_tab_panel(const string, const int, const bool, const bool)'

line: 14 (19)
INFO: int audio_form::create_tab_panel(string caption, int maximum_items = 0, bool repeat_boundary_items = false)

line: 19 (4)
ERROR: No matching symbol 'add_item'

line: 14 (19)
INFO: int audio_form::create_tab_panel(string caption, int maximum_items = 0, bool repeat_boundary_items = false)

line: 29 (7)
ERROR: Expression must be of boolean type, instead found 'int'

line: 14 (19)
INFO: int audio_form::create_tab_panel(string caption, int maximum_items = 0, bool repeat_boundary_items = false)

line: 33 (22)
ERROR: No matching symbol 'messages'

line: 14 (19)
INFO: int audio_form::create_tab_panel(string caption, int maximum_items = 0, bool repeat_boundary_items = false)

line: 35 (12)
ERROR: Expression must be of boolean type, instead found 'int'

line: 14 (19)
INFO: int audio_form::create_tab_panel(string caption, int maximum_items = 0, bool repeat_boundary_items = false)

line: 52 (6)
ERROR: No matching symbol 'chat'

I marked these as code just in case it breaks up stuff.
Concluding, I hope anyone can help me with this.
Greetings

I'm about to try sleeping so can probably be more help tomorrow, but the first big thing here is that you are calling the length method on an integer, which is impossible. you have int all=..., then for(int i=0; i<all.length()... but an integer doesn't have a length method. If you are trying to loop through the items in the all list in the form, you can use buffers.get_list_count(all) to see how many items are in the list.

Hopefully that's at least a good start.

Oh. Yeah I don't know how I came across that. Was probably because I first had b.all as arry for the all buffer items, but the compiler gave me a weird error there so I changed it to all.length without noting the int called all. I guess I do just string all2=b.all;? and then change all to all2? Will try it in a moment.

  1. Firstly, you accidentally named add_list_item as add_item.
  2. if (a = b) will never work, changed to if (a == b).
  3. Variables all and chats already exist, so you should change. For example, change to an array where your buffer items are contained. Eg: buffer_chats for chat etc.

And also make sure the named array variable exists. For example, here is example array:

string[] buffer_chats = {
	"Garo says: Hi",
	"Another user says: Hello"
};

Here is improved one. Make sure to test because I haven't tested as I'm about to go for dinner.

void chat_dialog() {
	audio_form message;
	message.create_window("message", false, false, true);
	int message2 = message.create_input_box("&Enter your message", "", "", 5000, false, true, true);
	int send = message.create_button("&Send message", true, false, true);
	audio_form buffers;
	buffers.create_window("Reading through your buffers (every list showing the latest 10000 items)", false, false, false);
	int all = buffers.create_list("All &buffers", 10000, false, false);
	int chats = buffers.create_list("&Chats", 10000, false, false);
	for(uint i = 0; i < all.length(); i++) buffers.add_list_item(all,all[i]+" "+(i+1)+" of "+(all.length()-1),-1,false,true); //Variable all already exists, change this if you want to add your buffer items
	for(uint i = 0; i < chats.length(); i++) buffers.add_list_item(all,chats[i]+" "+(i+1)+" of "+(chats.length()-1),-1,false,true); //Same, already exists.
	// These are suposed to run async, though I have no idea how to aproach such right now, as async must return a type such as an int or string if I remember right.
	f.create_window("chat", false, true, false);
	int categories = f.create_tab_panel("&actions", 2, false, false);
	int s1 = f.create_subform("Chat message", @message);
	int s2 = f.create_subform("Buffer", @buffers);
	int cancel = f.create_button("cancel", false, true, false);
	f.add_list_item(categories, "chat message", -1, false, true);
	f.add_list_item(categories, "buffers", -1, false, true);
	f.focus(categories);
	while(true) {
		wait(5);
		f.monitor();
		int current = f.get_list_position(categories);
		int old = 0; // Just now noticed this, probably would end up being every time at tab 0 when the int is declaed all the time new in the loop.
		if(old != categories) {
			if(current == 0) {
				f.set_state(s1 ,true, true);
				f.set_state(s2, false, false);
				f.set_subform(s1, @messages);
			}
			else if(current == 1) {
				f.set_state(s1, false, false);
				f.set_state(s2, true, true);
				f.set_subform(s2, @buffers);
			}
			else {
				alert("Error", "Critical form error.");
				exit();
			}
		}
		if(f.is_pressed(cancel)) {
			speak("Canceled");
			break;
		}
		if(chat.is_pressed(send)) {
			speak("This works.");
			}
		}
}

Wow, really thanks man. After trying a bit around it finally works now. Now i just gotta test the dialog itself but the compilation works! Hell yeah.

Alright. I'll send the code again. it works, though the setting stuff invisible stuff doesn't work as expected. Basically what is happening that it shows nevertheless my selection always first the actions panel with the two items, then the chat window, then the buffer window and then the cancel button.

void chat_dialog() {
	audio_form message;
	message.create_window("message", false, false, true);
	int message2 = message.create_input_box("&Enter your message", "", "", 5000, false, true, true);
	int send = message.create_button("&Send message", true, false, true);
	audio_form buffers;
	buffers.create_window("Reading through your buffers (every list showing the latest 10000 items)", false, false, false);
	int all = buffers.create_list("All &buffers", 10000, false, false);
	int chats = buffers.create_list("&Chats", 10000, false, false);
	string[] all2=b.all;
	string[] chats2=b.chats;
	for(uint i = 0; i < all2.length(); i++) buffers.add_list_item(all,all2[i]+" "+(i+1)+" of "+(all2.length()-1),-1,false,true);
	for(uint i = 0; i < chats2.length(); i++) buffers.add_list_item(chats,chats2[i]+" "+(i+1)+" of "+(chats2.length()-1),-1,false,true);
	// These are suposed to run async, though I have no idea how to aproach such right now, as async must return a type such as an int or string if I remember right.
	f.create_window("chat", false, true, false);
	int categories = f.create_tab_panel("&actions", 2, false);
	int s1 = f.create_subform("Chat message", @message);
	int s2 = f.create_subform("Buffer", @buffers);
	int cancel = f.create_button("cancel", false, true, false);
	f.add_list_item(categories, "chat message", -1, false, true);
	f.add_list_item(categories, "buffers", -1, false, true);
	f.focus(categories);
	int old = 0;
	while(true) {
		wait(5);
		f.monitor();
		int current = f.get_list_position(categories);
		if(old != categories) {
			if(current == 0) {
				f.set_state(s1 ,true, true);
				f.set_state(s2, false, false);
				f.set_subform(s1, @message);
			}
			else if(current == 1) {
				f.set_state(s1, false, false);
				f.set_state(s2, true, true);
				f.set_subform(s2, @buffers);
			}
			else {
				alert("Error", "Critical form error.");
				exit();
			}
		}
		if(f.is_pressed(cancel)) {
			speak("Canceled");
			break;
		}
		if(message.is_pressed(send)) {
			speak("This works.");
			}
		}
}

Still though, already has been very helpful and much apriciated.