PDA

View Full Version : Attribute Inquiry


SoonTin
12-03-2002, 09:14 PM
Hello there,

I would like to find out how (position (character "_") ...) can be used to inquire attribute starting immediately AFTER the character "_", e.g. to capture "abcde" from attribute string "12345_abcde". Any help will be greatly appreciated.

Thank you in advance for your help.

Best regards,
SoonTin

dorothea
12-03-2002, 09:35 PM
Hello SoonTin,

You can for instance use the function sd-string-split for splitting your string into substrings. You can specify the character '_' as delimiter. Then you delete the first substring. If necessary you can combine the rest of the substrings again to one string using the format command.

(sd-string-split "12345_abcde" "_")
=>
("12345" "abcde")

(second ("12345" "abcde"))
=>
"abcde"

Hope this helps,
Dorothea

SoonTin
12-03-2002, 11:36 PM
Hello Dorothea,

Thank you for your response. I only managed to get object basename say "xxxxx_M3-Screw" with result ".M3 Screw" returned but what I really want is "M3 Screw".

(setf DESCRIPTION (string-upcase (substitute (name-char 'Space) (character '-)
(subseq (sd-inq-obj-basename part)
(position (character ".") (sd-inq-obj-basename part))))))

Unfortunately I am not a professional programmer and have no idea where to look for information many times.

Appreciate your kind assistance.

Best regards,
SoonTin

dorothea
12-04-2002, 12:04 AM
Hello Soon Tin,

Unfortunately I don't really understand your problem. In your example code you try to find a '.' in the string but the example string doesn't have one. Please post the real name of an example part and the result you want to get. Then I'll try to find a lisp sequence to create the result string out of the part name.

If you have a look into the integration kit documentation you'll find some functions for string manipulation. The html find is:

<integration kit documentation directory>/reference/strings.html



Dorothea

SoonTin
12-04-2002, 12:40 AM
Hello Dorothea,

Sorry for the typo error in the example, it should be "xxxx.M3-Screw". I like to output "M3 Screw" (characters after ".") to the variable but do not know how it can be done.

Thank you once again for your help.

dorothea
12-04-2002, 12:56 AM
Hello Soon Tin,

For this example the code can look like this:
(I split up the code to show you step by step what I would do.)


(let (partname tmp1 tmp2 result)
(setf partname "xxxx.M3-Screw")
(setf tmp1 (sd-string-split partname "."))
;=> ("xxxx" "M3-Screw")
(setf tmp2 (second tmp1))
;=> "M3-Screw"
(setf result (sd-string-replace tmp2 "-" " "))
(display result)
;=> "M3 Screw"
)

This code works fine if all you part names have the same structure with the . and the - characters. If you have different part names then you have to make the code more general.


Hope this helps,
Dorothea

SoonTin
12-04-2002, 01:49 AM
Hello Dorothea,

I modified the lines in my programme and it works beautifully now.

Thank you a zillion times for your help. Appreciate your time and kindness.