Link to home
Start Free TrialLog in
Avatar of maximus1974
maximus1974

asked on

How to run a script in foxpro

I want to run the following script in foxpro. How can I do this? never used Foxpro and can't find an easy to do it.

 
procedure dropinvt  &&  added by dvfp when AllInOneFile is set
   close databases
   set talk off
   set safety off
   set exclusive off
   clear
   M0date = Date()
   Mwono = '    100'
   select 0
   use sysdata
   locate for Upper(Sysid)='AR01'
   store SubStr(Str(1000+Val(SubStr(Link,37,3)),4,0),2,3) to Mbatch
   select 1
   use data\wo100 alias A_import
   replace all ;
          Status with ''
   select 0
   use data\arinvt01 alias A_arinvt order item
   set filter to !Deleted()
   select 0
   use data\aridet01 alias A_aridet order item
   set filter to Qty>0 and Status<>'I'
   select 0
   use data\arseri01 alias A_arseri order serno1
   set filter to Status<>'I'
   select 0
   use data\aritrn01 alias A_aritrn
   select 0
   use data\womast01 alias A_womast order wono
   select 0
   use data\wotran01 alias A_wotran
   set filter to !Deleted()
   set order to 'LINENO'
   select A_import
   go top
   wait window noWait 'Working on WO '+AllTrim(Mwono)+' ....'
   scan
      select A_import
      Mitem = Item
      Mitemtrim = F0itemtr(Mitem)
      Mserno = A_import.Serno
      Mseqno = A_import.Seqno
      select A_arinvt
      seek Mitem
      if !Found()
         select A_import
         replace ;
                Status with 'PN NOT DEFINED'
         loop
      endif
      Isdet = .F.
      select A_aridet
      if A_arinvt.Serial='Y'
         if Empty(Mserno)
            select A_import
            replace ;
                   Status with 'SN MISSING'
            loop
         endif
         set order to 'serno1'
         seek Mserno+A_arinvt.Item
         if !Found()
            select A_import
            replace ;
                   Status with 'SN NOT IN DETAIL'
            loop
         endif
         select A_arseri
         set order to 'serno1'
         seek Mserno+A_arinvt.Item
         if Found()
            replace ;
                   Status with 'I'
            replace ;
                   Sysdate with (Date()), ;
                   Systime with Time(), ;
                   Userid with 'WO '+AllTrim(Mwono)
         endif
      else
         Isdet = .F.
         select A_aridet
         set order to 'seqno'
         seek Mseqno
         scan while Seqno=Mseqno
            if Item=Mitem
               Isdet = .T.
               exit
            endif
         endscan
         if !Isdet
            select A_import
            replace ;
                   Status with 'NOT IN DETAIL'
            loop
         endif
      endif
      select A_aritrn
      append blank
      replace ;
             Code with 'I', ;
             Item with A_arinvt.Item, ;
             Tdate with (M0date)
      replace ;
             Ref with 'WO '+AllTrim(Mwono), ;
             Qty with -A_import.Qty
      replace ;
             Cost with A_aridet.Cost, ;
             glAsst with A_arinvt.glLink, ;
             Whse with A_aridet.Whse
      replace ;
             Batch with Mbatch, ;
             Class with A_arinvt.Class, ;
             Cond with A_aridet.Cond
      replace ;
             Module with 'IT', ;
             Notes with A_aridet.Notes
      replace ;
             oWner with A_aridet.oWner, ;
             Consign with A_aridet.Consign
      replace ;
             puRno with A_aridet.puRno, ;
             puRdate with A_aridet.puRdate, ;
             Vendno with A_aridet.Vendno
      replace ;
             Invtcode with A_aridet.Invtcode, ;
             Spec_code with A_aridet.Spec_code
      replace ;
             Serno with A_aridet.Serno, ;
             Certifi with A_aridet.Certifi, ;
             Expdate with A_aridet.Expdate
      replace ;
             Cycles with A_aridet.Cycles, ;
             Remain with A_aridet.Remain, ;
             Hours with A_aridet.Hours
      replace ;
             oVeramt with A_aridet.oVeramt, ;
             Times with A_aridet.Times, ;
             Manuf with A_aridet.Manuf
      replace ;
             Cyclelimit with A_aridet.Cyclelimit, ;
             Timelimit with A_aridet.Timelimit
      replace ;
             Wono with Mwono, ;
             Lineno with A_aridet.Lineno
      replace ;
             oVertag with A_aridet.oVertag, ;
             oVershop with A_aridet.oVershop, ;
             oVerdate with A_aridet.oVerdate
      replace ;
             Model with A_aridet.Model, ;
             Apno with A_aridet.Apno, ;
             Batchno with A_aridet.Batchno, ;
             loTno with A_aridet.loTno
      replace ;
             Sysdate with (Date()), ;
             Systime with Time(), ;
             Userid with 'WO '+AllTrim(Mwono)
      select A_wotran
      Mlineno = Sys3()
      do while .T.
         seek Mlineno
         if Eof()
            exit
         endif
         Mlineno = Sys3()
      enddo
      append blank
      replace ;
             Wono with Mwono, ;
             Task with 'SCRAP'
      replace ;
             Item with Mitem, ;
             Descrip with A_arinvt.Descrip, ;
             Cond with A_aridet.Cond, ;
             Cost with A_aridet.Cost
      replace ;
             Lineno with Mlineno, ;
             Stkcode with A_arinvt.Stkcode
      replace ;
             Wotype with 'W', ;
             Custno with A_womast.Custno, ;
             Wodate with M0date
      replace ;
             Class with A_arinvt.Class, ;
             Rework with 'N'
      replace ;
             Comment with 'IMPORTED BY DROPINVT'
      replace ;
             Dept with A_womast.Dept, ;
             glLink with A_arinvt.glLink
      replace ;
             Qtyreq with A_import.Qty, ;
             Kit with 'N'
      replace ;
             Serno with Mserno, ;
             Qty with A_import.Qty, ;
             Add_qty with Qty
      replace ;
             Sysdate with Date(), ;
             Systime with Time(), ;
             Userid with Sys(0)
      replace ;
             Add_date with M0date, ;
             Add_time with Time(), ;
             Add_user with Sys(0)
      replace ;
             Listprice with A_arinvt.Price
      replace ;
             Gen_by with 'W'
      select A_arinvt
      if oNhand-A_import.Qty<=0
         replace ;
                oNhand with 0
      else
         replace ;
                oNhand with oNhand-A_import.Qty
      endif
      select A_aridet
      if A_arinvt.Serial='Y'
         replace ;
                Status with 'I', ;
                Qty with 0
      else
         if Qty-A_import.Qty<=0
            replace ;
                   Status with 'I', ;
                   Qty with 0
         else
            replace ;
                   Qty with Qty-A_import.Qty
         endif
      endif
      replace ;
             Invno with AllTrim(Mwono), ;
             Wono with Mwono, ;
             Task with 'SCRAP'
      replace ;
             Userid with 'WO '+AllTrim(Mwono), ;
             Sysdate with Date(), ;
             Systime with Time()
      select A_import
   endscan
   select A_import
   set filter to !Empty(Status)
   go top
   if !Eof()
      copy to 'reject.xls' type xls
      wait window 'Found rejects, please review Reject.xls and correct the Invt. thru Invt. Transfers as needed. Press and key.'
   endif
   close databases
   clear
   wait window 'Import complete, please go into Qavw and check the results'+Chr(13)+'Restore from a backup as needed.'+Chr(13)+Chr(13)+'Press any key to end.'
   clear
   return

