tincho 15-04-2021, 11:45
Esta función devuelve el nombre del directorio inmediatamente superior de una ruta que se pasa y ademas quita todos los niveles superiores a este, trabaja similar a la función nativa BaseName pero con el directorio.
Código:
'' <b>RAD Extension.</b><br>
'' Returns the directory without the path to it, that is, it returns the name of the directory. if you pass "/home/user/music" it will return "music"

Static Public Function BaseDir(Path As String) As String

  Dim strBase As String
  Dim stx As New String[]

  If InStr(Path, "/") > 0 Then
    stx = Split(Path, "/")
    strBase = stx[stx.Max]
  Endif

  Return strBase

End
Saludos
tincho 15-04-2021, 11:13
Esta la hizo Christof, de la lista internacional de Gambas, y yo la adapte.
Fue la que obtuvo la marca de velocidad mas alta (con FAST).
Código:
'' <b>RAD Extension.</b><br>
'' It removes the spaces at the beginning and the end of
'' a <b>s</b> and if there are repeated spaces, it converts them into one.

Static Public Function Trim(s As String) As String

  Dim sOut As String

  sOut = Trim(RTrim(s))
  While InStr(sOut, "  ")
    sOut = Replace(sOut, "  ", " ")
  Wend

  Return sOut

End
Saludos.
tincho 15-04-2021, 11:11
Esta hace lo mismo que la función de Go que se llama igual.
Código:
'' <b>RAD Extension.</b><br>
'' Converts the first character of each word to upper case.
'' GO Package strings

Static Public Function Title(s As String) As String

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

  sTmp = Trim(RTrim(s))
  While InStr(sTmp, "  ")
    sTmp = Replace(sTmp, "  ", " ")
  Wend

  For Each word In Split(sTmp, " ")
    aOut.Add(Upper(Mid(word, 1, 1)) & Mid(Lower(word), 2))
  Next

  Return aOut.Join(" ")

End
Saludos.
Páginas (574):    1 … 472 473 474 475 476 … 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,268
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.