October 28, 2025, 02:36:36 PM

News:

IWBasic runs in Windows 11!


problem with program crashing

Started by chris, November 23, 2008, 03:37:38 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

chris

i'm not sure why this is crashing just that when i hit the convert butten it crashes. many thanks for any help
CONST BUTTON_1 = 1
CONST EDIT_4 = 4
CONST COMBO_5 = 5
CONST COMBO_7 = 7
CONST STATIC_10 = 10
CONST STATIC_11 = 11
CONST STATIC_12 = 12
CONST EDIT_13 = 13
CONST BUTTON_14 = 14
DIALOG d1
CREATEDIALOG d1,0,0,660,187,0x80C80080,0,"Convert",&d1_handler
CONTROL d1,@SYSBUTTON,"Convert",483,27,92,49,0x50000000,1
CONTROL d1,@EDIT,"Edit1",72,32,121,28,0x50802000,4
CONTROL d1,@STATIC,"Convert",6,37,70,20,0x5000010B,10
CONTROL d1,@STATIC,"Degrees",202,35,70,20,0x5000010B,11
CONTROL d1,@STATIC,"To",331,29,70,20,0x5000010B,12
CONTROL d1,@EDIT,"Edit3",47,120,408,33,0x50800800,13
CONTROL d1,@SYSBUTTON,"Copy to Cilpbord",493,121,97,31,0x50000000,14
CONTROL d1,@COMBOBOX,"input",252,28,70,80,0x50800603,17
CONTROL d1,@COMBOBOX,"output",399,28,70,80,0x50800603,18
SHOWDIALOG d1
run = 1
WAITUNTIL run = 0
CLOSEDIALOG d1,@IDOK
SUB d1_handler
SELECT @MESSAGE
CASE @IDINITDIALOG
CENTERWINDOW d1
' Initialize any controls here
addSTRING d1,17, "C"
addSTRING d1,18, "F"
addSTRING d1,17, "F"
addSTRING d1,18, "C"
CASE @IDCLOSEWINDOW
CLOSEDIALOG d1,@IDOK
run = 0
CASE @IDCONTROL
SELECT @CONTROLID
CASE BUTTON_1
IF @NOTIFYCODE = 0
'button clicked
DEF input$, output$ :STRING
DEF TypeIn$, TypeOut$ : CHAR
DEF pos1, pos2 : INT
DEF NumOut : double
input$ = GETCONTROLTEXT (d1,4)
pos1 = GETSELECTED (d1,17)
pos2 = GETSELECTED (d1,18)
TypeIn$ = GETSTRING (d1,17,pos1)
TypeOut$ = GETSTRING (d1,18,pos2)
IF TypeIn$ = TypeOut$
output$ = APPEND$(" ",input$," Degrees ",TypeIn$," is ",input$," Degrees ",Typeout$)
ELSE
SELECT TypeIn$
CASE "C"
NumOut = VAL(input$)
NumOut = ((NumOut / 5)*9)+32
output$ =Append$( " ",input$," Degrees ",TypeIn$," is ",NumOut," Degrees ",Typeout$)
CASE "F"
NumOut = VAL(input$)
NumOut = ((NumOut - 32)/9)*5
output$ =Append$( " ",input$," Degrees ",TypeIn$," is ",NumOut," Degrees ",Typeout$)
ENDSELECT
ENDIF
SETCONTROLTEXT(d1,13,output$)
ENDIF
CASE EDIT_4
' respond to edit notifications here
CASE COMBO_5
'respond to control notifications here
CASE COMBO_7
'respond to control notifications here
CASE EDIT_13
'respond to edit notifications here
CASE BUTTON_14
IF @NOTIFYCODE = 0
'button clicked
ENDIF
ENDSELECT
ENDSELECT
RETURN
ENDSUB

Ionic Wind Support Team

Chris,
3 or 4 problems there, debug told me everything I needed to know. Learn how to use it and you'll be better off for it.

First crash is on line 54,  simple one there.

Second crash is on line 60, again a simple one.

