SEARCH() for "-"

Discussion related to "Everything" 1.5.
Post Reply
NotNull
Posts: 5961
Joined: Wed May 24, 2017 9:22 pm

SEARCH() for "-"

Post by NotNull »

Yes, another quotes-and-spaces question ..

Code: Select all

Filtername = dummy
Search =  A:="7-zip"  addcol:B  B:=SEARCH($param:,$A:)
Macro =  dummy
Searching for:dummy:z or dummy:"z" gives the expected result (3).

Searching for:dummy:"-" gives the expected result (2).

Searching for:dummy:- gives the unexpected result 1.



This is a boiled down version of what I am trying to accomplish. dummy:"some text" should also be parsed correctly (eventually).
Is there a way to get this working?

I think I miss formulas like QUOTE(text) and UNQUOTE(text), where the latter removes only the outside quotes.
That way text can always be quoted with quote(unquote(text)).
Or QUOTED(text) that encapsulates text in quotes if not already quoted. Something along thse lines..

AFAICT, preprocessor functions don't help here as they are parsed too early in the process.
void
Developer
Posts: 19870
Joined: Fri Oct 16, 2009 11:31 pm

Re: SEARCH() for "-"

Post by void »

$param: is expanded from the parameter as is.



A:="7-zip" addcol:B B:=SEARCH($param:,$A:)

dummy:"-"


=>

A:="7-zip" addcol:B B:=SEARCH("-",$A:)




dummy:-


=>

A:="7-zip" addcol:B B:=SEARCH(-,$A:)


Formulas will treat - as 0-0



To always treat the parameter as a string for formulas:

Code: Select all

A:="7-zip"  addcol:B  B:=SEARCH(#[QUOTE:#[REMOVEQUOTES:$param:#]:#]:,$A:)


dummy:-


=>

A:="7-zip" addcol:B B:=SEARCH("-",$A:)




I have put on my todo list to make this cleaner.
Some ideas:
$param-as-string:
#[STRING:$param:#]:
void
Developer
Posts: 19870
Joined: Fri Oct 16, 2009 11:31 pm

Re: SEARCH() for "-"

Post by void »

Everything 1.5.0.1397a adds support for #[STRING:...#]: to stringify a value.

Use
#[STRING:$param:#]:
to stringify $param:

#[STRING:"-"#]:
=>
"-"


#[STRING:-#]:
=>
"-"




A:="7-zip" addcol:B B:=SEARCH(#[STRING:$param:#]:,$A:)
Post Reply