ENCODE command problem

V+ discussions, tips and tricks, sample code, Q & A

ENCODE command problem

Postby rotekopler » Thu Nov 19, 2015 7:46 am

HEY,

when i use the command word ENCODE for a real number in order to copy it to a string, i get a " " before the number, for example:

real.number = 23

$string.number = $ENCODE(real.number)

$string.number = " 23"

my question is, how can i delete the empty space so the string will be only 23 ( $string.number="23")

is it possible?
rotekopler
 
Posts: 27
Joined: Sun Mar 01, 2015 11:56 pm

Re: ENCODE command problem

Postby brianch » Thu Nov 19, 2015 4:53 pm

Try this...

$string.number = $ENCODE(I0,real.number)

...see it that works better.

By the way: That is I for Integer as opposed to the number one.
brianch
 
Posts: 14
Joined: Fri Oct 24, 2008 9:06 am

Re: ENCODE command problem

Postby rotekopler » Sun Nov 22, 2015 12:24 am

Hi brianch,

thanks for the answer, but its still don't work.

may be you can explain more what is that "I0"?

when i tried to write it changed to io.

thanks
rotekopler
 
Posts: 27
Joined: Sun Mar 01, 2015 11:56 pm

Re: ENCODE command problem

Postby brianch » Sun Nov 22, 2015 7:17 am

My mistake, I forgot to add the slash to make it into a format specifier.

$string.number = $ENCODE(/I0,real.number)

Here is the manual page for $ENCODE...

http://www1.adept.com/main/KE/DATA/V%20 ... de_st.html

Which contains the following lines...

/D Use the default format, which is equivalent to /G15.8 (see below), except trailing zeros and all but one leading space are omitted.
The following format specifications accept a zero as the width field. This causes the actual field size to vary to fit the value and all leading spaces to be suppressed.


Explaining why you are seeing a leading space and the format specifier the number is zero to remove the leading space.

Sorry about that.
brianch
 
Posts: 14
Joined: Fri Oct 24, 2008 9:06 am

Re: ENCODE command problem

Postby rotekopler » Mon Nov 23, 2015 4:50 am

Hi brianch,

It's working good!

thanks!
rotekopler
 
Posts: 27
Joined: Sun Mar 01, 2015 11:56 pm


Return to V+

Who is online

Users browsing this forum: No registered users and 2 guests