|
Restored from previous forum. Originally posted by albanread.
; removed the assembly language routines. ; in the hope it will compile on other peoples machines!
;- Window Constants ; #Window_0 = 0
;- Gadget Constants ; #Gadget_IP = 0 #Gadget_Calc = 1 #Gadget_SM = 2 #Gadget_CLASS = 3 #Gadget_SLIDER = 4 #Gadget_PREFIX = 5 #Gadget_NETS = 6 #Gadget_HOSTS = 7 #Gadget_10 = 8 #Gadget_11 = 9 #Gadget_INVERT = 10 #Gadget_LIST = 11 #Gadget_14 = 12 #Gadget_15 = 13 #Gadget_16 = 14
;- StatusBar Constants ; #StatusBar_0 = 0
Procedure Open_Window_0() If OpenWindow(#Window_0, 247, 50, 351, 460, #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar , "IPcalc") If CreateStatusBar(#StatusBar_0, WindowID()) EndIf If CreateGadgetList(WindowID()) IPAddressGadget(#Gadget_IP, 20, 20, 180, 30) ButtonGadget(#Gadget_Calc, 10, 400, 150, 30, "Calc") IPAddressGadget(#Gadget_SM, 20, 70, 180, 30) StringGadget(#Gadget_CLASS, 240, 20, 60, 30, "") TrackBarGadget(#Gadget_SLIDER, 20, 120, 280, 30, 0, 32) StringGadget(#Gadget_PREFIX, 240, 70, 60, 30, "") StringGadget(#Gadget_NETS, 80, 170, 80, 30, "") StringGadget(#Gadget_HOSTS, 220, 170, 80, 30, "") TextGadget(#Gadget_10, 20, 170, 40, 30, "Nets") TextGadget(#Gadget_11, 170, 170, 50, 30, "Hosts") CheckBoxGadget(#Gadget_INVERT, 320, 70, 20, 30, "") TreeGadget(#Gadget_LIST, 20, 220, 310, 170) Frame3DGadget(#Gadget_14, 10, 150, 320, 60, "") Frame3DGadget(#Gadget_15, 10, 10, 330, 50, "") Frame3DGadget(#Gadget_16, 10, 60, 330, 50, "") EndIf EndIf EndProcedure
;--------------------------------------- CUT HERE -------------------------------------------------- ; purebasic removed the assembly language.
Procedure.l prefix( n.l) If n.l =0 ProcedureReturn 0 EndIf ProcedureReturn(-1 > 1 Next ProcedureReturn l.l EndProcedure
Procedure.l reverse( l.l ) a.b=PeekB(@l.l+0) b.b=PeekB(@l.l+1) c.b=PeekB(@l.l+2) d.b=PeekB(@l.l+3) PokeB(@l.l+0,d.b) PokeB(@l.l+1,c.b) PokeB(@l.l+2,b.b) PokeB(@l.l+3,a.b) ProcedureReturn l.l EndProcedure
Procedure.s ipAddressToString( ip.l) ipStr.s="" For i.l=0 To 3 ipStr.s=ipStr.s+Str(IPAddressField(ip.l,i))+"." Next i ipStr.s=Left(ipStr.s,Len(ipStr.s)-1) ProcedureReturn ipStr.s EndProcedure
Procedure updateGadgets( bits.l, reserved.l) SetGadgetText(#Gadget_PREFIX,StrU(bits.l,#long)) sMask.l=reverse(prefix(bits)) subNet.l = (132: prefix.l=32:EndIf bits.l = prefix.l updateGadgets3(bits.l, reserved.l) ;------------------------------------------------ Case #Gadget_IP subNet.l=GetGadgetState(#Gadget_IP) ip0.l = IPAddressField(subNet.l,0) If ip0.l oldIP0.l If ip0.l < 127 reserved.l=8 bits.l=8 SetGadgetText(#Gadget_CLASS,"A") ElseIf ip0.l < 191 bits.l=16 reserved.l=16 SetGadgetText(#Gadget_CLASS,"B") ElseIf ip0.l < 224 bits.l=24 reserved.l =24 SetGadgetText(#Gadget_CLASS,"C") ElseIf ip0.l < 239 SetGadgetText(#Gadget_CLASS,"D") ElseIf ip0.l < 255 SetGadgetText(#Gadget_CLASS,"E") EndIf updateGadgets(bits.l, reserved.l) EndIf If reserved.l<4: reserved.l=4: EndIf oldIP0.l = ip0.l ; endcase IP ---------------------------------- Case #Gadget_INVERT updateGadgets(bits.l, reserved.l) ;endcase INVERT ------------------------------- Case #Gadget_SM Mask.l = GetGadgetState(#Gadget_SM) prefix.l = maskToPrefix( Mask.l) reserved.l = prefix.l bits.l = prefix.l updateGadgets2(bits.l, reserved.l) ; ---------------------------------------------- Case #Gadget_LIST item.l=GetGadgetState(#Gadget_LIST) text.s=GetGadgetItemText(#Gadget_LIST,item.l,0 ) ;------------------------------------------------ Case #Gadget_Calc updateTree(bits.l, reserved.l) EndSelect EndIf Until Event = #PB_EventCloseWindow End
|