How do you join lines in a container so it becomes one line, so you
can use split?
Pierre Sahores
psahores at easynet.fr
Wed Jun 11 13:29:01 EDT 2003
Sadhunathan Nadesan a écrit :
>
> How do you join lines in a container?
>
> Question: I have a container which contains an sql cursor, ie, a number
> of lines of data (in this case 2 fields separated by the pipe symbol).
> I want to place this in an indexed array so I can use it in a replacement
> algorithm. Whenever the index field (field 1) is found in some data,
> replace it with the indexed field (field 2).
>
> So, I want to use the split command to create this array, but trying to
> split on return, or newline, or cr, or numToChar(10) ... this is a Unix
> system .. does not work.
>
> Therefore I tried to replace the end of line character with something
> else in the container so I could do this split. The "=" symbol.
>
> That did not work either.
>
> So I came up with the hokey method below .. putting the data out into an
> external file and basically running a tr on it to replace the newlines
> with =, then reading it back in to do the split. Seems pretty hokey to
> me, why can't I just do it in place? Read in the sql data directly and
> split it? No external files. But that does not seem to work.
>
> Oh well, thanks in advance for any help.
>
> Sadhu
>
> ps, code snippet below illustrating hokey solution.
>
> on sqlFetch
>
> put "select audio_date, audio_url from audio;" into sqlQuery
> put sqlQuery into url "file:/tmp/titlelist.sql"
> put "psql cybertalks -qt -f /tmp/titlelist.sql > /tmp/titlelist.dat" into command_string
>
> set shellCommand to "/bin/sh"
> put shell(command_string)
> replace numToChar(10) with "=" in url "file:/tmp/titlelist.dat"
> put url "file:/tmp/titlelist.dat" into sqlData
> split sqlData by "=" and "|"
> put keys(sqlData) into keywords
> repeat for each line x in keywords
> put x && " :---: " && sqlData[x] & cr
> end repeat
>
> end sqlFetch
> _______________________________________________
> metacard mailing list
> metacard at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/metacard
Allo Sadhu,
> set itemdel to "|"
> tune your metatalk code
--
Cordialement, Pierre Sahores
Inspection académique de Seine-Saint-Denis.
Applications et bases de données WEB et VPN
Qualifier et produire l'avantage compétitif
More information about the metacard
mailing list