Return code for the "find" function

Hello everyone

The "find" string function returns the position of the first occurrence of a substring in the target chain.
In the event that it finds nothing, what does it send back? -1 or something else?

Thank you for your help

Hello

Which software does this concern? SolidWorks, Excel, VBA?

I would be tempted to say that it returns 0 or nothing.

It can't be very complicated to do a test, right?

More info about FIND in vba:

http://www.commentcamarche.net/faq/36886-vba-recherche-de-donnees-la-methode-find

If no result, the statement returns "Nothing".

 

1 Like

It's PDM if I understood correctly

@+;-))

1 Like

I hadn't seen the title of the page (of the tab).

For EPDM, FIND should return null or nothing, but I maintain that it must be very simple to do a test! Do a bogus search with anything.

This is indeed the find function of ePDM and more specifically in the "dispatch" add-in.

FYI. This function returns 0 if the found string is in the first position. (Positioning starts at Zero). But the documentation says nothing when the string is not found. (Same thing for "left", "right", "mid", etc...)

 

1 Like

An example where the search will "probably" not find a result to test:

fdlsjkvhqmsdfjqzerltjgsdflmiglmdihnsbqzedsfqlmdfjmld

:D

Indeed, FIND must return -1, as shown here:

"Running the dispatch on a file that contains a space in its name. returns value of -1, which means there are no spaces found."

https://forum.solidworks.com/thread/73505

Other source: https://forum.solidworks.com/thread/60319

"1. Create <your variable> with value Find(%PathToSelectedFile%, \Designs\PDF's\)

All files in folder \Designs\PDF's\ will return a value that is not equal to -1. File that are not in this folder will return value -1."

2 Likes

Thank you .PL for your help.

1 Like
No worries:)