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 (551):    1 449 450 451 452 453 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,832
Últimos temas
gb.db2: columnas calculad...
Foro: Bases de Datos
Último mensaje por: Shordi, Hace 43 minutos
Respuestas: 13 - Vistas: 436
Gambas + ERP = GamERP.
Foro: Aplicaciones/Fragmentos de Código
Último mensaje por: tercoide, 30-04-2025, 15:57
Respuestas: 25 - Vistas: 1,999
Manejando imágenes desde ...
Foro: Videotutoriales
Último mensaje por: Shordi, 30-04-2025, 06:00
Respuestas: 2 - Vistas: 91
Imprimir resultados en el...
Foro: General
Último mensaje por: Turriano, 28-04-2025, 11:53
Respuestas: 5 - Vistas: 182
¿ Qué hay de nuevo en la ...
Foro: Instalación
Último mensaje por: tercoide, 27-04-2025, 15:20
Respuestas: 2 - Vistas: 122
Powered By MyBB, © 2002-2025 MyBB Group.
Made with by Curves UI.