Author Topic: units question..  (Read 3736 times)

0 Members and 1 Guest are viewing this topic.

Andrea

  • Water Moccasin
  • Posts: 2372
units question..
« on: October 21, 2005, 03:40:27 PM »
Hi all..

I have this..

(setq val1 0.25)

(setq val2 (rtos val1))   ;;returns  "0.2500"
(setq val2 (rtos val1 2 8))   ;;returns  "0.25000000"
(setq val2 (rtos val1 2 0))   ;;returns  "0"


so the question is...

how to get "0.25" without using (rtos val1 2 2)  ??




Keep smile...

Crank

  • Water Moccasin
  • Posts: 1503
Re: units question..
« Reply #1 on: October 21, 2005, 04:17:31 PM »
DIMZIN = 8
Vault Professional 2023     +     AEC Collection

Andrea

  • Water Moccasin
  • Posts: 2372
Re: units question..
« Reply #2 on: October 21, 2005, 04:20:04 PM »
DIMZIN ??

why using DIM variables ??
do I nee to change also LUPREC ??

Naaaahhh !!

Please can you explain exctly what DIMZIN affect ??

thanks.
Keep smile...

Serge J. Gianolla

  • Guest
Re: units question..
« Reply #3 on: October 21, 2005, 04:21:40 PM »
Since you work in decimal, check DIMZIN = 8
But if all you want to have is Val2 equal to Val1 then (setq Val2 Val1) or am i missing something!

Serge J. Gianolla

  • Guest
Re: units question..
« Reply #4 on: October 21, 2005, 04:23:10 PM »
Rats, got beaten by Crank :-D

deegeecees

  • Guest
Re: units question..
« Reply #5 on: October 21, 2005, 04:27:05 PM »
From the AutoCAD Developers Help:

Quote
vl-string-right-trim Function
 
Removes the specified characters from the end of a string

(vl-string-right-trim character-set string)

Arguments

character-set

A string listing the characters to be removed.

string

The string to be stripped of character-set.

Return Values

A string containing a substring of string with all trailing characters in character-set removed.

Examples

_$ (vl-string-right-trim " \t\n" " STR \n\t ")
" STR"
_$ (vl-string-right-trim "1356789" "3CPO is not R2D267891")
"3CPO is not R2D2"
_$ (vl-string-right-trim " " "There are too many spaces here      ")
"There are too many spaces here"

Andrea

  • Water Moccasin
  • Posts: 2372
Re: units question..
« Reply #6 on: October 21, 2005, 04:41:12 PM »
Since you work in decimal, check DIMZIN = 8
But if all you want to have is Val2 equal to Val1 then (setq Val2 Val1) or am i missing something!

Hey !! Hi, Serge..long time no talk..

in fact i need to compare ..(if (= val1 val2) ...

so if val1 is "0.25" and val2 is "0.25000000"..the result was nil.
sur i can do... (if (= (read val1) (read val2))....

but I dont want to convert for after reconvert again..see ?

thanks.
Keep smile...

Serge J. Gianolla

  • Guest
Re: units question..
« Reply #7 on: October 21, 2005, 04:55:51 PM »
I see, but when you are comparing with the read function, you are not converting and having to re-convert, comparison is done on the fly without changing the values from strings to reals! Capisci?

Andrea

  • Water Moccasin
  • Posts: 2372
Re: units question..
« Reply #8 on: October 22, 2005, 11:36:11 PM »
I see Serge...

But I need also to put the result in a dialog box...

see ? :-o
Keep smile...

Serge J. Gianolla

  • Guest
Re: units question..
« Reply #9 on: October 23, 2005, 02:46:32 AM »
OK, it appears that my good pal Andrea has a bit of hard time getting my explanation, so I'll try differently! Please, people who get upset when they don't see english words [you know who you are :evil:] look somewhere else or keep your remarks for yourselves, thank you.
Andrea,
Quand tu compares les 2 values a l'aide de READ, il n'y a pas de conversion qui intervient. Tes 2 valeurs restent des chaines de characteres, et peuvent donc etre passees a ta boite de dialogue apres. Ca va mieux comme explications? Tu comprends la comprenance? :lmao:

P.S: I was after ODCL2, but never mind. I started with ver 3, and so far so good. Ciao

Andrea

  • Water Moccasin
  • Posts: 2372
Re: units question..
« Reply #10 on: October 25, 2005, 05:20:14 PM »
Serge,...

Maybe i'm not clear with my explaination to...
I don't have a problem to compare...

I have proble to show the result..
because I need to re-convert in string...

see ?

 :?
Keep smile...

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: units question..
« Reply #11 on: October 27, 2005, 09:35:11 AM »
Perhaps this.
Code: [Select]
(setq rval1 0.25)
(setq rval2 0.25)

(setq $val1 (rtos rval1 2))
(setq $val2 (rtos rval2 2))

(setq $val1 (vl-string-right-trim "0" $val1))
(setq $val2 (vl-string-right-trim "0" $val2))

(= $val1 $val2)
0.25
0.25
"0.25000"
"0.25000"
"0.25"
"0.25"
T
_$
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.