join columns

Alain Farmer alain_farmer at yahoo.com
Thu Aug 28 17:11:48 EDT 2014


Improved it again :

function insertAsColumn colNumber, dataToInsert, intoThisTable
    --
    if dataToInsert is empty then
        answer "insert empty column ?" with "cancel" or "insert"
        if it is "cancel" then exit to top
    end if
    --
    if intoThisTable is empty then return dataToInsert
    --
    if the number of lines of dataToInsert is not the number of lines of intoThisTable
    then die "Error: Lists have different lengths."
    --
    set the itemdel to tab
    put the number of items of line 1 of intoThisTable into lastCol
    if (colNumber < 1) or (colNumber > lastCol) then
        ask "colNumber must be an integer between 1 and" && lastCol with 1
        if the result is "cancel" then exit to top
        if (it is empty) or (it is not a number)
        then die "colNumber must be an integer between 1 and" && lastCol
    end if
    --
    if colNumber is lastCol then
        repeat for each line x in dataToInsert
            get line x of dataToInsert
            put tab & it after line x of intoThisTable
        end repeat
    else
        repeat for each line x in dataToInsert
            get line x of dataToInsert
            put it & tab before item colNumber of line x of intoThisTable
        end repeat
    end if
    --
    return intoThisTable
    --
end insertAsColumn

on die dyingMessage
    answer dyingMessage
    exit to top
end die



On Thursday, August 28, 2014 4:04:10 PM, Magicgate Software - Skip Kimpel <skip at magicgate.com> wrote:
 


Haha. I like the paranoid version :)

SKIP


On Thu, Aug 28, 2014 at 3:53 PM, Alain Farmer <alain_farmer at yahoo.com>
wrote:

> Here is the paranoid version :
>
> function insertAsColumn colNumber, dataToInsert, intoThisTable
>     --
>     if dataToInsert is empty then
>         answer "insert empty column ?" with "cancel" or "insert"
>         if it is "cancel" then exit to top
>     end if
>     --
>     if intoThisTable is empty then return dataToInsert
>     --
>     if the number of lines of dataToInsert is not the number of lines of
> intoThisTable
>     then die "Error: Lists have different lengths."
>     --
>     set the itemdel to tab
>     put the number of items of line 1 of intoThisTable into lastCol
>     if (colNumber < 1) or (colNumber > lastCol) then
>         ask "colNumber must be an integer between 1 and" && lastCol with 1
>         if the result is "cancel" then exit to top
>         if (it is empty) or (it is not a number)
>         then die "colNumber must be an integer between 1 and" && lastCol
>     end if
>     --
>     repeat for each line x in dataToInsert
>         get line x of dataToInsert
>         put it & tab before item colNumber of line x of intoThisTable
>     end repeat
>     return intoThisTable
>     --
> end insertAsColumn
>
> on die dyingMessage
>     answer dyingMessage
>     exit to top
> end die
>
>
>
> On Thursday, August 28, 2014 3:31:30 PM, JB <sundown at pacifier.com> wrote:
>
>
>
> Thank you, Alain!  This example will
> help me out.
>
> John Balgenoth
>
>
> On Aug 28, 2014, at 12:24 PM, Alain Farmer <alain_farmer at yahoo.com> wrote:
>
> > Correction:
> >
> > function insertAsColumn colNumber, dataToInsert, intoThisTable
> >     --
> >     if the number of lines of dataToInsert is not the number of lines of
> intoThisTable
> >     then die "Error: Lists have different lengths."
> >     --
> >     set the itemdel to tab
> >     repeat for each line x in dataToInsert
> >         get line x of dataToInsert
> >         put it & tab before item colNumber of line x of intoThisTable
> >     end
> > repeat
> >     return intoThisTable
> >     --
> > end insertAsColumn
> >
> > on die dyingMessage
> >     answer dyingMessage
> >     exit to top
> > end die
> >
> >
> >
> >
> > On , Alain Farmer <alain_farmer at yahoo.com> wrote:
> >
> >
> >
> > on insertAsColumn colNumber, dataToInsert, intoThisTable
> >     --
> >     if the number of lines of dataToInsert is not the number of lines of
> intoThisTable
> >     then die "Error: Lists have different lengths."
> >     --
> >     set the itemdel to tab
> >     repeat for each line x in dataToInsert
> >         get line x of dataToInsert
> >         put it & tab before item colNumber of line x of intoThisTable
> >     end
> > repeat
> >     return intoThisTable
> >     --
> > insertAsColumn
> >
> > on die dyingMessage
> >     answer dyingMessage
> >     exit to top
> > end die
> >
> >
> >
> > On Thursday, August 28, 2014 2:59:04 PM, JB <sundown at pacifier.com>
> wrote:
> >
> >
> >
> > Richard Gaskin wrote a function to get a column
> > from a list.
> >
> > function GetCol pData, pCol --Richard Gaskin
> >     set the itemdel to tab
> >     put empty into tReturnList
> >     repeat for each line tLine in pData
> >         put item pCol of tLine &cr after tReturnList
> >     end repeat
> >     delete last char of tReturnList -- trailing CR
> >     return tReturnList
> > end GetCol
> >
> > Does anyone know how to convert this so you can
> > join the selected columns back together in any
> > order you want?
> >
> > John
> > Balgenorth
> > _______________________________________________
> > use-livecode mailing list
> > use-livecode at lists.runrev.com
> > Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> > http://lists.runrev.com/mailman/listinfo/use-livecode
> > _______________________________________________
> > use-livecode mailing list
> > use-livecode at lists.runrev.com
> > Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> > http://lists.runrev.com/mailman/listinfo/use-livecode

>
> >
>
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
_______________________________________________
use-livecode mailing list
use-livecode at lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


More information about the use-livecode mailing list