Page 1 of 1

searchstr can't find numbers?

PostPosted: Mon Jul 28, 2014 2:43 pm
by Wrangler
Reading a file line by line looking for " - 6" in each line.

SearchStr " - 6" "[line]" "[6found]" ""

[6found] seems to always return a 0, or not found. Yes, it does exist in the string. Tried adding ! to no avail. Am I missing something here?

Re: searchstr can't find numbers?

PostPosted: Mon Jul 28, 2014 3:08 pm
by Gaev
Wrangler:

This code worked for me ...
Code: Select all
SetVar "[line]" "abcd - 6xyz"
SearchStr " - 6" "[line]" "[6found]" ""
AlertBox "SearchPosition" "[6found]"


Note that I copied your SearchStr command as-is into my Button code ... there is a space before and after the minus sign ... does [line] contain these spaces in your application ?

Re: searchstr can't find numbers?

PostPosted: Mon Jul 28, 2014 3:19 pm
by Wrangler
Hi Gaev,

You sample code works for me too. Try copy and pasting this setvar:

SetVar "[line]" "L.A. Confidential – 6"
or
SetVar "[line]" "Sour Cream – 6"

I copy and pasted this out of the text file I'm reading in.

It returns a 0 for me. You?

Re: searchstr can't find numbers?

PostPosted: Mon Jul 28, 2014 3:34 pm
by mishem
In such cases, check the character code.
Like this.

Code: Select all
Loop "1" "200" "[i]"
If "-" "=" "[#[i]]"
    AlertBox "" "[i]"
EndIf
EndLoop


- = 45
– = 150

Re: searchstr can't find numbers?

PostPosted: Mon Jul 28, 2014 3:35 pm
by Wrangler
I think I figured it out. Something weird about the hypen. If I copy and paste it, then delete the hyphen and type it in, it works. Some kind of hidden things are passed along when copy and pasting out of the file. Now to figure out how to fix that...

Re: searchstr can't find numbers?

PostPosted: Mon Jul 28, 2014 3:42 pm
by mishem
45 is a minus
150 short dash

To correct before searching replace one character to another.
StrReplace

Re: searchstr can't find numbers?

PostPosted: Mon Jul 28, 2014 3:42 pm
by Wrangler
Thank you much, Mishem! Works by using [#150] in the searchstr action. [#45] (the OTHER hyphen :) ) doesn't.

This csv file came from a friend in Britain. Must have something to do with it.

Problem solved.