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.
tincho 14-04-2021, 12:17
Hola a todos.
En este tema voy a ir poniendo funciones que estoy agregando a la clase String para hacer que esta se parezca mas a su equivalente en otros lenguajes como Javascript, Go, etc.
Si alguno desea comentar corregir o agregar algo esta invitado a hacerlo, eso si, por favor comente si la función existe en otro lenguaje, para poder referenciarlo y por favor coloque la descripción de esta en inglés.
Mi intensión es proponer luego a los desarrolladores de Gambas la colección de nuevas funciones.
Ejemplo de la versión gambas de la función Compare del paquete strings del lenguaje GO
Código:
'' <b>GO Package strings</b><br>
'' <u>Compare</u> returns an integer comparing two strings lexicographically. The result will be 0 If a == b, -1 If a < b, And +1 If a > b.

Static Public Function Compare(a As String, b As String) As Integer
  If a == b Then
    Return 0
  Else
    If a < b Then
      Return -1
    Else
      Return 1
    Endif
  Endif
End

Saludos
Páginas (557):    1 457 458 459 460 461 557   
Bienvenido, Invitado
Tienes que registrarte para poder participar en nuestro foro.
Recordarme?
Miembros: 285
Último miembro: XLRG
Temas del foro: 1,720
Mensajes del foro: 8,934
Últimos temas
Archivos .ods
Foro: General
Último mensaje por: tincho, 01-07-2025, 18:54
Respuestas: 8 - Vistas: 169
Publicidad
Foro: Sobre gambas-es.org
Último mensaje por: tincho, 01-07-2025, 18:48
Respuestas: 6 - Vistas: 305
Web con gambas, a ver si ...
Foro: WebApp/WebForms
Último mensaje por: tincho, 01-07-2025, 17:47
Respuestas: 41 - Vistas: 32,393
Un sistema de ayudas cont...
Foro: Videotutoriales
Último mensaje por: guizans, 22-06-2025, 19:55
Respuestas: 3 - Vistas: 277
Crear una aplicación para...
Foro: Bases de Datos
Último mensaje por: Shell, 29-05-2025, 20:11
Respuestas: 11 - Vistas: 1,421
Powered By MyBB, © 2002-2025 MyBB Group.
Made with by Curves UI.