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 (574):    1 … 474 475 476 477 478 … 574   
Bienvenido, Invitado
Tienes que registrarte para poder participar en nuestro foro.
Recordarme?
Miembros: 317
Último miembro: Eo185sRonNh7
Temas del foro: 1,774
Mensajes del foro: 9,211
Últimos temas
El conector de alimentaci...
Foro: Hardware & IoT
Último mensaje por: tincho, 23-09-2026, 23:03
Respuestas: 3 - Vistas: 122
Me hace falta el dato de ...
Foro: Hardware & IoT
Último mensaje por: AlfredoSC, 21-09-2026, 04:13
Respuestas: 0 - Vistas: 91
Problemas con la versión ...
Foro: General
Último mensaje por: Piero71, 19-09-2026, 23:56
Respuestas: 3 - Vistas: 271
GauchoCAD vuelve a las pi...
Foro: Aplicaciones/Fragmentos de Código
Último mensaje por: tincho, 02-09-2026, 21:41
Respuestas: 21 - Vistas: 22,269
Programando con la IA
Foro: General
Último mensaje por: alberto-moyano, 02-09-2026, 18:04
Respuestas: 19 - Vistas: 9,273
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.