Re: [Gambas-user] simple replace question

2009-03-04 Thread Stefano Palmeri
Il mercoledì 4 marzo 2009 11:55:44 Bruce ha scritto:
 Hi guys,

 I'm trying to convert a string to float.  The string contents are 56½. 
 I've tried both

 replace(st,½,.5) and
 replace(st, Chr$(194), .5 )

 neither helps.

 Any ideas?

 tia
 ted

Strange. replace(st,½,.5) works on my system.

Gambas 2.11.1

Saluti,

Stefano

 ---
--- Open Source Business Conference (OSBC), March 24-25, 2009, San
 Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing
 the Enterprise -Strategies to boost innovation and cut costs with open
 source participation -Receive a $600 discount off the registration fee with
 the source code: SFAD http://p.sf.net/sfu/XcvMzF8H
 ___
 Gambas-user mailing list
 Gambas-user@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/gambas-user



--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] simple replace question

2009-03-04 Thread Emil Tchekov
Is your string UTF encoded? You should check if your character code is exactly 
194 and not wider... 16 Bits perhaps? Any Hex-Viewer will help.

regards

Emil

On Wednesday 04 March 2009 11:55:44 Bruce wrote:
 Hi guys,

 I'm trying to convert a string to float.  The string contents are 56½. 
 I've tried both

 replace(st,½,.5) and
 replace(st, Chr$(194), .5 )

 neither helps.

 Any ideas?

 tia
 ted

 ---
--- Open Source Business Conference (OSBC), March 24-25, 2009, San
 Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing
 the Enterprise -Strategies to boost innovation and cut costs with open
 source participation -Receive a $600 discount off the registration fee with
 the source code: SFAD http://p.sf.net/sfu/XcvMzF8H
 ___
 Gambas-user mailing list
 Gambas-user@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/gambas-user


--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] simple replace question

2009-03-04 Thread Rolf-Werner Eilert
Bruce schrieb:
 On Wednesday 04 March 2009 23:00:00 Stefano Palmeri wrote:
 
 Strange. replace(st,½,.5) works on my system.

 Gambas 2.11.1

 Saluti,

 Stefano
 
 Damn!  And I still can't get it working.  The only thing I've been able to 
 decipher is that Len(st)=4 not 3.  Using gambas 2.9.?? as its the latest 
 available for PCLinuxOS (see below).
 


The version will not matter, I guess. Try converting your string into 
ASCII before replacing:

newString = Conv(st, UTF-8, ASCII)

Replace(st, ½, .5)

On my old ASCII-table ½ is chr$(171). So it should work with this one, 
as it's known in ASCII.

If you get an error 32, your string wasn't UTF-8. Next idea: use 
String.Code to find out the Hex-code of each single character in st. 
Then rewrite the replace function for this combination of characters  - 
something like Replace(st, chr$(30)  chr$(1)  chr$(123), .5)...

Hope it helps...


Rolf

--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] simple replace question

2009-03-04 Thread Rolf-Werner Eilert
Bruce schrieb:
 On Thursday 05 March 2009 01:34:29 Rolf-Werner Eilert wrote:
 newString = Conv(st, UTF-8, ASCII)

 Replace(st, ½, .5)
 
 Thanks RW,
 
 That got me started at least.
 
 So far:
 TRY wx = Conv(lp1[5], UTF-8, ASCII)
 TRY wx = Replace(wx, ½, .5)
 TRY wx = Replace(wx, ¼, .25)
 TRY wx = Replace(wx, ¾, .75)
 seems to work.
 
 I had to put the TRY's in because 3/4 doesn't seem to handle properly 
 otherwise.  
 

No wonder, because 3/4 doesn't exist in ASCII. This is what my character 
table program says about this character:

UTF-8: 0xC2 0xBE
UTF-16: 0x00BE

C-Oktal terminiertes UTF-8: \302\276
Dezimale XML-Entität: #190;

So you should look for a string consisting of C2 and BE, that is 
chr$(194) and chr$(190) as we can presume this is UTF-8. Try this:

xStr = chr$(194)  chr$(190)
wx = Replace(wx, xStr, .75)

Does this run? Or even

wx = Replace(wx, chr$(194)  chr$(190), .75)

should work. At least if I'm right, but I never tried this.


Rolf

--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] simple replace question

2009-03-04 Thread Rolf-Werner Eilert
Bruce schrieb:
 On Thursday 05 March 2009 01:34:29 Rolf-Werner Eilert wrote:
 newString = Conv(st, UTF-8, ASCII)

 Replace(st, ½, .5)
 
 Thanks RW,
 
 That got me started at least.
 
 So far:
 TRY wx = Conv(lp1[5], UTF-8, ASCII)
 TRY wx = Replace(wx, ½, .5)
 TRY wx = Replace(wx, ¼, .25)
 TRY wx = Replace(wx, ¾, .75)
 seems to work.
 
 I had to put the TRY's in because 3/4 doesn't seem to handle properly 
 otherwise.  
 


Sorry, I forgot this: you must replace 3/4 to something else before you 
can Conv to ASCII. Arrrgh - this will not run.

Next idea: Look into the string and find out what Conv makes out of 
3/4 in ASCII - maybe it just makes 3/4 out of it? This is what you 
will have to look for. Your thing would then read as follows:

  TRY wx = Conv(lp1[5], UTF-8, ASCII)
  TRY wx = Replace(wx, ½, .5)
  TRY wx = Replace(wx, ¼, .25)
  TRY wx = Replace(wx, 3/4, .75)

We would need a String.Replace() function here...

Rolf

--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] simple replace question

2009-03-04 Thread Ron_1st
On Wednesday 04 March 2009, Rolf-Werner Eilert wrote:
 Bruce schrieb:
  On Thursday 05 March 2009 01:34:29 Rolf-Werner Eilert wrote:
  newString = Conv(st, UTF-8, ASCII)
 
  Replace(st, ½, .5)
  
  Thanks RW,
  
  That got me started at least.
  
  So far:
  TRY wx = Conv(lp1[5], UTF-8, ASCII)
  TRY wx = Replace(wx, ½, .5)
  TRY wx = Replace(wx, ¼, .25)
  TRY wx = Replace(wx, ¾, .75)
  seems to work.
  
  I had to put the TRY's in because 3/4 doesn't seem to handle properly 
  otherwise.  
  
 
 No wonder, because 3/4 doesn't exist in ASCII. This is what my character 
 table program says about this character:
 
 UTF-8: 0xC2 0xBE
 UTF-16: 0x00BE
 
 C-Oktal terminiertes UTF-8: \302\276
 Dezimale XML-Entität: #190;
 
 So you should look for a string consisting of C2 and BE, that is 
 chr$(194) and chr$(190) as we can presume this is UTF-8. Try this:
 
 xStr = chr$(194)  chr$(190)
 wx = Replace(wx, xStr, .75)
 
 Does this run? Or even
 
 wx = Replace(wx, chr$(194)  chr$(190), .75)
 
 should work. At least if I'm right, but I never tried this.
 
 
 Rolf
 

http://www.eki.ee/letter/chardata.cgi?ucode=00BE

found in charsets:  8859-1 (BE); 8859-13 (BE); 8859-8 (BE); 8859-9 (BE); 
CP1116 (F3); CP1122 (B9); CP1252 (BE); CP1254 (BE); CP1255 (BE); CP1256 (BE); 
CP1257 (BE); CP1258 (BE); CP775 (F3); CP850 (F3); CP857 (F3); CP863 (AD);

Dangerous the differences between char sets.
I was suprised it is not in ASCII also.
I know my Epson fX80 with IBM supplied ROM did have it. (ancient history :) )

Ron

 --
 Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
 -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
 -Strategies to boost innovation and cut costs with open source participation
 -Receive a $600 discount off the registration fee with the source code: SFAD
 http://p.sf.net/sfu/XcvMzF8H
 ___
 Gambas-user mailing list
 Gambas-user@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/gambas-user
 


Best regards,

Ron_1st

-- 

--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] simple replace question

2009-03-04 Thread Benoît Minisini
 Bruce schrieb:
  On Thursday 05 March 2009 01:34:29 Rolf-Werner Eilert wrote:
  newString = Conv(st, UTF-8, ASCII)
 
  Replace(st, ½, .5)
 
  Thanks RW,
 
  That got me started at least.
 
  So far:
  TRY wx = Conv(lp1[5], UTF-8, ASCII)
  TRY wx = Replace(wx, ½, .5)
  TRY wx = Replace(wx, ¼, .25)
  TRY wx = Replace(wx, ¾, .75)
  seems to work.
 
  I had to put the TRY's in because 3/4 doesn't seem to handle properly
  otherwise.

 Sorry, I forgot this: you must replace 3/4 to something else before you
 can Conv to ASCII. Arrrgh - this will not run.

 Next idea: Look into the string and find out what Conv makes out of
 3/4 in ASCII - maybe it just makes 3/4 out of it? This is what you

 will have to look for. Your thing would then read as follows:
   TRY wx = Conv(lp1[5], UTF-8, ASCII)
   TRY wx = Replace(wx, ½, .5)
   TRY wx = Replace(wx, ¼, .25)
   TRY wx = Replace(wx, 3/4, .75)

 We would need a String.Replace() function here...

 Rolf


String.Replace() is not needed, because there is no difference between ASCII 
and UTF-8 when replacing strings.

There is no reason why Replace(st, ½, .5) won't work, unless the st string 
is not UTF-8 of course.

Regards,

-- 
Benoît


--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user