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.
tincho 15-04-2021, 10:54
Esta función se comporta igual que la de Go.
Código:
'' <b>GO Package strings</b><br>
'' Contains reports whether substr is within s.

Static Public Function Contains(s As String, substr As String) As Boolean

  If InStr(s, substr) > 0 Then
    Return True
  Else
    Return False
  Endif

End
Saludos.
tincho 15-04-2021, 10:11
Hola a todos.
De forma análoga al tema titulado Extendiendo la clase String aprovechare para compartir con ustedes algunas funciones que he ido haciendo y que a mi me resultaron útiles. He aquí la primera de ellas:
Código:
Library "libc:6"

Public Struct stat_
  st_dev As Long
  st_ino As Long
  st_nlink As Long
  st_mode As Integer
  st_uid As Integer
  st_gid As Integer
  __pad0 As Integer
  st_rdev As Long
  st_size As Long
  st_blksize As Long
  st_blocks As Long
  st_atime As Long
  st_atimensec As Long
  st_mtime As Long
  st_mtimensec As Long
  st_ctime As Long
  st_ctimensec As Long
  __glibc_reserved[3] As Long
End Struct

Private Const _STAT_VER_LINUX As Integer = 1
Private Extern __xstat(_STAT_VER As Integer, __path As String, __statbuf As Stat_) As Integer

'' <b>RAD Extension.</b><br>
'' Create a file parameters list using the GNU coreutils program stat. Note: the tags for access to the information are:<br>
'' Dev, Ino, Path, Link, Mode, SetUID, SetGID, Rdev, Size, BlkSize, Blocks, LastAccess, LastModified, LastChange<br>
'' Original <https://www.gambas-it.org/wiki/index.php?title=Stat_()>

Static Public Sub Stat(f As String) As Collection

  Dim i As Integer
  Dim st As New Stat_
  Dim inf As New Collection

  i = __xstat(_STAT_VER_LINUX, f, st)
  If i < 0 Then Error.Raise("Function error '__xstat()' !")

  With st
    inf.Add(.st_dev, "Dev")
    inf.Add(.st_ino, "Ino")
    inf.Add(f, "Path")
    inf.Add(.st_nlink, "Link")
    inf.Add(.st_mode, "Mode")
    inf.Add(.st_uid, "SetUID")
    inf.Add(.st_gid, "SetGID")
    inf.Add(.st_rdev, "Rdev")
    inf.Add(.st_size, "Size")
    inf.Add(.st_blksize, "BlkSize")
    inf.Add(.st_blocks, "Blocks")
    inf.Add(.st_atime, "LastAccess")
    inf.Add(.st_mtime, "LastModified")
    inf.Add(.st_ctime, "LastChange")
  End With

  Return inf

End
Nota: Esta función no hubiese sido posible sin el articulo que Vuott publico en la wiki el foro italiano.
Saludos.
Páginas (551):    1 451 452 453 454 455 551   
Bienvenido, Invitado
Tienes que registrarte para poder participar en nuestro foro.
Recordarme?
Miembros: 279
Último miembro: pepe70
Temas del foro: 1,700
Mensajes del foro: 8,831
Últimos temas
gb.db2: columnas calculad...
Foro: Bases de Datos
Último mensaje por: guizans, Hace 9 horas
Respuestas: 12 - Vistas: 429
Gambas + ERP = GamERP.
Foro: Aplicaciones/Fragmentos de Código
Último mensaje por: tercoide, 30-04-2025, 15:57
Respuestas: 25 - Vistas: 1,996
Manejando imágenes desde ...
Foro: Videotutoriales
Último mensaje por: Shordi, 30-04-2025, 06:00
Respuestas: 2 - Vistas: 86
Imprimir resultados en el...
Foro: General
Último mensaje por: Turriano, 28-04-2025, 11:53
Respuestas: 5 - Vistas: 173
¿ Qué hay de nuevo en la ...
Foro: Instalación
Último mensaje por: tercoide, 27-04-2025, 15:20
Respuestas: 2 - Vistas: 119
Powered By MyBB, © 2002-2025 MyBB Group.
Made with by Curves UI.