tincho 15-04-2021, 11:03
Esta función esta interesante porque permite lograr una lista de "Campos" a partir de una cadena de texto separada por espacios o tabuladores.
Código:
'' <b>RAD Extension.</b><br>
'' Fields splits the string s around each instance of one or more consecutive white space characters returning a string[] of substrings of s or an empty string[] if s contains only white space.
'' GO Package strings
Static Public Function Fields(s As String) As String[]

  Dim sTmp As String
  Dim word As String
  Dim aOut As New String[]

  While InStr(sTmp, "\t")
    sTmp = Replace(sTmp, "\t", " ")
  Wend

  sTmp = Trim(RTrim(s))

  While InStr(sTmp, "  ")
    sTmp = Replace(sTmp, "  ", " ")
  Wend

  For Each word In Split(sTmp, " ")
    aOut.Add(word)
  Next

  Return aOut

End
Saludos.
tincho 15-04-2021, 10:59
Esta es la versión "gambosa" de Count de Go.
Código:
'' <b>RAD Extension.</b><br>
'' Counts how much times some string apear in other

Static Public Function Count(sWhere As String, sWhich As String) As Integer

  Dim k As Integer = 1
  Dim q As Integer
  Dim r As Integer

  Repeat
    q = InStr(sWhere, sWhich, k)
    If q > 0 Then
      Inc r
      k = q + String.Len(sWhich)
    Endif
  Until InStr(sWhere, sWhich, k) = 0 Or k > String.Len(sWhere)

  Return r

End
Saludos.
tincho 15-04-2021, 10:57
Esta función imita la homóloga de Go.
Código:
'' <b>GO Package strings</b><br>
'' <u>ContainsAny</u> reports whether any Unicode code points in chars are within s.

Static Public Function ContainsAny(s As String, chars As String) As Boolean

  Dim i As Integer
  Dim b As Boolean = False

  For i = 0 To chars.Len - 1
    If s Like "*" & chars[i, 1] & "*" Then
      b = True
      Break
    Endif
  Next
  Return b
End

Saludos.
Páginas (573):    1 472 473 474 475 476 573   
Bienvenido, Invitado
Tienes que registrarte para poder participar en nuestro foro.
Recordarme?
Miembros: 314
Último miembro: LKTFermin2
Temas del foro: 1,769
Mensajes del foro: 9,181
Últimos temas
Programando con la IA
Foro: General
Último mensaje por: seta43, 30-07-2026, 12:20
Respuestas: 12 - Vistas: 7,482
GauchoCAD vuelve a las pi...
Foro: Aplicaciones/Fragmentos de Código
Último mensaje por: tincho, 27-07-2026, 14:15
Respuestas: 15 - Vistas: 20,786
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.