Welcome! Log In Create A New Profile

Advanced

How does "Position" in a character string work?

Posted by Dan M 
I have tried ...

StartLocation is an int = Position(MyString, "Delivery", 0, FromEnd)
Info(StartLocation)

and ...

StartLocation is an int = Position(MyString, "Delivery", 1, FromBeginning)
Info(StartLocation)

Both give StartLocation a value of 1730 which is wrong, both times...

I have tested the length of the string using ...

Info(Length(MyString)) (which is 2366)

AND I have searched the string to verify the word "Delivery" is only located in the string one time

This code gives me the exact data I need:
===================================

FirstCut is a string = Right( MyString , 624)
EDT_Edit2 = Left(FirstCut, 191 )

===================================
I thought ...

StartLocation is an int = Position(MyString, "Delivery", 1, FromBeginning)

would give me the position of the letter "D" in delivery?

I guess I am not reading the help correctly, or at least not understanding ...

The complete string is below ...

Any help is greatly appreciated ... Dan

--------------- complete string -------------------------------------

Part Search:

HONEYWELL 1TL1-2G is in stock! | Buy 1TL12G | 1TL1 2G

Your Shopping Cart
is currently empty.
Cust. Service Chat:

Tech Support Chat:
Live chat by LivePerson

Featured Products

CTP-1200

G.C. Electronics
Our Most Popular Cable Tie Kit

700 4" Ties (Various Colors)
400 8" Ties (Natural)
100 11" Ties (Natural)
Special Price: $14.29
R0E00008AKCE00

Renesas
On-Chip Debugger

For M16C Family, H8 Family, H8/Tiny and Super Low Power Series, and 740 Family
Our Price: $137.79

HONEYWELL Website

Part Number: 1TL1-2G
Manufacturer: HONEYWELL
Product Manager Chat:
 

  Retrieving Additional Information
Important Notice:
Product Image:
(Click to Zoom)
Description:
MICRO SWITCH™TL Series toggle switches have high strength, temperature resistant, non-tracking case material and silver cadmium oxide contacts.Pull-to-Unlock toggle levers prevent accidental operation; the lever must be pulled approx. 2,3 mm (0.09 inches) to change positions.
Package Type:
Packing Method:
Product Info:
RoHS Status : Non-Compliant
Manufacturing Status:
Product Highlights:
Qualified to MIL-S-3950
Environment-proof sealing
1,2, and 4 pole circuitry
Standard and pull-to-unlock levers
2 and 3 position, maintained and momentary toggle action
Temperature range: -85
Completely sealed switching chamber
Step-design case provides added space between terminals to help prevent shorting
UL recognized, CSA certified
CE approved
Potential Applications:
Industrial machinery and equipment
Military and commercial aviation
Construction equipment
Test instruments
Agricultural machinery
Process control
Medical instrumentation
Additional Images:

Delivery for 1TL1-2G
In Stock: 36 pcs. can ship now
Factory Lead-Time: 6 weeks
Pricing for 1TL1-2G Quantity Price
1 - 24 $34.56
25 - 49 $28.69
50 - 249 $25.24
250 - 999 $23.50
1000 + $21.43
Order Quantity:
Your Part Number:
(optional)
Customers who bought HONEYWELL 1TL1-2G also purchased:

HONEYWELL 1TL1-2G
HONEYWELL Part Numbers In Stock
HONEYWELL 1TL1-2G Index
  |   Link to This Page  |   Print this Page  |   Return to Search Results  |   « Home Page
XXXXXXXXX X 2007 - 2009 XXXXXXXXXXXXXXXXXXX  |  Terms of Use  |  Product Index |  In Stock Products | In Stock - Buy Now  |  Site Map  |  Customer Service

Ruben Sanchez Peña
Re: How does "Position" in a character string work?
July 14, 2009 01:53PM
Hi. The result is correct. Position ever return the offset from the beginning.

Try this

/////////////////////////////////////////////////////////////////

str is string = [


Part Search:

HONEYWELL 1TL1-2G is in stock! | Buy 1TL12G | 1TL1 2G

Your Shopping Cart
is currently empty.
Cust. Service Chat:

Tech Support Chat:
Live chat by LivePerson

Featured Products

CTP-1200

G.C. Electronics
Our Most Popular Cable Tie Kit

700 4" Ties (Various Colors)
400 8" Ties (Natural)
100 11" Ties (Natural)
Special Price: $14.29
R0E00008AKCE00

Renesas
On-Chip Debugger

For M16C Family, H8 Family, H8/Tiny and Super Low Power Series, and 740 Family
Our Price: $137.79

HONEYWELL Website

Part Number: 1TL1-2G
Manufacturer: HONEYWELL
Product Manager Chat:


Retrieving Additional Information
Important Notice:
Product Image:
(Click to Zoom)
Description:
MICRO SWITCH™TL Series toggle switches have high strength, temperature resistant, non-tracking case material and silver cadmium oxide contacts.Pull-to-Unlock toggle levers prevent accidental operation; the lever must be pulled approx. 2,3 mm (0.09 inches) to change positions.
Package Type:
Packing Method:
Product Info:
RoHS Status : Non-Compliant
Manufacturing Status:
Product Highlights:
Qualified to MIL-S-3950
Environment-proof sealing
1,2, and 4 pole circuitry
Standard and pull-to-unlock levers
2 and 3 position, maintained and momentary toggle action
Temperature range: -85
Completely sealed switching chamber
Step-design case provides added space between terminals to help prevent shorting
UL recognized, CSA certified
CE approved
Potential Applications:
Industrial machinery and equipment
Military and commercial aviation
Construction equipment
Test instruments
Agricultural machinery
Process control
Medical instrumentation
Additional Images:

Delivery for 1TL1-2G
In Stock: 36 pcs. can ship now
Factory Lead-Time: 6 weeks
Pricing for 1TL1-2G Quantity Price
1 - 24 $34.56
25 - 49 $28.69
50 - 249 $25.24
250 - 999 $23.50
1000 + $21.43
Order Quantity:
Your Part Number:
(optional)
Customers who bought HONEYWELL 1TL1-2G also purchased:

HONEYWELL 1TL1-2G
HONEYWELL Part Numbers In Stock
HONEYWELL 1TL1-2G Index
| Link to This Page | Print this Page | Return to Search Results | « Home Page
XXXXXXXXX X 2007 - 2009 XXXXXXXXXXXXXXXXXXX | Terms of Use | Product Index | In Stock Products | In Stock - Buy Now | Site Map | Customer Service




]

arrCar is array of 10000 characters

FOR nn = 1 TO Length(str)
arrCar[nn] = str[[nn]]
END


Info(Position(str,"Delivery",0,FromEnd))
Info(Position(str,"Delivery"))

Info(Position(str,"Delivery",0,FromEnd))

//////////////////////////////

If you put a breakpoint in the first info line and inspect the array with the debugger you will see the "D" is in 1701 array position, equal value like in the info values.






Dan

I've always had more luck (?!) with PositionOccurrence rather than Position. Don't know why - it's just always worked better for me and completely consistently in contrast with Position which gives me results I don't understand like the ones you have in your example.

Just my observation.

Chris L
Melbourne, Oz
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: