[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Any easy way to change a string ? and a bug (or maybe a feature ?)


Le lundi 14 octobre 2024, 17:42:56 UTC+2 Benoît Minisini a écrit :
> Le 14/10/2024 à 17:19, Laurent Carlier a écrit :
> > For example:
> > 
> > DIM myString as String ="RETUIOPLJBDNLQSXNKNSXKSXKBSKXKBBB"
> > 
> > I would like to change the 10th character, replacing it with another. I
> > can't find an easy way to do it.
> 
> Mid$(myString, 10, 1) = "X"
> 
> But strings are immutable, so you actually create a new string.
> 
> > Is it a bug ?:
> > 
> > DIM myByte as Byte = &hFF&
> > DIM myString as String = "test string :"
> > 
> > myString &= CStr(myByte)
> > 
> > gives "test string :0\x00FF" instead of "test string :0\xFF", Byte is
> > converted to a Short value, so unusual. As a workaround, i use
> > chr$(myByte)
> > 
> > Regards,
> > Laurent Carlier
> 
> Yes, but not on the master. Which version of Gambas do you use to get that?
> 
> You should get: "test string:255"

Oh, thanks. I forgot about mid$ ! 

So is it possible to get value converted to \xFF instead of 255 ? Because i 
use strings to store values i stream in a file.

Regards,
++

Attachment: signature.asc
Description: This is a digitally signed message part.


Follow-Ups:
Re: Any easy way to change a string ? and a bug (or maybe a feature ?)Benoît Minisini <benoit.minisini@xxxxxxxxxxxxxxxx>
References:
Any easy way to change a string ? and a bug (or maybe a feature ?)Laurent Carlier <lordheavym@xxxxxxxxx>
Re: Any easy way to change a string ? and a bug (or maybe a feature ?)Benoît Minisini <benoit.minisini@xxxxxxxxxxxxxxxx>