alle prese (nuovamente) con il problema di tag ID3 dei file multimediali, mi servirebbe una bella funzione che restituisce una stringa compresa tra' due marcatori.
public function EstraiStringa(stringa as string,leftMarker as string, rightmarker as string) as string
questo perche' alcuni programmi tipo estituiscono una sola riga con tutte le proprieta' in linea.
Tipo (e sfortunatamente il ritorno a capo non funziona sempre ....):
id3v1 tag info for /home/v1p3r/Musica/Pokki_DJ_-_Energy_sigletta del calcio a 5.mp3:
Title : Artist:
Album : Year: , Genre: Unknown (255)
Comment: Track: 1
id3v2 tag info for /home/v1p3r/Musica/Pokki_DJ_-_Energy_sigletta del calcio a 5.mp3:
COMM (Comments): ()[eng]: http://www.jamendo.com cc_standard
TALB (Album/Movie/Show title): Energy
TCOM (Composer): Pokki DJ
TCON (Content type): Electronic (52)
TENC (Encoded by): Jamendo:http://www.jamendo.com| LAME
TIT2 (Title/songname/content description): Energy
TPE1 (Lead performer(s)/Soloist(s)): Pokki DJ
TRCK (Track number/Position in set): 1
TYER (Year): 2014
WCOP (Copyright/Legal information): http://creativecommons.org/licenses/by/3.0/
WOAF (Official audio file webpage): http://www.jamendo.com/en/track/1282679
WOAR (Official artist/performer webpage): http://www.jamendo.com/en/artist/6135
WOAS (Official audio source webpage): http://www.jamendo.com/en/album/152981
WPUB (Official publisher webpage): http://www.jamendo.com
APIC (Attached picture): (Cover Image)[, 3]: image/jpg, 18747 bytes
TXXX (User defined text information): (Tagging time): 2017-01-30T12:19:13
qualche segnalazione di funzione "magica" interna a gambas3?
io per ora ho fatto cosi':
Public Function EstraiStringa(stringa As String, leftMarker As String, rightMarker As String) As String
Dim appoggio As String
appoggio = Mid(stringa, InStr(stringa, leftMarker) + Len(leftMarker))
appoggio = Left(appoggio, InStr(appoggio, rightMarker) - 1)
Return appoggio
End
...potresti utilizzare anche la funzione esterna (http://www.seadooforum.com/images/smilies/FacePalm.gif) , che t'ho scritto in C, contenuta nella libreria dinamica condivisa, il cui sorgente è visibile nella funzione interna "Creaso( )" di questo codice Gambas esemplificativo:
Library "/tmp/substringa"
' char * SubStringa(const char *s, char *m1, char *m2)
' Cerca la parte di stringa delimitata da due singoli caratteri (non vocali accentate).
Private Extern SubStringa(s As String, m1 As String, m2 As String) As String
Public Sub Main()
Dim testo, mar1, mar2, rit As String
Creaso()
testo = "Prova un'altra volta questo testo."
mar1 = "'"
mar2 = "\x20"
rit = SubStringa(testo, mar1, mar2)
Print rit
End
Private Procedure Creaso()
File.Save("/tmp/substringa.c", "#include <stdio.h>\n" &
"#include <stdlib.h>\n" &
"#include <string.h>\n" &
"#include <math.h>\n\n\n" &
"char * SubStringa(const char *s, char *m1, char *m2) {\n\n" &
" char *rit1, *rit2, *fin;\n" &
" size_t lun1, lun2;\n\n" &
" rit1 = strchr(s, *m1);\n" &
" if (NULL==rit1)\n" &
" return \"ERRORE: Il 1° marcatore non e stato trovato !\";\n\n" &
" rit2 = strrchr(s, *m2);" &
" if (NULL==rit2)\n" &
" return \"ERRORE: Il 2° marcatore non e stato trovato !\";\n\n" &
" lun1 = strlen(s) - strlen(rit1+1);\n" &
" lun2 = strlen(s) - strlen(rit2+1);\n\n" &
" fin = calloc(2048, sizeof(char));\n" &
" snprintf(fin, abs(lun1-lun2), \"%s\", s+lun1);\n\n" &
" return fin;\n\n}")
Shell "gcc -o /tmp/substringa.so /tmp/substringa.c -lm -shared -fPIC" Wait
End