MapInfo Pro Developers User Group

 View Only
  • 1.  Retain data during split without specifying every data column

    Posted 09-13-2017 09:02

    Hey,

    I am currently automating our process for generating background maps, and as part of this, I am writing a small script / program that will iterate though each table in a map window / workspace and run the split target command.

    When I run the split command manually from (spatial -> Split -> Split target) and select the Disaggregation Method as Value then the resulting MapBasic command ends up like this:

    Objects Split Into Target Concurrency All DropIndex Auto Data FOT_ID=FOT_ID,MOB_ID=MOB_ID,FEAT_KODE=FEAT_KODE,FEAT_TYPE=FEAT_TYPE,FEATSTATUS=FEATSTATUS,GEOMSTATUS=GEOMSTATUS,KOM_KODE=KOM_KODE,TIMEOF_CRE=TIMEOF_CRE,TIMEOF_PUB=TIMEOF_PUB,TIMEOF_REV=TIMEOF_REV,TIMEOF_EXP=TIMEOF_EXP

    It seems a bit redundant to specify that every data column should be copied, and if it is required then I also have to iterate though all the columns of every table to generate the Objects Split command. It would therefore be much easier if there was a command akin to this:

    Objects Split Into Target Concurrency All DropIndex Auto Data All

    Although that just results in the error, “Field All does not exist in table {Table name}”.

    Is it possible to set a parameter specifying that it should copy all data, without having to specify every column?



  • 2.  RE: Retain data during split without specifying every data column

    Employee
    Posted 09-13-2017 13:44

    Hi Jonathan

    Unfortunately the aggregate part for all the object processing statement don't support that you specify "all". I could have used this some years back too.

    What I ended up doing was to write a small function that would loop the column, concatenate these two and two with a = in between.

    The result from this function I added to a string holding the object processing statement and then used Run Command to execute the final combined statement.

    Moving this to a function also gives me the option to handle certain conditions where I don't want to keep/write the value to the column. In some cases a single column in a table can be readonly for instance.

    It could look like this:

    Run Command "Objects Split Into Target Concurrency All DropIndex Auto Data " & COLGetColumnEqualColumns(sTab)

    Where COLGetColumnEqualColumns is the function I mentioned earlier



  • 3.  RE: Retain data during split without specifying every data column

    Posted 09-14-2017 06:39

    Hi Peter

    Ah, that's a pretty good solution, I didn’t think of calling a function like that as a

    parameter for the MapBasic call.

    Thanks!