Daily Build Script Sample

These days, I still get query about my article 7 steps of daily build process I posted at the end of 2002. I have not posted to devmanclub.com for a long time. I feel guilty that lots of people are asking for the daily build script I mentioned. I’d like to post the article I wrote two years ago here and share with my readers who are interested in development management processes.

Seven steps of build and release process

1. The builder (part of development team) is primarily responsible for managing the build release.

2. A build is made after the check-in deadline. Typically build will be made at mid-night.

3. The builder creates a share point on a well-known server for releasing the builds. The share point to be used will be \\servername\builds [1]

4. Under this share point, each build is released. The process of release would be a copy of all the relevant binaries, files and necessary setup scripts from the build machine to a corresponding directory under the share point. The build release directories would be named as the build number. \\servername\builds\buildnumber.[2]

5. The most recent build will always be mapped to the release point of \\servername\builds\current [3]. This enables easy location of the current release and also helps in the development of automated scripts by the development and testing community to install the most current build on their test machines etc.

6. At any time, the last 20 will be kept on the build release server. As new builds are released, the old ones falling outside this range will be archived.

7. All key milestone builds will be kept on the release machines until the product is released. The release directories would be appropriately named. For example, \\servername\builds\beta1 would contain the Beta1 of the application.

================================================================================

[1] This is a typical file share. Right click a folder in Windows Explorer and select Share…

[2] The folder will be created by build script.

[3] You can archive this using DFS (Distributed File System) that comes with Windows 2000

作者:王建硕

声明:本脚本及注释仅代表个人观点,不代表任何组织或公司。

它以”现状”提供且没有任何担保,同时也没有授予任何权利

Author: Jian Shuo Wang

Disclaimer: This scripts and comments only represent personal opinion and do not represent any organization or company. This post is provided as-is with no warranties and confers no rights.

整体上讲,这个编译脚本做了几件事情:

拿到最新的版本

通过更改配置文件把版本号加到DLL中

编译

把结果拷贝到发布服务器中指定编译版本号的目录中

Basically, the build script did the following things:

Get the latest version of the source code

Add the version number into the DLL by modifying the configuration files

Build

Copy the build result to the folder for the specified build on the release server

我尝试加入中文注解,并补充行号,以便引用

I added Chinese comment (and English translation) and line numbers, for sake of easy reference

1 @REM ===============================================================================

2 @REM Build script

3 @REM Author: Jian Shuo Wang

4 @REM Created: 12:04 PM 3/12/2002

5 @REM Modified:

6 @REM 1.1 SD Label added at 12:04 PM 3/12/2002

7 @REM 1.2 Fix the bug to delete .css file from release server

8 @REM 1.3 Add version numbers to both DLLs and web page

9 @REM 1.4 Added facade server and moved all webclient

10 @REM to web folder.

11 @REM 1.5 Fixed bug 258 [Build] Build script doesn’t provide label description

12 @REM 1.6 Reorged the folder and added WinUI to builds]

13 @REM 1.7 Add build number to all EXEs and DLLs

14 @REM 1.8 Depress prompt by echo D to web.config.

15 @REM

16 @REM

17 @REM ===============================================================================

18

编译脚本的变化有可能产生编译结果的变化或产生新的Bug,编译脚本也可能产生Bug,所以编译脚本的也要有版本号

Changes of build script may affect the compile result or cause new bug. There may be bugs in the build script itself. So we need to give a version to the build script.

19 @SET BuildScriptVersion=1.8

20

21 @REM ===============================================================================

22 @REM Usage:

23 @REM copybuilds.bat

24 @REM is the revision number. In case you need

25 @REM to create a build with revision number other

26 @REM then 0, you can use

27 @REM copybuilds.bat 1

28 @REM to create builds like 2295.1

29 @REM ===============================================================================

30

建议Build号的格式:

a.b.cccc.d, 如2.0.2533.0

a – 主版本号

b – 副版本号

cccc – 每日编译号

d – 更新号

主副版本号在一个产品大的发布之前不变,每日编译号每天加一 (注意,开始值不一定为1,建议为一个随机的4位数,这样保证它的位数一直是4位,方便引用。

Suggested Build Number Format:

a.b.cccc.d, eg: 2.0.2533.0

a – Major Build Number

b – Minor Build Number

cccc – Daily Build Number

d – Revision number

每日编译脚本每天自动运行,不过有时当出现Build break (自动运行/编译失败),或BVT测试没有通过, 可能会临时产生新的版本,这很少见,但一旦发生,可以手动运行编译脚本,并指派更新号。如果一天有多个build, 他们会有不同的更新号,比如 2.0.2533.1, 2.0.2533.2….

Daily build runs daily automatically. However, when Build Break (auto run/build failure) happens, or BVT (Build Verification Test) does not pass, it is possible to create some temporary new build. This is rare. But when it does happen, we can run the build script manually and assign a new revision number. If there are more than one build on the same day, they have different revision number, for example, 2.0.2533.1, 2.0.2533.2….

31 @SET BuildRev=0

32

33 @REM ===============================================================================

34 @REM This script is extended to be used on sha-jswang-02 exclusively

35 @REM ===============================================================================

36

37 @REM ===============================================================================

38 @REM Define variables

39 @REM ===============================================================================

40

定义一些变量,因为编译脚本基本上只会在编译服务器上运行,所以很多东西直接写到Code里了。编译服务器可以使团队中配置最差的机器,或利用率最低的机器,最好保证没有人在上面编程,否则不小心更改了设置就会产生Build环境改变,就可能会改变最终的编译结果。

Define some variables. Since the daily build script generally only runs on the build machine, we can hard code a lot of places into the script. It is OK to use the most poorly configured machine in the team, or a computer with lowest utilization. It is important that nobody develops on it. Otherwise, the developer may change the configuration that causes Build environment change, so to change the final result of the daily build.

41 @PATH=c:\program files\Microsoft Visual Studio .NET\Common7\IDE;%PATH%;

42 @SET SCRIPTROOT=C:\WebRaid

43 @SET SDROOT=C:\webraid\workplace

44

45 @SET SLNROOT=C:\webraid\workplace\src\RAID

46 @SET WEBUIROOT=C:\webraid\workplace\src\RAID\RAID_WEBUI

47 @SET WINUIROOTDEBUG=C:\webraid\workplace\src\RAID\WinUI\bin\Debug

48 @SET WINUIROOTRELEASE=C:\webraid\workplace\src\RAID\WinUI\bin\Release

49 @SET RELEASESERVER=\\sha-calvin\WebRAID\builds\

50 @SET WINUIROOTRELEASE=C:\webraid\workplace\src\RAID\WinUI\bin\Release

51 @SET BUILDREPORT=%SCRIPTROOT%\BuildReport.txt

52

53 @REM ===============================================================================

54 @REM Database related variables

55 @REM ===============================================================================

56

57 @SET MASTER_DB_SERVER=steven02

58 @SET MASTER_DB_SA=sa

59 @SET MASTER_DB_PASSWORD=123

60 @SET BCPCMD=-U”%MASTER_DB_SA%” -P”%MASTER_DB_PASSWORD%” -S “%MASTER_DB_SERVER%”

61

62 @REM ===============================================================================

63 @REM Generate build numbers, SD Labels.

64 @REM ===============================================================================

65

66 @CSCRIPT //NoLogo %SCRIPTROOT%\GenBuildNo.vbs > %SCRIPTROOT%\SetBuildNo.bat

67 @CALL %SCRIPTROOT%\SetBuildNo.Bat

68

69 @SET SDLABEL=build%BuildNo%

70 @SET BuildName=%BuildNo%

71

72 @REM ===============================================================================

73 @REM Check whether is is parameter for this script

74 @REM ===============================================================================

就在这里加更新号

Add build revision number here.

75

76 @If A%1A==AA goto :Continue

77 @SET BUILDRev=%1

78 @SET SDLABEL=build%BuildNo%.%BuildRev%

79 @SET BuildName=%BuildNo%.%BuildRev%

80 :Continue

81

82

准备编译报告。编译报告要存放到该Build所在的目录,以便以后了解Build时的情况

Prepare compile report. Compile report should be saved into the folder of the build, so you know the situation when the build was created.

83

84 @ECHO ===============================================================================

85 @ECHO P E C K E R B U I L D S C R I P T V %BuildScriptVersion%

86 @ECHO ===============================================================================

87 @ECHO.

88 @ECHO Build Number: %BuildName%

89 @ECHO.

90

91 @REM ===============================================================================

92 @REM BUILD REPORT

93 @REM ===============================================================================

94

95 @ECHO ======================================== > %BuildReport%

96 @ECHO Build Report for Build %BuildName% >> %BuildReport%

97 @ECHO Build Script Version: %BuildScriptVersion% >> %BUILDREPORT%

98 @ECHO Builder: Jian Shuo Wang (jswang) >> %BUILDREPORT%

99 @ECHO Start Build: >> %BUILDREPORT%

100 @Date /T >> %SCRIPTROOT%\buildreport.txt

101 @TIME /T >> %SCRIPTROOT%\buildreport.txt

102

103 @REM ===============================================================================

104 @REM Get the latest source

105 @REM ===============================================================================

106

107 @C:

108 @CD %SDROOT%

109

我的这个例子中用的是自己的一个工具,VSS有自己的命令行参数

I am using our own tool in this sample. Visual SourceSafe has its own command line parameter.

110

111 @ECHO ===============================================================================

112 @ECHO Retrieving source code from SD Server

113 @ECHO ===============================================================================

114 @ECHO Please wait …

115

116 SD sync -f src… > NUL

117 @ECHO.

118

建立Label,就是把产生这个版本的所有文件的当前版本记录下来,一旦以后某天需要恢复到这个版本,只需把代码同步到这个标签就可以了,然后我们就能保证从源代码树中编译出来任何制定的版本。

Create Label, which is a record of all the version numbers of the used files that generates this build, in case one day, we need to restore this build from the source code. We can do a label synchronization to make sure we can build out the certain build from the source code tree.

119 @REM ===============================================================================

120 @REM Create label

121 @REM ===============================================================================

122

123 @REM Create Labels

124 @ECHO OFF

125 @ECHO Label: %SDLABEL% >%WEBUIROOT%\Temp.txt

126 @ECHO Owner: FAREAST\jswang >>%WEBUIROOT%\Temp.txt

127 @ECHO Description: >>%WEBUIROOT%\Temp.txt

128 @ECHO Build Number %BuildName% >>%WEBUIROOT%\Temp.txt

129 @ECHO Options: unlocked >>%WEBUIROOT%\Temp.txt

130 @ECHO View: >>%WEBUIROOT%\Temp.txt

131 @ECHO //depot/… >>%WEBUIROOT%\Temp.txt

132

133 Type %WEBUIROOT%\Temp.txt | SD label -i

134

135 @ECHO ===============================================================================

136 @ECHO Synchronizing label

137 @ECHO ===============================================================================

138 @ECHO Please wait …

139

140 SD labelsync -l %SDLABEL%

141

142 DEL %WEBUIROOT%\Temp.txt

143

144

正式开始编译。 我会产生一个release版,一个Debug版

Finally, starts to compile. I will generate a RELEASE version a DEBUG version.

145

146

147

148

149

150

151 @REM ===============================================================================

152 @REM Begin to build

153 @REM ===============================================================================

154

155 @REM ===============================================================================

156 @REM Change the version number for DLLs

157 @REM ===============================================================================

158

159 @ECHO ===============================================================================

160 @ECHO Adding build number to DLLs

161 @ECHO ===============================================================================

162

163 Call %SCRIPTROOT%\AddBuildNumber.bat %SLNROOT%\SystemFrameworks\AssemblyInfo.cs

164 Call %SCRIPTROOT%\AddBuildNumber.Bat %SLNROOT%\Common\AssemblyInfo.cs

165 Call %SCRIPTROOT%\AddBuildNumber.Bat %SLNROOT%\DataAccess\AssemblyInfo.cs

166 Call %SCRIPTROOT%\AddBuildNumber.Bat %SLNROOT%\RAID_WebUI\AssemblyInfo.cs

167 Call %SCRIPTROOT%\AddBuildNumber.Bat %SLNROOT%\BusinessFacade\AssemblyInfo.cs

168 Call %SCRIPTROOT%\AddBuildNumber.Bat %SLNROOT%\WindowsControl\AssemblyInfo.cs

169 Call %SCRIPTROOT%\AddBuildNumber.Bat %SLNROOT%\WinUI\AssemblyInfo.cs

170

171

172 @REM ===============================================================================

173 @REM Add Version Number to Default.aspx

174 @REM ===============================================================================

175

176 Attrib -R %WEBUIROOT%\Default.aspx

177 Type %SCRIPTROOT%\VersionSpanStart.txt >> %WEBUIROOT%\Default.aspx

178 @ECHO Build %BuildName% >> %WEBUIROOT%\Default.aspx

179 Type %SCRIPTROOT%\VersionSpanEnd.txt >> %WEBUIROOT%\Default.aspx

180

181 @REM ===============================================================================

182 @REM Build debug version

183 @REM ===============================================================================

184

185 @ECHO ===============================================================================

186 @ECHO Begin to Build Debug Version %BuildName%

187 @ECHO ===============================================================================

188 @ECHO It may take 1-2 minutes. Please wait …

189

190 DEVENV %SLNROOT%\RAID.SLN /rebuild “debug” >> %BUILDREPORT%

191

192 @ECHO Build completed

193 @ECHO.

194

195 @ECHO ===============================================================================

196 @ECHO Begin to Build Release Version %BuildName%

197 @ECHO ===============================================================================

198 @ECHO It may take 1-2 minutes. Please wait …

199

200 DEVENV %SLNROOT%\RAID.SLN /rebuild “release” >> %BUILDREPORT%

201

202 @ECHO Build completed

203 @ECHO.

204

205

206 @ECHO ===============================================================================

207 @ECHO Begin to Build Release Version of WindowsControl %BuildName%

208 @ECHO ===============================================================================

209 @ECHO It may take 1-2 minutes. Please wait …

210

211 DEVENV %SDROOT%\src\WindowsControl.T\WindowsControl.sln /rebuild “release” >> %BUILDREPORT%

212

213 @ECHO Build completed

214 @ECHO.

215

把开发现状的数据库结构Dump成SQL语句, 以便安装程序可以完整的复原开发现状

Dump the existing database structure into SQL scripts, so that setup program can restore the database

216

217 @REM ===============================================================================

218 @REM D A T A B A S E S E T U P

219 @REM

220 @REM The following script is provide by Jian Wu. It uses bcp tool to get all the

221 @REM data in the SQL Database and put it in files with .db.txt extension.

222 @REM ===============================================================================

223

224 @ECHO ===============================================================================

225 @ECHO Dumping databases

226 @ECHO ===============================================================================

227

228 bcp “GTECRAID.dbo.Alias” out “%SCRIPTROOT%\Alias.db.txt” -c %BCPCMD%

229 bcp “GTECRAID.dbo.BugStore” out “%SCRIPTROOT%\BugStore.db.txt” -c %BCPCMD%

230 bcp “GTECRAID.dbo.FldItems” out “%SCRIPTROOT%\FldItems.db.txt” -c %BCPCMD%

231 bcp “GTECRAID.dbo.Flds” out “%SCRIPTROOT%\Flds.db.txt” -c %BCPCMD%

232 bcp “GTECRAID.dbo.Links” out “%SCRIPTROOT%\Links.db.txt” -c %BCPCMD%

233 bcp “GTECRAID.dbo.LinkTokens” out “%SCRIPTROOT%\LinkTokens.db.txt” -c %BCPCMD%

234 bcp “GTECRAID.dbo.NotificationRules” out “%SCRIPTROOT%\NotificationRules.db.txt” -c %BCPCMD%

235 bcp “GTECRAID.dbo.StaticWebPart” out “%SCRIPTROOT%\StaticWebPart.db.txt” -c %BCPCMD%

236 bcp “GTECRAID.dbo.Tabs” out “%SCRIPTROOT%\Tabs.db.txt” -c %BCPCMD%

237 bcp “GTECRAID.dbo.TabWebParts” out “%SCRIPTROOT%\TabWebParts.db.txt” -c %BCPCMD%

238 bcp “GTECRAID.dbo.[User]” out “%SCRIPTROOT%\User.db.txt” -c %BCPCMD%

239 bcp “GTECRAID.dbo.UserAlias” out “%SCRIPTROOT%\UserAlias.db.txt” -c %BCPCMD%

240 bcp “GTECRAID.dbo.UserQueryStore” out “%SCRIPTROOT%\UserQueryStore.db.txt” -c %BCPCMD%

241 bcp “GTECRAID.dbo.WebParts” out “%SCRIPTROOT%\WebParts.db.txt” -c %BCPCMD%

242

编译完成,开始拷贝编译出来的二进制文件

Compile completed. Start to copy the binary outcome of the compilation

243

244 @REM ===============================================================================

245 @REM Begin to copy files to release server

246 @REM ===============================================================================

247

248

249 @REM ===============================================================================

250 @REM A T T E N T I O N ON A P P S E R V E R S E T U P

251 @REM

252 @REM The builder moved the file web.config from Pecker_Facade folder to

253 @REM setup folder and rename it to server.web.config during the setup.

254 @REM This helps to reduce the complexity

255 @REM of the code by reducing the number of folder needed. The setup script

256 @REM will re-build the server folder and move the web.config file there.

257 @REM

258 @REM C H A N G E S

259 @REM

260 @REM THE NOTE ABOVE IS NOT LONG VALID. I have setup a new folder named

261 @REM “Sever” in the root folder of the distribution disk that holds all server

262 @REM DLLs and configuration information

263 @REM ===============================================================================

264

265 @ECHO ===============================================================================

266 @ECHO Copying AppServer Debug Version

267 @ECHO ===============================================================================

268

269 ECHO D | XCOPY %WEBUIROOT%\..\PECKER_FACADE\web.config %RELEASESERVER%%BUILDName%\Debug\Server /I /S /Y

270 XCOPY %WEBUIROOT%\bin %RELEASESERVER%%BUILDName%\Debug\Server\Bin /S /Y /I

271

272 @ECHO ===============================================================================

273 @ECHO Copying AppServer Release Version

274 @ECHO ===============================================================================

275

276 ECHO D | XCOPY %WEBUIROOT%\..\PECKER_FACADE\web.config %RELEASESERVER%%BUILDName%\Release\Server /I /S /Y

277 XCOPY %WINUIROOTRELEASE%\*.DLL %RELEASESERVER%%BUILDName%\Release\Server\Bin /S /Y /I

278

279

280 @ECHO ===============================================================================

281 @ECHO Copying Database Data

282 @ECHO ===============================================================================

283

284 XCOPY %SCRIPTROOT%\*.db.txt %RELEASESERVER%%BUILDName%\Debug\Database /S /Y /I

285 XCOPY %SCRIPTROOT%\*.db.txt %RELEASESERVER%%BUILDName%\Release\Database /S /Y /I

286 Del %SCRIPTROOT%\*.db.txt

287

288 XCOPY %WEBUIROOT%\..\PECKER_FACADE\database.sql %RELEASESERVER%%BUILDName%\Release\Database /I /S /Y

289 XCOPY %WEBUIROOT%\..\PECKER_FACADE\database.sql %RELEASESERVER%%BUILDName%\Debug\Database /I /S /Y

290

291 @ECHO ===============================================================================

292 @ECHO Copying WebUI Debug Version

293 @ECHO ===============================================================================

294

295 XCOPY %WEBUIROOT% %RELEASESERVER%%BUILDName%\Debug\Web /S /EXCLUDE:%SCRIPTROOT%\Excludelist.txt /Y /I

296 COPY %WEBUIROOT%\*.css %RELEASESERVER%%BUILDName%\Debug\Web

297

298 @ECHO ======================================== >> %BUILDREPORT%

299 @ECHO Copy WebUI Debug Ends: >> %BUILDREPORT%

300 Date /T >> %BUILDREPORT%

301 TIME /T >> %BUILDREPORT%

302

303 @ECHO ===============================================================================

304 @ECHO Copying WebUI Release Version

305 @ECHO ===============================================================================

306

307 XCOPY %WEBUIROOT% %RELEASESERVER%%BUILDName%\Release\Web /S /EXCLUDE:%SCRIPTROOT%\Excludelist.txt /Y /I

308 COPY %WEBUIROOT%\*.css %RELEASESERVER%%BUILDName%\Release\Web

309

310 @ECHO ======================================== >> %BUILDREPORT%

311 @ECHO Copy WebUI Release Ends: >> %BUILDREPORT%

312 Date /T >> %BUILDREPORT%

313 TIME /T >> %BUILDREPORT%

314

315

316 @ECHO ===============================================================================

317 @ECHO Copying WinUI Debug Version

318 @ECHO ===============================================================================

319

320 XCOPY %WINUIROOTDEBUG% %RELEASESERVER%%BUILDName%\Debug\Win /S /EXCLUDE:%SCRIPTROOT%\Excludelist.txt /Y /I

321 COPY %WINUIROOTDEBUG%\..\..\help\*.chm %RELEASESERVER%%BUILDName%\Debug\Win /Y

322

323 @ECHO ======================================== >> %BUILDREPORT%

324 @ECHO Copy WinUI Debug Ends: >> %BUILDREPORT%

325 Date /T >> %BUILDREPORT%

326 TIME /T >> %BUILDREPORT%

327

328 @ECHO ===============================================================================

329 @ECHO Copying WinUI Release Version

330 @ECHO ===============================================================================

331

332 XCOPY %WINUIROOTRELEASE% %RELEASESERVER%%BUILDName%\Release\Win /S /Y /I

333 XCOPY %WINUIROOTDEBUG%\WinUI.exe.xml %RELEASESERVER%%BUILDName%\Release\Win /I /S /Y

334 COPY %WINUIROOTRELEASE%\..\..\help\*.chm %RELEASESERVER%%BUILDName%\Release\Win /Y

335

336 Copy %SDROOT%\src\WindowsControl.T\bin\Release\WindowsControl.dll %RELEASESERVER%%BUILDName%\Release\Win\WindowsControl.dll /Y

337

338 @ECHO ======================================== >> %BUILDREPORT%

339 @ECHO Copy WinUI Release Ends: >> %BUILDREPORT%

340 Date /T >> %BUILDREPORT%

341 TIME /T >> %BUILDREPORT%

342

343

开发过程中有简易的Setup.bat保证可以在一个崭新的机器上安装最终程序,这保证了测试的起点是一样的

Simple setup.bat to install the compiled build onto a new machine. This ensures the starting point of the test is identical every time you setup.

344

345

346

347 @ECHO ===============================================================================

348 @ECHO Moving the setup.bat script

349 @ECHO ===============================================================================

350

351 Move %RELEASESERVER%%BUILDName%\Debug\Web\Setup.bat %RELEASESERVER%%BUILDName%\Debug

352 Move %RELEASESERVER%%BUILDName%\Release\Web\Setup.bat %RELEASESERVER%%BUILDName%\Release

353

354

355 @ECHO ===============================================================================

356 @ECHO Copy the build report to release server

357 @ECHO ===============================================================================

358

359 Copy %BUILDREPORT% %RELEASESERVER%%BUILDName%

360

大功告成

Mission completed

361

362 @ECHO ===============================================================================

363 @ECHO Build completed successfully

364 @ECHO ===============================================================================

如有任何疑问,欢迎跟贴

Comments are welcome.

王建硕[微软]

本贴子以”现状”提供且没有任何担保,同时也没有授予任何权利

Jian Shuo Wang [Microsoft]

This post is provided as-is with no warranties and confers no rights.

6 thoughts on “Daily Build Script Sample

  1. Jian Shuo Wang

    Hehe. I just wanted to post it somewhere on the Internet to share with my readers. Hope you guys don’t mind. It is the world I came from…. I posted the article in 2002. That is more than 2 years ago. It is interesting for me to take a look what I have been working very hard before…

  2. carsten

    OK, here’s a little BASIC thing I did back in 1987, a converter for milling anf turning machine operators. Made in Bill Gates’ DOS 3.1, as I remember.

    Nonsense for non-machinists, but the point is, that Clare is still quite confused when she sees it !

    Unfortunately the outcome is in danish, so for you who don’t have this special skill of language, forget it.

    10 REM BEREGNINGSPROGRAM

    40 KEY OFF

    50 ON KEY(3) GOSUB 5140: KEY(3) ON

    60 CLS:COLOR 12,0,0:LOCATE 1,15:PRINT “****************************************************”:LOCATE 2,15:PRINT “* *”:LOCATE 3,15:PRINT “* “;:COLOR 14,0,0:PRINT “* BEREGNINGSPROGRAM *”;

    70 COLOR 12,0,0:PRINT ” CHJ 5/88 *”:LOCATE 4,15:PRINT “* *”:LOCATE 5,15:PRINT “****************************************************”

    80 PI=3.14159265#

    90 COLOR 10,0,0:LOCATE 8,15:PRINT “0 AFSLUT”

    100 LOCATE 10,15:PRINT “1 TREKANTBEREGNING”:LOCATE 12,15:PRINT “2 OMREGNING AF VINKEL I MIN. OG SEK. TIL DECIMALTAL”

    110 LOCATE 14,15:PRINT “3 SK’REDATABEREGNING”:LOCATE 16,15:PRINT “4 KONUSBEREGNING”

    120 LOCATE 18,15:PRINT “5 RUHEDSBEREGNING”

    125 LOCATE 21,5:PRINT “Tast et nummer og tryk ENTER….

    130 LOCATE 23,5:COLOR 5,0,0:PRINT “( Tryk F3 og ENTER for retur i beregningerne )

    140 A$=INKEY$: IF A$=”” THEN 140

    150 IF A$=”1″ THEN CLS:GOTO 1000

    160 IF A$=”2″ THEN CLS:GOTO 2000

    170 IF A$=”3″ THEN CLS:GOTO 3000

    180 IF A$=”4″ THEN CLS:GOTO 4000

    190 IF A$=”5″ THEN CLS:GOTO 5000

    200 IF A$=”0″ THEN COLOR 7,0,0:CLS:SYSTEM

    210 GOTO 140

    1000 A1$=”Aa,”:A2$=”ab,”:A3$=”Ab,”:A4$=”ac,”:A5$=”Ac,”:A6$=”Ba,”:A7$=”Bb,”:A8$=”bc,”:A9$=”Bc,”:A10$=”A “:A11$=”B ”

    1010 PI=3.14159265#:CLS

    1020 CLS: COLOR 6,0,0

    1030 REM tegn trekant

    1040 FOR L = 0 TO 9

    1050 LOCATE 11+L,47:PRINT CHR$(179)

    1060 NEXT L

    1070 FOR L=0 TO 9:LOCATE 11+L,46-L:PRINT “/”

    1080 NEXT L

    1090 FOR L=0 TO 9:LOCATE 21,37+L:PRINT CHR$(126)

    1100 NEXT L

    1110 COLOR 14,0,0:LOCATE 1,18:PRINT “** BEREGNING AF RETVINKLEDE TREKANTER **”

    1120 COLOR 10,0,0:LOCATE 21,35:PRINT “B”

    1130 LOCATE 21,48:PRINT “C”

    1140 LOCATE 10,48:PRINT “A”

    1150 LOCATE 22,41:PRINT “a”

    1160 LOCATE 16,49:PRINT “b”

    1170 LOCATE 16,39:PRINT “c”

    1180 LOCATE 4:INPUT “Indgiv det ukendte element “;X$

    1190 IF X$=”A”OR X$=”B”OR X$=”a”OR X$=”b”OR X$=”c”THEN 1740 ELSE 1180

    1200 LOCATE 5,19:PRINT K$

    1210 LOCATE 6,19:PRINT F$:LOCATE 6

    1220 PRINT “Kendte elementer:”

    1230 LOCATE 8:INPUT “Indgiv nummer for kendte variable “;A:LOCATE 4:PRINT ” ”

    1240 IF ATF THEN LOCATE 8:PRINT ” “:GOTO 1230

    1250 LOCATE 5,19:PRINT ” “:LOCATE 6:PRINT ” “:LOCATE 8:PRINT ” “:GOTO 1650

    1260 LOCATE 4:PRINT”Indgiv “T$:LOCATE 4,10:INPUT XX:GOSUB 1870

    1270 IF TB$=” “THEN GOTO 1300

    1280 IF TB$=” “THEN GOTO 1300

    1290 LOCATE 5:PRINT “Indgiv “TB$:LOCATE 5,10:INPUT YY:GOSUB 1890

    1300 GOTO 1340

    1310 IF X$=”A”OR X$=”B” THEN GOTO 1330

    1320 PRINT :PRINT TAB(4) X$” = “;:PRINT USING “#####.###”;PR:GOTO 1830

    1330 PP=INT(PR):PRINT X$;”= “;PP;”grader,”;:GOTO 1810

    1340 IF X$=”A”GOTO 1390

    1350 IF X$=”B”GOTO 1440

    1360 IF X$=”a”GOTO 1490

    1370 IF X$=”b”GOTO 1550

    1380 IF X$=”c”GOTO 1600

    1390 REM BEREGNINGER FOR A

    1400 IF T$=”a”AND TB$=”b”THEN X=XX/YY:PR=ATN(X):PR=(PR*180)/PI:GOTO 1310

    1410 IF T$=”a”AND TB$=”c”THEN X=XX/YY:PR=ATN(X/SQR(1-X*X)):PR=(PR*180)/PI:GOTO 1310

    1420 IF T$=”b”AND TB$=”c”THEN X=XX/YY:PR=1.570796-ATN(X/SQR(1-X*X)):PR=(PR*180)/PI:GOTO 1310

    1430 IF T$=”B”THEN XX=(XX*180)/PI:PR=90-XX:GOTO 1310

    1440 REM BEREGNINGER FOR B

    1450 IF T$=”a”AND TB$=”b”THEN X=XX/YY:PR=ATN(X):PR=(PR*180)/PI:PR=90-PR:GOTO 1310

    1460 IF T$=”a”AND TB$=”c” THEN X=XX/YY:PR=ATN(X/SQR(1-X*X)):PR=(PR*180)/PI:PR=90-PR:GOTO 1310

    1470 IF T$=”b”AND TB$=”c”THEN X=XX/YY:PR=1.570796-ATN(X/SQR(1-X*X)):PR=(PR*180)/PI:PR=90-PR:GOTO 1310

    1480 IF T$=”A”THEN XX=(XX*180)/PI:PR=90-XX:GOTO 1310

    1490 REM BEREGNINGER FOR a

    1500 IF T$=”A”AND TB$=”b”THEN PR=TAN(XX)*YY:GOTO 1310

    1510 IF T$=”A”AND TB$=”c”THEN PR=SIN(XX)*YY:GOTO 1310

    1520 IF T$=”B”AND TB$=”b”THEN PR=1/TAN(XX)*YY:GOTO 1310

    1530 IF T$=”b”AND TB$=”c”THEN PR=SQR((YY*YY)-(XX*XX)):GOTO 1310

    1540 IF T$=”B”AND TB$=”c”THEN PR=COS(XX)*YY:GOTO 1310

    1550 REM BEREGNINGER FOR b

    1560 IF T$=”A”AND TB$=”a”THEN PR=1/TAN(XX)*YY:GOTO 1310

    1570 IF T$=”a”AND TB$=”c”THEN PR=SQR((YY*YY)-(XX*XX)):GOTO 1310

    1580 IF T$=”A”AND TB$=”c”OR T$=”B”AND TB$=”c”THEN PR=COS(XX)*YY:GOTO 1310

    1590 IF T$=”B”AND TB$=”a”THEN PR=TAN(XX)*YY:GOTO 1310

    1600 REM BEREGNINGER FOR c

    1610 IF T$=”A”AND TB$=”a”THEN X=SIN(XX):PR=YY/X:GOTO 1310

    1620 IF T$=”a”AND TB$=”b”THEN PR=SQR((XX*XX)+(YY*YY)):GOTO 1310

    1630 IF T$=”A”AND TB$=”b”OR T$=”B”AND TB$=”a”THEN X=COS(XX):PR=YY/X:GOTO 1310

    1640 IF T$=”B”AND TB$=”b”THEN X=SIN(XX):PR=YY/X:GOTO 1310

    1650 IF A=1 THEN B=-1:GOTO 1710

    1660 IF A=2 THEN B=0:GOTO 1710

    1670 IF A=3 THEN B=1:GOTO 1710

    1680 IF A=4 THEN B=2:GOTO 1710

    1690 IF A=5 THEN B=3:GOTO 1710

    1700 IF A=6 THEN B=4:GOTO 1710

    1710 T$=MID$(F$,((A*2)+B),1)

    1720 TB$=MID$(F$,(A*2)+1+B,1)

    1730 GOTO 1260

    1740 IF X$=”” THEN LOCATE 4:PRINT ” “:GOTO 1180

    1750 M=ASC(X$)

    1760 IF M=65 THEN F$=A2$+A4$+A8$+A11$:K$=” 1 2 3 4″:TF=4:GOTO 1200

    1770 IF M=66 THEN F$=A2$+A4$+A8$+A10$:K$=” 1 2 3 4″:TF=4:GOTO 1200

    1780 IF M=97 THEN F$=A3$+A5$+A7$+A8$+A9$:K$=” 1 2 3 4 5″:TF=5:GOTO 1200

    1790 IF M=98 THEN F$=A1$+A4$+A5$+A6$+A9$:K$=” 1 2 3 4 5″:TF=5:GOTO 1200

    1800 IF M=99 THEN F$=A1$+A2$+A3$+A6$+A7$:K$=” 1 2 3 4 5″:TF=5:GOTO 1200

    1810 CA=INT(PR):CC=PR-CA:CA=CC*60:CD=INT(CA):PRINT CD;”min.,”;:CB=INT(CD):CC=CA-CB:CF=CC*60:CE=INT(CF):PRINT CE;”sek.”

    1820 PRINT :PRINT X$;”= “;:PRINT USING “##.###”;PR;:PRINT ” decimalt.”

    1830 LOCATE 9:BEEP:PRINT “Ny opgave (j),eller slut ?”

    1840 A$=INKEY$: IF A$=”” THEN 1840

    1850 IF A$=”J”OR A$=”j”THEN GOTO 1020

    1860 COLOR 7,0,0:CLS:RUN 50

    1870 IF T$=”A”OR T$=”B” THEN XX=(XX/180)*PI

    1880 RETURN

    1890 IF TB$=”A”OR TB$=”B” THEN YY=(YY/180)*PI

    1900 RETURN

    1910 LOCATE 18,10:GOSUB 1940

    1920 LOCATE 19,11:GOSUB 1940

    1930 LOCATE 20,12:GOSUB 1940

    1940 PRINT CHR$(92)

    1950 RETURN

    1960 COLOR 7,0,0:CLS:END

    2000 REM

    2010 CLS:LOCATE 3,10:COLOR 14,0,0:PRINT “** OMREGNING FRA GRADER, MINUTTER OG SEKUNDER TIL DECIMALTAL **”

    2020 X=0:Y=0:Z=0:P$=”Grader”:PP$=”Grad”

    2030 COLOR 10,0,0

    2040 LOCATE 6,20:INPUT “indgiv grader “;X

    2050 LOCATE 8,20:INPUT “indgiv minutter”;Y

    2060 LOCATE 10,20:INPUT “indgiv sekunder”;Z

    2070 IF Z=0 THEN 2110:REM sekunder

    2080 IF Y=0 THEN 2130:REM minutter

    2090 PR=Y/60:PR=PR+(Z/60)/60:PR=PR+X:LOCATE 13,30:GOSUB 2150

    2100 QQ=1:GOTO 3260

    2110 PR=Y/60+X:LOCATE 13,30:GOSUB 2150

    2120 QQ=1:GOTO 3260

    2130 IF Z=0 THEN PR=X ELSE PR=(Z/60)/60+X:LOCATE 13,30:GOSUB 2150

    2140 QQ=1:GOTO 3260

    2150 IF PR 0 THEN K=INT(PR):PRINT K;PR:PR=PR-K

    5070 IF PR0 THEN LOCATE 15,19:P=INT(P*O):PRINT “TILSP’NDING I MM. PR. MIN. :”;INT(P) ELSE GOTO 5130

    5120 QF=2

    5130 QQ=3:GOTO 3260

    5140 RUN 50:RETURN

Leave a Reply

Your email address will not be published. Required fields are marked *