ListBox Object, For Each, and why is this not working?

For questions about using Classic.

Post » Mon Jun 22, 2009 7:12 pm

So basically, at the start of the layout, I have an event that lists the names of .dat files in a folder to a listbox, then I have an subevent that happens immediately afterwards:
[code:7y7v5245]ListBox: 494 For each line
> ListBoxSet line ListBox 0 .CurrentIndex data to GetToken(ListBox 1 .LineText(ListBox 2 .CurrentIndex),1, ".")[/code:7y7v5245]

Basically this should strip every line from the ".dat" at the end of it, but for some reason, it doesn't seem to work. It works if I change "Set line data" to "Add line", so the "For each line" is most certainly run, but it doesn't seem to edit the line data for some reason. Later, when I try to do this (still a subevent to "Start of layout"):

[code:7y7v5245]ListBox: 494 For each line
System: 0 ListBox 0 .LineText(ListBox 1 .CurrentIndex) Equal to global('language')
> SystemSet global variable 'languageindex' to ListBox 0 .CurrentIndex
> ListBoxSelect line ListBox 0 .CurrentIndex[/code:7y7v5245]

It doesn't seem to work either. I basically want to look for a line that is equivalent to the global string 'language' and set a global value called 'languageindex' to the line number of it, yet it doesn't change the value of 'languageindex' at all. Neither of these events do not work even if I put them as independent events instead of subevents.

Any help?

EDIT: Okay, so apparently LineData != LineText. I managed to partially fix it by changing it to LineData, but then it wasn't working when I tried to read the LineData later on. Now, the real question is: Why the heck can you not alter the actual line text?
B
16
S
8
G
4
Posts: 136
Reputation: 3,144

Post » Tue Jun 23, 2009 2:29 pm

I don't think many people have played around with the application side of Construct, apart from maybe me. Even I haven't really done all that much with it apart from creating some very basic data storage fields, mainly as a proof of concept.

Unfortunately, I don't think I even used the listbox object at any stage... so I'm afraid I won't be much help, sorry. :(

Maybe one of the dev's can shed some light on this?

~Sol
Tired of crappy file hosts that are crappy? Get DROPBOX - https://db.tt/uwjysXJF
Moderator
B
45
S
17
G
37
Posts: 2,853
Reputation: 25,966

Post » Tue Jun 23, 2009 3:39 pm

Set line data associates data with a line. So if you had a list of names you could set an e-mail to go with each line which wasn't visible, for example. It won't change the item name.

As the copy as text is a bit dodgy, it'd help if for the second issue you uploaded a .cap file. But there is a FindLine expression; you don't need to do a for each loop and check the text.
B
3
S
2
G
5
Posts: 1,777
Reputation: 5,529

Post » Tue Jun 23, 2009 4:18 pm

Rich, what I basically wanted to do was turn a list with this:

english.dat
finnish.dat

Into this:

english
finnish

I figured out that LineData is separate thing from LineText, but now my question mainly is that why can't I alter the actual LineText, only LineData?

Construct in general is missing quite a lot of things in regard of creating applications (and using application rendering), but those really belong to a separate topic, and this particular problem was about doing a multilingual game. In any case, I managed to get around this by adding my edited lines to another ListBox, but in the future it'd be nice not to have to do this.
B
16
S
8
G
4
Posts: 136
Reputation: 3,144

Post » Tue Jun 23, 2009 6:17 pm

The control plugins are very complete':

http://msdn.microsoft.com/en-us/library ... 85%29.aspx

There is no API function to replace the text of a line. What you should do is add them how you want them. There is a 'For each file' condition of the File object, for example. You could use this and strip the '.dat' out before you add the file.
B
3
S
2
G
5
Posts: 1,777
Reputation: 5,529


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 4 guests