[Gambas-user] how print each char/possition in string including spaces
ML
d4t4full at ...626...
Thu Dec 10 20:33:25 CET 2015
On 2015-12-10 15:23, Benoît Minisini wrote:
> Le 10/12/2015 19:19, PICCORO McKAY Lenz a écrit :
>> 2015-12-10 13:21 GMT-04:30 ML <d4t4full at ...626...>:
>>> Gerardo,
>>>
>>> I think you speak spanish, I've been to your site. I'll switch to ES-AR.
>> YEAH, the mail report correct!
>>> If I'm wrong, then please accept my apologies, tell me, and I'll repost
>>> in US-EN.
>> i'll paste also in US due for others if are need later when we resolved
>>> Tenés que iterar con un FOR-NEXT teniendo en cuenta la longitud del
>>> string. Por ejemplo, pon esto en FORM_OPEN:
>> YA lo hice, pero el puerto serial (no se como ponerl e inxluso en el
>> texto en ingles no lo puse) el puerto serial creo solo puede devolver
>> 8 bits
>>
>> Para que tengas una idea, en argentina se emplean impresoras fiscales,
>> y estas devuelven data (todas devuelven distinta data), pero como el
>> serial solo devuelve un byte de 8 gits (creo es asi) es decir una sola
>> palabra, por tanto la impresora "pica" el resultado en dos partes, ese
>> es el primer problema
>>
>> El segundo problema es que la salida son realmente codigos ascii ejemplo:
>> "0"
>> que es :
>> "^B^C^C^C^A^A0
>> ^A^C^F"
>> En la primera no se ve nada porque son caracteres no imprimibles, pero
>> en geany se pueden ver los caracteres ocultos y en un textbox, la
>> segunda es lo que Print de gambas imprime en la cosola y que vez en la
>> tabla ascii
>>
>> alguna idea? la que tengo es imprimir cada caracter imprimible, pero
>> no puedo hacer split por el "^" porque a veces devuelve un caracter
>> extrano entre estos (todos los kit fiscales lo hacen)
>>> Dim myString As String = "Hello"
>>> Dim pointer As Integer = 0
>>> For pointer = 1 To Len(myString)
>>> 'Esto será MUY molesto, pero sirve para ejemplo. Además myString no es muy largo... ;)
>>> Message.Info("Caracter en posición " & Str(pointer) & " es '" & Mid(myString, pointer, 1) & "'.")
>>> Next
>>> El primer caracter en strings en Gambas tiene índice 1.
>>> Saludos.
>>>
>>> *On 2015-12-10 14:39, PICCORO McKAY Lenz wrote:*
>>>> of the chari have a String "var1" = "this its a string"
>>>> how can i print each position/char of the string including the spaces!
>>>> Lenz McKAY Gerardo (PICCORO)
>>>> http://qgqlochekone.blogspot.com
>>>>
> Please use english on the mailing-list. It's not that I love that
> language, but it's the current "lingua franca" that allows everyone to
> understand the mails!
> Regards,
Sorry, Benoît.
I thought the question was simple enough and tried to make it even
simpler by switching language.
Gerardo,
I know what you mean. Point is, ASCII has printable and non-printable
characters.
Printable characters are ALWAYS in the &H20 to &H7F range.
Anything below &H20 not only is non-printable but also normally used as
control characters.
Anything above &H7F may or may not print.
For example take newline or LineFeed. ASCII code &H0A. Non-printable,
but in Linux -and Gambas- you can refer to it as "\n".
You can think of the "^" prefix like subtracting &H40 from the next
character's ASCII code.
What you see as "^A" (analogous to Ctrl-A in the keyboard) refers to
ASCII control code SOH (ASCII &H01).
It comes from ASC("A") - &H40 = 1: The old teletype CONTROL keys just
resetted bit 6 (value is 64, or &H40) of the character key pressed with it.
I'm sure you saw "^[" when you press Escape in some (console) programs:
ASC("[") - &H40 = &H1B (ASCII ESC).
The double-character combination you see is the OS's best effort to make
printable something that is not.
Try this in Gambas:
Dim myString As String = Chr$(27) 'Escape, char &H1B
Message.Info("Character '" & myString & "', ASCII code: " & Asc(myString))
myString = "\n" 'Linefeed, char (ASCII &H0A)
Message.Info("Character '" & myString & "', ASCII code: " & Asc(myString))
Remember that ASC will only return the ASCII code of the FIRST character
in a string. If you need several, you will have to use a loop.
I also made Fiscal Printer Drivers. Under my belt are at least
Venezuela, Bulgaria, Chile, Panama, Argentina, and even Russia.
They are ALL a freaking pain in the lower back, and there are few -if
any- standards, as they all depend on crazy laws made by crazier people.
Bad news, I made them all in Win/VB6 for my company. Advantage of VB in
these cases is the existence of Win-libraries.
I never used serial ports in Gambas. I can give it a try, though. But
will have to be at least tomorrow.
Hope that helped,
zxMarce.
More information about the User
mailing list