Page 1 of 1

Multiple Issues - New to Purebasic

Posted: Fri Nov 07, 2014 9:05 pm
by johnorourke1351
Hi

I have a purebasic main source file and a form file that is generated. I am getting some errors I don't understand from the form generation and events that it generates and then when I press buttons it does nothing other than display the form. I can't even get to the first line of the event. Also there is a Save button which the form generator generates 2 events . I'm not sure why it does this for the "save" button but I give it an event procedure to execute in the jobentry.pbf form for the save button and it removes my SaveButtonEvent and replaces it with just Save in the tool parameters but it declares 2 save events SaveButtonEvent and Save. I want to run the CalcButtonEvent and test it for validating the fields I enter in the form but it goes nowhere. Here is the code:

Main program (jobentry.pb):

XIncludeFile "Jobentry.pbf" ; Include the first window definition

Declare CheckNull(Gadget)


;OpenMainWindow() ; Open the first window. This procedure name is always 'Open' followed by the window name
;OpenDateWindow() ; Open the second window
OpenWindow_0()
;OpenWindow_1()

; The event procedures, as specified in the 'event procedure' property of each gadget
Procedure Save(EventType)
Debug "Save Button event"
EndProcedure

Procedure DeleteButtonEvent(EventType)

Debug "DeleteButton event"
EndProcedure

Procedure CalcButtonEvent(EventType)
Result = ValidateFields
Debug "Calc button event"
EndProcedure

Procedure ValidateFields()


