{ "header": { "version": 1, "type": "record" }, "body": { "record1": { "<1>": "declare function msg, end_window, fieldcount, get_status, post_event\r\ndeclare subroutine rlist, record_lock\r\n\r\n$insert logical\r\n$insert rlist_equates\r\n$insert msg_equates\r\n$insert dict_equates\r\n$insert message_box_equates\r\n\r\ndeclare subroutine update_index, SetInitDirOptions, yield\r\ndeclare function message_box\r\nequ CrLf$ to char(13):char(10)\r\n\r\n*CfgFile line one = number of columns\r\n*CfgFile line two = types 1=general 2=text\r\n*CfgFile line three = file to import in excel\r\n*CfgFile line four = number of column heading lines so excel can bold the fuckers\r\n*\r\n\r\nIF ( .util_start->visible = 1 )THEN \r\n @user0 = iconv( .util_start->text, 'D' )\r\n @user1 = iconv( .util_end->text, 'D' )\r\nEND\r\n*\r\n\r\nSystemGenerated = Get_Property( @window, '@SystemGenerated' )\r\nNoExcel = Get_Property( @window, '@NoExcel' )\r\nExpandMV = .expand_mv->check\r\nCfgFile = ''\r\nDosTable = .path->text\r\nIF DosTable[1,1] = 'C' or DosTable[1,1] = 'V' ELSE\r\n MsgInfo = ''\r\n MsgInfo = 'You must export only to your C: drive, or IF you are using terminal server use the V: drive...Please change the export path to reflect this.'\r\n MsgInfo = '!'\r\n Void = msg( '', MsgInfo )\r\n return 0\r\nEND\r\n\r\nOSOpen 'V:\\AUTOEXEC.BAT' To TPathHandle THEN \r\n OSClose TPathHandle\r\n DriveToUse = 'V:'\r\n DosTable[1,1] = 'V'\r\nEND ELSE\r\n DriveToUse = 'C:'\r\nEND\r\nCfgFile<2> = DosTable\r\n\r\nTable = .exporttablenames->text\r\nDictTable = 'DICT.':Table\r\nopen Table to TableVar ELSE\r\n Void = msg( '', 'Unable to open ':Table:'...' )\r\n return 0\r\nEND\r\nopen DictTable to @dict ELSE\r\n Void = msg( '', 'Unable to open ':DictTable:'...' )\r\n return 0\r\nEND\r\n\r\n\r\n\r\nstatus() = 0\r\noswrite '' on DosTable\r\nTstat = status()\r\nIF Tstat THEN \r\n Err = 'Bad operating system filename'\r\n Err<-1> = 'Access Denied'\r\n Err<-1> = 'Disk or Directory full'\r\n Err<-1> = 'Operating system error not defined elsewhere'\r\n Err<-1> = 'Attempt to write a read only file'\r\n Void = msg( '', Err )\r\n return 0\r\nEND\r\nosopen DosTable to DosTableVar ELSE\r\n Err = 'Bad operating system filename'\r\n Err<-1> = 'Access Denied'\r\n Err<-1> = 'File does not exist'\r\n Err<-1> = 'Undefined error'\r\n Void = msg( '', Err )\r\n return 0\r\nEND\r\n\r\nCLEARSELECT\r\n\r\nStatement = 'SELECT ':Table\r\nColumns = Get_Property(@WINDOW:'.EXPORT_INFO','ARRAY')<1>\t;*.export_info->array<1>\r\nswap @vm:@vm with '' in Columns\r\nIF Columns[-1,1] = @vm THEN Columns[-1,1] = ''\r\n\r\nBColumns = .query_info->array\r\nBColumnsQ = BColumns<2>\r\nBColumns = BColumns<1>\r\nswap @vm:@vm with '' in BColumns\r\nIF BColumns[-1,1] = @vm THEN BColumns[-1,1] = ''\r\nswap @vm:@vm with '' in BColumnsQ\r\nIF BColumnsQ[-1,1] = @vm THEN BColumnsQ[-1,1] = ''\r\nBcnt = fieldcount( BColumns, @vm )\r\nCcnt = fieldcount( Columns, @vm )\r\nCfgFile<1> = Ccnt\r\nIF Bcnt THEN \r\n\tFOR i = 1 to Bcnt\r\n\t CompVal = BColumnsQ<1,i>\r\n\t Op = field( CompVal, ' ', 1 )\r\n\t swap '~' with 'NOT ' in Op\r\n\t Rest = field( CompVal, ' ', 2, 999 )\r\n\t swap ' ' with '\" \"' in Rest\r\n\t Rest = '\"':Rest:'\"'\r\n\t IF CompVal <> '' THEN \r\n\t IF i = 1 THEN \r\n\t Statement := ' WITH ' \r\n\t END ELSE\r\n\t Statement := ' AND WITH '\r\n\t END\r\n\t Statement := BColumns<1,i>:' ':Op:' ':Rest\r\n\t END\r\n\tnext i\r\nEND\r\n\r\n\r\n\r\nIF Statement <> 'SELECT ':Table THEN \r\n * btree column selection\r\n DoneSelect = true$\r\n \r\n SWAP '\"TO\"' WITH 'TO' IN STATEMENT\r\n * ABOVE LINE OF CODE IS SO YOU CAN DO A RANGE ON ONE LINE\r\n * I.E. DATE_OUT FROM 8/1/97 TO 8/5/97 IT REMOVES THE QUOTES\r\n * IT WILL THEN USE THE INDEXES\r\n Void = utility( 'CURSOR', 'H' ) \r\n rlist( Statement, target_activelist$, '', '', '' )\r\n IF Get_Status(errCode) THEN\r\n \tCALL ErrMsg(errCode)\r\n \tRETURN\r\n END\r\n \r\nEND ELSE\r\n DoneSelect = false$\r\nEND\r\n\r\n*\r\nStatement = 'SELECT ':Table\r\nNColumns = .nquery_info->array\r\nNColumnsQ = NColumns<2>\r\nNColumns = NColumns<1>\r\nswap @vm:@vm with '' in NColumns\r\nIF NColumns[-1,1] = @vm THEN NColumns[-1,1] = ''\r\nswap @vm:@vm with '' in NColumnsQ\r\nIF NColumnsQ[-1,1] = @vm THEN NColumnsQ[-1,1] = ''\r\nNcnt = fieldcount( NColumns, @vm )\r\nIF Ncnt THEN \r\n\tFOR i = 1 to Ncnt\r\n\t CompVal = NColumnsQ<1,i>\r\n\t Op = field( CompVal, ' ', 1 )\r\n\t swap '~' with 'NOT ' in Op\r\n\t Rest = field( CompVal, ' ', 2, 999 )\r\n\t swap ' ' with '\" \"' in Rest\r\n\t Rest = '\"':Rest:'\"'\r\n\t IF CompVal <> ''THEN \r\n\t IF i = 1 THEN \r\n\t Statement := ' WITH ' \r\n\t END ELSE\r\n\t Statement := ' AND WITH '\r\n\t END\r\n\t Statement := NColumns<1,i>:' ':Op:' ':Rest\r\n\t END\r\n\tnext i\r\nEND\r\n\r\n\r\nIF Statement <> 'SELECT ':Table THEN \r\n Void = utility( 'CURSOR', 'H' )\r\n SWAP '\"TO\"' WITH 'TO' IN STATEMENT\r\n rlist( Statement, target_activelist$, '', '', '' ) \r\nEND ELSE\r\n IF DoneSelect = false$ THEN \r\n\t MsgInfo = ''\r\n\t MsgInfo = 'You have not defined any query information...Do you wish to export the whole table?'\r\n\t MsgInfo = '?'\r\n\t MsgInfo = 'BNYC'\r\n\t IF SystemGenerated THEN \r\n\t Resp = 1\r\n\t END ELSE\r\n\t Resp = msg( '', MsgInfo )\r\n\t END\r\n\t IF Resp = 1 THEN \r\n \t Void = utility( 'CURSOR', 'H' )\r\n \t rlist( Statement, target_activelist$, '', '', '' ) \r\n\t END ELSE\r\n\t return 0\r\n\t END\r\n END\r\nEND\r\n\r\nIF @reccount THEN \r\n Ccnt = fieldcount( Columns, @vm )\r\n\tBytePos = 0\r\n * set headings\r\n TColumns = Columns\r\n convert @vm to @fm in TColumns\r\n Headings = xlate( DictTable, TColumns, dict_display$, 'X' )\r\n CONVERT @VM TO ' ' IN HEADINGS\r\n * CAUSE IT WOULD CAUSE A SECOND HEADING LINE \r\n * SO THIS CODE IS IRRELEVANT ON PARSING MULTI LINE HEADINGS\r\n Continue = True$\r\n BlobOut = ''\r\n FOR i = 1 to 999 while Continue\r\n\t Continue = false$\r\n FOR j = 1 to Ccnt\r\n Thead = Headings\r\n BlobOut := Quote( Headings ):\",\"\r\n IF len( Headings ) THEN \r\n Continue = true$\r\n END\r\n\t next j\r\n\t BlobOut := CrLf$\r\n next i\r\n * END OF IRRELEVANT CODE\r\n CfgFile<3> = i-1\r\n TextCnt = 0\r\n TextCfgOut = ''\r\n \r\n FOR i = 1 to Ccnt\r\n Output = xlate( DictTable, Columns<1,i>, dict_conv$, 'X' )\r\n IF Output ELSE\r\n TextCnt +=1\r\n TextCfgOut := i:@fm\r\n END\r\n next i\r\n swap @fm with CrLf$ in TextCfgOut\r\n \r\n \r\n CfgFile<4> = TextCnt\r\n CfgFile<5> = TextCfgOut\r\n osbwrite BlobOut on DosTableVar AT BytePos\r\n\tBytePos += len( BlobOut )\t \r\n\tTstat = status()\r\n\tIF Tstat THEN \r\n\t Err = 'Bad operating system filename'\r\n\t Err<-1> = 'Access Denied'\r\n\t Err<-1> = 'Disk or directory full'\r\n\t Err<-1> = 'File does not exist'\r\n\t Err<-1> = 'Undefined error'\r\n\t Err<-1> = 'Attempt to write a read only file'\r\n\t Err<-1> = 'Invalid beginning byte position'\r\n\t Void = msg( '', Err )\r\n\t return 0\r\n\tEND\r\n FieldsRec = xlate( DictTable, '%FIELDS%', '', 'X' )\r\n \r\n * setup positions or tag as null\r\n \r\n Fmcs\t\t= ''\r\n Parts\t\t= ''\r\n Outputs\t\t= ''\r\n MultiValue\t= ''\r\n FOR i = 1 to Ccnt\r\n locate Columns<1,i> in FieldsRec<3> using @vm setting Fpos THEN \r\n Fmcs\t\t\t= FieldsRec\r\n Parts\t\t= FieldsRec\r\n Outputs\t\t= FieldsRec\r\n MultiValue\t= FieldsRec\r\n END ELSE\r\n MsgInfo = ''\r\n MsgInfo = 'Unable to locate ':Columns<1,i>:' in %FIELDS%...Get Bryce for Help.'\r\n MsgInfo = '!'\r\n Void = msg( '', MsgInfo )\r\n return 0\r\n END\r\n next i\r\n IF ExpandMV THEN \r\n\t locate 0 in Fmcs using @fm setting IDPos ELSE\r\n\t MsgInfo = ''\r\n\t MsgInfo = 'You have choosen to expand multi-values, you must select the ID to the table as one of your export colums, so you know which record each value corresponds to. Typically this is SEQ.'\r\n\t MsgInfo = 'H'\r\n\t Void = msg( '', MsgInfo )\r\n\t return 0\r\n\t END\r\n END\r\n .percent_complete->visible = 1\r\n .gasbarbox->visible = 1\r\n CurrentSize = .gasbar->size\r\n NewSize = CurrentSize\r\n NewSize<3> = 0\r\n .gasbar->size = NewSize\r\n .gasbar->visible = 1\r\n\t@rn.counter = 0\r\n\tEof = false$\r\n\tOnePercent = iconv( @reccount*.01, 'MD0' )\r\n\tloop\r\n\t readnext @id ELSE Eof = true$\r\n\tuntil Eof\r\n\t read @record from TableVar, @id ELSE\r\n\t Void = msg( '', 'Unable to read ':@id:' from ':Table )\r\n\t return 0\r\n\t END\r\n\t BlobOut = ''\r\n\t Continue = true$\r\n\t \r\n\t\tFOR I = 1 TO 999 WHIle Continue\r\n\t\t\tContinue = false$\r\n\t\t\tFOR J = 1 TO Ccnt\r\n\t\t\t\tThisFmc = Fmcs\r\n\t\t\t\tIsMV = MultiValue\r\n\t\t\t\t\r\n\t\t\t\tIF ThisFmc <> '' THEN\r\n\t\t\t\t\tIF ThisFmc = 0 THEN\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\tIF Parts NE '' THEN\r\n\t\t\t\t\t\t\tTCol = FIELD(@ID,'*',Parts)\r\n\t\t\t\t\t\tEND ELSE\r\n\t\t\t\t\t\t\tTCol = @id\r\n\t\t\t\t\t\tEND\r\n \r\n\t\t\t\t\t\tIF Outputs NE '' THEN TCol = OCONV(Tcol,Outputs)\r\n \r\n\t\t\t\t\t\tIF ExpandMV AND TCol<1,i> = '' AND NOT(IsMV) THEN\r\n\t\t\t\t\t\t\tBlobOut := quote( TCol<1,1> ):',' \r\n\t\t\t\t\t\tEND ELSE\r\n\t\t\t\t\t\t\tBlobOut := quote( TCol<1,i> ):','\r\n\t\t\t\t\t\tEND\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t END ELSE\r\n\r\n\t\t\t\t\t\tTCol = @RECORD\r\n\t\t\t\t\t\tconvert '\"' to '' in TCol\r\n\t\t\t\t\t\tThisOutput = Outputs\r\n\t\t\t\t\t\tIF ThisOutput THEN\r\n\t\t\t\t\t\t\tIF ExpandMV AND TCol<1,i> = '' AND NOT(IsMV) THEN\r\n\t\t\t\t\t\t\t\tBlobOut := QUOTE( OCONV( TCol<1,1>, ThisOutput ) ):',' \r\n\t\t\t\t\t\t\tEND ELSE\r\n\t\t\t\t\t\t\t\tBlobOut := QUOTE( OCONV( TCol<1,i>, ThisOutput ) ):','\r\n\t\t\t\t\t\t\tEND\r\n\t\t\t\t\t\tEND ELSE\r\n\t\t\t\t\t\t\tIF ExpandMV AND TCol<1,i> = '' AND NOT(IsMV) THEN\r\n\t\t\t\t\t\t\t\tBlobOut := QUOTE( TCol<1,1> ):',' \r\n\t\t\t\t\t\t\tEND ELSE\r\n\t\t\t\t\t\t\t\tBlobOut := QUOTE( TCol<1,i> ):','\r\n\t\t\t\t\t\t\tEND\r\n\t\t\t\t\t\tEND\r\n\t\t\t\t\t\tIF LEN( Tcol<1,i+1> ) THEN\r\n\t\t\t\t\t\t\tContinue = true$\r\n\t\t\t\t\t\tEND\r\n\t\t\t\t\tEND\r\n\t\t\t\tEND ELSE\r\n * calculate\r\n TCol = calculate( Columns<1,j> )\r\n convert '\"' to '' in TCol\r\n ThisOutput = Outputs\r\n IF ThisOutput THEN \r\n IF ExpandMV AND TCol<1,i> = '' AND not(IsMV) THEN \r\n BlobOut := quote( oconv( TCol<1,1>, ThisOutput ) ):',' \r\n END ELSE\r\n BlobOut := quote( oconv( TCol<1,i>, ThisOutput ) ):','\r\n END\r\n END ELSE\r\n IF ExpandMV AND TCol<1,i> = '' AND not(IsMV) THEN \r\n BlobOut := quote( TCol<1,1> ):',' \r\n END ELSE\r\n BlobOut := quote( TCol<1,i> ):','\r\n END\r\n END\r\n IF len( Tcol<1,i+1> ) THEN \r\n Continue = true$\r\n END\r\n END \r\n\t next j\r\n\t BlobOut := CrLf$\r\n\t next i\r\n\t osbwrite BlobOut on DosTableVar AT BytePos\r\n\t BytePos += len( BlobOut )\t \r\n\t Tstat = status()\r\n\t IF Tstat THEN \r\n\t Err = 'Bad operating system filename'\r\n\t Err<-1> = 'Access Denied'\r\n\t Err<-1> = 'Disk or directory full'\r\n\t Err<-1> = 'File does not exist'\r\n\t Err<-1> = 'Undefined error'\r\n\t Err<-1> = 'Attempt to write a read only file'\r\n\t Err<-1> = 'Invalid beginning byte position'\r\n\t Void = msg( '', Err )\r\n\t return 0\r\n\t END\r\n IF mod( @rn.counter, OnePercent ) ELSE\r\n\t \t NewWidth = CurrentSize<3> * @rn.counter/@reccount\r\n\t\t .percent_complete->text = oconv(iconv( @rn.counter/@reccount*100, 'MD0' ), 'MD0' ):'%'\r\n\t\t NewSize<3> = NewWidth\r\n\t\t .gasbar->redraw = 0\r\n\t\t .gasbar->size = NewSize\r\n\t .gasbar->redraw = 1\r\n\t END\r\n\trepeat\r\n IF @rn.counter > 0 AND @reccount > 0 THEN \r\n\t NewWidth = CurrentSize<3> * @rn.counter/@reccount\r\n\t .percent_complete->text = oconv(iconv( @rn.counter/@reccount*100, 'MD0' ), 'MD0' ):'%'\r\n\t NewSize<3> = NewWidth\r\n\t .gasbar->redraw = 0\r\n\t .gasbar->size = NewSize\r\n\t .gasbar->redraw = 1\r\n END\r\n .percent_complete->visible = 0\r\n .gasbarbox->visible = 0\r\n swap @fm with CrLf$ in CfgFile\r\n CfgFile := CrLf$\r\n oswrite CfgFile on DriveToUse:'\\IMP.CFG' \r\n IF status() THEN \r\n Void = msg( '', 'Error creating Excel import config file.':DriveToUse:'\\IMP.CFG' )\r\n return 0\r\n END\r\n osclose DosTableVar\r\n\r\n \r\n\tSetInitDirOptions(\"D\")\r\n\tList = ''\r\n\t\r\n\tOfficePath = DriveToUse:'\\Program Files\\Microsoft Office 2000\\Office'\r\n\tinitdir OfficePath\r\n\tList = DirList()\r\n\t\r\n\tIF List = '' THEN\r\n\t\tOfficePath = DriveToUse:'\\Program Files\\Microsoft Office\\Office'\r\n\t\tinitdir OfficePath\r\n\t\tList = DirList()\r\n\tEND\r\n\t\t\r\n\tIF List = '' THEN\r\n\t\tFOR i = 1 to 15\r\n\t\t\tOfficePath = DriveToUse:'\\Program Files\\Microsoft Office\\Office':I\r\n\t\t\tinitdir OfficePath\r\n\t\t\tlist = DirList()\r\n\t\tuntil list <> ''\r\n\t\tnext i\r\n\tEND\r\n\r\n\tIF NoExcel ELSE\r\n RetVal = utility( 'RUNWIN', OfficePath:'\\EXCEL.EXE R:\\OINSIGHT\\IMPORT.XLS', '' )\r\n END\r\n\r\n \r\n IF SystemGenerated AND not( NoExcel ) THEN \r\n\t\tTCust = Get_Property( @window, '@CurCustomer' ) \r\n \tMsgText = ''\r\n \tMsgText:= CrLf$:'1) Check the data'\r\n \tMsgText:= CrLf$:'2) Save the spreadsheet As \"Microsoft Excel 97-2000 & 5.0/95 Workbook.\"'\r\n \tMsgText:= CrLf$:'3) Name the spreadsheet starting with CustomerName AND THEN n...for the shipment number of the day.'\r\n \tMsgText:= CrLf$:'4) Launch Lotus Notes AND Email this spreadsheet to ':TCust:'.'\r\n \t*Void = message_box( '', MsgText, 'Email Reminder!', MSG_ICON_INFO$ + MSG_BTN_OK$ ) \r\n \tVoid = post_event( @window, 'CLOSE' )\r\n END\r\nEND ELSE\r\n MsgInfo = ''\r\n MsgInfo = 'No records meeting your search criteria...'\r\n MsgInfo = '!'\r\n Void = msg( '', MsgInfo )\r\nEND\r\n\r\nVoid = utility( 'CURSOR', 'A' )\r\n@user0 = ''\r\n@user1 = ''\r\nreturn 0\r\n\r\n*===========================================================================*\r\nCheckError:\r\n Status = get_status( ErrorCodes )\r\n ErrorCode = Get_Property( Parent, 'DDEERROR' )\r\n* DEBUG\r\nreturn\r\n\r\n*===========================================================================*\r\n\r\n" } } }