Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for cdadd.cmd

(view source code of cdadd.cmd as plain text)

  1. /*
  2.  ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
  3.  º CDadd:                  Adds all CDs from a list (CDPTXT.INI) to CDP.INI  º
  4.  º Written by Rob van der Woude                                              º
  5.  º Latest revision:   1999/08/02                                             º
  6.  º This program needs CDlist.cmd to create CDPTXT.INI                        º
  7.  º Please feel free to use, distribute and modify this program.              º
  8.  º However, do so entirely at your own risk.                                 º
  9.  º The author cannot be held responsible for any damage or loss of data,     º
  10.  º caused by the use or inability to use this program.                       º
  11.  º If you modify this program, please document the modifications.            º
  12.  º I would also like to receive an e-mail message stating the nature of the  º
  13.  º modifications.                                                            º
  14.  ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
  15. */
  16.  
  17. /* Initialize RexxUtil */
  18. call RxFuncAdd "SysLoadFuncs", "RexxUtil", "SysLoadFuncs"
  19. call SysLoadFuncs
  20.  
  21. mmbase = strip( value( "MMBASE", , "OS2ENVIRONMENT" ), "T", ";" )
  22. cdpini = mmbase||"\CDPNEW.INI"
  23. cdptxt = mmbase||"\CDPTXT.INI"
  24. cdpbak = mmbase||"\CDPNEW.BAK"
  25.  
  26. call SysFileTree cdptxt, "found.", "F"
  27. if found.0 <> 1 then do
  28. 	call SysCls
  29. 	say ""
  30. 	call beep 880, 250
  31. 	say " CDPTXT.INI not found!"
  32. 	say " Call "||progname||" from the drive where CDPTXT.INI is located"
  33. 	say ""
  34. 	exit
  35. end
  36.  
  37. call SysFileTree cdpini, "exist.", "F", , "**---"
  38. if exist.0 = 1 then do
  39. 	call SysFileTree cdpbak, "exist.", "F", , "**---"
  40. 	if exist.0 = 1 then address CMD "@CMD /C DEL "||cdpbak
  41. 	address CMD "@CMD /C REN "||cdpini||" *.BAK"
  42. end
  43.  
  44. /* Reset file */
  45. call lineout cdptxt
  46. inline = linein( cdptxt, 1, 1 )
  47.  
  48. /* Check header */
  49. test1 = ";Tekst-versie van CDP.INI"
  50. test2 = ";Text version of CDP.INI"
  51. if inline <> test1 & inline <> test2 then do
  52. 	call SysCls
  53. 	say ""
  54. 	call beep 440, 250
  55. 	call beep 880, 250
  56. 	call beep 1760, 250
  57. 	say " ERROR: the file "||cdptxt||" is invalid."
  58. 	say ""
  59. 	say " Correct the error and try again."
  60. 	say ""
  61. 	exit
  62. end
  63.  
  64. call SysCls
  65. cd.  = ""
  66. cd.0 = 0
  67. Checksum = "Checksum"
  68. IMMCDDiscTitle = "IMMCDDiscTitle"
  69. IMMCDDiscProgram = "IMMCDDiscProgram"
  70.  
  71. /* Read and process the lines one by one */
  72. do until lines( cdptxt ) = 0
  73. 	inline  = linein( cdptxt, , 1 )
  74. 	select
  75. 		when inline = "" & cd.Checksum <> "" then do
  76. 			say "["||cd.Checksum||"]"
  77. 			say "09"X||"IMMCDDiscTitle = "||cd.IMMCDDiscTitle
  78. 			say "09"X||"IMMCDDiscProgram = "||cd.IMMCDDiscProgram
  79. 			cd.0 = ( length( cd.IMMCDDiscProgram ) - 3 ) / 2
  80. 			do i=1 to cd.0 by 1
  81. 				say "09"X||i||" = "||cd.i
  82. 			end
  83. 			say ""
  84. 			interpret 'cd.IMMCDDiscProgram = 'cd.IMMCDDiscProgram
  85. 			call SysIni cdpini, cd.Checksum, "IMMCDDiscTitle", cd.IMMCDDiscTitle
  86. 			call SysIni cdpini, cd.Checksum, "IMMCDDiscProgram", cd.IMMCDDiscProgram
  87. 			do i=1 to cd.0 by 1
  88. 				call SysIni cdpini, cd.Checksum, i, cd.i
  89. 			end
  90. 			cd.  = ""
  91. 			cd.0 = 0
  92. 		end
  93. 		when abbrev( inline, "  " ) = 1 then do
  94. 			cd_entry = strip( inline )
  95. 			parse value cd_entry with key"="cdvalue
  96. 			key     = strip( key )
  97. 			cdvalue = strip( cdvalue )
  98. 			do forever
  99. 				parse value cdvalue with lead"; "trail
  100. 				if trail = "" then leave
  101. 				cdvalue = lead||"0D0A"X||trail
  102. 			end
  103. 			cd.key = cdvalue
  104. 		end
  105. 		otherwise nop
  106. 	end
  107. end
  108.  

page last modified: 2023-03-10