Append$ only accepts strings, not characters, not double numbers, and there is very little reason to use it in this case.

From the users guide:

Quote
Parameters
str1 - The first string in the parameter list
... - One or more additional strings to concatenate


Change TypeIn$ and TypeOut$ to a STRING type and not CHAR
Change the APPEND$ lines to use str$(NumOut)

Or better yet use the USING statement and format it.

In anyevent, here is your code with the corrections:




CONST BUTTON_1 = 1
CONST EDIT_4 = 4
CONST COMBO_5 = 5
CONST COMBO_7 = 7
CONST STATIC_10 = 10
CONST STATIC_11 = 11
CONST STATIC_12 = 12
CONST EDIT_13 = 13
CONST BUTTON_14 = 14
DIALOG d1
CREATEDIALOG d1,0,0,660,187,0x80C80080,0,"Convert",&d1_handler
CONTROL d1,@SYSBUTTON,"Convert",483,27,92,49,0x50000000,1
CONTROL d1,@EDIT,"Edit1",72,32,121,28,0x50802000,4
CONTROL d1,@STATIC,"Convert",6,37,70,20,0x5000010B,10
CONTROL d1,@STATIC,"Degrees",202,35,70,20,0x5000010B,11
CONTROL d1,@STATIC,"To",331,29,70,20,0x5000010B,12
CONTROL d1,@EDIT,"Edit3",47,120,408,33,0x50800800,13
CONTROL d1,@SYSBUTTON,"Copy to Cilpbord",493,121,97,31,0x50000000,14
CONTROL d1,@COMBOBOX,"input",252,28,70,80,0x50800603,17
CONTROL d1,@COMBOBOX,"output",399,28,70,80,0x50800603,18
SHOWDIALOG d1
run = 1
WAITUNTIL run = 0
CLOSEDIALOG d1,@IDOK
SUB d1_handler
SELECT @MESSAGE
CASE @IDINITDIALOG
CENTERWINDOW d1
' Initialize any controls here
addSTRING d1,17, "C"
addSTRING d1,18, "F"
addSTRING d1,17, "F"
addSTRING d1,18, "C"
CASE @IDCLOSEWINDOW
CLOSEDIALOG d1,@IDOK
run = 0
CASE @IDCONTROL
SELECT @CONTROLID
CASE BUTTON_1
IF @NOTIFYCODE = 0
'button clicked
DEF input$, output$ :STRING
DEF TypeIn$, TypeOut$ : STRING
DEF pos1, pos2 : INT
DEF NumOut : double
input$ = GETCONTROLTEXT (d1,4)
pos1 = GETSELECTED (d1,17)
pos2 = GETSELECTED (d1,18)
TypeIn$ = GETSTRING (d1,17,pos1)
TypeOut$ = GETSTRING (d1,18,pos2)
IF TypeIn$ = TypeOut$
output$ = APPEND$(" ",input$," Degrees ",TypeIn$," is ",input$," Degrees ",Typeout$)
ELSE
SELECT TypeIn$
CASE "C"
NumOut = VAL(input$)
NumOut = ((NumOut / 5)*9)+32
output$ =Append$( " ",input$," Degrees ",TypeIn$," is ",str$(NumOut)," Degrees ",Typeout$)
CASE "F"
NumOut = VAL(input$)
NumOut = ((NumOut - 32)/9)*5
output$ =Append$( " ",input$," Degrees ",TypeIn$," is ",str$(NumOut)," Degrees ",Typeout$)
ENDSELECT
ENDIF
SETCONTROLTEXT(d1,13,output$)
ENDIF
CASE EDIT_4
' respond to edit notifications here
CASE COMBO_5
'respond to control notifications here
CASE COMBO_7
'respond to control notifications here
CASE EDIT_13
'respond to edit notifications here
CASE BUTTON_14
IF @NOTIFYCODE = 0
'button clicked
ENDIF
ENDSELECT
ENDSELECT
RETURN
ENDSUB


Ionic Wind Support Team

chris

thnak you for the quick responce for some reson i thought that debug only work with projets. anyway thank you for the help
yours chris