Page 2 of 2

Re: List and strings

Posted: Sat May 18, 2019 11:04 pm
by amyren
msu wrote:
Sat May 18, 2019 9:31 pm
"Not" can only result in True (1) or False (0).
I dont get it.
IF will also only result in True or False, NOT will only invert the result.

Re: List and strings

Posted: Sat May 18, 2019 11:36 pm
by msu
Please also read the documentation.

Here is an example with "Not":

Code: Select all

loadedline$ = "Hallo"
If Not loadedline$ = False
	DebugPrint("loadedline$ is not empty")
EndIf

Re: List and strings

Posted: Sun May 19, 2019 8:34 am
by bitRocky
You have to use parenthesis:

Code: Select all

			If not (loadedline$ = "unwanted") ;dont load this entry
				InsertItem(myvar$, loadedline$)
			EndIf

Re: List and strings

Posted: Sun May 19, 2019 10:43 am
by jPV
How about just doing it like this?

Code: Select all

			If loadedline$ <> "unwanted"
				InsertItem(myvar$, loadedline$)
			EndIf
Or if there are Unicode strings, then it's better like this:

Code: Select all

			If CompareStr(loadedline$, "unwanted")
				InsertItem(myvar$, loadedline$)
			EndIf

Re: List and strings

Posted: Sun May 19, 2019 4:58 pm
by amyren
Thanks all.
I ended up using the paranteses, now saving a few lines compared to my first workaround solution.

Code: Select all

If not (loadedline$ = "unwanted")  Then InsertItem(myvar$, loadedline$) 

Re: List and strings

Posted: Mon May 20, 2019 12:45 pm
by amyren
I did try to use RemoveItem to remove entries in my string-lists, but I failed at my first attemts.
I probably had gotten the syntax wrong or something.
However, I did re-read the docs and now RemoveItem is working as I want.

But after my first failed attemt, I did try to change my script to use mylist$[selcteditem] = Nil.
This did work fine, as long as the Nilled item was the last one in the list. If it was in the middle of the list, it started to cause problems.
Commands like ListItems or Sort will stop if a Nil is reached.

So my question is, is there a way to rebuild a string list after having an item in the middle Nilled?

Re: List and strings

Posted: Fri Oct 25, 2019 9:48 pm
by airsoftsoftwair
msu wrote:
Sun May 12, 2019 5:02 pm
In addition, the table library is very slow. :oops:

Code: Select all

- New: Major optimization for table library; InsertItem(), RemoveItem(), and ListItems() will now be
  massively faster but only if your code adheres to several rules: the table needs to have been created
  using the new CreateList() function and write access must be done exclusively through InsertItem()
  and RemoveItem(); if you add or remove table items in any other way, the behaviour is undefined; if
  you follow the rules described above, InsertItem(), RemoveItem() and ListItems() will be massively
  faster