/* * rolling.cmd * * Work out side f square wire to get rectangular wire */ /* --- Crank up the maths package --- */ Do until Abbrev( 'NO', reply, 1) = 1 /* --- Get some input --- */ say 'Type width , thickness [, length]' pull w ',' t ',' l If w || t = '' then LEAVE If Datatype( w, 'M') then LEAVE If w < t then Do /* swap t and w if w less than t */ temp = t t = w w = temp End /* --- Produce some output --- * * * We calculate the side as being $\sqrt[3]{tw^2}$. This is easy. */ side = topower(t * w**2, 1/3) diam = format(side * 1.128379167,,2) /* 2*sqrt(side**2/pi) -- 2/sqrt(pi) = 1.128379167 */ sqside = format( side,,2) say 'You want square wire with side' sqside', or' diam 'diam round' /* --- Maybe print out the original length needed --- * * * Original length is $twl \over x^2$. */ If l\='' then Do vol = w*t*l say 'Of length' format(vol/(sqside**2),,2)', or' format(vol/(3.14159*(diam/2)**2),,2) 'respectively' Say 'Volume' vol/1000 || ', weight' vol * 11.2/1000'gm in 9ctY' Call mould End Say 'Again?' Parse UPPER PULL reply End /* --- Tidy up after us --- */ exit mould: If l \= '' then Do Say 'Specify diam of round stock as "d", or thickness of square as ",t"' Parse UPPER PULL diam ',' thik If diam \= '' then Do If Datatype( diam, 'N') then Say 'Length of' diam 'round wire =' format(vol/(3.14159*(diam/2)**2),,2) End If thik \= '' then Do If Datatype( thik, 'N') then Say 'Length of' thik 'square wire =' format(vol/(thik**2),,2) End End Return