Source language: Translate to:

searchstr can't find numbers?

Questions about using NeoBook's scripting language

Moderator: Neosoft Support

searchstr can't find numbers?

Postby Wrangler » Mon Jul 28, 2014 2:43 pm

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?
Wrangler
--------------
"You never know about a woman. Whether she'll laugh, cry or go for a gun." - Louis L'Amour

Windows 7 Ultimate SP1 64bit
16GB Ram
Asus GTX 950 OC Strix
Software made with NeoBook
http://highdesertsoftware.com
User avatar
Wrangler
 
Posts: 1507
Joined: Thu Mar 31, 2005 11:40 pm
Location: USA

Re: searchstr can't find numbers?

Postby Gaev » Mon Jul 28, 2014 3:08 pm

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 ?
User avatar
Gaev
 
Posts: 3738
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Re: searchstr can't find numbers?

Postby Wrangler » Mon Jul 28, 2014 3:19 pm

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?
Wrangler
--------------
"You never know about a woman. Whether she'll laugh, cry or go for a gun." - Louis L'Amour

Windows 7 Ultimate SP1 64bit
16GB Ram
Asus GTX 950 OC Strix
Software made with NeoBook
http://highdesertsoftware.com
User avatar
Wrangler
 
Posts: 1507
Joined: Thu Mar 31, 2005 11:40 pm
Location: USA

Re: searchstr can't find numbers?

Postby mishem » Mon Jul 28, 2014 3:34 pm

In such cases, check the character code.
Like this.

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


- = 45
– = 150
mishem
 
Posts: 576
Joined: Mon Oct 08, 2012 1:51 pm

Re: searchstr can't find numbers?

Postby Wrangler » Mon Jul 28, 2014 3:35 pm

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...
Wrangler
--------------
"You never know about a woman. Whether she'll laugh, cry or go for a gun." - Louis L'Amour

Windows 7 Ultimate SP1 64bit
16GB Ram
Asus GTX 950 OC Strix
Software made with NeoBook
http://highdesertsoftware.com
User avatar
Wrangler
 
Posts: 1507
Joined: Thu Mar 31, 2005 11:40 pm
Location: USA

Re: searchstr can't find numbers?

Postby mishem » Mon Jul 28, 2014 3:42 pm

45 is a minus
150 short dash

To correct before searching replace one character to another.
StrReplace
Last edited by mishem on Mon Jul 28, 2014 3:44 pm, edited 1 time in total.
mishem
 
Posts: 576
Joined: Mon Oct 08, 2012 1:51 pm

Re: searchstr can't find numbers?

Postby Wrangler » Mon Jul 28, 2014 3:42 pm

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.
Wrangler
--------------
"You never know about a woman. Whether she'll laugh, cry or go for a gun." - Louis L'Amour

Windows 7 Ultimate SP1 64bit
16GB Ram
Asus GTX 950 OC Strix
Software made with NeoBook
http://highdesertsoftware.com
User avatar
Wrangler
 
Posts: 1507
Joined: Thu Mar 31, 2005 11:40 pm
Location: USA


Return to NeoBook Action Commands

Who is online

Users browsing this forum: No registered users and 1 guest