forum-msg-id-131461-edit

Original date:2017-10-25 04:00:58 Edited by: rneu Subject: Simple function not working

I am trying to create a simple GUI program in Phix that adds numbers in 2 text fields:

include pGUI.e 
 
Ihandle t1, t2, t3, l1, l2, l3, b1, v1, h1, h2, h3, dlg 
 
IupOpen()  
 
function addfn() 
	setText(l3, sprintf(append("", value(getText(t1)) + value(getText(t2)))))  
	return IUP_DEFAULT 
end function 
 
l1=IupLabel("First value: ") 
t1 = IupText("EXPAND=YES") 
h1=IupHbox({l1, IupLabel(), t1}) 
IupSetAttribute(h1,"PADDING", "5x5") 
 
l2=IupLabel("Second value: ") 
t2 = IupText("EXPAND=YES") 
h2=IupHbox({l2, IupLabel(), t2}) 
IupSetAttribute(h2,"PADDING", "5x5") 
 
b1=IupButton("Calculate", Icallback("addfn")) 
IupSetAttribute(b1,"PADDING", "5x5") 
 
l3=IupLabel("Read sum here.") 
h3=IupHbox({b1, IupLabel("->"), l3}) 
IupSetAttribute(h3,"PADDING", "5x5") 
 
v1=IupVbox({IupLabel(), h1,IupLabel(),h2,IupLabel(), h3}) 
IupSetAttribute(v1,"PADDING", "5x5") 
 
dlg=IupDialog(v1) 
IupSetAttribute(dlg,"PADDING", "5x5") 
 
 
IupShow(dlg)  
IupMainLoop()  
IupClose() 

However, it is giving following errors:

..printf(append("", value(getText(t1)) + value(getText(t2)))))  -- PROBLEM IN.. 
                                                            ^ missing parameters 
 setText(l3, sprintf(append("", value(getText(t1)) + value(getText(t2)))))  -.. 
                                                   ^Warning: sq_add() assumed 
 setText(l3, sprintf(append("", value(getText(t1)) + value(getText(t2)))))  -.. 
                                      ^Warning: forward call assumed 
 setText(l3, sprintf(append("", value(getText(t1)) + value(getText(t2)))))  -.. 
 ^Warning: forward call assumed 
Where is the problem and how can this be corrected? Thanks for your help.

Not Categorized, Please Help

Search



Quick Links

User menu

Not signed in.

Misc Menu