PDA

View Full Version : Calculations


dennishea
11-02-2006, 01:54 AM
I am trying to do simple math. This is the line of code I have tried.

func BUTTON115_OnClick(hWnd$, Msg$, wParam$, lParam$)
HandleEventParms

edit_set(edit106$, numedit101$ + numedit102$ + numedit103$ + numedit104$ + numedit105$);

return (true);
end;

What am I doing wrong? Thanks in advance.

dennishea

kornalius
11-02-2006, 03:01 AM
numedit101$ and numedit102$ etc... are all control handles, they hold control handles (memory pointers sort of).

You need to retrieve the edit box text value using the control handle.

edit_set(edit106$, edit_get(numedit101$) + edit_get(numedit102$) + edit_get(numedit103$) + editget(numedit104$) + edit_get(numedit105$));

This should do what you want if I understood your problem correctly.

dennishea
11-03-2006, 02:31 PM
Thanks for quick reply. This helped alot and got me going again. I now need help in interpating error messages. I have been able to under stand some and solve them. This one I can not.

error: (c:\program files\ppl\projects\WorkRelated.frm#BUTTON116) [Can only declare a variable at func/proc/class main code level! at 'LOCAL' (2,3)]
error: (c:\program files\ppl\projects\WorkRelated.frm#BUTTON117) [Can only declare a variable at func/proc/class main code level! at 'LOCAL' (2,3)]
error: (c:\program files\ppl\projects\WorkRelated.ppl) [Can only declare a variable at func/proc/class main code level! at 'GLOBAL' (103,3)]
error: (c:\program files\ppl\projects\WorkRelated.ppl) [Can only declare a variable at func/proc/class main code level! at 'LOCAL' (104,3)]

I'm not always able to interpit the number at the end of the line.
Thanks again for your patience and help.

dennishea

zehlein
11-03-2006, 03:07 PM
these should reference the line and column in the sourcecode the error occured in

kornalius
11-03-2006, 03:20 PM
Place all Local and Global statements right under (next line) the Proc or Func declaration line.

dennishea
11-03-2006, 04:21 PM
Ok, I tried that with no success. It worked up to the point where I put this code in.

if (edit_get(numedit101$) > edit_get(numedit102$))
max$ = edit_get(numedit101$);
else
max$ = edit_get(numedit102$);
end;
if (max$ > edit_get(numedit103$))
max$ = max$;
else
max$ = edit_get(numedit103$);
end;
if (max$ > edit_get(numedit104$))
max$ = max$;
else
max$ = edit_get(numedit104$);
end;
if (max$ > edit_get(numedit105$))
max$ = max$;
else
max$ = edit_get(numedit105$);
end;
if (edit_get(numedit101$) < edit_get(numedit102$))
min$ = edit_get(numedit101$);
else
min$ = edit_get(numedit102$);
if (min$ < edit_get(numedit103$))
min$ = min$;
else
min$ = edit_get(numedit103$);
end;
if (min$ < edit_get(numedit104$))
min$ = min$;
else
min$ = edit_get(numedit104$);
end;
if (min$ < edit_get(numedit105$))
min$ = min$;
else
min$ = edit_get(numedit105$);
end;
edit_set(edit107$,max$ - min$);

I'm not sure what I'm doing wrong. All I'm trying to attempt is finding the difference between the biggest and smallest numbers out of 5 entries.

dennishea

kornalius
11-03-2006, 08:06 PM
Hi,

Your best bet would be to double-check the values you are getting from the numedit104$ for example. Do a ShowMessage(edit_get(numedit104$) somewhere.

Please let me know what the dialog box says.

dennishea
11-04-2006, 03:33 AM
Ok I'm not sure what you are asking. I figured out where the errors were coming from and fixed that. I left out one end; on one of the if's. I then used showmessage as you suggested and when I got to my min$ comparason(<--bad spelling I know) I ran into garbage result. I cut out that if end section and pasted the one above it and changed the 3 to 4 and tried again, my thinking was maybe I was overlooking a syntax error, but ended with same garbage in variable. I end up with something like this ( ô?" ) though the middle character is actually a square empty box. Is there something wrong with my logic for filtering?

dennishea

p.s.
did some more experimenting and those characters depending on numbers I put in bounce back and forth between min$ and max$.

kornalius
11-04-2006, 03:54 AM
It looks like you are getting unicode strings. Try doing the following:

char(edit_get(numedit104$))

This will convert the unicode string (widestring) to normal single-byte string that PPL supports.

I am sure you are running this code PocketPc right?

I was sure the edit_get was returning single-byte strings, I will double-check tomorrow before re-releasing 1.07.

dennishea
11-04-2006, 04:30 AM
Is this what you meant for me to do?

if (char(edit_get(numedit101$)) > char(edit_get(numedit102$)))
mx$ = char(edit_get(numedit101$));
else
mx$ = char(edit_get(numedit102$));
end;
if (mx$ > char(edit_get(numedit103$)))
mx$ = mx$;
else
mx$ = char(edit_get(numedit103$));
end;
if (mx$ > char(edit_get(numedit104$)))
mx$ = mx$;
else
mx$ = char(edit_get(numedit104$));
end;
if (mx$ > char(edit_get(numedit105$)))
mx$ = mx$;
else
mx$ = char(edit_get(numedit105$));
end;
if (char(edit_get(numedit101$)) < char(edit_get(numedit102$)))
mn$ = char(edit_get(numedit101$));
else
mn$ = char(edit_get(numedit102$));
end;
if (mn$ < char(edit_get(numedit103$)))
mn$ = mn$;
else
mn$ = char(edit_get(numedit103$));
end;
if (mn$ < char(edit_get(numedit104$)))
mn$ = mn$;
else
mn$ = char(edit_get(numedit104$));
end;
showmessage(mn$);
if (mn$ < char(edit_get(numedit105$)))
mn$ = mn$;
else
mn$ = char(edit_get(numedit105$));
end;
edit_set(edit107$,mx$ - mn$);
showmessage(mx$," ",mn$);

This is what I tried and I still get the same exact results.

dennishea

p.s.

The pc is running 1.05 and the ppc is running 1.06. The desktop put up the odd charactors and the ppc doesn't give weird charactors but it doesn't give the right answer. It doesn't seem to be subtracting mn$ from mx$. They both hold the number their suppose to. Thats on the ppc. Plus I had to take all ocurrences of char() out of button115 for it to run even.

kornalius
11-04-2006, 04:44 AM
Mmmm. Looks like edit_get is not working on NUMEDIT controls. I will double-check and let you know tomorrow.

dennishea
11-04-2006, 06:26 PM
This is the lastest error.

-- Content of errorlog.txt --

PPL compiler v.1.07 Pro

Filename : c:\program files\ppl\projects\workrelated.ppl
Parsing...
c:\program files\ppl\projects\workrelated.ppl
C:\Program Files\PPL\Runtime\Lib\swapi.ppl
C:\Program Files\PPL\Runtime\Lib\common.ppl
** warning ** (c:\program files\ppl\projects\WorkRelated.frm#BUTTON115) Variable is not defined as local and might be used as global at 'EDIT106$' (3,12)
** warning ** (c:\program files\ppl\projects\WorkRelated.frm#BUTTON115) Variable is not defined as local and might be used as global at 'NUMEDIT101$' (3,32)
** warning ** (c:\program files\ppl\projects\WorkRelated.frm#BUTTON115) Variable is not defined as local and might be used as global at 'NUMEDIT102$' (3,56)
** warning ** (c:\program files\ppl\projects\WorkRelated.frm#BUTTON115) Variable is not defined as local and might be used as global at 'NUMEDIT103$' (3,80)
** warning ** (c:\program files\ppl\projects\WorkRelated.frm#BUTTON115) Variable is not defined as local and might be used as global at 'NUMEDIT104$' (3,104)
** warning ** (c:\program files\ppl\projects\WorkRelated.frm#BUTTON115) Variable is not defined as local and might be used as global at 'NUMEDIT105$' (3,128)
** warning ** (c:\program files\ppl\projects\WorkRelated.frm#BUTTON115) Variable is not defined as local and might be used as global at 'EDIT106$' (4,15)
** warning ** (c:\program files\ppl\projects\WorkRelated.frm#BUTTON115) Variable is not defined as local and might be used as global at 'NUMEDIT101$' (5,16)
** warning ** (c:\program files\ppl\projects\WorkRelated.frm#BUTTON115) Variable is not defined as local and might be used as global at 'NUMEDIT102$' (5,40)
** warning ** (c:\program files\ppl\projects\WorkRelated.frm#BUTTON115) Variable is not defined as local and might be used as global at 'MX$' (6,5)
** warning ** (c:\program files\ppl\projects\WorkRelated.frm#BUTTON115) Variable is not defined as local and might be used as global at 'NUMEDIT101$' (6,20)
** warning ** (c:\program files\ppl\projects\WorkRelated.frm#BUTTON115) Variable is not defined as local and might be used as global at 'MX$' (8,5)
** warning ** (c:\program files\ppl\projects\WorkRelated.frm#BUTTON115) Variable is not defined as local and might be used as global at 'NUMEDIT102$' (8,20)
** warning ** (c:\program files\ppl\projects\WorkRelated.frm#BUTTON115) Variable is not defined as local and might be used as global at 'MX$' (10,15)
** warning ** (c:\program files\ppl\projects\WorkRelated.frm#BUTTON115) Variable is not defined as local and might be used as global at 'MX$' (11,7)
** warning ** (c:\program files\ppl\projects\WorkRelated.frm#BUTTON115) Variable is not defined as local and might be used as global at 'NUMEDIT103$' (11,22)
** warning ** (c:\program files\ppl\projects\WorkRelated.frm#BUTTON115) Variable is not defined as local and might be used as global at 'MX$' (12,5)
** warning ** (c:\program files\ppl\projects\WorkRelated.frm#BUTTON115) Variable is not defined as local and might be used as global at 'MX$' (12,11)
** warning ** (c:\program files\ppl\projects\WorkRelated.frm#BUTTON115) Variable is not defined as local and might be used as global at 'MX$' (14,5)
** warning ** (c:\program files\ppl\projects\WorkRelated.frm#BUTTON115) Variable is not defined as local and might be used as global at 'NUMEDIT103$' (14,20)
** warning ** (c:\program files\ppl\projects\WorkRelated.frm#BUTTON115) Variable is not defined as local and might be used as global at 'MX$' (16,15)
** warning ** (c:\program files\ppl\projects\WorkRelated.frm#BUTTON115) Variable is not defined as local and might be used as global at 'MX$' (17,7)
** warning ** (c:\program files\ppl\projects\WorkRelated.frm#BUTTON115) Variable is not defined as local and might be used as global at 'NUMEDIT104$' (17,22)
** warning ** (c:\program files\ppl\projects\WorkRelated.frm#BUTTON115) Variable is not defined as local and might be used as global at 'MX$' (18,3)
** warning ** (c:\program files\ppl\projects\WorkRelated.frm#BUTTON115) Variable is not defined as local and might be used as global at 'MX$' (18,9)
** warning ** (c:\program files\ppl\projects\WorkRelated.frm#BUTTON115) Variable is not defined as local and might be used as global at 'MX$' (20,3)
** warning ** (c:\program files\ppl\projects\WorkRelated.frm#BUTTON115) Variable is not defined as local and might be used as global at 'NUMEDIT104$' (20,18)
** warning ** (c:\program files\ppl\projects\WorkRelated.frm#BUTTON115) Variable is not defined as local and might be used as global at 'MX$' (22,15)
** warning ** (c:\program files\ppl\projects\WorkRelated.frm#BUTTON115) Variable is not defined as local and might be used as global at 'MX$' (23,7)
** warning ** (c:\program files\ppl\projects\WorkRelated.frm#BUTTON115) Variable is not defined as local and might be used as global at 'NUMEDIT105$' (23,22)
** warning ** (c:\program files\ppl\projects\WorkRelated.frm#BUTTON115) Variable is not defined as local and might be used as global at 'MX$' (24,5)
** warning ** (c:\program files\ppl\projects\WorkRelated.frm#BUTTON115) Variable is not defined as local and might be used as global at 'MX$' (24,11)
** warning ** (c:\program files\ppl\projects\WorkRelated.frm#BUTTON115) Variable is not defined as local and might be used as global at 'MX$' (26,5)
** warning ** (c:\program files\ppl\projects\WorkRelated.frm#BUTTON115) Variable is not defined as local and might be used as global at 'NUMEDIT105$' (26,20)
** warning ** (c:\program files\ppl\projects\WorkRelated.frm#BUTTON115) Variable is not defined as local and might be used as global at 'MX$' (28,15)
** warning ** (c:\program files\ppl\projects\WorkRelated.frm#BUTTON115) Variable is not defined as local and might be used as global at 'NUMEDIT101$' (29,16)
** warning ** (c:\program files\ppl\projects\WorkRelated.frm#BUTTON115) Variable is not defined as local and might be used as global at 'NUMEDIT102$' (29,40)
** warning ** (c:\program files\ppl\projects\WorkRelated.frm#BUTTON115) Variable is not defined as local and might be used as global at 'MN$' (30,5)
** warning ** (c:\program files\ppl\projects\WorkRelated.frm#BUTTON115) Variable is not defined as local and might be used as global at 'NUMEDIT101$' (30,20)
** warning ** (c:\program files\ppl\projects\WorkRelated.frm#BUTTON115) Variable is not defined as local and might be used as global at 'MN$' (32,5)
** warning ** (c:\program files\ppl\projects\WorkRelated.frm#BUTTON115) Variable is not defined as local and might be used as global at 'NUMEDIT102$' (32,20)
** warning ** (c:\program files\ppl\projects\WorkRelated.frm#BUTTON115) Variable is not defined as local and might be used as global at 'MN$' (34,15)
** warning ** (c:\program files\ppl\projects\WorkRelated.frm#BUTTON115) Variable is not defined as local and might be used as global at 'MN$' (35,7)
** warning ** (c:\program files\ppl\projects\WorkRelated.frm#BUTTON115) Variable is not defined as local and might be used as global at 'NUMEDIT103$' (35,22)
** warning ** (c:\program files\ppl\projects\WorkRelated.frm#BUTTON115) Variable is not defined as local and might be used as global at 'MN$' (36,5)
** warning ** (c:\program files\ppl\projects\WorkRelated.frm#BUTTON115) Variable is not defined as local and might be used as global at 'MN$' (36,11)
** warning ** (c:\program files\ppl\projects\WorkRelated.frm#BUTTON115) Variable is not defined as local and might be used as global at 'MN$' (38,5)
** warning ** (c:\program files\ppl\projects\WorkRelated.frm#BUTTON115) Variable is not defined as local and might be used as global at 'NUMEDIT103$' (38,20)
** warning ** (c:\program files\ppl\projects\WorkRelated.frm#BUTTON115) Variable is not defined as local and might be used as global at 'MN$' (40,15)
** warning ** (c:\program files\ppl\projects\WorkRelated.frm#BUTTON115) Variable is not defined as local and might be used as global at 'MN$' (41,7)
** warning ** (c:\program files\ppl\projects\WorkRelated.frm#BUTTON115) Variable is not defined as local and might be used as global at 'NUMEDIT104$' (41,22)
** warning ** (c:\program files\ppl\projects\WorkRelated.frm#BUTTON115) Variable is not defined as local and might be used as global at 'MN$' (42,5)
** warning ** (c:\program files\ppl\projects\WorkRelated.frm#BUTTON115) Variable is not defined as local and might be used as global at 'MN$' (42,11)
** warning ** (c:\program files\ppl\projects\WorkRelated.frm#BUTTON115) Variable is not defined as local and might be used as global at 'MN$' (44,5)
** warning ** (c:\program files\ppl\projects\WorkRelated.frm#BUTTON115) Variable is not defined as local and might be used as global at 'NUMEDIT104$' (44,20)
** warning ** (c:\program files\ppl\projects\WorkRelated.frm#BUTTON115) Variable is not defined as local and might be used as global at 'MN$' (46,15)
** warning ** (c:\program files\ppl\projects\WorkRelated.frm#BUTTON115) Variable is not defined as local and might be used as global at 'MN$' (47,7)
** warning ** (c:\program files\ppl\projects\WorkRelated.frm#BUTTON115) Variable is not defined as local and might be used as global at 'NUMEDIT105$' (47,22)
** warning ** (c:\program files\ppl\projects\WorkRelated.frm#BUTTON115) Variable is not defined as local and might be used as global at 'MN$' (48,5)
** warning ** (c:\program files\ppl\projects\WorkRelated.frm#BUTTON115) Variable is not defined as local and might be used as global at 'MN$' (48,11)
** warning ** (c:\program files\ppl\projects\WorkRelated.frm#BUTTON115) Variable is not defined as local and might be used as global at 'MN$' (50,5)
** warning ** (c:\program files\ppl\projects\WorkRelated.frm#BUTTON115) Variable is not defined as local and might be used as global at 'NUMEDIT105$' (50,20)
** warning ** (c:\program files\ppl\projects\WorkRelated.frm#BUTTON115) Variable is not defined as local and might be used as global at 'MN$' (52,15)
** warning ** (c:\program files\ppl\projects\WorkRelated.frm#BUTTON115) Variable is not defined as local and might be used as global at 'EDIT107$' (53,12)
** warning ** (c:\program files\ppl\projects\WorkRelated.frm#BUTTON115) Variable is not defined as local and might be used as global at 'MX$' (53,21)
** warning ** (c:\program files\ppl\projects\WorkRelated.frm#BUTTON115) Variable is not defined as local and might be used as global at 'MN$' (53,27)
** warning ** (c:\program files\ppl\projects\WorkRelated.frm#BUTTON115) Variable is not defined as local and might be used as global at 'EDIT107$' (54,15)
** warning ** (c:\program files\ppl\projects\WorkRelated.frm#BUTTON116) Variable is not defined as local and might be used as global at 'NUMEDIT101$' (3,12)
** warning ** (c:\program files\ppl\projects\WorkRelated.frm#BUTTON116) Variable is not defined as local and might be used as global at 'NUMEDIT102$' (4,12)
** warning ** (c:\program files\ppl\projects\WorkRelated.frm#BUTTON116) Variable is not defined as local and might be used as global at 'NUMEDIT103$' (5,12)
** warning ** (c:\program files\ppl\projects\WorkRelated.frm#BUTTON116) Variable is not defined as local and might be used as global at 'NUMEDIT104$' (6,12)
** warning ** (c:\program files\ppl\projects\WorkRelated.frm#BUTTON116) Variable is not defined as local and might be used as global at 'NUMEDIT105$' (7,12)
** warning ** (c:\program files\ppl\projects\WorkRelated.frm#BUTTON116) Variable is not defined as local and might be used as global at 'EDIT106$' (8,12)
** warning ** (c:\program files\ppl\projects\WorkRelated.frm#BUTTON116) Variable is not defined as local and might be used as global at 'EDIT107$' (9,12)
Total parsing time (219 ms)
Linking... (62 ms)
Saving ppc file... (16 ms)
Compiling... (15 ms)
Completion time (312 ms)
** 0 error(s), 74 warning(s)

-- Content of debuglog.txt --

11/4/2006 01:09:18 PM : Generated by the PPL interpreter v.1.07 Pro
11/4/2006 01:09:18 PM : Root C:\Program Files\PPL\Runtime\
11/4/2006 01:09:19 PM : Available memory 246,202,368 bytes
11/4/2006 01:09:19 PM : WORKRELATED.PPL started
11/4/2006 01:09:33 PM : ** runtime error ** (swapi.ppl) (EDIT_SET(2,0)) Access violation at 0x77d6c1d1 (155,3)

11/4/2006 01:10:38 PM : WORKRELATED.PPL ended (79,704 ms)
11/4/2006 01:10:38 PM : Available memory 247,189,504 bytes

I downloaded 1.07 and installed it and this is how it responeded to my code. Am I suppose to uninstall the old first or just install over top of it?

dennishea

p.s. sorry about error log I didn't realize that when I copied the line that gave the description of the error that there was a whole log with it. I think I understand what the warnings are saying but don't know the proper way to solve it.

kornalius
11-04-2006, 06:34 PM
You need to declare all your variables within a Global() statement.

Global(NumEdit104$, NumEdit105$, NumEdit106$) and so on.

Place the Global() line right under the func line.

Btw, I have fixed the edit_get() and edit_set() functions in the Swapi.ppl to work correctly now.

Have you downloaded the latest 1.07 re-released today?

It looks like you are assigning Edit_Set() to a wrong NumEdit value.

Show us your code WorkRelated.ppl that calls Edit_Set().

dennishea
11-04-2006, 10:20 PM
Ok I reinstalled 1.07 and still same problems. Here is the code.

// Code auto-generated by PPL version 1.07 Pro
// Do not modify this code directly.

#include "swapi.ppl"

#define FORM100_ID 100
#define NUMEDIT101_ID 101
#define NUMEDIT102_ID 102
#define NUMEDIT103_ID 103
#define NUMEDIT104_ID 104
#define NUMEDIT105_ID 105
#define EDIT106_ID 106
#define EDIT107_ID 107
#define LABEL108_ID 108
#define STATIC109_ID 109
#define STATIC110_ID 110
#define STATIC111_ID 111
#define STATIC112_ID 112
#define LABEL113_ID 113
#define LABEL114_ID 114
#define BUTTON115_ID 115
#define BUTTON116_ID 116
#define BUTTON117_ID 117

#code {WorkRelated.ppl,25}
#code {WorkRelated.frm#FORM100}
func Menu5001_OnClick(hWnd$, Msg$, wParam$, lParam$)
HandleEventParms
PostMessage(hWnd$, WM_CLOSE, 0, 0);
return (true);
end;

#code {WorkRelated.frm#BUTTON115}
func BUTTON115_OnClick(hWnd$, Msg$, wParam$, lParam$)
HandleEventParms
edit_set(edit106$, (edit_get(numedit101$) + edit_get(numedit102$) + edit_get(numedit103$) + edit_get(numedit104$) + edit_get(numedit105$))/ 5);
if (edit_get(numedit101$) > edit_get(numedit102$))
mx$ = edit_get(numedit101$);
else
mx$ = edit_get(numedit102$);
end;
if (mx$ > edit_get(numedit103$))
mx$ = mx$;
else
mx$ = edit_get(numedit103$);
end;
if (mx$ > edit_get(numedit104$))
mx$ = mx$;
else
mx$ = edit_get(numedit104$);
end;
if (mx$ > edit_get(numedit105$))
mx$ = mx$;
else
mx$ = edit_get(numedit105$);
end;
if (edit_get(numedit101$) < edit_get(numedit102$))
mn$ = edit_get(numedit101$);
else
mn$ = edit_get(numedit102$);
end;
if (mn$ < edit_get(numedit103$))
mn$ = mn$;
else
mn$ = edit_get(numedit103$);
end;
if (mn$ < edit_get(numedit104$))
mn$ = mn$;
else
mn$ = edit_get(numedit104$);
end;
if (mn$ < edit_get(numedit105$))
mn$ = mn$;
else
mn$ = edit_get(numedit105$);
end;
edit_set(edit107$,mx$ - mn$);
return (true);
end;

#code {WorkRelated.frm#BUTTON116}
func BUTTON116_OnClick(hWnd$, Msg$, wParam$, lParam$)
HandleEventParms
edit_set(numEdit101$,"");
edit_set(numedit102$,"");
edit_set(numedit103$,"");
edit_set(numedit104$,"");
edit_set(numedit105$,"");
edit_set(edit106$,"");
edit_set(edit107$,"");
return (true);
end;

#code {WorkRelated.frm#BUTTON117}
func BUTTON117_OnClick(hWnd$, Msg$, wParam$, lParam$)
HandleEventParms
PostMessage(hWnd$, WM_CLOSE, 0, 0);
return (true);
end;

#code {WorkRelated.ppl,101}
func WinMain
Global(MsgList$, AppPath$, FORM100$, NUMEDIT101$, NUMEDIT102$, NUMEDIT103$, NUMEDIT104$, NUMEDIT105$, EDIT106$, EDIT107$, LABEL108$, STATIC109$, STATIC110$, STATIC111$, STATIC112$, LABEL113$, LABEL114$, BUTTON115$, BUTTON116$, BUTTON117$, m5000$);
Local(fnt$, keys$);
List(MsgList$);

FORM100$ = NewFormEx("My Form100", "PPLForm", 0, WS_BORDER|WS_VISIBLE, 0, 26, 240, 269, NULL);

NUMEDIT101$ = NewControl(101, "EDIT", NULL, "", WS_VISIBLE|ES_AUTOHSCROLL|ES_AUTOVSCROLL|WS_TABSTO P|ES_NUMBER|WS_BORDER, FORM100$, 176, 32, 40, 16);
SetWindowPos(NUMEDIT101$, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
CreateEvent("NUMEDIT101", NUMEDIT101$);

NUMEDIT102$ = NewControl(102, "EDIT", NULL, "", WS_VISIBLE|ES_AUTOHSCROLL|ES_AUTOVSCROLL|WS_TABSTO P|ES_NUMBER|WS_BORDER, FORM100$, 176, 48, 40, 16);
SetWindowPos(NUMEDIT102$, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
CreateEvent("NUMEDIT102", NUMEDIT102$);

NUMEDIT103$ = NewControl(103, "EDIT", NULL, "", WS_VISIBLE|ES_AUTOHSCROLL|ES_AUTOVSCROLL|WS_TABSTO P|ES_NUMBER|WS_BORDER, FORM100$, 176, 64, 40, 16);
SetWindowPos(NUMEDIT103$, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
CreateEvent("NUMEDIT103", NUMEDIT103$);

NUMEDIT104$ = NewControl(104, "EDIT", NULL, "", WS_VISIBLE|ES_AUTOHSCROLL|ES_AUTOVSCROLL|WS_TABSTO P|ES_NUMBER|WS_BORDER, FORM100$, 176, 80, 40, 16);
SetWindowPos(NUMEDIT104$, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
CreateEvent("NUMEDIT104", NUMEDIT104$);

NUMEDIT105$ = NewControl(105, "EDIT", NULL, "", WS_VISIBLE|ES_AUTOHSCROLL|ES_AUTOVSCROLL|WS_TABSTO P|ES_NUMBER|WS_BORDER, FORM100$, 176, 96, 40, 16);
SetWindowPos(NUMEDIT105$, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
CreateEvent("NUMEDIT105", NUMEDIT105$);

EDIT106$ = NewControl(106, "EDIT", NULL, "", WS_VISIBLE|ES_AUTOHSCROLL|ES_AUTOVSCROLL|WS_BORDER |WS_TABSTOP, FORM100$, 176, 138, 40, 16);
SetWindowPos(EDIT106$, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
CreateEvent("EDIT106", EDIT106$);

EDIT107$ = NewControl(107, "EDIT", NULL, "", WS_VISIBLE|ES_AUTOHSCROLL|ES_AUTOVSCROLL|WS_BORDER |WS_TABSTOP, FORM100$, 176, 154, 40, 16);
SetWindowPos(EDIT107$, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
CreateEvent("EDIT107", EDIT107$);

LABEL108$ = NewControl(108, "STATIC", NULL, "Data", WS_VISIBLE, FORM100$, 136, 32, 32, 16);
SetWindowPos(LABEL108$, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
CreateEvent("LABEL108", LABEL108$);

STATIC109$ = NewControl(109, "STATIC", NULL, "Data", WS_VISIBLE, FORM100$, 136, 48, 32, 16);
SetWindowPos(STATIC109$, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
CreateEvent("STATIC109", STATIC109$);

STATIC110$ = NewControl(110, "STATIC", NULL, "Data", WS_VISIBLE, FORM100$, 136, 64, 32, 16);
SetWindowPos(STATIC110$, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
CreateEvent("STATIC110", STATIC110$);

STATIC111$ = NewControl(111, "STATIC", NULL, "Data", WS_VISIBLE, FORM100$, 136, 79, 32, 16);
SetWindowPos(STATIC111$, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
CreateEvent("STATIC111", STATIC111$);

STATIC112$ = NewControl(112, "STATIC", NULL, "Data", WS_VISIBLE, FORM100$, 136, 95, 32, 16);
SetWindowPos(STATIC112$, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
CreateEvent("STATIC112", STATIC112$);

LABEL113$ = NewControl(113, "STATIC", NULL, "Average", WS_VISIBLE, FORM100$, 117, 138, 48, 16);
SetWindowPos(LABEL113$, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
CreateEvent("LABEL113", LABEL113$);

LABEL114$ = NewControl(114, "STATIC", NULL, "Difference", WS_VISIBLE, FORM100$, 106, 153, 64, 16);
SetWindowPos(LABEL114$, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
CreateEvent("LABEL114", LABEL114$);

BUTTON115$ = NewControl(115, "BUTTON", NULL, "Calculate", WS_VISIBLE|WS_TABSTOP, FORM100$, 8, 88, 64, 16);
SetWindowPos(BUTTON115$, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
AddEvent(BUTTON115$, BN_CLICKED, 115, &BUTTON115_OnClick);
CreateEvent("BUTTON115", BUTTON115$);

BUTTON116$ = NewControl(116, "BUTTON", NULL, "Clear", WS_VISIBLE|WS_TABSTOP, FORM100$, 8, 105, 64, 16);
SetWindowPos(BUTTON116$, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
AddEvent(BUTTON116$, BN_CLICKED, 116, &BUTTON116_OnClick);
CreateEvent("BUTTON116", BUTTON116$);

BUTTON117$ = NewControl(117, "BUTTON", NULL, "Exit", WS_VISIBLE|WS_TABSTOP, FORM100$, 8, 122, 64, 16);
SetWindowPos(BUTTON117$, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
AddEvent(BUTTON117$, BN_CLICKED, 117, &BUTTON117_OnClick);
CreateEvent("BUTTON117", BUTTON117$);

CreateEvent("FORM100", FORM100$);

list(keys$);
if (Count(keys$) > 0)
CreateAccelTable(FORM100$, keys$);
end;

m5000$ = NewMenu(FORM100$, "File", 5000);
NewMenuItem(m5000$, -1, "Exit", 5001);
AddEvent(NULL, WM_COMMAND, 5001, &Menu5001_OnClick);

CenterForm(FORM100$);
ShowWindow(FORM100$, SW_SHOW);
SetForegroundWindow(FORM100$);
Form_Repaint(FORM100$);

#code {WorkRelated.frm#}
return (true);
end;

This isn't much but you have to crawl before you walk. Most of this code as you can see was automaticly created except button115 116 117.

dennishea

dennishea
11-05-2006, 08:56 AM
More information diffurrent view.[br]../../e107_files/public/1162716000_112_FT1236_ppl_error.png[br]../../e107_files/public/1162716000_112_FT1236_ppl_prg.png

The program starts up fine, you enter the data and hit the calulate button and it pops up the error window. you hit ok to clear that and prg window pops back into view. At different times and different problems the prg window displays different results. This time it not displaying the average, which normally it does with the right answer and now it is displaying a wrong answer for the difference. I hope this helps in trying to sort out the problems. If you look at winmain in the program there is a global listing all the controls or are you talking about something different?

As always ready to learn and program.
dennishea

kornalius
11-05-2006, 03:13 PM
It looks like setting a NUMEDIT to a "" value doesn't work.

Have you tried changing "" by "0" instead?

I will do the test on my side and see what the result is.

dennishea
11-05-2006, 03:21 PM
Will try now.

dennishea

ok am back I'm not sure what your saying. Do I need to have the program on inialization clear all variables before it starts and putting 0's in between "0" puts 0 in numedit's so when you do go to use it you have to clear the 0 out before you can put your data in.

dennishea
11-05-2006, 03:40 PM
Here is the files if that helps.

dennishea[br]1162741194_112_FT1236_workrelated.zip

kornalius
11-05-2006, 04:19 PM
No, I just meant that all lines:

edit_set(xxxxx$, "");

Should be replaced by:

edit_set(xxxxx$, "0");

Try this, I think "" is causing problems.

dennishea
11-05-2006, 06:37 PM
I tried it and it still does the same thing.

dennishea

matteo.m
11-05-2006, 07:50 PM
Hi Dennishea, i was curious, so i cutted your code from Sat Nov 04 2006, 11:20PM and i pasted into the pide. I saved, and runned and I'm not getting any error message.... in my Pide your program just work fine....

kornalius
11-05-2006, 08:03 PM
I got it, you need to convert your value to a string.

edit_set(edit106$, str((edit_get(numedit101$) + edit_get(numedit102$) + edit_get(numedit103$) + edit_get(numedit104$) + edit_get(numedit105$)) / 5));

edit_set(edit107$, str(mx$ - mn$));

I will review all the swapi functions so they convert to strings the values when used with Windows API messages.

dennishea
11-08-2006, 04:14 PM
kornalius

func BUTTON101_OnClick(hWnd$, Msg$, wParam$, lParam$)
HandleEventParms
conv$ = str(0.03937);
if (str(edit_get(EDIT108$)) > str(edit_get(EDIT109$)))
Edit_Set((EDIT109$),STR((edit_get(EDIT108$)) / conv$));
else
Edit_Set((EDIT108$),STR((edit_get(EDIT109$)) * conv$));
end;
return (true);
end;

The above code works fine by itself but would look better with less decimal places. I have tried sprintf and can't seem to get it to work. I have been able to satisfy the compiler but can't get any numbers to show. This is an example of sprintf layout.

sprintf(s$, " text: %4.2 \n",edit104$);

Do you need the text for this to function and actually I'm not sure how this works or if you will how to place it in the code. could somebody explain the s$ and it's function.

The format tags follow this prototype: %[flags][width][.precision][modifiers]type

The only thing I want to change is how many numbers to the right of the decimal place.

kornalius
11-08-2006, 05:54 PM
conv$ = 0.03937;
sprintf(s$, "%4.2f", int(conv$));
ShowMessage(s$);
edit_set(numedit104$, s$);

Make sure conv$ is an integer value when passed to sprintf(). s$ will contain a string, that is why you don't need to use str() when using it with edit_set().

bmanske
11-08-2006, 06:34 PM
First, In the SprintF example you gave, you have to do like you do in your functioning code call</p>

EditStr104$ = EDIT_GET(EDIT104$); </p>

EDIT_GET returns the string in the numeric text box. With the string you can edit it as a string. Use the POS function to find the decimal point, then chop off characters after that. The value will not be rounded with this method... </p>

Or you can get the value from the Numeric Edit control: </p>

EditVal104$ = INT(EDIT_GET(EDIT104$)); </p>

Then you can modify the value like this: </p>

EditVal104$ = Trunc((EditVal104$ + 0.005) * 100)/100; </p>

This will round and chop off the value to 2 decimal places. You would need to use the STR() function to display it back in the control. The trade off here is that you have lost numeric precision (or you have to use a different variable), you will not get a consistant number of places to the right of the decimal point unless you use extra code, and some numbers may not print right because sometimes binary and decimal numbers don't match up perfectly. </p>

SprintF uses the number as the above example. It does a formatted print to a string, then you'd use the output number as you did in the first example where you use STR() to put it back into the control. So in your example s$ is the variable that receives the output string from the sprintf function. The example format string you gave would put &quot;text:...&quot; into s$. I would use &quot;%#.2f&quot;. meaning %=format spec follows, #=fill the output string with 0's if necessary to get to the display precision number, .2= display 2 digits to the right of the decimal point, f=display it as a floating point number. So it would look like this: </p>

sprintf(s$,&quot;%#.2f&quot;, int(edit_get(EDIT104$)));
edit_set(EDIT104$, s$); </p>

Hope this helps. Brad </p>

dennishea
11-08-2006, 08:08 PM
other then being remarked out does this look right?
I tried this and a couple other variations and still can't get going.

func BUTTON101_OnClick(hWnd$, Msg$, wParam$, lParam$)
HandleEventParms
conv$ = str(0.03937);
if (str(edit_get(NUMEDIT104$)) &gt; str(edit_get(NUMEDIT105$)))
Edit_Set((NUMEDIT105$),STR((edit_get(NUMEDIT104$)) / conv$));
//sprintf(s$,&quot;%4.2f&quot;, int(NUMEDIT105$));
//Edit_Set(NUMEDIT105$,s$);
else
Edit_Set((NUMEDIT104$),STR((edit_get(NUMEDIT105$)) * conv$));
//sprintf(s$,&quot;%4.2f&quot;,int(NUMEDIT104$));
//Edit_Set(NUMEDIT104$,s$);
end;
return (true);
end;

I Missing something.
thanks in advance.

kornalius
11-09-2006, 01:27 AM
dennishea, NUMEDIT104$ and NUMEDIT105$ are edit control handles. You need to get the edit text with edit_get(NUMEDIT104$) for sprintf() to work.

Like Brad explained this will do the job:

sprintf(s$,&quot;%#.2f&quot;, int(edit_get(EDIT104$)));

edit_set(EDIT104$, s$);

Let us know.

dennishea
11-09-2006, 01:35 PM
Yes things are starting to shine.Yes yes yes. :p :D Now I have a new question and problem. Numedit won't let me enter a decimal or period I'm not sure which is proper for numbers. It displays the results right but won't let me enter numbers like 2.5 or 1.237.

Thanks again for all the help kornalius.

p.s.

Went ahead and tried edit instead of numedit and that let's me enter 2.5. It works great on the pc but on ppc when I run it, it works until I enter things like two decimal places and most of the time it exits the program to windowsce. If I only enter 1 decimal place it seems pretty stable. Any ideas on that one.