home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / ijfire14.zip / install.cmd < prev    next >
OS/2 REXX Batch file  |  2000-03-03  |  18KB  |  768 lines

  1. /*
  2. ** Module   :INSTALL.CMD
  3. ** Abstract :Installation script for FXWRAP.SYS
  4. **
  5. ** Copyright (C) F/X Communications
  6. **
  7. ** Log: Sat  17/10/1998 Created
  8. **
  9. */
  10. level=1
  11.  
  12. '@echo off'
  13.  
  14. say 'FXWrap Install Copyright (C) 1998  F/X Communications'
  15. say
  16.  
  17. parse source os2 type invocation
  18. lastslash = lastpos('\',invocation)
  19. path = substr(invocation,1,lastslash-1)
  20.  
  21. /***************************************************************************
  22. ** Common part of installed/uninstaller
  23. */
  24.  
  25. /* Determine drive letter where OS/2 is installed */
  26.  
  27. drive=strip(left(value('COMSPEC',,'OS2ENVIRONMENT'),1))
  28.  
  29. do while drive='' | stream(drive':\config.sys','c','query exists')=''
  30.  
  31.     say 'Install is unable to automatically determine '
  32.     say 'drive letter where OS/2 is installed'
  33.     say
  34.  
  35.     /* unable to determine drive. Ask user */
  36.  
  37.     say 'Please enter drive letter for your OS/2 partition:'
  38.     pull drive
  39.     if length(drive)<>1 | stream(drive':\config.sys','c','query exists')=''
  40.     then do
  41.         say 'Invalid drive'
  42.         drive=''
  43.     end
  44. end
  45.  
  46. /* Determine PROTOCOL.INI location */
  47. config=drive':\config.sys'
  48. protini=''
  49.  
  50. do while lines(config)>0
  51.     str=translate(strip(linein(config)))
  52.  
  53.     if left(str,6)<>'DEVICE'
  54.         then iterate
  55.  
  56.     if pos('PROTMAN.OS2',str) >0
  57.     then do
  58.         parse value str with 'DEVICE='protman prot_path
  59.  
  60.         /* If /I: is specified, then use value passed in /I */
  61.         /* else use path of protman itself */
  62.  
  63.         prot_path=strip(prot_path)
  64.  
  65.         if prot_path = ''
  66.         then do
  67.             protini=left(protman, lastpos('\',protman)-1)
  68.         end
  69.         else do
  70.             parse value prot_path with beg':\'protman
  71.             protini=right(beg,1)':\'protman
  72.         end
  73.     end
  74. end
  75. call stream config, 'c', 'close'
  76.  
  77. do while protini=''
  78.     say 'Install is unable to automatically determine '
  79.     say 'path of PROTOCOL.INI'
  80.     say
  81.  
  82.     /* unable to determine drive. Ask user */
  83.     say 'Please enter path of PROTOCOL.INI:'
  84.     pull protini
  85.     if stream(protini'\protocol.ini','c','query exists')=''
  86.     then do
  87.         say 'Path is ivalid'
  88.     end
  89. end
  90.  
  91. /* check prerequisites */
  92.  
  93. if stream(protini'\PROTOCOL.!!!','c', 'query exists')<>''
  94. then do
  95.     say 'File PROTOCOL.!!! exists in directory 'protini
  96.     say 'Probably caused by cancelled installation of FXWRAP'
  97.     say 'Check contents of file, and please rename or delete it.'
  98.     say 'Then restart installation of FXWRAP.'
  99.     exit
  100. end
  101.  
  102. if stream(drive':\CONFIG.!!!','c', 'query exists')<>''
  103. then do
  104.     say 'File CONFIG.!!! exists in 'translate(drive)':\'
  105.     say 'Probably caused by cancelled installation of FXWRAP'
  106.     say 'Check contents of file, and please rename or delete it.'
  107.     say 'Then restart installation of FXWRAP.'
  108.     exit
  109. end
  110.  
  111. /* Last chance */
  112.  
  113. say 'Press'
  114. say '<I> to install FXWRAP'
  115. say '<U> to uninstall previously installed FXWRAP'
  116. say 'any other key to exit'
  117.  
  118. pull answer
  119.  
  120. backup_copy=backup_name(protini'\PROTOCOL.')
  121. backup_config=backup_name(drive':\CONFIG.')
  122.  
  123. if backup_copy='' | backup_config=''
  124. then do
  125.     say 'Unable to create backup copy of system files, aborting.'
  126.     exit
  127. end
  128.  
  129. if answer='U'
  130.     then call uninstall;
  131.  
  132. if answer='I'
  133.     then call install;
  134. exit
  135.  
  136. /*--------------------------------------------------------------------------*/
  137. /* Installation procedure                                                   */
  138. /*--------------------------------------------------------------------------*/
  139.  
  140. Install:
  141.  
  142. if stream(path'\FXWRAP.SYS','c', 'query exists')=''
  143. then do
  144.     say 'File FXWRAP.SYS is NOT found in the INSTALL.CMD directory, aborting.'
  145.     exit
  146. end
  147.  
  148. config=drive':\config.sys'
  149.  
  150. do while lines(config)>0
  151.     str=translate(strip(linein(config)))
  152.  
  153.     if left(str,6)<>'DEVICE'
  154.         then iterate
  155.  
  156.     if pos('FXWRAP.SYS', str) >0
  157.     then do
  158.         say 'Install does not support installation of more than one'
  159.         say 'instance of FXWRAP.SYS.'
  160.         exit
  161.     end
  162. end
  163. call stream config, 'c', 'close'
  164.  
  165.  
  166. /* Parse PROTOCOL.INI and build bind tree */
  167.  
  168. config=protini'\PROTOCOL.INI'
  169. nif_list=''
  170. bind_list.=''
  171. cur_nif=''
  172. tcpip_nif=''
  173.  
  174. /* determine full list of NIF's */
  175. /* determine full list of bindings for each NIF's*/
  176.  
  177. do while lines(config) > 0
  178.     str=strip(linein(config))
  179.     if str=''
  180.         then iterate;
  181.  
  182.     if left(str,1)=';'
  183.         then iterate;
  184.  
  185.     if left(str,1)='[' /*section name*/
  186.     then do
  187.         cur_nif=strip(substr(str,2,length(str)-2))
  188.  
  189.         if translate(cur_nif)='TCPIP_NIF'
  190.             then tcpip_nif=cur_nif;
  191.  
  192.         nif_list=nif_list' 'cur_nif
  193.         bind_list.cur_nif=''
  194.         bind_list.cur_nif.bound=0
  195.         iterate
  196.     end
  197.  
  198.     if cur_nif=''
  199.         then iterate;
  200.  
  201.     parse value str with variable'='var_value
  202.  
  203.     if translate(strip(variable))='BINDINGS'
  204.     then do
  205.         bind_list.cur_nif=var_value
  206.         iterate
  207.     end
  208.  
  209.     if cur_nif='IBMLXCFG'
  210.     then do
  211.         parse value str with nif_name'='file_name
  212.         nif_name=strip(nif_name)
  213.         file_name=strip(file_name)
  214.         bind_list.nif_name.file=file_name
  215.     end
  216. end
  217. call stream config, 'c', 'close'
  218. nif_list=strip(nif_list)
  219.  
  220. /* Determine bottom level NIF's */
  221.  
  222. bottom_nifs=''
  223.  
  224. do i=1 to words(nif_list)
  225.     call find_bindings word(nif_list,i)
  226. end
  227.  
  228. do i=1 to words(nif_list)
  229.     cur_nif=word(nif_list,i)
  230.  
  231.     if bind_list.cur_nif.bound = 1
  232.     then do
  233.         bottom_nifs=bottom_nifs' 'cur_nif
  234.     end
  235. end
  236.  
  237. bottom_nifs=strip(bottom_nifs)
  238.  
  239. /* */
  240. j=1
  241. sel_nif=-1
  242.  
  243. if pos('FXWRAP_NIF', translate(bind_list.tcpip_nif)) > 0
  244. then do
  245.     say 'Install does not support installation of more than one'
  246.     say 'instance of FXWRAP.SYS.'
  247.     exit
  248. end
  249.  
  250. /* Show note about possible problems */
  251.  
  252. say
  253. say '************************** WARNING !!! **************************'
  254. say
  255. say 'Installation of FXWRAP.SYS makes it impossible for MPTS.EXE to'
  256. say 'correctly process PROTOCOL.INI. If you need to use MPTS to change'
  257. say 'your network and protocol configuration, then uninstall FXWRAP,'
  258. say 'make MPTS changes, and then reinstall FXWRAP. Simply use'
  259. say 'INSTALL.CMD to install and uninstall FXWRAP.'
  260. say
  261. say '************************** WARNING !!! **************************'
  262. say
  263. say 'You have 'words(bottom_nifs)' LAN adapter(s) installed'
  264. say
  265. say 'Select the adapter attached to the external network'
  266. say '(or 0 to cancel the installation):'
  267. say
  268.  
  269. do i=1 to words(nif_list)
  270.     cur_nif=word(nif_list,i)
  271.  
  272.     if bind_list.cur_nif.bound = 1
  273.     then do
  274.         lan_num=wordpos(cur_nif, translate(bind_list.tcpip_nif,' ',','))-1
  275.         say j'. lan'lan_num':' strip(adapter_name(cur_nif))
  276.         j=j+1
  277.     end
  278. end
  279.  
  280. say '0. Exit'
  281.  
  282. do while sel_nif='' | verify(sel_nif,'0123456789') <> 0 | sel_nif < 0 | sel_nif >= j
  283.     say 'Choice:'
  284.     pull sel_nif .
  285. end
  286.  
  287. if sel_nif=0
  288.     then exit;
  289.  
  290. j = 0
  291.  
  292. replace_nif=''
  293.  
  294. do i=1 to words(nif_list)
  295.     cur_nif=word(nif_list,i)
  296.     if bind_list.cur_nif.bound = 1
  297.     then do
  298.         j = j + 1
  299.         if j = sel_nif
  300.         then do
  301.             replace_nif=cur_nif
  302.             leave;
  303.         end
  304.     end
  305. end
  306.  
  307. say 'Processing 'adapter_name(replace_nif)
  308.  
  309. infile =protini'\PROTOCOL.INI'
  310. outfile=protini'\PROTOCOL.!!!'
  311.  
  312. do while lines(infile) > 0
  313.     str2=linein(infile)
  314.     str=strip(str2)
  315.  
  316.     if str='' | left(str,1)=';' | left(str,1)='['
  317.     then do
  318.         call lineout outfile, str2
  319.         iterate
  320.     end
  321.  
  322.     parse value str2 with var_name'='var_value
  323.  
  324.     if translate(strip(var_name))='BINDINGS'
  325.     then do
  326.         repl_pos=pos(translate(replace_nif),translate(var_value))
  327.         if repl_pos > 0
  328.         then do
  329.             var_value=replace_bindings(var_value, replace_nif, 'FXWRAP_nif')
  330.             call lineout outfile, '   'strip(var_name)'   = 'var_value
  331.         end
  332.         else
  333.             call lineout outfile, str2;
  334.     end
  335.     else
  336.         call lineout outfile, str2;
  337. end
  338.  
  339. call lineout outfile,'[FXWRAP_nif]'
  340. call lineout outfile,''
  341. call lineout outfile,'   Drivername = FXWRAP1$'
  342. call lineout outfile,'   Bindings   = 'replace_nif
  343. call lineout outfile,''
  344.  
  345. call stream outfile, 'c', 'close'
  346. call stream infile, 'c', 'close'
  347.  
  348. say 'Processing 'translate(drive)':\CONFIG.SYS'
  349.  
  350. tmpconfig=drive':\CONFIG.!!!'
  351. infile   =drive':\CONFIG.SYS'
  352. inserted=0
  353.  
  354. do while lines(infile) > 0
  355.     str=linein(infile)
  356.     call lineout tmpconfig, str
  357.  
  358.     if inserted=1
  359.         then iterate;
  360.  
  361.     if pos('\IBMCOM\MACS\',translate(str)) > 0 & left(translate(strip(str)),6)='DEVICE'
  362.     then do
  363.         call lineout tmpconfig, 'DEVICE='protini'\MACS\FXWRAP.SYS'
  364.         inserted=1
  365.     end
  366. end
  367.  
  368. if inserted=0
  369. then do
  370.     call lineout tmpconfig, 'DEVICE='protini'\MACS\FXWRAP.SYS'
  371. end
  372.  
  373. call stream tmpconfig, 'c', 'close'
  374. call stream infile, 'c', 'close'
  375.  
  376. /* replace PROTOCOL.INI */
  377. /* replace CONFIG.SYS */
  378. /* copy FXWRAP.SYS to all other MAC's */
  379.  
  380. 'copy FXWRAP.SYS 'protini'\MACS >nul 2>nul'
  381. if rc<>0
  382. then do
  383.     say 'Unable to copy FXWRAP.SYS to 'protini'\MACS'
  384.     exit
  385. end
  386.  
  387. 'copy 'protini'\PROTOCOL.INI 'backup_copy '>nul 2>nul'
  388.  
  389. if rc<>0
  390. then do
  391.     say 'Unable to create backup copy of PROTOCOL.INI'
  392.     exit
  393. end
  394.  
  395. say protini'\PROTOCOL.INI saved as 'backup_copy;
  396.  
  397. 'copy 'drive':\CONFIG.SYS 'backup_config '>nul 2>nul'
  398.  
  399. if rc<>0
  400. then do
  401.     say 'Unable to create backup copy of CONFIG.SYS'
  402.     exit
  403. end
  404.  
  405. say drive':\CONFIG.SYS saved as 'backup_config
  406.  
  407. 'copy 'outfile protini'\PROTOCOL.INI >nul 2>nul'
  408. if rc<>0
  409. then do
  410.     say 'Unable to replace 'protini'\PROTOCOL.INI'
  411.     exit
  412. end
  413. 'del 'outfile '> nul 2>nul'
  414.  
  415. 'copy 'tmpconfig drive':\CONFIG.SYS >nul 2>nul'
  416. if rc<>0
  417. then do
  418.     say 'Unable to replace 'drive':\CONFIG.SYS'
  419.     exit
  420. end
  421. 'del 'tmpconfig '> nul 2>nul'
  422.  
  423. say 'Installation completed successfully'
  424. say 'You must reboot computer to activate FXWRAP.SYS device driver.'
  425.  
  426. return ''
  427.  
  428. /*--------------------------------------------------------------------------*/
  429. /* Uninstallation procedure                                                 */
  430. /*--------------------------------------------------------------------------*/
  431.  
  432. uninstall:
  433. /* Parse PROTOCOL.INI and build bind tree */
  434.  
  435. config=protini'\PROTOCOL.INI'
  436. nif_list=''
  437. bind_list.=''
  438. cur_nif=''
  439.  
  440. /* determine full list of NIF's */
  441. /* determine full list of bindings for each NIF's*/
  442.  
  443. do while lines(config) > 0
  444.     str=strip(linein(config))
  445.     if str=''
  446.         then iterate;
  447.  
  448.     if left(str,1)=';'
  449.         then iterate;
  450.  
  451.     if left(str,1)='[' /*section name*/
  452.     then do
  453.         cur_nif=strip(substr(str,2,length(str)-2))
  454.         nif_list=nif_list' 'cur_nif
  455.         bind_list.cur_nif=''
  456.         bind_list.cur_nif.bound=0
  457.         iterate
  458.     end
  459.  
  460.     if cur_nif=''
  461.         then iterate;
  462.  
  463.     parse value str with variable'='var_value
  464.  
  465.     if translate(strip(variable))='BINDINGS'
  466.     then do
  467.         bind_list.cur_nif=var_value
  468.         iterate
  469.     end
  470.  
  471.     if cur_nif='IBMLXCFG'
  472.     then do
  473.         parse value str with nif_name'='file_name
  474.         nif_name=strip(nif_name)
  475.         file_name=strip(file_name)
  476.         bind_list.nif_name.file=file_name
  477.     end
  478. end
  479.  
  480. call stream config, 'c', 'close'
  481.  
  482. nif_list=strip(nif_list)
  483.  
  484. /* Determine bottom level NIF's */
  485.  
  486. bottom_nifs=''
  487.  
  488. do i=1 to words(nif_list)
  489.     call find_bindings word(nif_list,i)
  490. end
  491.  
  492. do i=1 to words(nif_list)
  493.     cur_nif=word(nif_list,i)
  494.     /*say 'nif_list.'cur_nif'='bind_list.cur_nif*/
  495.     if bind_list.cur_nif.bound = 1
  496.     then do
  497.         bottom_nifs=bottom_nifs' 'cur_nif
  498.     end
  499. end
  500.  
  501. bottom_nifs=strip(bottom_nifs)
  502.  
  503. fxwrap_nif=''
  504. /* Find FXWRAP_nif and find their bindings */
  505. do i=1 to words(bottom_nifs)
  506.     cur_nif=word(bottom_nifs,i)
  507.     if left(translate(cur_nif),6)='FXWRAP'
  508.     then do
  509.         /*say cur_nif',' bind_list.cur_nif*/
  510.         fxwrap_nif=cur_nif
  511.         leave
  512.     end
  513. end
  514. if fxwrap_nif=''
  515. then do
  516.     say 'FXWRAP is NOT installed, aborting'
  517.     exit
  518. end
  519.  
  520. /*say cur_nif 'bound to' bind_list.cur_nif*/
  521.  
  522. say 'Processing 'fxwrap_nif
  523.  
  524. infile =protini'\PROTOCOL.INI'
  525. outfile=protini'\PROTOCOL.!!!'
  526.  
  527. do while lines(infile) > 0
  528.     str2=linein(infile)
  529.     str=strip(str2)
  530.  
  531.     if str='' | left(str,1)=';' | left(str,1)='['
  532.     then do
  533.         if left(str,1)='['
  534.         then do
  535.             if translate(strip(substr(str,2,length(str)-2)))=translate(fxwrap_nif)
  536.             then do
  537.                 do while lines(infile) > 0
  538.                     str2 = linein(infile)
  539.                     if left(strip(str2),1)='['
  540.                     then do
  541.                         call lineout outfile, str2;
  542.                         leave
  543.                     end
  544.                 end
  545.             end
  546.             else
  547.                 call lineout outfile, str2;
  548.         end
  549.         else
  550.             call lineout outfile, str2;
  551.         iterate
  552.     end
  553.  
  554.     parse value str2 with var_name'='var_value
  555.  
  556.     if translate(strip(var_name))='BINDINGS'
  557.     then do
  558.         repl_pos=pos(translate(fxwrap_nif),translate(var_value))
  559.         if repl_pos > 0
  560.         then do
  561.             var_value=replace_bindings(var_value, fxwrap_nif, bind_list.fxwrap_nif)
  562.             call lineout outfile, '   'strip(var_name)'   = 'var_value
  563.         end
  564.         else
  565.             call lineout outfile, str2;
  566.     end
  567.     else
  568.         call lineout outfile, str2;
  569. end
  570.  
  571. call stream outfile, 'c', 'close'
  572. call stream infile, 'c', 'close'
  573.  
  574. say 'Processing 'translate(drive)':\CONFIG.SYS'
  575.  
  576. tmpconfig=drive':\CONFIG.!!!'
  577. infile   =drive':\CONFIG.SYS'
  578. inserted=0
  579.  
  580. do while lines(infile) > 0
  581.     str=linein(infile)
  582.     /* Find FXWRAP.SYS */
  583.     if left(translate(strip(str)),6)='DEVICE' & pos('FXWRAP.SYS',translate(str)) > 0
  584.         then iterate;
  585.     else
  586.         call lineout tmpconfig, str;
  587. end
  588.  
  589. call stream tmpconfig, 'c', 'close'
  590. call stream infile, 'c', 'close'
  591.  
  592. /* replace PROTOCOL.INI */
  593. /* replace CONFIG.SYS */
  594. /* copy FXWRAP.SYS to all other MAC's */
  595.  
  596. 'copy 'protini'\PROTOCOL.INI 'backup_copy '>nul 2>nul'
  597.  
  598. if rc<>0
  599. then do
  600.     say 'Unable to create backup copy of PROTOCOL.INI'
  601.     exit
  602. end
  603.  
  604. say protini'\PROTOCOL.INI saved as 'backup_copy;
  605.  
  606. 'copy 'drive':\CONFIG.SYS 'backup_config '>nul 2>nul'
  607.  
  608. if rc<>0
  609. then do
  610.     say 'Unable to create backup copy of CONFIG.SYS'
  611.     exit
  612. end
  613.  
  614. say drive':\CONFIG.SYS saved as 'backup_config
  615.  
  616. 'copy 'outfile protini'\PROTOCOL.INI >nul 2>nul'
  617. if rc<>0
  618. then do
  619.     say 'Unable to replace 'protini'\PROTOCOL.INI'
  620.     exit
  621. end
  622. 'del 'outfile '> nul 2>nul'
  623.  
  624. 'copy 'tmpconfig drive':\CONFIG.SYS >nul 2>nul'
  625. if rc<>0
  626. then do
  627.     say 'Unable to replace 'drive':\CONFIG.SYS'
  628.     exit
  629. end
  630.  
  631. 'del 'tmpconfig '> nul 2>nul'
  632.  
  633. say 'Uninstallation completed successfully'
  634. say 'You must reboot computer to deactivate FXWRAP.SYS device driver.'
  635.  
  636. return ''
  637.  
  638. /*--------------------------------------------------------------------------*/
  639. /* Utility procedure                                                        */
  640. /*--------------------------------------------------------------------------*/
  641.  
  642. find_bindings: procedure expose bind_list. level
  643.     cur_nif=arg(1)
  644.  
  645.     if bind_list.cur_nif<>''
  646.     then do
  647.         /*bindings can be separated by commas and by spaces */
  648.         bind_list.cur_nif=space(translate(bind_list.cur_nif,' ', ','),1)
  649.  
  650.         do j=1 to words(strip(bind_list.cur_nif))
  651.             nif=word(strip(bind_list.cur_nif),j)
  652.             bind_list.nif.bound=1
  653.             call find_bindings nif
  654.         end
  655.     end
  656. return 0
  657.  
  658. adapter_name:
  659.     fname=arg(1)
  660.     adaptername=fname
  661.     fname=bind_list.fname.file
  662.     section=''
  663.  
  664.     if fname<>'' & stream(protini'\MACS\'fname,'c','query exists')<>''
  665.     then do
  666.         ad_nif=protini'\MACS\'fname
  667.  
  668.         do while lines(ad_nif)
  669.             str=strip(linein(ad_nif))
  670.  
  671.             if str=''
  672.                 then iterate;
  673.  
  674.             if left(str,'1')='['
  675.             then do
  676.                 if section<>''
  677.                     then leave; /* parse only first section of .NIF*/
  678.                 section=strip(substr(str,2,length(str)-2))
  679.                 iterate
  680.             end
  681.  
  682.             if section=''
  683.                 then iterate;
  684.  
  685.             parse value str with var_name'='var_value
  686.             if translate(strip(var_name))='TITLE'
  687.             then do
  688.                 adaptername=var_value
  689.                 leave
  690.             end
  691.         end
  692.         call stream ad_nif, 'c', 'close'
  693.     end
  694. return adaptername
  695.  
  696. backup_name: procedure
  697.     backup_copy=''
  698.     basefile=arg(1)
  699.     bkp=0
  700.  
  701.     do while backup_copy='' & bkp < 1000
  702.         bkp_ext=right(bkp,3,'0')
  703.         if stream(basefile||bkp_ext,'c','query exists')=''
  704.         then do
  705.             backup_copy=basefile||bkp_ext
  706.         end
  707.         bkp=bkp+1
  708.     end
  709. return backup_copy
  710.  
  711. /*
  712. replace_bindings: procedure
  713.     var_value=translate(strip(arg(1)),' ', ',')
  714.     find_nif=strip(arg(2))
  715.     repl_nif=strip(arg(3))
  716.     out=''
  717.  
  718.     if left(strip(arg(1)),1)=','
  719.         then var_value='~ 'var_value
  720.  
  721.     do i = 1 to words(var_value)
  722.  
  723.         if translate(word(var_value, i))=translate(find_nif)
  724.         then do
  725.             out=out||repl_nif;
  726.         end
  727.         else do
  728.             out = out||word(var_value, i)
  729.         end
  730.  
  731.         if i<>words(var_value)
  732.             then out=out||' '
  733.     end
  734.  
  735.     var_value=out
  736.  
  737.     if left(strip(arg(1)),1)=','
  738.         then var_value=substr(var_value,2);
  739.  
  740.     var_value=translate(var_value,',', ' ')
  741. return var_value
  742. */
  743.  
  744. replace_bindings: procedure
  745.     var_value=strip(arg(1))
  746.     find_nif=strip(arg(2))
  747.     repl_nif=strip(arg(3))
  748.     out=''
  749.  
  750.     do while var_value<>''
  751.         prev=strip(var_value)
  752.         parse value strip(var_value) with beg','var_value
  753.  
  754.         if translate(beg)=translate(find_nif)
  755.         then do
  756.             beg=repl_nif;
  757.         end
  758.  
  759.         out=out||beg
  760.         if var_value<>'' | prev=','
  761.             then out=out','
  762.     end
  763.  
  764.     var_value=out
  765.  
  766. return var_value
  767.  
  768.