| 1 | /* |
| 2 | * rolling.cmd |
| 3 | * |
| 4 | * Work out side f square wire to get rectangular wire |
| 5 | */ |
| 6 | |
| 7 | /* --- Crank up the maths package --- */ |
| 8 | |
| 9 | Do until Abbrev( 'NO', reply, 1) = 1 |
| 10 | /* --- Get some input --- */ |
| 11 | |
| 12 | say 'Type width , thickness [, length]' |
| 13 | pull w ',' t ',' l |
| 14 | If w || t = '' then LEAVE |
| 15 | If Datatype( w, 'M') then LEAVE |
| 16 | |
| 17 | If w < t then Do /* swap t and w if w less than t */ |
| 18 | temp = t |
| 19 | t = w |
| 20 | w = temp |
| 21 | End |
| 22 | |
| 23 | /* --- Produce some output --- * |
| 24 | * |
| 25 | * We calculate the side as being $\sqrt[3]{tw^2}$. This is easy. |
| 26 | */ |
| 27 | side = topower(t * w**2, 1/3) |
| 28 | diam = format(side * 1.128379167,,2) /* 2*sqrt(side**2/pi) -- 2/sqrt(pi) = 1.128379167 */ |
| 29 | sqside = format( side,,2) |
| 30 | say 'You want square wire with side' sqside', or' diam 'diam round' |
| 31 | |
| 32 | /* --- Maybe print out the original length needed --- * |
| 33 | * |
| 34 | * Original length is $twl \over x^2$. |
| 35 | */ |
| 36 | |
| 37 | If l\='' then Do |
| 38 | vol = w*t*l |
| 39 | say 'Of length' format(vol/(sqside**2),,2)', or' format(vol/(3.14159*(diam/2)**2),,2) 'respectively' |
| 40 | Say 'Volume' vol/1000 || ', weight' vol * 11.2/1000'gm in 9ctY' |
| 41 | Call mould |
| 42 | End |
| 43 | Say 'Again?' |
| 44 | Parse UPPER PULL reply |
| 45 | End |
| 46 | |
| 47 | /* --- Tidy up after us --- */ |
| 48 | |
| 49 | exit |
| 50 | |
| 51 | mould: |
| 52 | If l \= '' then Do |
| 53 | Say 'Specify diam of round stock as "d", or thickness of square as ",t"' |
| 54 | Parse UPPER PULL diam ',' thik |
| 55 | If diam \= '' then Do |
| 56 | If Datatype( diam, 'N') then |
| 57 | Say 'Length of' diam 'round wire =' format(vol/(3.14159*(diam/2)**2),,2) |
| 58 | End |
| 59 | If thik \= '' then Do |
| 60 | If Datatype( thik, 'N') then |
| 61 | Say 'Length of' thik 'square wire =' format(vol/(thik**2),,2) |
| 62 | End |
| 63 | End |
| 64 | Return |