procedure f0itemtr
   parameters Mtitem
   private Mcount, Mxitem
   if Empty(Mtitem)
      return ''
   endif
   Mcount = 1
   Mtitemtrim = ''
   Mxitem = AllTrim(Mtitem)
   Mlitem = Len(Mxitem)
   do while Mcount<=Mlitem
      if SubStr(Mxitem,Mcount,1)$'0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
         Mtitemtrim = Mtitemtrim+SubStr(Mxitem,Mcount,1)
      endif
      Mcount = Mcount+1
   enddo
   Mtitemtrim = Left(Mtitemtrim+Space(35),35)
   return Mtitemtrim
endproc

procedure sys3
   return SubStr(Sys(2015),3,10)
endproc

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of jrbbldr
jrbbldr

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of Pavel Celba
Pavel Celba
Flag of Czechia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of maximus1974
maximus1974

ASKER

I cannot find a dropinvt.prg anywhere. is it possible he named the *.prg a different name? Would it work that way.
Please pardon my ignorance.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you. What about if I cannot find the .prg file? is it possible for the fxp to run without the prg? If not, this means the prg file associated with the dropinvt.fxp is somewhere within the Server.
FoxPro can use/interpret either FXP or PRG.  FXP = PRG processed by COMPILE command.

FoxPro Run-time (used when you have vRunFox9.EXE) cannot use the PRG file directly. You have to compile it into FXP file first.

The COMPILE command just "slightly" changes the PRG, e.g. keywords are encoded to one or two bytes, variable names are converted to Name Table etc. FXP does not mean binary code like the one generated by e.g. C++ compilers.  FoxPro COMPILE command does not optimize the code in any way.

I've supposed you have dropinvt.prg available when reading the source code in your question. But the PRG can have any name OS allows.