Page 1 of 1 1
Topic Options
#153571 - 2005-12-16 09:29 PM INST function help
pfarrelli Offline
Fresh Scripter

Registered: 2005-11-16
Posts: 46
If string1 the string to search IN is smaller than string2 the one to search for, INSTR returns nothing ... not ZERO .. nothing!! Is that supposed to be the case?

In the code below, the version returned by the file is 8.1.0.825 ($version) and is SHORTER than the sting looking into it .. thus returning NOTHING. You would think it would return 0.

----------------------------------


$versionstring = "10.0.2.2000"
$version10loc = "c:\Program Files\Symantec Antivirus\vpc32.exe"
$version7loc = "v:\vpc32.ex7"
$version8loc = "v:\vpc32.ex8"


$Version= getfileversion($version8loc)
at (3,1) "version looking for " $versionstring
at (4,1) "version is " $version

$offset = instr ($version , $versionstring)
at (5,1) "offset is " $offset
if $offset <> 0
at (6,1) "strings are the same"
else
at (6,1) "strings are different"
endif

-----------------------------------

Top
#153572 - 2005-12-16 09:38 PM Re: INST function help
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
oh a bug!
Code:

$short = "short"
$long = "a really long string"

? "looking for a short string in a long string"
? "instr = " + instr($long,$short)

?

? "looking for a long string in a short string"
? "instr = " + instr($short,$long)



Might want to move this post to the Beta forum since it does seem to be a bug

Top
#153573 - 2005-12-16 09:40 PM Re: INST function help
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
but it seems to not stop this from working.

Code:

if instr($short,$long)
? "true"
else
? "false"
endif



it returns false like it should.

Top
#153574 - 2005-12-16 09:53 PM Re: INST function help
pfarrelli Offline
Fresh Scripter

Registered: 2005-11-16
Posts: 46
yes .. it still works .. but not pretty! :-)

thanks.

Top
#153575 - 2005-12-16 09:56 PM Re: INST function help
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
I'd still say this is a bug too. Should give some value and doesn't.
Top
#153576 - 2005-12-16 10:24 PM Re: INST function help
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
hmm...
actually, if you check for the vartype, I'd say it returns boolean TRUE.
so, I would say, if the bug is somewhere, it's in the sub routine that is responsible of translating boolean TRUE to 1 and FALSE to 0.
_________________________
!

download KiXnet

Top
#153577 - 2005-12-20 03:52 AM Re: INST function help
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
You could always use the MinorVersion() or the CompareVersions() UDFs instead.
_________________________
There are two types of vessels, submarines and targets.

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 1270 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.097 seconds in which 0.046 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org