I've been stuck on this one for several days now, I am missing something, but don't know what. I need a new pair of eyes to help me solve the problem.
Rasion d'etre for the script.
I am importing Aircraft Histories written in Excel into a table, The format of the spreadsheet is that each REG field has its own line of information. I am trying to automate the sequence of converting all the lines of a corresponding MSN into one record in the Table. [See attached PDF of Table]. I can explain better if you have the PDF in front of you.
1. right-click on the records with a blue background and run script from a small Right_click Menu with the script name on it.
2. I want the script to fetch_prev though the table while field MSN is blank, keeping the REG field value and adding each old one to the Old_id field as well as carrying backwards any values in the Op_name SUB and STATUS fields.
the records with the grey and Blue background to be deleted after being processed by the script.
the result I am after is to have just line with red font [on the pdf example] with all the info from the deleted lines.
My code so far is as follows:
thanks in anticipation
P.S [Added later]
I can only get the script to do 2 iterations beford it ends. It works if I keep clicking away on the right-click menu, so I think the logic is basically sound, it's the code in the last IF.. THEN statement that is causing me problems, its something to do with recno() I think, but am clutching at straws now.
Rasion d'etre for the script.
I am importing Aircraft Histories written in Excel into a table, The format of the spreadsheet is that each REG field has its own line of information. I am trying to automate the sequence of converting all the lines of a corresponding MSN into one record in the Table. [See attached PDF of Table]. I can explain better if you have the PDF in front of you.
1. right-click on the records with a blue background and run script from a small Right_click Menu with the script name on it.
2. I want the script to fetch_prev though the table while field MSN is blank, keeping the REG field value and adding each old one to the Old_id field as well as carrying backwards any values in the Op_name SUB and STATUS fields.
the records with the grey and Blue background to be deleted after being processed by the script.
the result I am after is to have just line with red font [on the pdf example] with all the info from the deleted lines.
My code so far is as follows:
Code:
tbl = table.current() idx = tbl.index_primary_put() tbl.query_detach_all() dagger: dim CurrentReg as c = current(tbl.reg) dim CurrentMsn as c = current(tbl.msn) dim CurrentOper as c = current(tbl.op_name) dim CurrentStatus as c = current(tbl.status) dim CurrentSub as c = current(tbl.sub) dim CurrentOldId as c = current(tbl.old_id) IF ut(CurrentMsn) = "" THEN tbl.fetch_prev() IF ut(CurrentReg) = "" THEN tbl.change_begin() tbl.op_name = CurrentOper tbl.status = CurrentStatus IF ut(CurrentSub) <> "" THEN tbl.sub = CurrentSub END IF tbl.change_end(.t.) ELSE dim PrevReg as c = current(tbl.reg) IF ut(CurrentOldId) = "" THEN Nod = "" ELSE Nod = "," + ut(CurrentOldId) END IF tbl.change_begin() IF isblank("tbl.old_id") THEN tbl.old_id = ut(PrevReg) + nod ELSE tbl.old_id = ut(tbl.old_id) + "," + ut(PrevReg) + nod END IF tbl.status = CurrentStatus tbl.op_name = CurrentOper tbl.Reg = CurrentReg IF ut(CurrentSub)<> "" THEN tbl.sub = ut(CurrentSub) END IF tbl.change_end(.t.) END IF tbl.fetch_next() tbl.change_begin() tbl.delete() tbl.change_end(.t.) topparent.refresh_layout() sys_send_keys("{up}") tbl.fetch_prev() END IF CurrentMsn = current(tbl.msn) IF ut(CurrentMsn) = "" goto dagger END IF
P.S [Added later]
I can only get the script to do 2 iterations beford it ends. It works if I keep clicking away on the right-click menu, so I think the logic is basically sound, it's the code in the last IF.. THEN statement that is causing me problems, its something to do with recno() I think, but am clutching at straws now.
Comment