List and strings

Find quick help here to get you started with Hollywood
amyren
Posts: 81
Joined: Thu May 02, 2019 11:53 am

Re: List and strings

Post by amyren » Sat May 18, 2019 11:04 pm

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.

User avatar
msu
Posts: 44
Joined: Mon Jun 13, 2016 11:36 am
Location: Sinzig/Germany

Re: List and strings

Post by msu » Sat May 18, 2019 11:36 pm

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

bitRocky
Posts: 105
Joined: Fri Nov 14, 2014 6:01 pm

Re: List and strings

Post by bitRocky » Sun May 19, 2019 8:34 am

You have to use parenthesis:

Code: Select all

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

User avatar
jPV
Posts: 279
Joined: Sat Mar 26, 2016 10:44 am
Location: RNO
Contact:

Re: List and strings

Post by jPV » Sun May 19, 2019 10:43 am

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

amyren
Posts: 81
Joined: Thu May 02, 2019 11:53 am

Re: List and strings

Post by amyren » Sun May 19, 2019 4:58 pm

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$) 

amyren
Posts: 81
Joined: Thu May 02, 2019 11:53 am

Re: List and strings

Post by amyren » Mon May 20, 2019 12:45 pm

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?

User avatar
airsoftsoftwair
Posts: 3185
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: List and strings

Post by airsoftsoftwair » Fri Oct 25, 2019 9:48 pm

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

Post Reply