Result = CheckNull(#String_Jobid)
Result = CheckNull(#Date_Pour)
Result = CheckNull(#String_One_Way_Travel)
Result = CheckNull(#String_Load_Size)
Result = CheckNull(#String_YPH_Ordered)
Result = CheckNull(#String_Slab_Depth)
Result = CheckNull(#String_Pour_Start_Time)
Result = CheckNull(#String_Added_Yard_Time)
Result = CheckNull(#String_Added_Return_Time)
Result = CheckNull(#String_Pump_Move_Time)
Result = CheckNull(#String_Grab_Ass_Trucks)

EndProcedure

Procedure CheckNull(Gadget)
TestString$ = GetGadgetText(Gadget)
If TestString$ = ""
MessageRequester ("Error", "You must enter a value", #PB_MessageRequester_Ok)
ProcedureReturn 1
Else
ProcedureReturn 0
EndIf
EndProcedure

; The main event loop as usual, the only change is to call the automatically
; generated event procedure for each window.
Repeat
Event = WaitWindowEvent()

Select EventWindow()
Case Window_0
Window_0_Events(Event) ; This procedure name is always window name followed by '_Events'

;Case Window_1
;Window_1_Events(Event)

EndSelect

Until Event = #PB_Event_CloseWindow ; Quit on any window close

Now here is the generated jobentry.pbf form:

;
; This code is automatically generated by the FormDesigner.
; Manual modification is possible to adjust existing commands, but anything else will be dropped when the code is compiled.
; Event procedures needs to be put in another source file.
;

Global Window_0

Global Text_0, Text_1, Text_Pour_Date, Text_One_Way_Travel, Text_Load_Size, Text_YPH_Ordered, Text_Slab_Dept, Text_Pour_Start_Time, Text_Added_Yard_Time, Text_Added_Return_Time, Text_Pump_Move_Time, Text_Grab_Ass_Trucks, Text_13, Text_14, Text_15, Text_16, Text_17, Text_18, Text_19, Text_20, Text_21, Text_22, Text_23, Text_24, Text_25, Text_26, Text_27, Text_28, Text_29, Text_30, Text_31, Text_32, Text_33, Text_34, Text_35, Text_36, Button_First, Button_Previous, Button_Next, Button_Last, Text_38, Button_Save, Button_Delete, Button_Calc

Enumeration FormGadget
#String_Jobid
#String_Name
#Date_Pour
#String_One_Way_Travel
#String_Load_Size
#String_YPH_Ordered
#String_Slab_Depth
#String_Pour_Start_Time
#String_Added_Yard_Time
#String_Added_Return_Time
#String_Pump_Move_Time
#String_Grab_Ass_Trucks
#String_Maximum_YPH
#String_Unload_Time
#String_Total_Trip_Time
#String_Yards_Per_Truck_Hour
#String_Actual_Trucks_Required
#String_Optimum_Trucks_Required
#String_Maximum_Trucks_Required
#String_Trucks_Req_by_YPH_Order
#String_1st_Batch_Time
#String_YPH_by_Optimal_Trucks
#String_Added_Gap
#String_Trucks_Loaded_at_One_Time
#String_Hours_to_Pour_Opt_Trucks
#String_Hours_to_Pour_Max_Trucks
#String_Total_Number_of_Trips
#String_Mins_Out_of_Concrete_by_Opt
#String_Minimum_Yds_at_Pump
#String_Total_Mins_Wasted_by_Max
#String_Adjusted_Truck_Count_if_Limited_Access
#String_Total_Lost_Hrs_to_Pump_Move
#String_Wasted_Assets_using_YPH_Order
#String_Wasted_Hours_by_Grab_Ass
#String_Substitute_Slab_Depth_Limited_Access
#String_Substitute_Slab_Depth_for_Underorder
EndEnumeration

Declare CalcButtonEvent(EventType)
Declare DeleteButtonEvent(EventType)
Declare Save(EventType)
Declare SaveButtonEvent(Event, Window)

Procedure OpenWindow_0(x = 0, y = 0, width = 1500, height = 800)
Window_0 = OpenWindow(#PB_Any, x, y, width, height, "", #PB_Window_SystemMenu | #PB_Window_MaximizeGadget)
SetWindowColor(Window_0, RGB(192,192,192))
Text_0 = TextGadget(#PB_Any, 120, 110, 50, 25, "Job ID")
StringGadget(#String_Jobid, 180, 110, 100, 25, "")
SetGadgetColor(#String_Jobid, #PB_Gadget_FrontColor,RGB(0,0,0))
SetGadgetColor(#String_Jobid, #PB_Gadget_BackColor,RGB(255,255,128))
Text_1 = TextGadget(#PB_Any, 120, 150, 50, 25, "Name")
StringGadget(#String_Name, 180, 150, 100, 25, "")
SetGadgetColor(#String_Name, #PB_Gadget_BackColor,RGB(255,255,128))
Text_Pour_Date = TextGadget(#PB_Any, 100, 190, 70, 25, "Pour Date")
DateGadget(#Date_Pour, 180, 190, 100, 25, "")
Text_One_Way_Travel = TextGadget(#PB_Any, 60, 230, 110, 25, "One Way Travel")
Text_Load_Size = TextGadget(#PB_Any, 100, 270, 70, 25, "Load Size")
Text_YPH_Ordered = TextGadget(#PB_Any, 80, 310, 90, 25, "YPH Ordered")
StringGadget(#String_One_Way_Travel, 180, 230, 100, 25, "")
SetGadgetColor(#String_One_Way_Travel, #PB_Gadget_BackColor,RGB(255,255,128))
StringGadget(#String_Load_Size, 180, 270, 100, 25, "")
SetGadgetColor(#String_Load_Size, #PB_Gadget_BackColor,RGB(255,255,128))
StringGadget(#String_YPH_Ordered, 180, 310, 100, 25, "")
SetGadgetColor(#String_YPH_Ordered, #PB_Gadget_BackColor,RGB(255,255,128))
Text_Slab_Dept = TextGadget(#PB_Any, 90, 350, 80, 25, "Slab Depth")
Text_Pour_Start_Time = TextGadget(#PB_Any, 60, 390, 110, 25, "Pour Start Time")
Text_Added_Yard_Time = TextGadget(#PB_Any, 50, 430, 120, 30, "Added Yard Time")
Text_Added_Return_Time = TextGadget(#PB_Any, 40, 470, 130, 25, "Added Return Time")
Text_Pump_Move_Time = TextGadget(#PB_Any, 50, 510, 120, 25, "Pump Move Time")
Text_Grab_Ass_Trucks = TextGadget(#PB_Any, 60, 550, 110, 25, "Grab Ass Trucks")
StringGadget(#String_Slab_Depth, 180, 350, 100, 25, "")
SetGadgetColor(#String_Slab_Depth, #PB_Gadget_BackColor,RGB(255,255,128))
StringGadget(#String_Pour_Start_Time, 180, 390, 100, 25, "")
SetGadgetColor(#String_Pour_Start_Time, #PB_Gadget_BackColor,RGB(255,255,128))
StringGadget(#String_Added_Yard_Time, 180, 430, 100, 25, "")
SetGadgetColor(#String_Added_Yard_Time, #PB_Gadget_BackColor,RGB(255,255,128))
StringGadget(#String_Added_Return_Time, 180, 470, 100, 25, "")
SetGadgetColor(#String_Added_Return_Time, #PB_Gadget_BackColor,RGB(255,255,128))
StringGadget(#String_Pump_Move_Time, 180, 510, 100, 25, "")
SetGadgetColor(#String_Pump_Move_Time, #PB_Gadget_BackColor,RGB(255,255,128))
StringGadget(#String_Grab_Ass_Trucks, 180, 550, 100, 25, "")
SetGadgetColor(#String_Grab_Ass_Trucks, #PB_Gadget_BackColor,RGB(255,255,128))
Text_13 = TextGadget(#PB_Any, 410, 110, 100, 25, "Maximum YPH")
StringGadget(#String_Maximum_YPH, 520, 110, 100, 25, "")
SetGadgetColor(#String_Maximum_YPH, #PB_Gadget_BackColor,RGB(189,255,189))
Text_14 = TextGadget(#PB_Any, 410, 150, 100, 25, "Unload Time")
Text_15 = TextGadget(#PB_Any, 400, 190, 110, 25, "Total Trip Time")
Text_16 = TextGadget(#PB_Any, 370, 230, 140, 25, "Yards Per Truck Hour")
Text_17 = TextGadget(#PB_Any, 350, 270, 160, 25, "Actual Trucks Required")
Text_18 = TextGadget(#PB_Any, 330, 310, 180, 25, "Optimum Trucks Required")
Text_19 = TextGadget(#PB_Any, 330, 350, 180, 25, "Maximum Trucks Required")
Text_20 = TextGadget(#PB_Any, 340, 390, 170, 25, "Trucks Req by YPH Order")
StringGadget(#String_Unload_Time, 520, 150, 100, 25, "")
SetGadgetColor(#String_Unload_Time, #PB_Gadget_BackColor,RGB(189,255,189))
StringGadget(#String_Total_Trip_Time, 520, 190, 100, 25, "")
SetGadgetColor(#String_Total_Trip_Time, #PB_Gadget_BackColor,RGB(189,255,189))
StringGadget(#String_Yards_Per_Truck_Hour, 520, 230, 100, 25, "")
SetGadgetColor(#String_Yards_Per_Truck_Hour, #PB_Gadget_BackColor,RGB(189,255,189))
StringGadget(#String_Actual_Trucks_Required, 520, 270, 100, 25, "")
SetGadgetColor(#String_Actual_Trucks_Required, #PB_Gadget_BackColor,RGB(189,255,189))
StringGadget(#String_Optimum_Trucks_Required, 520, 310, 100, 25, "")
SetGadgetColor(#String_Optimum_Trucks_Required, #PB_Gadget_BackColor,RGB(183,255,183))
StringGadget(#String_Maximum_Trucks_Required, 520, 350, 100, 25, "")
SetGadgetColor(#String_Maximum_Trucks_Required, #PB_Gadget_BackColor,RGB(183,255,183))
StringGadget(#String_Trucks_Req_by_YPH_Order, 520, 390, 100, 25, "")
SetGadgetColor(#String_Trucks_Req_by_YPH_Order, #PB_Gadget_BackColor,RGB(193,255,193))
Text_21 = TextGadget(#PB_Any, 720, 110, 110, 25, "1st Batch Time")
Text_22 = TextGadget(#PB_Any, 670, 150, 160, 25, "YPH by Optimal Trucks")
Text_23 = TextGadget(#PB_Any, 740, 190, 90, 25, "Added Gap")
Text_24 = TextGadget(#PB_Any, 640, 230, 190, 25, "Trucks Loaded at One Time")
Text_25 = TextGadget(#PB_Any, 650, 270, 180, 25, "Hours to Pour Opt Trucks")
Text_26 = TextGadget(#PB_Any, 650, 310, 180, 25, "Hours to Pour Max Trucks")
Text_27 = TextGadget(#PB_Any, 670, 350, 160, 25, "Total Number of Trips")
Text_28 = TextGadget(#PB_Any, 630, 390, 200, 25, "Mins Out of Concrete by Opt")
StringGadget(#String_1st_Batch_Time, 840, 110, 100, 25, "")
SetGadgetColor(#String_1st_Batch_Time, #PB_Gadget_BackColor,RGB(189,255,189))
StringGadget(#String_YPH_by_Optimal_Trucks, 840, 150, 100, 25, "")
SetGadgetColor(#String_YPH_by_Optimal_Trucks, #PB_Gadget_BackColor,RGB(189,255,189))
StringGadget(#String_Added_Gap, 840, 190, 100, 25, "")
SetGadgetColor(#String_Added_Gap, #PB_Gadget_BackColor,RGB(255,183,255))
StringGadget(#String_Trucks_Loaded_at_One_Time, 840, 230, 100, 25, "")
SetGadgetColor(#String_Trucks_Loaded_at_One_Time, #PB_Gadget_BackColor,RGB(168,255,168))
StringGadget(#String_Hours_to_Pour_Opt_Trucks, 850, 270, 100, 25, "")
SetGadgetColor(#String_Hours_to_Pour_Opt_Trucks, #PB_Gadget_BackColor,RGB(181,255,181))
StringGadget(#String_Hours_to_Pour_Max_Trucks, 850, 310, 100, 25, "")
SetGadgetColor(#String_Hours_to_Pour_Max_Trucks, #PB_Gadget_BackColor,RGB(181,255,181))
StringGadget(#String_Total_Number_of_Trips, 840, 350, 100, 25, "")
SetGadgetColor(#String_Total_Number_of_Trips, #PB_Gadget_BackColor,RGB(181,255,181))
StringGadget(#String_Mins_Out_of_Concrete_by_Opt, 840, 390, 100, 25, "")
SetGadgetColor(#String_Mins_Out_of_Concrete_by_Opt, #PB_Gadget_BackColor,RGB(255,183,255))
Text_29 = TextGadget(#PB_Any, 1080, 110, 160, 25, "Minimum Yds at Pump")
Text_30 = TextGadget(#PB_Any, 1050, 150, 190, 25, "Total Mins Wasted by Max")
Text_31 = TextGadget(#PB_Any, 970, 190, 270, 25, "Adjusted Truck Count if Limited Access")
Text_32 = TextGadget(#PB_Any, 1030, 230, 210, 25, "Total Lost Hrs to Pump Move")
Text_33 = TextGadget(#PB_Any, 1020, 270, 220, 25, "Wasted Assets using YPH Order")
Text_34 = TextGadget(#PB_Any, 1050, 310, 190, 25, "Wasted Hours by Grab Ass")
Text_35 = TextGadget(#PB_Any, 980, 350, 260, 25, "Substitute Slab Depth Limited Access")
Text_36 = TextGadget(#PB_Any, 980, 390, 260, 25, "Substitute Slab Depth for Underorder")
StringGadget(#String_Minimum_Yds_at_Pump, 1250, 110, 100, 25, "")
SetGadgetColor(#String_Minimum_Yds_at_Pump, #PB_Gadget_BackColor,RGB(181,255,181))
StringGadget(#String_Total_Mins_Wasted_by_Max, 1250, 150, 100, 25, "")
SetGadgetColor(#String_Total_Mins_Wasted_by_Max, #PB_Gadget_BackColor,RGB(255,183,255))
StringGadget(#String_Adjusted_Truck_Count_if_Limited_Access, 1250, 190, 100, 25, "")
SetGadgetColor(#String_Adjusted_Truck_Count_if_Limited_Access, #PB_Gadget_BackColor,RGB(255,183,255))
StringGadget(#String_Total_Lost_Hrs_to_Pump_Move, 1250, 230, 100, 25, "")
SetGadgetColor(#String_Total_Lost_Hrs_to_Pump_Move, #PB_Gadget_BackColor,RGB(255,183,255))
StringGadget(#String_Wasted_Assets_using_YPH_Order, 1250, 270, 100, 25, "")
SetGadgetColor(#String_Wasted_Assets_using_YPH_Order, #PB_Gadget_BackColor,RGB(255,183,255))
StringGadget(#String_Wasted_Hours_by_Grab_Ass, 1250, 310, 100, 25, "")
SetGadgetColor(#String_Wasted_Hours_by_Grab_Ass, #PB_Gadget_BackColor,RGB(255,183,255))
StringGadget(#String_Substitute_Slab_Depth_Limited_Access, 1250, 350, 100, 25, "")
SetGadgetColor(#String_Substitute_Slab_Depth_Limited_Access, #PB_Gadget_BackColor,RGB(168,226,255))
StringGadget(#String_Substitute_Slab_Depth_for_Underorder, 1250, 390, 100, 25, "")
SetGadgetColor(#String_Substitute_Slab_Depth_for_Underorder, #PB_Gadget_BackColor,RGB(168,226,255))
Button_First = ButtonGadget(#PB_Any, 410, 620, 30, 25, "<<")
Button_Previous = ButtonGadget(#PB_Any, 450, 620, 30, 25, "<")
Button_Next = ButtonGadget(#PB_Any, 490, 620, 30, 25, ">")
Button_Last = ButtonGadget(#PB_Any, 530, 620, 40, 25, ">>")
Text_38 = TextGadget(#PB_Any, 0, 0, 100, 25, "Job Analysis")
Button_Save = ButtonGadget(#PB_Any, 50, 620, 50, 25, "Save")
Button_Delete = ButtonGadget(#PB_Any, 120, 620, 60, 25, "Delete")
Button_Calc = ButtonGadget(#PB_Any, 200, 620, 40, 25, "Calc")
EndProcedure

Procedure Window_0_Events(event)
Select event
Case #PB_Event_CloseWindow
ProcedureReturn #False

Case #PB_Event_Menu
Select EventMenu()
EndSelect

Case #PB_Event_Gadget
Select EventGadget()
Case Button_Save
Save(EventType())
Case Button_Delete
DeleteButtonEvent(EventType())
Case Button_Calc
CalcButtonEvent(EventType())
EndSelect
Default
SaveButtonEvent(event,Window_0)
EndSelect
ProcedureReturn #True
EndProcedure

That's it. Hope someone has the patience to go through it.

Thanks.
John o

Re: Multiple Issues - New to Purebasic

Posted: Sat Nov 08, 2014 12:04 am
by skywalk
Hi, it is easier to help if you post small code samples within <Code> blocks and Put comments or Debug statements where you have a problem.

Code: Select all

Declare CheckNull(Gadget)
Declare CalcButtonEvent(EventType)
Declare DeleteButtonEvent(EventType)
Declare Save(EventType)
;Declare SaveButtonEvent(Event, Window)
;
; This code is automatically generated by the FormDesigner.
; Manual modification is possible to adjust existing commands, but anything else will be dropped when the code is compiled.
; Event procedures needs to be put in another source file.
;
Global Window_0
Global Text_0, Text_1, Text_Pour_Date, Text_One_Way_Travel, Text_Load_Size, Text_YPH_Ordered, Text_Slab_Dept, Text_Pour_Start_Time, Text_Added_Yard_Time, Text_Added_Return_Time, Text_Pump_Move_Time, Text_Grab_Ass_Trucks, Text_13, Text_14, Text_15, Text_16, Text_17, Text_18, Text_19, Text_20, Text_21, Text_22, Text_23, Text_24, Text_25, Text_26, Text_27, Text_28, Text_29, Text_30, Text_31, Text_32, Text_33, Text_34, Text_35, Text_36, Button_First, Button_Previous, Button_Next, Button_Last, Text_38, Button_Save, Button_Delete, Button_Calc

Enumeration FormGadget
  #String_Jobid
  #String_Name
  #Date_Pour
  #String_One_Way_Travel
  #String_Load_Size
  #String_YPH_Ordered
  #String_Slab_Depth
  #String_Pour_Start_Time
  #String_Added_Yard_Time
  #String_Added_Return_Time
  #String_Pump_Move_Time
  #String_Grab_Ass_Trucks
  #String_Maximum_YPH
  #String_Unload_Time
  #String_Total_Trip_Time
  #String_Yards_Per_Truck_Hour
  #String_Actual_Trucks_Required
  #String_Optimum_Trucks_Required
  #String_Maximum_Trucks_Required
  #String_Trucks_Req_by_YPH_Order
  #String_1st_Batch_Time
  #String_YPH_by_Optimal_Trucks
  #String_Added_Gap
  #String_Trucks_Loaded_at_One_Time
  #String_Hours_to_Pour_Opt_Trucks
  #String_Hours_to_Pour_Max_Trucks
  #String_Total_Number_of_Trips
  #String_Mins_Out_of_Concrete_by_Opt
  #String_Minimum_Yds_at_Pump
  #String_Total_Mins_Wasted_by_Max
  #String_Adjusted_Truck_Count_if_Limited_Access
  #String_Total_Lost_Hrs_to_Pump_Move
  #String_Wasted_Assets_using_YPH_Order
  #String_Wasted_Hours_by_Grab_Ass
  #String_Substitute_Slab_Depth_Limited_Access
  #String_Substitute_Slab_Depth_for_Underorder
EndEnumeration

Procedure OpenWindow_0(x = 0, y = 0, width = 1500, height = 800)
  Window_0 = OpenWindow(#PB_Any, x, y, width, height, "", #PB_Window_SystemMenu | #PB_Window_MaximizeGadget)
  SetWindowColor(Window_0, RGB(192,192,192))
  Text_0 = TextGadget(#PB_Any, 120, 110, 50, 25, "Job ID")
  StringGadget(#String_Jobid, 180, 110, 100, 25, "")
  SetGadgetColor(#String_Jobid, #PB_Gadget_FrontColor,RGB(0,0,0))
  SetGadgetColor(#String_Jobid, #PB_Gadget_BackColor,RGB(255,255,128))
  Text_1 = TextGadget(#PB_Any, 120, 150, 50, 25, "Name")
  StringGadget(#String_Name, 180, 150, 100, 25, "")
  SetGadgetColor(#String_Name, #PB_Gadget_BackColor,RGB(255,255,128))
  Text_Pour_Date = TextGadget(#PB_Any, 100, 190, 70, 25, "Pour Date")
  DateGadget(#Date_Pour, 180, 190, 100, 25, "")
  Text_One_Way_Travel = TextGadget(#PB_Any, 60, 230, 110, 25, "One Way Travel")
  Text_Load_Size = TextGadget(#PB_Any, 100, 270, 70, 25, "Load Size")
  Text_YPH_Ordered = TextGadget(#PB_Any, 80, 310, 90, 25, "YPH Ordered")
  StringGadget(#String_One_Way_Travel, 180, 230, 100, 25, "")
  SetGadgetColor(#String_One_Way_Travel, #PB_Gadget_BackColor,RGB(255,255,128))
  StringGadget(#String_Load_Size, 180, 270, 100, 25, "")
  SetGadgetColor(#String_Load_Size, #PB_Gadget_BackColor,RGB(255,255,128))
  StringGadget(#String_YPH_Ordered, 180, 310, 100, 25, "")
  SetGadgetColor(#String_YPH_Ordered, #PB_Gadget_BackColor,RGB(255,255,128))
  Text_Slab_Dept = TextGadget(#PB_Any, 90, 350, 80, 25, "Slab Depth")
  Text_Pour_Start_Time = TextGadget(#PB_Any, 60, 390, 110, 25, "Pour Start Time")
  Text_Added_Yard_Time = TextGadget(#PB_Any, 50, 430, 120, 30, "Added Yard Time")
  Text_Added_Return_Time = TextGadget(#PB_Any, 40, 470, 130, 25, "Added Return Time")
  Text_Pump_Move_Time = TextGadget(#PB_Any, 50, 510, 120, 25, "Pump Move Time")
  Text_Grab_Ass_Trucks = TextGadget(#PB_Any, 60, 550, 110, 25, "Grab Ass Trucks")
  StringGadget(#String_Slab_Depth, 180, 350, 100, 25, "")
  SetGadgetColor(#String_Slab_Depth, #PB_Gadget_BackColor,RGB(255,255,128))
  StringGadget(#String_Pour_Start_Time, 180, 390, 100, 25, "")
  SetGadgetColor(#String_Pour_Start_Time, #PB_Gadget_BackColor,RGB(255,255,128))
  StringGadget(#String_Added_Yard_Time, 180, 430, 100, 25, "")
  SetGadgetColor(#String_Added_Yard_Time, #PB_Gadget_BackColor,RGB(255,255,128))
  StringGadget(#String_Added_Return_Time, 180, 470, 100, 25, "")
  SetGadgetColor(#String_Added_Return_Time, #PB_Gadget_BackColor,RGB(255,255,128))
  StringGadget(#String_Pump_Move_Time, 180, 510, 100, 25, "")
  SetGadgetColor(#String_Pump_Move_Time, #PB_Gadget_BackColor,RGB(255,255,128))
  StringGadget(#String_Grab_Ass_Trucks, 180, 550, 100, 25, "")
  SetGadgetColor(#String_Grab_Ass_Trucks, #PB_Gadget_BackColor,RGB(255,255,128))
  Text_13 = TextGadget(#PB_Any, 410, 110, 100, 25, "Maximum YPH")
  StringGadget(#String_Maximum_YPH, 520, 110, 100, 25, "")
  SetGadgetColor(#String_Maximum_YPH, #PB_Gadget_BackColor,RGB(189,255,189))
  Text_14 = TextGadget(#PB_Any, 410, 150, 100, 25, "Unload Time")
  Text_15 = TextGadget(#PB_Any, 400, 190, 110, 25, "Total Trip Time")
  Text_16 = TextGadget(#PB_Any, 370, 230, 140, 25, "Yards Per Truck Hour")
  Text_17 = TextGadget(#PB_Any, 350, 270, 160, 25, "Actual Trucks Required")
  Text_18 = TextGadget(#PB_Any, 330, 310, 180, 25, "Optimum Trucks Required")
  Text_19 = TextGadget(#PB_Any, 330, 350, 180, 25, "Maximum Trucks Required")
  Text_20 = TextGadget(#PB_Any, 340, 390, 170, 25, "Trucks Req by YPH Order")
  StringGadget(#String_Unload_Time, 520, 150, 100, 25, "")
  SetGadgetColor(#String_Unload_Time, #PB_Gadget_BackColor,RGB(189,255,189))
  StringGadget(#String_Total_Trip_Time, 520, 190, 100, 25, "")
  SetGadgetColor(#String_Total_Trip_Time, #PB_Gadget_BackColor,RGB(189,255,189))
  StringGadget(#String_Yards_Per_Truck_Hour, 520, 230, 100, 25, "")
  SetGadgetColor(#String_Yards_Per_Truck_Hour, #PB_Gadget_BackColor,RGB(189,255,189))
  StringGadget(#String_Actual_Trucks_Required, 520, 270, 100, 25, "")
  SetGadgetColor(#String_Actual_Trucks_Required, #PB_Gadget_BackColor,RGB(189,255,189))
  StringGadget(#String_Optimum_Trucks_Required, 520, 310, 100, 25, "")
  SetGadgetColor(#String_Optimum_Trucks_Required, #PB_Gadget_BackColor,RGB(183,255,183))
  StringGadget(#String_Maximum_Trucks_Required, 520, 350, 100, 25, "")
  SetGadgetColor(#String_Maximum_Trucks_Required, #PB_Gadget_BackColor,RGB(183,255,183))
  StringGadget(#String_Trucks_Req_by_YPH_Order, 520, 390, 100, 25, "")
  SetGadgetColor(#String_Trucks_Req_by_YPH_Order, #PB_Gadget_BackColor,RGB(193,255,193))
  Text_21 = TextGadget(#PB_Any, 720, 110, 110, 25, "1st Batch Time")
  Text_22 = TextGadget(#PB_Any, 670, 150, 160, 25, "YPH by Optimal Trucks")
  Text_23 = TextGadget(#PB_Any, 740, 190, 90, 25, "Added Gap")
  Text_24 = TextGadget(#PB_Any, 640, 230, 190, 25, "Trucks Loaded at One Time")
  Text_25 = TextGadget(#PB_Any, 650, 270, 180, 25, "Hours to Pour Opt Trucks")
  Text_26 = TextGadget(#PB_Any, 650, 310, 180, 25, "Hours to Pour Max Trucks")
  Text_27 = TextGadget(#PB_Any, 670, 350, 160, 25, "Total Number of Trips")
  Text_28 = TextGadget(#PB_Any, 630, 390, 200, 25, "Mins Out of Concrete by Opt")
  StringGadget(#String_1st_Batch_Time, 840, 110, 100, 25, "")
  SetGadgetColor(#String_1st_Batch_Time, #PB_Gadget_BackColor,RGB(189,255,189))
  StringGadget(#String_YPH_by_Optimal_Trucks, 840, 150, 100, 25, "")
  SetGadgetColor(#String_YPH_by_Optimal_Trucks, #PB_Gadget_BackColor,RGB(189,255,189))
  StringGadget(#String_Added_Gap, 840, 190, 100, 25, "")
  SetGadgetColor(#String_Added_Gap, #PB_Gadget_BackColor,RGB(255,183,255))
  StringGadget(#String_Trucks_Loaded_at_One_Time, 840, 230, 100, 25, "")
  SetGadgetColor(#String_Trucks_Loaded_at_One_Time, #PB_Gadget_BackColor,RGB(168,255,168))
  StringGadget(#String_Hours_to_Pour_Opt_Trucks, 850, 270, 100, 25, "")
  SetGadgetColor(#String_Hours_to_Pour_Opt_Trucks, #PB_Gadget_BackColor,RGB(181,255,181))
  StringGadget(#String_Hours_to_Pour_Max_Trucks, 850, 310, 100, 25, "")
  SetGadgetColor(#String_Hours_to_Pour_Max_Trucks, #PB_Gadget_BackColor,RGB(181,255,181))
  StringGadget(#String_Total_Number_of_Trips, 840, 350, 100, 25, "")
  SetGadgetColor(#String_Total_Number_of_Trips, #PB_Gadget_BackColor,RGB(181,255,181))
  StringGadget(#String_Mins_Out_of_Concrete_by_Opt, 840, 390, 100, 25, "")
  SetGadgetColor(#String_Mins_Out_of_Concrete_by_Opt, #PB_Gadget_BackColor,RGB(255,183,255))
  Text_29 = TextGadget(#PB_Any, 1080, 110, 160, 25, "Minimum Yds at Pump")
  Text_30 = TextGadget(#PB_Any, 1050, 150, 190, 25, "Total Mins Wasted by Max")
  Text_31 = TextGadget(#PB_Any, 970, 190, 270, 25, "Adjusted Truck Count if Limited Access")
  Text_32 = TextGadget(#PB_Any, 1030, 230, 210, 25, "Total Lost Hrs to Pump Move")
  Text_33 = TextGadget(#PB_Any, 1020, 270, 220, 25, "Wasted Assets using YPH Order")
  Text_34 = TextGadget(#PB_Any, 1050, 310, 190, 25, "Wasted Hours by Grab Ass")
  Text_35 = TextGadget(#PB_Any, 980, 350, 260, 25, "Substitute Slab Depth Limited Access")
  Text_36 = TextGadget(#PB_Any, 980, 390, 260, 25, "Substitute Slab Depth for Underorder")
  StringGadget(#String_Minimum_Yds_at_Pump, 1250, 110, 100, 25, "")
  SetGadgetColor(#String_Minimum_Yds_at_Pump, #PB_Gadget_BackColor,RGB(181,255,181))
  StringGadget(#String_Total_Mins_Wasted_by_Max, 1250, 150, 100, 25, "")
  SetGadgetColor(#String_Total_Mins_Wasted_by_Max, #PB_Gadget_BackColor,RGB(255,183,255))
  StringGadget(#String_Adjusted_Truck_Count_if_Limited_Access, 1250, 190, 100, 25, "")
  SetGadgetColor(#String_Adjusted_Truck_Count_if_Limited_Access, #PB_Gadget_BackColor,RGB(255,183,255))
  StringGadget(#String_Total_Lost_Hrs_to_Pump_Move, 1250, 230, 100, 25, "")
  SetGadgetColor(#String_Total_Lost_Hrs_to_Pump_Move, #PB_Gadget_BackColor,RGB(255,183,255))
  StringGadget(#String_Wasted_Assets_using_YPH_Order, 1250, 270, 100, 25, "")
  SetGadgetColor(#String_Wasted_Assets_using_YPH_Order, #PB_Gadget_BackColor,RGB(255,183,255))
  StringGadget(#String_Wasted_Hours_by_Grab_Ass, 1250, 310, 100, 25, "")
  SetGadgetColor(#String_Wasted_Hours_by_Grab_Ass, #PB_Gadget_BackColor,RGB(255,183,255))
  StringGadget(#String_Substitute_Slab_Depth_Limited_Access, 1250, 350, 100, 25, "")
  SetGadgetColor(#String_Substitute_Slab_Depth_Limited_Access, #PB_Gadget_BackColor,RGB(168,226,255))
  StringGadget(#String_Substitute_Slab_Depth_for_Underorder, 1250, 390, 100, 25, "")
  SetGadgetColor(#String_Substitute_Slab_Depth_for_Underorder, #PB_Gadget_BackColor,RGB(168,226,255))
  Button_First = ButtonGadget(#PB_Any, 410, 620, 30, 25, "<<")
  Button_Previous = ButtonGadget(#PB_Any, 450, 620, 30, 25, "<")
  Button_Next = ButtonGadget(#PB_Any, 490, 620, 30, 25, ">")
  Button_Last = ButtonGadget(#PB_Any, 530, 620, 40, 25, ">>")
  Text_38 = TextGadget(#PB_Any, 0, 0, 100, 25, "Job Analysis")
  Button_Save = ButtonGadget(#PB_Any, 50, 620, 50, 25, "Save")
  Button_Delete = ButtonGadget(#PB_Any, 120, 620, 60, 25, "Delete")
  Button_Calc = ButtonGadget(#PB_Any, 200, 620, 40, 25, "Calc")
EndProcedure

Procedure Window_0_Events(event)
  Select event
  Case #PB_Event_CloseWindow
    ProcedureReturn #False
    
  Case #PB_Event_Menu
    Select EventMenu()
    EndSelect
    
  Case #PB_Event_Gadget
    Select EventGadget()
    Case Button_Save
      Save(EventType()) 
    Case Button_Delete
      DeleteButtonEvent(EventType()) 
    Case Button_Calc
      CalcButtonEvent(EventType()) 
    EndSelect
  Default
    ;SaveButtonEvent(event,Window_0)
  EndSelect
  ProcedureReturn #True
EndProcedure

;OpenMainWindow() ; Open the first window. This procedure name is always 'Open' followed by the window name
;OpenDateWindow() ; Open the second window
OpenWindow_0()
;OpenWindow_1()

; The event procedures, as specified in the 'event procedure' property of each gadget
Procedure Save(EventType)
  Debug "Save Button event"
EndProcedure

Procedure DeleteButtonEvent(EventType)
  Debug "DeleteButton event"
EndProcedure

Procedure CalcButtonEvent(EventType)
  Result = ValidateFields
  Debug "Calc button event"
EndProcedure

Procedure ValidateFields()
  Result = CheckNull(#String_Jobid)
  Result = CheckNull(#Date_Pour)
  Result = CheckNull(#String_One_Way_Travel)
  Result = CheckNull(#String_Load_Size)
  Result = CheckNull(#String_YPH_Ordered)
  Result = CheckNull(#String_Slab_Depth)
  Result = CheckNull(#String_Pour_Start_Time)
  Result = CheckNull(#String_Added_Yard_Time)
  Result = CheckNull(#String_Added_Return_Time)
  Result = CheckNull(#String_Pump_Move_Time)
  Result = CheckNull(#String_Grab_Ass_Trucks) 
EndProcedure

Procedure CheckNull(Gadget)
  TestString$ = GetGadgetText(Gadget)
  If TestString$ = ""
    MessageRequester ("Error", "You must enter a value", #PB_MessageRequester_Ok)
    ProcedureReturn 1
  Else
    ProcedureReturn 0
  EndIf
EndProcedure 

; The main event loop as usual, the only change is to call the automatically
; generated event procedure for each window.
Repeat
  Event = WaitWindowEvent()
  Select EventWindow()
  Case Window_0
    Window_0_Events(Event) ; This procedure name is always window name followed by '_Events'
    ;Case Window_1
    ;Window_1_Events(Event)
  EndSelect
Until Event = #PB_Event_CloseWindow ; Quit on any window close

Re: Multiple Issues - New to Purebasic

Posted: Sat Nov 08, 2014 1:28 am
by johnorourke1351
I have made big text around the areas of concentration. I tried to reduce the program by cutting out code but this removed all the objects. Thanks for any assistance you can offer. If you want to reduce the program further, I may have to remove the objects first rather than the code in the generated program.

Declare CheckNull(Gadget)
I want to execute a calculation on the leftmost column fields after I check them for validity. I never get to the calc event
Declare CalcButtonEvent(EventType)
Declare DeleteButtonEvent(EventType)
I have a save button for eventually saving the entered fields on the first column in a file so I have a save button. In the form's parameter entry area for the save object I create a SaveButton and in the eventprocedure I give it a name of SaveButtonEvent. But the program generates 2 save events and changes the Event procedure name from SaveButtonEvent to Save
Declare Save(EventType)
Declare SaveButtonEvent(Event, Window)
;
; This code is automatically generated by the FormDesigner.
; Manual modification is possible to adjust existing commands, but anything else will be dropped when the code is compiled.
; Event procedures needs to be put in another source file.
;
Global Window_0
Global Text_0, Text_1, Text_Pour_Date, Text_One_Way_Travel, Text_Load_Size, Text_YPH_Ordered, Text_Slab_Dept, Text_Pour_Start_Time, Text_Added_Yard_Time, Text_Added_Return_Time, Text_Pump_Move_Time, Text_Grab_Ass_Trucks, Text_13, Text_14, Text_15, Text_16, Text_17, Text_18, Text_19, Text_20, Text_21, Text_22, Text_23, Text_24, Text_25, Text_26, Text_27, Text_28, Text_29, Text_30, Text_31, Text_32, Text_33, Text_34, Text_35, Text_36, Button_First, Button_Previous, Button_Next, Button_Last, Text_38, Button_Save, Button_Delete, Button_Calc

Enumeration FormGadget
#String_Jobid
#String_Name
#Date_Pour
#String_One_Way_Travel
#String_Load_Size
#String_YPH_Ordered
#String_Slab_Depth
#String_Pour_Start_Time
#String_Added_Yard_Time
#String_Added_Return_Time
#String_Pump_Move_Time
#String_Grab_Ass_Trucks
#String_Maximum_YPH
#String_Unload_Time
#String_Total_Trip_Time
#String_Yards_Per_Truck_Hour
#String_Actual_Trucks_Required
#String_Optimum_Trucks_Required
#String_Maximum_Trucks_Required
#String_Trucks_Req_by_YPH_Order
#String_1st_Batch_Time
#String_YPH_by_Optimal_Trucks
#String_Added_Gap
#String_Trucks_Loaded_at_One_Time
#String_Hours_to_Pour_Opt_Trucks
#String_Hours_to_Pour_Max_Trucks
#String_Total_Number_of_Trips
#String_Mins_Out_of_Concrete_by_Opt
#String_Minimum_Yds_at_Pump
#String_Total_Mins_Wasted_by_Max
#String_Adjusted_Truck_Count_if_Limited_Access
#String_Total_Lost_Hrs_to_Pump_Move
#String_Wasted_Assets_using_YPH_Order
#String_Wasted_Hours_by_Grab_Ass
#String_Substitute_Slab_Depth_Limited_Access
#String_Substitute_Slab_Depth_for_Underorder
EndEnumeration

Procedure OpenWindow_0(x = 0, y = 0, width = 1500, height = 800)
Window_0 = OpenWindow(#PB_Any, x, y, width, height, "", #PB_Window_SystemMenu | #PB_Window_MaximizeGadget)
SetWindowColor(Window_0, RGB(192,192,192))
Text_0 = TextGadget(#PB_Any, 120, 110, 50, 25, "Job ID")
StringGadget(#String_Jobid, 180, 110, 100, 25, "")
SetGadgetColor(#String_Jobid, #PB_Gadget_FrontColor,RGB(0,0,0))
SetGadgetColor(#String_Jobid, #PB_Gadget_BackColor,RGB(255,255,128))
Text_1 = TextGadget(#PB_Any, 120, 150, 50, 25, "Name")
StringGadget(#String_Name, 180, 150, 100, 25, "")
SetGadgetColor(#String_Name, #PB_Gadget_BackColor,RGB(255,255,128))
Text_Pour_Date = TextGadget(#PB_Any, 100, 190, 70, 25, "Pour Date")
DateGadget(#Date_Pour, 180, 190, 100, 25, "")
Text_One_Way_Travel = TextGadget(#PB_Any, 60, 230, 110, 25, "One Way Travel")
Text_Load_Size = TextGadget(#PB_Any, 100, 270, 70, 25, "Load Size")
Text_YPH_Ordered = TextGadget(#PB_Any, 80, 310, 90, 25, "YPH Ordered")
StringGadget(#String_One_Way_Travel, 180, 230, 100, 25, "")
SetGadgetColor(#String_One_Way_Travel, #PB_Gadget_BackColor,RGB(255,255,128))
StringGadget(#String_Load_Size, 180, 270, 100, 25, "")
SetGadgetColor(#String_Load_Size, #PB_Gadget_BackColor,RGB(255,255,128))
StringGadget(#String_YPH_Ordered, 180, 310, 100, 25, "")
SetGadgetColor(#String_YPH_Ordered, #PB_Gadget_BackColor,RGB(255,255,128))
Text_Slab_Dept = TextGadget(#PB_Any, 90, 350, 80, 25, "Slab Depth")
Text_Pour_Start_Time = TextGadget(#PB_Any, 60, 390, 110, 25, "Pour Start Time")
Text_Added_Yard_Time = TextGadget(#PB_Any, 50, 430, 120, 30, "Added Yard Time")
Text_Added_Return_Time = TextGadget(#PB_Any, 40, 470, 130, 25, "Added Return Time")
Text_Pump_Move_Time = TextGadget(#PB_Any, 50, 510, 120, 25, "Pump Move Time")
Text_Grab_Ass_Trucks = TextGadget(#PB_Any, 60, 550, 110, 25, "Grab Ass Trucks")
StringGadget(#String_Slab_Depth, 180, 350, 100, 25, "")
SetGadgetColor(#String_Slab_Depth, #PB_Gadget_BackColor,RGB(255,255,128))
StringGadget(#String_Pour_Start_Time, 180, 390, 100, 25, "")
SetGadgetColor(#String_Pour_Start_Time, #PB_Gadget_BackColor,RGB(255,255,128))
StringGadget(#String_Added_Yard_Time, 180, 430, 100, 25, "")
SetGadgetColor(#String_Added_Yard_Time, #PB_Gadget_BackColor,RGB(255,255,128))
StringGadget(#String_Added_Return_Time, 180, 470, 100, 25, "")
SetGadgetColor(#String_Added_Return_Time, #PB_Gadget_BackColor,RGB(255,255,128))
StringGadget(#String_Pump_Move_Time, 180, 510, 100, 25, "")
SetGadgetColor(#String_Pump_Move_Time, #PB_Gadget_BackColor,RGB(255,255,128))
StringGadget(#String_Grab_Ass_Trucks, 180, 550, 100, 25, "")
SetGadgetColor(#String_Grab_Ass_Trucks, #PB_Gadget_BackColor,RGB(255,255,128))
Text_13 = TextGadget(#PB_Any, 410, 110, 100, 25, "Maximum YPH")
StringGadget(#String_Maximum_YPH, 520, 110, 100, 25, "")
SetGadgetColor(#String_Maximum_YPH, #PB_Gadget_BackColor,RGB(189,255,189))
Text_14 = TextGadget(#PB_Any, 410, 150, 100, 25, "Unload Time")
Text_15 = TextGadget(#PB_Any, 400, 190, 110, 25, "Total Trip Time")
Text_16 = TextGadget(#PB_Any, 370, 230, 140, 25, "Yards Per Truck Hour")
Text_17 = TextGadget(#PB_Any, 350, 270, 160, 25, "Actual Trucks Required")
Text_18 = TextGadget(#PB_Any, 330, 310, 180, 25, "Optimum Trucks Required")
Text_19 = TextGadget(#PB_Any, 330, 350, 180, 25, "Maximum Trucks Required")
Text_20 = TextGadget(#PB_Any, 340, 390, 170, 25, "Trucks Req by YPH Order")
StringGadget(#String_Unload_Time, 520, 150, 100, 25, "")
SetGadgetColor(#String_Unload_Time, #PB_Gadget_BackColor,RGB(189,255,189))
StringGadget(#String_Total_Trip_Time, 520, 190, 100, 25, "")
SetGadgetColor(#String_Total_Trip_Time, #PB_Gadget_BackColor,RGB(189,255,189))
StringGadget(#String_Yards_Per_Truck_Hour, 520, 230, 100, 25, "")
SetGadgetColor(#String_Yards_Per_Truck_Hour, #PB_Gadget_BackColor,RGB(189,255,189))
StringGadget(#String_Actual_Trucks_Required, 520, 270, 100, 25, "")
SetGadgetColor(#String_Actual_Trucks_Required, #PB_Gadget_BackColor,RGB(189,255,189))
StringGadget(#String_Optimum_Trucks_Required, 520, 310, 100, 25, "")
SetGadgetColor(#String_Optimum_Trucks_Required, #PB_Gadget_BackColor,RGB(183,255,183))
StringGadget(#String_Maximum_Trucks_Required, 520, 350, 100, 25, "")
SetGadgetColor(#String_Maximum_Trucks_Required, #PB_Gadget_BackColor,RGB(183,255,183))
StringGadget(#String_Trucks_Req_by_YPH_Order, 520, 390, 100, 25, "")
SetGadgetColor(#String_Trucks_Req_by_YPH_Order, #PB_Gadget_BackColor,RGB(193,255,193))
Text_21 = TextGadget(#PB_Any, 720, 110, 110, 25, "1st Batch Time")
Text_22 = TextGadget(#PB_Any, 670, 150, 160, 25, "YPH by Optimal Trucks")
Text_23 = TextGadget(#PB_Any, 740, 190, 90, 25, "Added Gap")
Text_24 = TextGadget(#PB_Any, 640, 230, 190, 25, "Trucks Loaded at One Time")
Text_25 = TextGadget(#PB_Any, 650, 270, 180, 25, "Hours to Pour Opt Trucks")
Text_26 = TextGadget(#PB_Any, 650, 310, 180, 25, "Hours to Pour Max Trucks")
Text_27 = TextGadget(#PB_Any, 670, 350, 160, 25, "Total Number of Trips")
Text_28 = TextGadget(#PB_Any, 630, 390, 200, 25, "Mins Out of Concrete by Opt")
StringGadget(#String_1st_Batch_Time, 840, 110, 100, 25, "")
SetGadgetColor(#String_1st_Batch_Time, #PB_Gadget_BackColor,RGB(189,255,189))
StringGadget(#String_YPH_by_Optimal_Trucks, 840, 150, 100, 25, "")
SetGadgetColor(#String_YPH_by_Optimal_Trucks, #PB_Gadget_BackColor,RGB(189,255,189))
StringGadget(#String_Added_Gap, 840, 190, 100, 25, "")
SetGadgetColor(#String_Added_Gap, #PB_Gadget_BackColor,RGB(255,183,255))
StringGadget(#String_Trucks_Loaded_at_One_Time, 840, 230, 100, 25, "")
SetGadgetColor(#String_Trucks_Loaded_at_One_Time, #PB_Gadget_BackColor,RGB(168,255,168))
StringGadget(#String_Hours_to_Pour_Opt_Trucks, 850, 270, 100, 25, "")
SetGadgetColor(#String_Hours_to_Pour_Opt_Trucks, #PB_Gadget_BackColor,RGB(181,255,181))
StringGadget(#String_Hours_to_Pour_Max_Trucks, 850, 310, 100, 25, "")
SetGadgetColor(#String_Hours_to_Pour_Max_Trucks, #PB_Gadget_BackColor,RGB(181,255,181))
StringGadget(#String_Total_Number_of_Trips, 840, 350, 100, 25, "")
SetGadgetColor(#String_Total_Number_of_Trips, #PB_Gadget_BackColor,RGB(181,255,181))
StringGadget(#String_Mins_Out_of_Concrete_by_Opt, 840, 390, 100, 25, "")
SetGadgetColor(#String_Mins_Out_of_Concrete_by_Opt, #PB_Gadget_BackColor,RGB(255,183,255))
Text_29 = TextGadget(#PB_Any, 1080, 110, 160, 25, "Minimum Yds at Pump")
Text_30 = TextGadget(#PB_Any, 1050, 150, 190, 25, "Total Mins Wasted by Max")
Text_31 = TextGadget(#PB_Any, 970, 190, 270, 25, "Adjusted Truck Count if Limited Access")
Text_32 = TextGadget(#PB_Any, 1030, 230, 210, 25, "Total Lost Hrs to Pump Move")
Text_33 = TextGadget(#PB_Any, 1020, 270, 220, 25, "Wasted Assets using YPH Order")
Text_34 = TextGadget(#PB_Any, 1050, 310, 190, 25, "Wasted Hours by Grab Ass")
Text_35 = TextGadget(#PB_Any, 980, 350, 260, 25, "Substitute Slab Depth Limited Access")
Text_36 = TextGadget(#PB_Any, 980, 390, 260, 25, "Substitute Slab Depth for Underorder")
StringGadget(#String_Minimum_Yds_at_Pump, 1250, 110, 100, 25, "")
SetGadgetColor(#String_Minimum_Yds_at_Pump, #PB_Gadget_BackColor,RGB(181,255,181))
StringGadget(#String_Total_Mins_Wasted_by_Max, 1250, 150, 100, 25, "")
SetGadgetColor(#String_Total_Mins_Wasted_by_Max, #PB_Gadget_BackColor,RGB(255,183,255))
StringGadget(#String_Adjusted_Truck_Count_if_Limited_Access, 1250, 190, 100, 25, "")
SetGadgetColor(#String_Adjusted_Truck_Count_if_Limited_Access, #PB_Gadget_BackColor,RGB(255,183,255))
StringGadget(#String_Total_Lost_Hrs_to_Pump_Move, 1250, 230, 100, 25, "")
SetGadgetColor(#String_Total_Lost_Hrs_to_Pump_Move, #PB_Gadget_BackColor,RGB(255,183,255))
StringGadget(#String_Wasted_Assets_using_YPH_Order, 1250, 270, 100, 25, "")
SetGadgetColor(#String_Wasted_Assets_using_YPH_Order, #PB_Gadget_BackColor,RGB(255,183,255))
StringGadget(#String_Wasted_Hours_by_Grab_Ass, 1250, 310, 100, 25, "")
SetGadgetColor(#String_Wasted_Hours_by_Grab_Ass, #PB_Gadget_BackColor,RGB(255,183,255))
StringGadget(#String_Substitute_Slab_Depth_Limited_Access, 1250, 350, 100, 25, "")
SetGadgetColor(#String_Substitute_Slab_Depth_Limited_Access, #PB_Gadget_BackColor,RGB(168,226,255))
StringGadget(#String_Substitute_Slab_Depth_for_Underorder, 1250, 390, 100, 25, "")
SetGadgetColor(#String_Substitute_Slab_Depth_for_Underorder, #PB_Gadget_BackColor,RGB(168,226,255))
Button_First = ButtonGadget(#PB_Any, 410, 620, 30, 25, "<<")
Button_Previous = ButtonGadget(#PB_Any, 450, 620, 30, 25, "<")
Button_Next = ButtonGadget(#PB_Any, 490, 620, 30, 25, ">")
Button_Last = ButtonGadget(#PB_Any, 530, 620, 40, 25, ">>")
Text_38 = TextGadget(#PB_Any, 0, 0, 100, 25, "Job Analysis")
Here is the save button
Button_Save = ButtonGadget(#PB_Any, 50, 620, 50, 25, "Save")
Button_Delete = ButtonGadget(#PB_Any, 120, 620, 60, 25, "Delete")
Button_Calc = ButtonGadget(#PB_Any, 200, 620, 40, 25, "Calc")
EndProcedure

Procedure Window_0_Events(event)
Select event
Case #PB_Event_CloseWindow
ProcedureReturn #False

Case #PB_Event_Menu
Select EventMenu()
EndSelect
[size 200] This code doesn't seem to execute enven though the form is displayed and it lets me enter values[/200]

Case #PB_Event_Gadget
Select EventGadget()
Case Button_Save
Save(EventType())
Case Button_Delete
DeleteButtonEvent(EventType())
Case Button_Calc
CalcButtonEvent(EventType())
EndSelect
Default
;SaveButtonEvent(event,Window_0)
EndSelect
ProcedureReturn #True
EndProcedure

This is the main program. You are apparently not including the .pbf file in the main program[/200]

;OpenMainWindow() ; Open the first window. This procedure name is always 'Open' followed by the window name
;OpenDateWindow() ; Open the second window
OpenWindow_0()
;OpenWindow_1()

; The event procedures, as specified in the 'event procedure' property of each gadget
This is the event name that was generated by the forms program

Procedure Save(EventType)
Debug "Save Button event"
EndProcedure

Procedure DeleteButtonEvent(EventType)
Debug "DeleteButton event"
EndProcedure
This is the event I want to execute . I want to validate the first 8 fields in column 1 and then do calculations. I never get to Validate
Procedure CalcButtonEvent(EventType)
Result = ValidateFields
Debug "Calc button event"
EndProcedure

Procedure ValidateFields()
Result = CheckNull(#String_Jobid)
Result = CheckNull(#Date_Pour)
Result = CheckNull(#String_One_Way_Travel)
Result = CheckNull(#String_Load_Size)
Result = CheckNull(#String_YPH_Ordered)
Result = CheckNull(#String_Slab_Depth)
Result = CheckNull(#String_Pour_Start_Time)
Result = CheckNull(#String_Added_Yard_Time)
Result = CheckNull(#String_Added_Return_Time)
Result = CheckNull(#String_Pump_Move_Time)
Result = CheckNull(#String_Grab_Ass_Trucks)
EndProcedure

Procedure CheckNull(Gadget)
TestString$ = GetGadgetText(Gadget)
If TestString$ = ""
MessageRequester ("Error", "You must enter a value", #PB_MessageRequester_Ok)
ProcedureReturn 1
Else
ProcedureReturn 0
EndIf
EndProcedure

I never get here either

; The main event loop as usual, the only change is to call the automatically
; generated event procedure for each window.
Repeat
Event = WaitWindowEvent()
Select EventWindow()
Case Window_0
Window_0_Events(Event) ; This procedure name is always window name followed by '_Events'
;Case Window_1
;Window_1_Events(Event)
EndSelect
Until Event = #PB_Event_CloseWindow ; Quit on any window close

Re: Multiple Issues - New to Purebasic

Posted: Sat Nov 08, 2014 3:15 pm
by Demivec
@skywalk: I bet you didn't see that coming. :mrgreen:

Re: Multiple Issues - New to Purebasic

Posted: Sat Nov 08, 2014 5:33 pm
by skywalk
haha :shock:
johnorourke1351 - My suggestion was to place your "small" code within the Forum Code blocks so it can be copied to PB and compiled. Your comments should be inline and prefixed with a semicolon and maybe some arrows like:
;<-- this line does not work
or
;<-- this procedure is never called.
What you have posted now is too time consuming for me to consider.

Re: Multiple Issues - New to Purebasic

Posted: Sat Nov 08, 2014 5:56 pm
by johnorourke1351
Hi,

I have commented my code in a much smaller version and posted it in a new topic in the general discussion forum.
Addict commented on it and I found that he has indicated that I was missing parentheses when calling the ValidateFields procedure.
That was the problem and the program now works.

Thanks for your remarks. I will try to conform to these standards in the future.

:D
John O