CoCreate User Forum  

Go Back   CoCreate User Forum > Applications > CoCreate Drafting

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old 11-23-2005, 02:26 AM
max77 max77 is offline
Registered User
 
Join Date: Aug 2005
Posts: 22
string

hi!
two questions about string:

-i would like lo translate a number in a string, which command sholud I use?
-i need to search inside a string another one using "jolly" characters like ? e *. is it possible? how?

thank you!!!!!!!!!!!!!!!!!!!!
Reply With Quote
  #2  
Old 11-23-2005, 04:14 AM
Michael Kahle's Avatar
Michael Kahle Michael Kahle is offline
Registered User
 
Join Date: Oct 2002
Posts: 121
Re: string

First one is easy --> LET Abc (STR 14.234) returns a string
opposite is LET Xyz (VAL "12.123")

Second one --> don't know abaout it. Maybe it helps to use a combination of
'POS', 'SUBSTR', '=' ?
__________________
Best regards,
Michael

--

Spam goes nospam@ptc.com and spam@postini.com
Reply With Quote
  #3  
Old 11-23-2005, 08:55 AM
John Scheffel's Avatar
John Scheffel John Scheffel is offline
Administrator
 
Join Date: Sep 2002
Location: San Jose, CA
Posts: 1,288
Re: string

I've never heard the expression "jolly" characters, but I'm guessing it is the same as "wildcard" characters, meaning a character which can represent any character(s) in a search string. It comes from wildcards in poker which can used as any card in the deck. The ? can be any single character, and * can be one or more characters.

The only macro command I know of for searching strings is the POS command which Michael mentioned. I ran a quick test and it does not support the standard wildcard characters ? or *, it treats them as a standard character. The Programming Help for POS does not mention support for any wildcard characters.

As Michael indicated, it might be possible to write a custom macro which can do it, but I don't think there is a standard command or macro which does it.
__________________
John Scheffel
Reply With Quote
  #4  
Old 11-23-2005, 05:09 PM
Lim Chee Beng's Avatar
Lim Chee Beng Lim Chee Beng is offline
Registered User
 
Join Date: Nov 2002
Location: Malaysia
Posts: 210
Re: string

As what Michael and John suggested, to search substring within a string, I normally use the POS command as below. Wildcard does not seem to be allowed. However, wildcard is allowed in infotext operations.
PHP Code:
(POS string1 string2
The function returns the first position (non-zero integer) of string2 within string1. If string2 is not contained in string1, it returns 0.

Last edited by Lim Chee Beng; 11-23-2005 at 05:24 PM.
Reply With Quote
  #5  
Old 11-24-2005, 07:16 AM
max77 max77 is offline
Registered User
 
Join Date: Aug 2005
Posts: 22
Re: string

Thank you!
It's true... wildcard are not allowed. i tried yesterday and it didn't work.If you try, you can also name a part using ? and * characters...it's allowed!
So...i'm gonna writing a macro for it.

Thank you again!
Reply With Quote
  #6  
Old 11-24-2005, 12:34 PM
Darren Darren is offline
Registered User
 
Join Date: Oct 2002
Location: Norway
Posts: 19
Cool Re: string

There is a way of using wildcards against text - take a look at "FIND_AND_REPLACE" here: http://www.cocreateusers.org/macros/macro.htm
Reply With Quote
  #7  
Old 11-24-2005, 02:22 PM
John van Doorn's Avatar
John van Doorn John van Doorn is offline
Registered User
 
Join Date: Nov 2002
Location: The Netherlands
Posts: 83
Re: string

Hi,

Please have a look at the command MATCH

Code:
Returns 1 if the first string is matched by the pattern specified by the second string, otherwise returns 0. The pattern may contain wildcards as follows: 


    *     Matches any string including the null string.


    ?     Matches any single character.


    [...] Matches any one of the enclosed characters.  A pair of characters
          separated by a hyphen (-) matches any character lexically between the
          pair, inclusive.  A NOT operator, !, can be specified immediately
          following the left bracket to match any single character not enclosed
          in the brackets.


    \     Removes any special meaning of the following character.


          Any other character matches itself.
Kind Regards,
John
__________________
High performance CAD workstations
Please visit us at https://www.cadware.nl
Reply With Quote
  #8  
Old 11-25-2005, 01:01 AM
Michael Kahle's Avatar
Michael Kahle Michael Kahle is offline
Registered User
 
Join Date: Oct 2002
Posts: 121
Re: string

Wow, great, yes, really - still things to learn for CoCreate people as well ;-)

The command to use is MATCH:

MATCH string string ===> number


Returns 1 if the first string is matched by the pattern specified by the second string, otherwise returns 0. The pattern may contain wildcards as follows:


* Matches any string including the null string.


? Matches any single character.


[...] Matches any one of the enclosed characters. A pair of characters
separated by a hyphen (-) matches any character lexically between the
pair, inclusive. A NOT operator, !, can be specified immediately
following the left bracket to match any single character not enclosed
in the brackets.


\ Removes any special meaning of the following character.


Any other character matches itself.
__________________
Best regards,
Michael

--

Spam goes nospam@ptc.com and spam@postini.com
Reply With Quote
  #9  
Old 11-25-2005, 05:26 AM
max77 max77 is offline
Registered User
 
Join Date: Aug 2005
Posts: 22
Re: string

Thank you!!!!!!!!!!!!!!!!!!!!!!!!

It's really great!
So now I don't have to loose time to write a custom macro for it!
thank you very much!!
Reply With Quote
  #10  
Old 11-28-2005, 09:16 AM
John Scheffel's Avatar
John Scheffel John Scheffel is offline
Administrator
 
Join Date: Sep 2002
Location: San Jose, CA
Posts: 1,288
Re: string

Yet another macro command I wasn't aware of and have never used. This is what makes reading these forums worthwhile, every week I learn something new. It even seems to support a tiny bit of the regular expression syntax with the brackets.
__________________
John Scheffel
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 12:12 PM.



Hosted by SureServer    Forums   Modeling FAQ   Macro Site   Vendor/Contractors   Software Resellers   CoCreate   Gallery   Home   Board Members   Regional User Groups  By-Laws  

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.