INPUT "Number of loads on the beam (1 to 8): "; NumLoads
INPUT "SPAN OF BEAM (metres): ";span
PRINT
PRINT "ENTER NUMBER OF SECTIONS ALONG THE BEAM TO BE USED:"
PRINT "MOST PROGRAMS LIMIT THE NUMBER OF SECTIONS TO 21, BUT ON LARGER"
PRINT "SPANS THIS CAN BE INACCURATE. THERE ARE SIMPLE RULES TO DECIDE:"
PRINT "NUMBER OF SECTIONS MUST ALWAYS BE AN ODD NUMBER. THE (NUMBER - 1) MUST"
PRINT "ALSO BE DIVIDABLE BY 10 (eg. 21, 51, 101, 201, 301, 401, 501, etc"
PRINT
INPUT "NUMBER OF SECTIONS: "; NumOfSect
StepNo = (NoOfSect-1)/10
'DIM v$(NoOfSect+1), m$(NoOfSect+1), s(NoOfSect+1), d$(NoOfSect+1)
'DIM SFatSect(NoOfSect+1), mSect(NoOfSect+1), DefSect(NoOfSect+1), Dist(NoOfSect+1)
'Dist(1) = 0
'Dist(NoOfSect) = Span
'LoadType = 0
DIM DorI$(NumLoads+1), WC(NumLoads+1), WD(NumLoads+1), LoadDescrip$(NumLoads+1)
DIM ld(NumLoads+1), wi(NumLoads+1), Cover(NumLoads+1), LoadType(NumLoads+1)
'NOMAINWIN
[WindowSetup]
WindowWidth = 1032 : WindowHeight = 650
UpperLeftX = INT((DisplayWidth-WindowWidth)/2)
UpperLeftY = INT((DisplayHeight-WindowHeight)/2)
childWide=1400 : childHigh=1000 'child window dimensions
OPEN "SIMPLE BEAM ANALYSIS" FOR WINDOW AS #main
PRINT #main, "trapclose [quit]"
PRINT #main, "resizehandler [resize]"
hMain = hwnd(#main) 'main window handle
CALLDLL #user32, "GetWindowLongA",_
hMain AS ULONG,_ 'handle of window
_GWl_HINSTANCE AS LONG,_ 'flag for instance handle
hInstance AS ULONG 'returns instance handle of window
dwStyle=_WS_CLIPCHILDREN OR _WS_CHILD OR _WS_VISIBLE OR _
_WS_BORDER or _WS_VSCROLL OR _WS_HSCROLL
'create an MDI Client Control
CALLDLL #user32, "CreateWindowExA",_
0 AS LONG,_ 'extended class style
"MDICLIENT" AS PTR,_ 'class name
"" AS PTR,_ 'title or string
dwStyle AS LONG,_ 'window style
2 AS LONG,_ 'x org
2 AS LONG,_ 'y org
1021 AS LONG,_ 'width
602 AS LONG,_ 'height
hMain AS ULONG,_ 'parent window
0 AS ULONG,_ 'handle to menu = 0 for class menu
hInstance AS ULONG,_ 'instance handle of parent window
"" AS PTR,_ 'always NULL
hMDI AS ULONG 'returns handle of MDI Client
vpos = 10: sp = 20: TopOfTable = vpos+sp*15: colWide = 65
BMSF = TopOfTable + ((NumLoads+1)*sp) + sp
MENU #m, "&File" , "E&xit", [quit]
WindowWidth=childWide: WindowHeight=childHigh
[ControlSetup]
TextboxColor$ = "White"
STYLEBITS #m.textbox5, _ES_CENTER, _WS_BORDER, 0, 0
TEXTBOX #m.textbox5, 10+150+10, vpos-10+sp*14, 70, 20
STYLEBITS #m.textbox6, _ES_CENTER, _WS_BORDER, 0, 0
TEXTBOX #m.textbox6, 10+150+10+70+200, vpos-10+sp*14, 70, 20
STYLEBITS #m.textbox7, _ES_CENTER, _WS_BORDER, 0, 0
TEXTBOX #m.textbox7, 10+150+10+70+20+250+40+200, vpos-10+sp*14, 70, 20
STYLEBITS #m.textbox8, _ES_CENTER, _WS_BORDER, 0, 0
TEXTBOX #m.textbox8, 330, 100, 70, 20
FOR row = 1 TO 1
FOR col = 1 TO 9
TextboxColor$ = "255 135 0"
SELECT CASE col
CASE 1: xpos = 10 : width = 65
CASE 2: xpos = 75 : width = 380
CASE 3,4,5,6,7,8: xpos = col*65+(455-65*3) : width = 65
CASE 9: xpos = (10+65+380)+(col-3)*65 : width = 75
END SELECT
SELECT CASE col
CASE 1, 3, 4, 5, 6, 7, 8, 9
STYLEBITS #m.top, _ES_CENTER OR _ES_READONLY, _WS_BORDER, 0, 0
CASE 2
STYLEBITS #m.top, _ES_LEFT OR _ES_READONLY, _WS_BORDER, 0, 0
END SELECT
TEXTBOX #m.top, xpos, TopOfTable, width, 20
MAPHANDLE #m.top, "#m.top";row;col
NEXT col
NEXT row
FOR row = 1 TO NumLoads
FOR col = 1 TO 9
TextboxColor$ = "white"
SELECT CASE col
CASE 1: xpos = 10 : width = 65
TextboxColor$ = "255 135 0"
CASE 2: xpos = 75 : width = 380
CASE 3,4,5,6,7,8: xpos = col*65+(455-65*3) : width = 65
CASE 9: xpos = (10+65+380)+(col-3)*65 : width = 75
END SELECT
SELECT CASE col
CASE 1, 3, 4: STYLEBITS #m.tb, _ES_CENTER, _WS_BORDER OR _ES_AUTOHSCROLL OR _ES_AUTOVSCROLL, 0, 0
CASE 2: STYLEBITS #m.tb, _ES_LEFT, _WS_BORDER OR _ES_AUTOHSCROLL OR _ES_AUTOVSCROLL, 0, 0
CASE 5, 6, 7, 8, 9: STYLEBITS #m.tb, _ES_RIGHT, _WS_BORDER, 0, 0
END SELECT
TEXTBOX #m.tb, xpos, TopOfTable + row*20, width, 20
MAPHANDLE #m.tb, "#m.tb";row;col
NEXT col
NEXT row
posBelow = TopOfTable + (9-1)*sp + sp + 15
STATICTEXT #m.lbl1 "BENDING MOMENTS and SHEAR FORCES", 10, BMSF, 300, 20
STATICTEXT #m.lbl2 "BM (KNm) SF (KN)", 50, BMSF+sp, 140, 20
STATICTEXT #m.lbl3 "PRESS CALC TO FORMAT DATA ENTRY AND CALCULATE", 350, BMSF+sp, 300, 20
STATICTEXT #m.lbl4 "BENDING MOMENTS and SHEAR FORCES", 350, BMSF+sp*2, 300, 20
STATICTEXT #m.lbl5 "OUTPUT RESULTS TO PRINTER", 350, BMSF+sp*4, 300, 20
TEXTEDITOR #m.txtEd1 10, BMSF+sp*2, 300, 300
BUTTON #m.btn1, "CALC", [calc], UL, 680, BMSF+sp, 75, 20
BUTTON #m.btn2, "PRINT", [PrintToPrinter], UL, 680, BMSF+sp*4, 75, 20
' OPEN CHILD WINDOW
OPEN "" FOR WINDOW_POPUP AS #m
BackgroundColor$ = "cyan"
PRINT #m, "trapclose [quit]"
hChild = hwnd(#m) 'handle of popup window
CALLDLL #user32, "SetParent",_
hChild AS ULONG,_ 'make popup the child
hMDI AS ULONG,_ 'make MDI the parent
result AS LONG
'use MoveWindow to force window resize
'so scrollbars will show
CALLDLL #user32, "MoveWindow",hMain AS ULONG,_
11 AS LONG, 11 AS LONG,_
1015 AS LONG, 633 AS LONG,_
1 AS BOOLEAN, r AS BOOLEAN
'-------------
' Enter headings in header row
#m.top11, "Load No."
#m.top12, "Description"
#m.top13, "DL or LL"
#m.top14, "Type"
#m.top15, "W/Ldg"
#m.top16, "W or H"
#m.top17, "A"
#m.top18, "C"
#m.top19, "TOTAL LOAD"
for row = 1 to NumLoads+1
h$ = "#m.tb";row;"1"
#h$ "Load ";row
next row
#m.textbox5, (USING("###.###", span))
#m.textbox6, NumLoads
#m.textbox7, NumOfSect
WAIT
'-------------
[calc]
'Extract the data typed into table
FOR row = 1 TO NumLoads
'Load description column
h2$ = "#m.tb";row;2
#h2$ "!contents? amt$"
LoadDescrip$(row) = amt$
#m.txtEd1, LoadDescrip$(row)
'Dead or Live Load column
h3$ = "#m.tb";row;3
#h3$ "!contents? amt$"
DorI$(row) = amt$
#m.txtEd1, DorI$(row)
'Load type column (PL,UDL,TPR)
h4$ = "#m.tb";row;4
#h4$ "!contents? amt$"
LoadType$(row) = amt$
#m.txtEd1, LoadType$(row)
NEXT
' Set up formatting and numeric check for cols 5 to 8
FOR row = 1 TO NumLoads
FOR col = 5 TO 9
h1$ = "#m.tb";row;col
#h1$ "!contents? amt$"
GOSUB [DoFormatCheck]
NEXT col
' LOAD or Loading
h5$ = "m.tb"; row;col
#h5$ "!contents? amt$"
GOSUB [DoFormatCheck]
ld(row) = num(row,5)
#m.txtEd1, (USING("###.##", num(row,5)))
'Height of wall or width of loaded area
h6$ = "m.tb"; row;col
#h6$ "!contents? amt$"
wi(row) = num(row,6)
GOSUB [DoFormatCheck]
#m.txtEd1, (USING("###.##", num(row,6)))
'Starting point of load measured
'from left support
h7$ = "m.tb"; row;col
#h7$ "!contents? amt$"
GOSUB [DoFormatCheck]
StartTo(row) = num(row,7)
#m.txtEd1, (USING("###.##", num(row,7)))
'Length of load
h8$ = "m.tb"; row;col
#h8$ "!contents? amt$"
GOSUB [DoFormatCheck]
Cover(row) = num(row,8)
#m.txtEd1, (USING("###.##", num(row,8)))
NEXT
FOR row = 1 TO NumLoads
For col = 9 TO 9
'Filter loading conditions by types of load
SELECT CASE LoadType$(row)
CASE "PL"
WC(row) = ld(row)
PRINT "ld(row) = ";ld(row)
CASE "UDL"
WC(row) = ld(row) * wi(row) * Cover(row)
PRINT "ld(row) = ";ld(row); " "; "wi(row) = ";wi(row); " "; "Cover(row) = ";Cover(row)
CASE "TPR L"
WC(row) = ld(row) * wi(row) * Cover(row)/2
PRINT "ld(row) = ";ld(row); " "; "wi(row) = ";wi(row); " "; "Cover(row) = ";Cover(row)
CASE "TPR R"
WC(row) = ld(row) * wi(row) * Cover(row)/2
PRINT "ld(row) = ";ld(row); " "; "wi(row) = ";wi(row); " "; "Cover(row) = ";Cover(row)
END SELECT
PRINT "WC(row) = ";WC(row) ' TEMPORARY CHECK CODE
h9$ = "m.tb"; row; col
WC = WC(row)
PRINT WC ' TEMPORARY CHECK CODE
#h9$, WC
#m.txtEd1, (USING("###.##", WC(row))) 'this comes out correct so variables are working.
NEXT col
NEXT row
WAIT
[PrintToPrinter]
DUMP
' TEMPORARY WAIT - TO BE DELETED
WAIT
GOSUB [CalcSFBM]
WAIT
[resize]
newWide = WindowWidth - 4
newHigh = WindowHeight - 4
ret = MoveWindow(hMDI, 2, 2, newWide, newHigh)
ret = MoveWindow(hChild, 0, 0, childWide, childHigh)
WAIT
WAIT
[quit]
CLOSE #m
END