Advertisement
ramkesheoran

ImportDataFrom_Notepad

Nov 2nd, 2011
2,962
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
XPP 1.88 KB | None | 0 0
  1. static void ImportDataFrom_Notepad(Args _args)
  2. {
  3. //     #define.ioComma(",")
  4. //     #define.ioEndLine("|")
  5. //     #define.ioEndLine("\n")
  6. //
  7. //     #define.ioRead("r")
  8. //
  9.      #define.ioComma("|")
  10.    //  #define.ioEndLine("|")
  11.      #define.ioEndLine("\n")
  12.  
  13.      #define.ioRead("r")
  14.  
  15.  
  16.      TestNotepad TestNotepad;
  17.      AsciiIo io ;
  18.      str Name;
  19.      str amount;
  20.      str currencyCode;
  21.      str transdate;
  22.  
  23.      int                         n = 1,idx =1;
  24.      SysOperationProgress        lprogress;
  25.      #AviFiles
  26.  
  27.     ;
  28.      io = new AsciiIo("C:\\Test\\28.txt", #ioRead);  // This is the network path where the data file will be read from
  29.     if(!io)
  30.       error ("File cannot be open");
  31.  
  32.     lprogress = new SysOperationProgress();
  33.     lprogress.setCaption("Insert From Notepad ");
  34.     lprogress.setAnimation(#AviUpdate);
  35.  
  36.     if (io)
  37.     {
  38.         io.inFieldDelimiter(#ioComma);
  39.         io.inRecordDelimiter(#ioEndLine);
  40.         [Name,transdate, amount ,currencyCode] = io.read();
  41.  
  42.         while (io.status() == IO_Status::Ok)
  43.             {
  44.                     if (io.status() != IO_Status::Ok)
  45.                     {
  46.                         error("File not found");
  47.                     }
  48.                 lprogress.setCount(n,Idx);
  49.                 lprogress.setText("Inserting trans");
  50.                 n++;
  51.                 Idx++;
  52.                 TestNotepad.Name = strltrim(Name);
  53. //                TestNotepad.TransDate =  mkdate( str2int( substr( transdate, 1, 2 ) ), str2int( substr( transdate, 3, 2 ) ), str2int( substr( transdate, 5, 4 ) ) );
  54.                 TestNotepad.TransDate =  str2date(transdate,123);
  55.                 TestNotepad.Amount = str2num(amount);
  56.                 TestNotepad.CurrencyCode = currencyCode;
  57.                 TestNotepad.insert();
  58.  
  59.                 [Name,transdate, amount ,currencyCode] = io.read();
  60.             }
  61.      }
  62. }
  63.  
  64.  
  65.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement