e-mail: a.w.reijersen.van.buuren@hccnet.nl


SOFTWARE:   With directions for use in English.


DIRECTIONS FOR USE

[number] = line number
[] = end of line

change: [greater than] to CHR$(62)
change: [less than] to CHR$(60)
REMOVE this upper part with text including the line that follows!
--------------------------------------------------------------------------------

[ 1]DECLARE SUB calc.seconds.sub ()[]
[ 2]DECLARE SUB pr.seconds.sub ()[]
[ 3]DECLARE SUB opens.file.memo.sub ()[]
[ 4]DECLARE SUB opens.file.x.sub ()[]
[ 5]DECLARE SUB get.memo.sub ()[]
[ 6]DECLARE SUB remove.spaces (a$)[]
[ 7]DECLARE SUB pr.start.head ()[]
[ 8]DECLARE SUB find.last.sub ()[]
[ 9]DECLARE SUB screennumber.12 ()[]
[ 10]DECLARE SUB find.x ()[]
[ 11]DECLARE SUB find.y ()[]
[ 12]DECLARE SUB find.z ()[]
[ 13]DECLARE SUB find.r ()[]
[ 14]DECLARE SUB reset.memo.sub ()[]
[ 15]DECLARE SUB pr.x.sub ()[]
[ 16]DECLARE SUB mark.starting.calc.sub ()[]
[ 17]DECLARE SUB mark.stopping.calc.sub ()[]
[ 18]DECLARE SUB put.memo.sub ()[]
[ 19]DECLARE SUB save.xyzrnrs.sub ()[]
[ 20]DECLARE SUB ld.start.position.sub ()[]
[ 21]DECLARE SUB blockade ()[]
[ 22]DECLARE SUB toets ()[]
[ 23]DECLARE SUB pr.x.start.date.time.sub ()[]
[ 24]DECLARE SUB pr.x.stop.date.time.sub ()[]
[ 25][]
[ 26]'=============================================[]
[ 27]DEFLNG A-Z[]
[ 28][]
[ 29]'===============================================[]
[ 30] 'find the numbers x, y en z which apply for the formula[]
[ 31] 'x * x + y * y + z * z = r * r[]
[ 32]'===============================================[]
[ 33] ' maximal r^2 = 2147483647[]
[ 34][]
[ 35] 'Long Integers 2,147,483,647 -2,147,483,648[]
[ 36][]
[ 37] CONST false = 0[]
[ 38] CONST true = NOT false[]
[ 39][]
[ 40] CONST max = 2147483647[]
[ 41] CONST title.file.x$ = "c:\wiskunde\filedirs\x\"[]
[ 42] CONST title.file.memo$ = "c:\wiskunde\filedirs\x\memox.rnd"[]
[ 43][]
[ 44]'===============================================[]
[ 45][]
[ 46] DIM SHARED x AS DOUBLE[]
[ 47] DIM SHARED y AS DOUBLE[]
[ 48] DIM SHARED z AS DOUBLE[]
[ 49] DIM SHARED r AS DOUBLE[]
[ 50][]
[ 51] DIM SHARED square AS DOUBLE[]
[ 52][]
[ 53] DIM SHARED x.start AS DOUBLE[]
[ 54] DIM SHARED y.start AS DOUBLE[]
[ 55] DIM SHARED z.start AS DOUBLE[]
[ 56] DIM SHARED r.start AS DOUBLE[]
[ 57][]
[ 58][]
[ 59] DIM SHARED adres AS LONG[]
[ 60] DIM SHARED adres.start AS LONG[]
[ 61][]
[ 62] DIM SHARED opens.file.x AS LONG[]
[ 63] DIM SHARED len.file.x AS LONG[]
[ 64][]
[ 65] DIM SHARED opens.file.r AS LONG[]
[ 66] DIM SHARED len.file.r AS LONG[]
[ 67][]
[ 68] DIM SHARED opens.file.memo AS LONG[]
[ 69] DIM SHARED len.file.memo AS LONG[]
[ 70][]
[ 71] DIM SHARED start.moment AS STRING * 20[]
[ 72] DIM SHARED stop.moment AS STRING * 20[]
[ 73][]
[ 74] DIM SHARED seconds.max AS LONG[]
[ 75] DIM SHARED seconds.start AS LONG[]
[ 76] DIM SHARED seconds.stop AS LONG[]
[ 77] DIM SHARED seconds.total AS LONG[]
[ 78][]
[ 79][]
[ 80] DIM SHARED ws AS STRING[]
[ 81] DIM SHARED esc AS STRING * 1[]
[ 82] esc = CHR$(27)[]
[ 83][]
[ 84] seconds.max = 86400 '24 * 60 * 60[]
[ 85][]
[ 86]'===============================================[]
[ 87][]
[ 88] DEF FNp$ (x, y)[]
[ 89] IF x [less than] 1 THEN[]
[ 90] x = 1[]
[ 91] END IF[]
[ 92] IF x [greater than] 80 THEN[]
[ 93] x = 80[]
[ 94] END IF[]
[ 95] IF y [less than] 1 THEN[]
[ 96] y = 1[]
[ 97] END IF[]
[ 98] IF y [greater than] 30 THEN[]
[ 99] y = 30[]
[ 100] END IF[]
[ 101] LOCATE y, x[]
[ 102] END DEF[]
[ 103][]
[ 104]'===============================================[]
[ 105][]
[ 106] TYPE xyzfile[]
[ 107] adresnr AS LONG[]
[ 108] xnr AS LONG[]
[ 109] ynr AS LONG[]
[ 110] znr AS LONG[]
[ 111] rnr AS LONG[]
[ 112] END TYPE[]
[ 113][]
[ 114] DIM SHARED xyznrs AS xyzfile[]
[ 115] xyznrs.adresnr = false[]
[ 116] xyznrs.xnr = false[]
[ 117] xyznrs.ynr = false[]
[ 118] xyznrs.znr = false[]
[ 119] xyznrs.rnr = false[]
[ 120][]
[ 121] TYPE memofile[]
[ 122] memox AS LONG[]
[ 123] memolenfile AS LONG[]
[ 124] memocopy AS LONG[]
[ 125] memocopiedtorlist AS LONG[]
[ 126] memocopiedtocharge AS LONG[]
[ 127] memoready AS LONG[]
[ 128] memostartdate AS STRING * 10[]
[ 129] memostarttime AS STRING * 8[]
[ 130] memostopdate AS STRING * 10[]
[ 131] memostoptime AS STRING * 8[]
[ 132] END TYPE[]
[ 133][]
[ 134] DIM SHARED memoxyzr AS memofile[]
[ 135] memoxyzr.memox = false[]
[ 136] memoxyzr.memolenfile = false[]
[ 137] memoxyzr.memocopy = false[]
[ 138] memoxyzr.memocopiedtorlist = false[]
[ 139] memoxyzr.memocopiedtocharge = false[]
[ 140] memoxyzr.memoready = false[]
[ 141] memoxyzr.memostartdate = ""[]
[ 142] memoxyzr.memostarttime = ""[]
[ 143] memoxyzr.memostopdate = ""[]
[ 144] memoxyzr.memostoptime = ""[]
[ 145] []
[ 146]'===============================================[]
[ 147] CLOSE[]
[ 148][]
[ 149] CHDIR "C:\"[]
[ 150][]
[ 151] screennumber.12[]
[ 152][]
[ 153] opens.file.memo.sub[]
[ 154][]
[ 155] x.start = 1[]
[ 156][]
[ 157] IF len.file.memo THEN[]
[ 158][]
[ 159] ld.start.position.sub[]
[ 160][]
[ 161] IF memoxyzr.memoready THEN[]
[ 162] 'x searched[]
[ 163] x.start = len.file.memo + 1[]
[ 164] ELSE[]
[ 165] 'search of x the remaining numbers because of a possible break.[]
[ 166] find.last.sub[]
[ 167] x.start = x.start + 1[]
[ 168] END IF[]
[ 169] END IF[]
[ 170][]
[ 171] 'start with the nest x and find all numbers for x.[]
[ 172][]
[ 173][]
[ 174] find.x[]
[ 175][]
[ 176] COLOR 15[]
[ 177] PRINT FNp$(1, 1); "?";[]
[ 178] PRINT FNp$(41, 1); "?";[]
[ 179] PRINT FNp$(80, 1); "?";[]
[ 180][]
[ 181] DO[]
[ 182] blockade[]
[ 183] toets[]
[ 184] IF ws = esc THEN[]
[ 185] STOP[]
[ 186] END IF[]
[ 187] LOOP[]
[ 188][]
[ 189]SUB blockade[]
[ 190][]
[ 191][]
[ 192] DO[]
[ 193] w$ = INKEY$[]
[ 194] LOOP WHILE LEN(w$)[]
[ 195][]
[ 196][]
[ 197]END SUB[]
[ 198][]
[ 199]SUB calc.seconds.sub[]
[ 200][]
[ 201][]
[ 202] IF seconds.start [greater than] seconds.stop THEN[]
[ 203] 'next day has started.[]
[ 204] seconds.total = seconds.max - seconds.start + seconds.stop[]
[ 205] ELSE[]
[ 206] seconds.total = seconds.stop - seconds.start[]
[ 207] END IF[]
[ 208][]
[ 209][]
[ 210]END SUB[]
[ 211][]
[ 212]SUB find.last.sub[]
[ 213][]
[ 214][]
[ 215][]
[ 216] pr.start.head[]
[ 217][]
[ 218] COLOR 15[]
[ 219][]
[ 220] PRINT FNp$(1, 5);[]
[ 221] PRINT USING "finish old number x: #########"; x.start;[]
[ 222][]
[ 223][]
[ 224] IF adres = 1 THEN[]
[ 225] mark.starting.calc.sub[]
[ 226] END IF[]
[ 227][]
[ 228] pr.x.start.date.time.sub[]
[ 229][]
[ 230] FOR x = x.start TO x.start[]
[ 231] []
[ 232] pr.x.sub[]
[ 233][]
[ 234] FOR y = y.start TO x[]
[ 235] FOR z = z.start + 1 TO y[]
[ 236] square = x * x + y * y + z * z[]
[ 237] r.start = INT(SQR(square))[]
[ 238] find.r[]
[ 239] NEXT[]
[ 240][]
[ 241] z.start = false - 1[]
[ 242][]
[ 243] NEXT[]
[ 244][]
[ 245] y.start = false[]
[ 246][]
[ 247] NEXT[]
[ 248][]
[ 249][]
[ 250] mark.stopping.calc.sub[]
[ 251][]
[ 252] pr.x.stop.date.time.sub[]
[ 253][]
[ 254] 'save.to.r.files.sub[]
[ 255][]
[ 256][]
[ 257]END SUB[]
[ 258][]
[ 259]SUB find.r[]
[ 260][]
[ 261][]
[ 262] IF r.start * r.start = square THEN[]
[ 263] r = r.start[]
[ 264] save.xyzrnrs.sub[]
[ 265] END IF[]
[ 266][]
[ 267][]
[ 268]END SUB[]
[ 269][]
[ 270]SUB find.x[]
[ 271][]
[ 272][]
[ 273] pr.start.head[]
[ 274][]
[ 275][]
[ 276] FOR x = x.start TO max \ 3[]
[ 277] seconds.start = TIMER[]
[ 278] start.moment = STRING$(20, 32)[]
[ 279] MID$(start.moment, 1, 10) = DATE$[]
[ 280] MID$(start.moment, 13, 8) = TIME$[]
[ 281][]
[ 282] pr.x.start.date.time.sub[]
[ 283] []
[ 284] mark.starting.calc.sub[]
[ 285][]
[ 286] y = false[]
[ 287] z = false[]
[ 288] r = x[]
[ 289][]
[ 290] pr.x.sub[]
[ 291][]
[ 292] opens.file.x.sub[]
[ 293] adres = 1[]
[ 294] save.xyzrnrs.sub[]
[ 295][]
[ 296][]
[ 297] IF x [greater than] 100 THEN[]
[ 298] number = (x + 1) * (x + 1) - (x * x)[]
[ 299] y.start = INT(SQR(number \ 2))[]
[ 300] find.y[]
[ 301] ELSE[]
[ 302] y.start = 1[]
[ 303] find.y[]
[ 304] END IF[]
[ 305][]
[ 306] mark.stopping.calc.sub[]
[ 307][]
[ 308] pr.x.stop.date.time.sub[]
[ 309][]
[ 310] seconds.stop = TIMER[]
[ 311] stop.moment = STRING$(20, 32)[]
[ 312] MID$(stop.moment, 1, 10) = DATE$[]
[ 313] MID$(stop.moment, 13, 8) = TIME$[]
[ 314][]
[ 315] PRINT FNp$(1, 16); "previous start: "; start.moment;[]
[ 316] PRINT FNp$(1, 18); "previous stop: "; stop.moment;[]
[ 317][]
[ 318] 'save.to.r.files.sub[]
[ 319][]
[ 320] calc.seconds.sub[]
[ 321] pr.seconds.sub[]
[ 322][]
[ 323] NEXT[]
[ 324][]
[ 325][]
[ 326]END SUB[]
[ 327][]
[ 328]SUB find.y[]
[ 329][]
[ 330] []
[ 331] FOR y = y.start TO x[]
[ 332] z.start = false[]
[ 333] find.z[]
[ 334] NEXT[]
[ 335][]
[ 336][]
[ 337]END SUB[]
[ 338][]
[ 339]SUB find.z[]
[ 340][]
[ 341] []
[ 342] FOR z = z.start TO y[]
[ 343] square = x * x + y * y + z * z[]
[ 344] r.start = INT(SQR(square))[]
[ 345] find.r[]
[ 346] NEXT[]
[ 347][]
[ 348][]
[ 349]END SUB[]
[ 350][]
[ 351]SUB get.memo.sub[]
[ 352][]
[ 353][]
[ 354] IF x [greater than] len.file.memo THEN[]
[ 355] reset.memo.sub[]
[ 356] ELSE[]
[ 357] GET #opens.file.memo, x, memoxyzr[]
[ 358] END IF[]
[ 359][]
[ 360][]
[ 361]END SUB[]
[ 362][]
[ 363]SUB ld.start.position.sub[]
[ 364][]
[ 365][]
[ 366] x = len.file.memo[]
[ 367][]
[ 368] get.memo.sub[]
[ 369][]
[ 370] IF memoxyzr.memoready THEN[]
[ 371] 'x searched[]
[ 372] x.start = len.file.memo + 1[]
[ 373] EXIT SUB[]
[ 374] END IF[]
[ 375][]
[ 376] opens.file.x.sub[]
[ 377][]
[ 378] IF len.file.x THEN[]
[ 379] GET #opens.file.x, len.file.x, xyznrs[]
[ 380] adres = len.file.x + 1[]
[ 381] []
[ 382] 'xyznrs.adresnr = false[]
[ 383] x = xyznrs.xnr[]
[ 384] y = xyznrs.ynr[]
[ 385] z = xyznrs.znr[]
[ 386] 'xyznrs.rnr = false[]
[ 387][]
[ 388] ELSE[]
[ 389] []
[ 390] adres = 1[]
[ 391] x = len.file.memo[]
[ 392] y = false[]
[ 393] z = false[]
[ 394][]
[ 395] END IF[]
[ 396][]
[ 397] adres.start = adres[]
[ 398] x.start = x[]
[ 399] y.start = y[]
[ 400] z.start = z[]
[ 401][]
[ 402][]
[ 403]END SUB[]
[ 404][]
[ 405]SUB mark.starting.calc.sub[]
[ 406][]
[ 407][]
[ 408] get.memo.sub[]
[ 409][]
[ 410][]
[ 411] memoxyzr.memox = x 'x number[]
[ 412] memoxyzr.memolenfile = false ' len file[]
[ 413] memoxyzr.memocopy = false 'copy made (yes=true)[]
[ 414] memoxyzr.memocopiedtorlist = false 'copie to r list[]
[ 415] memoxyzr.memocopiedtocharge = false 'charge brought up to date[]
[ 416] memoxyzr.memoready = false 'x researched[]
[ 417] memoxyzr.memostartdate = DATE$ 'moment of starting research[]
[ 418] memoxyzr.memostarttime = TIME$[]
[ 419] memoxyzr.memostopdate = "" 'moment of stopping research[]
[ 420] memoxyzr.memostoptime = ""[]
[ 421] []
[ 422] put.memo.sub[]
[ 423][]
[ 424][]
[ 425]END SUB[]
[ 426][]
[ 427]SUB mark.stopping.calc.sub[]
[ 428][]
[ 429][]
[ 430] get.memo.sub[]
[ 431][]
[ 432][]
[ 433] len.file.x = LOF(opens.file.x) / LEN(xyznrs)[]
[ 434][]
[ 435] 'memoxyzr.memox = false 'x number[]
[ 436] memoxyzr.memolenfile = len.file.x ' len file[]
[ 437] 'memoxyzr.memocopy = false 'copy made (yes=true)[]
[ 438] 'memoxyzr.memocopiedtorlist = false 'copie to r list[]
[ 439] 'memoxyzr.memocopiedtocharge = false 'charge brought up to date[]
[ 440] memoxyzr.memoready = true 'x searched[]
[ 441] 'memoxyzr.memostartdate = "" 'moment start searching[]
[ 442] 'memoxyzr.memostarttime = ""[]
[ 443] memoxyzr.memostopdate = DATE$ 'moment stop searching[]
[ 444] memoxyzr.memostoptime = TIME$[]
[ 445][]
[ 446] put.memo.sub[]
[ 447][]
[ 448][]
[ 449]END SUB[]
[ 450][]
[ 451]SUB opens.file.memo.sub[]
[ 452][]
[ 453][]
[ 454] opens.file.memo = FREEFILE[]
[ 455] OPEN title.file.memo$ FOR RANDOM AS #opens.file.memo LEN = LEN(memoxyzr)[]
[ 456] len.file.memo = LOF(opens.file.memo) \ LEN(memoxyzr)[]
[ 457][]
[ 458][]
[ 459]END SUB[]
[ 460][]
[ 461]SUB opens.file.x.sub[]
[ 462][]
[ 463] IF opens.file.x THEN[]
[ 464] CLOSE #opens.file.x[]
[ 465] opens.file.x = false[]
[ 466] END IF[]
[ 467][]
[ 468] opens.file.x = FREEFILE[]
[ 469] a$ = title.file.x$ + STR$(x) + ".rnd"[]
[ 470] CALL remove.spaces(a$)[]
[ 471] OPEN a$ FOR RANDOM AS #opens.file.x LEN = LEN(xyznrs)[]
[ 472] len.file.x = LOF(opens.file.x) / LEN(xyznrs)[]
[ 473][]
[ 474][]
[ 475]END SUB[]
[ 476][]
[ 477]SUB pr.seconds.sub[]
[ 478][]
[ 479][]
[ 480] PRINT ; FNp$(1, 20); SPACE$(78);[]
[ 481] COLOR 9[]
[ 482] PRINT ; FNp$(1, 20); "working time: "; seconds.total; "seconds";[]
[ 483] PRINT "( min:"; seconds.total \ 60;[]
[ 484] PRINT "( sec:"; seconds.total - (seconds.total \ 60) * 60;[]
[ 485] PRINT ") )";[]
[ 486] COLOR 15[]
[ 487][]
[ 488][]
[ 489]END SUB[]
[ 490][]
[ 491]SUB pr.start.head[]
[ 492][]
[ 493][]
[ 494][]
[ 495] COLOR 15[]
[ 496][]
[ 497] PRINT FNp$(1, 1); "Searching";[]
[ 498] PRINT FNp$(1, 3); "Started: "; DATE$; " "; TIME$;[]
[ 499][]
[ 500] PRINT FNp$(1, 7);[]
[ 501] PRINT USING " x-start: #########"; x.start;[]
[ 502][]
[ 503][]
[ 504]END SUB[]
[ 505][]
[ 506]SUB pr.x.start.date.time.sub[]
[ 507][]
[ 508] []
[ 509] PRINT FNp$(1, 12);[]
[ 510] COLOR 14[]
[ 511] PRINT DATE$; " ";[]
[ 512] COLOR 9[]
[ 513] PRINT TIME$;[]
[ 514] COLOR 15[]
[ 515][]
[ 516][]
[ 517]END SUB[]
[ 518][]
[ 519]SUB pr.x.stop.date.time.sub[]
[ 520][]
[ 521][]
[ 522] PRINT FNp$(1, 14);[]
[ 523] COLOR 14[]
[ 524] PRINT DATE$; " ";[]
[ 525] COLOR 9[]
[ 526] PRINT TIME$;[]
[ 527] COLOR 15[]
[ 528][]
[ 529][]
[ 530]END SUB[]
[ 531][]
[ 532]SUB pr.x.sub[]
[ 533][]
[ 534] []
[ 535] COLOR 15[]
[ 536] PRINT FNp$(1, 10);[]
[ 537] PRINT USING "######### "; x;[]
[ 538][]
[ 539][]
[ 540]END SUB[]
[ 541][]
[ 542]SUB put.memo.sub[]
[ 543][]
[ 544][]
[ 545] PUT #opens.file.memo, x, memoxyzr[]
[ 546][]
[ 547] len.file.memo = LOF(opens.file.memo) \ LEN(memoxyzr)[]
[ 548][]
[ 549][]
[ 550]END SUB[]
[ 551][]
[ 552]SUB remove.spaces (a$)[]
[ 553] []
[ 554][]
[ 555] new.a$ = ""[]
[ 556] FOR i = 1 TO LEN(a$)[]
[ 557] IF MID$(a$, i, 1) [greater than] CHR$(32) THEN[]
[ 558] new.a$ = new.a$ + MID$(a$, i, 1)[]
[ 559] END IF[]
[ 560] NEXT i[]
[ 561][]
[ 562] a$ = new.a$[]
[ 563][]
[ 564][]
[ 565]END SUB[]
[ 566][]
[ 567]SUB reset.memo.sub[]
[ 568][]
[ 569] []
[ 570] memoxyzr.memox = false 'x number[]
[ 571] memoxyzr.memolenfile = false ' len file[]
[ 572] memoxyzr.memocopy = false 'copy gemaakt (yes=true)[]
[ 573] memoxyzr.memocopiedtorlist = false 'copie to r list[]
[ 574] memoxyzr.memocopiedtocharge = false 'charge brought up to date[]
[ 575] memoxyzr.memoready = false 'x searched[]
[ 576] memoxyzr.memostartdate = "" 'moment start searching[]
[ 577] memoxyzr.memostarttime = ""[]
[ 578] memoxyzr.memostopdate = "" 'moment stop searching[]
[ 579] memoxyzr.memostoptime = ""[]
[ 580][]
[ 581][]
[ 582]END SUB[]
[ 583][]
[ 584]SUB save.xyzrnrs.sub[]
[ 585] []
[ 586][]
[ 587] xyznrs.adresnr = adres[]
[ 588] xyznrs.xnr = x[]
[ 589] xyznrs.ynr = y[]
[ 590] xyznrs.znr = z[]
[ 591] xyznrs.rnr = r[]
[ 592][]
[ 593] PUT #opens.file.x, adres, xyznrs[]
[ 594] adres = adres + 1[]
[ 595] []
[ 596][]
[ 597]END SUB[]
[ 598][]
[ 599]SUB screennumber.12[]
[ 600][]
[ 601][]
[ 602] SCREEN 12[]
[ 603] WINDOW (0, 479)-(639, 0)[]
[ 604] CLS[]
[ 605][]
[ 606][]
[ 607]END SUB[]
[ 608][]
[ 609]SUB slaap[]
[ 610][]
[ 611][]
[ 612] start.tijd# = TIMER[]
[ 613][]
[ 614] DO[]
[ 615] IF start.tijd# [greater than] TIMER THEN[]
[ 616] EXIT DO[]
[ 617] END IF[]
[ 618] IF start.tijd# + 10 [less than]= TIMER THEN[]
[ 619] EXIT DO[]
[ 620] END IF[]
[ 621] LOOP[]
[ 622][]
[ 623][]
[ 624]END SUB[]
[ 625][]
[ 626]SUB toets[]
[ 627][]
[ 628][]
[ 629] ws = ""[]
[ 630] DO[]
[ 631] ws = INKEY$[]
[ 632] LOOP WHILE LEN(ws) = false[]
[ 633][]
[ 634][]
[ 635]END SUB[]
[ 636][]