PDA

View Full Version : Some minor bugs?


Richard
10-05-2006, 06:46 AM
With my background in VB, these may or may not be bugs...
interesting though.

1. The DIV function

In VB this returns the integer part from a division, so
x$ = 76.5;
x$ = x$ DIV 10;
would have given 7.0 in VB.

The normal divide / returns the fraction part
x$ = 76.5;
x$ = x$ / 10;
would give 7.65

In PPL I get 7.65 from the DIV. Is this a feature of C++?
(If so, another reason why I never liked C++)

My work around was:
x$ = 76.5;
x$ = (x$ - (x$ MOD 10)) / 10;

2. One trick I used in VB was to store lists in an invisible
control as this allowed me to insert or delete items which
is not that easy in an array.

When I tried this in PPL my list was sorted, so no longer
matched the order that I wanted.
Note: LBS_Sort was NOT checked!

My work around was to put the item number as a sting
at the start of each line.

3. When I tried to fix 2, my first solution was like this,
With my item number in n$ and the text in t$

w$ = STR(n$); // Get item as string
w$ = Lpad(w$, "0", 2) // add leading zero
w$ = w$ % t$; // append text
z$ = ListBox_Add(lstParms$, w$); // put in list

However the LPAD returned an empty sring
so my code finished up like this:

w$ = STR(n$);
if (n$ < 10)
w$ = "0" % w$;
end;
w$ = w$ % t$;
z$ = ListBox_Add(lstParms$, w$);

That's it (so far).

MagNet
10-05-2006, 01:41 PM
Hm, I don't know about the div but you don't have to use array if you don't want to use the invisible control. There's simply a list function that doesn't sort anything and you just add stuff and then take it.

Check the help file for "list".

PointOfLight
10-05-2006, 02:22 PM
To the best of my knowlege, DIV and MOD are BASIC / Pascal functions, and do not exist in C / C++. You're right, however, in that the traditional functionality of DIV should be to return the whole number part of a division operation.

As for your list needs, MagNet is right in that you should be using the List functions. They are easy to use and very handy for what you are trying to do.

Kornalius, you might need to check the creation of list objects when LBS_SORT is not checked, because that would be really unfriendly if it sorted the list no matter what.

kornalius
10-05-2006, 03:50 PM
Hi Richard:

#1. You are right the DIV should return only the integer part. This is a bug. It will be fixed for 1.04 don't worry.

#2. Use the Linked-Lists functions. That VB trick is just nasty! ;)

#3. For the LPad issue change your "0" by '0'. You need a char value and not a string value there. It will return the perfect string.

kornalius
10-05-2006, 04:14 PM
After thinking about it for a little while (2 mins) I decided to fix the LPAD and RPAD functions to accept strings, chars and numbers.

w$ = LPad(w$, "0", 2);
w$ = LPad(w$, '0', 2);
w$ = LPad(w$, 48, 2);
w$ = LPad(w$, #48, 2);

All of these lines will all work in 1.04.

Richard
10-05-2006, 06:15 PM
Thanks guys, I'm very impressed with all the help I am getting, it's brilliant!

FYI I'm on holiday for a couple weeks, so bye for now.

Richard

kornalius
10-05-2006, 07:50 PM
Your welcome.
Have a good holiday Richard.

bmanske
10-06-2006, 05:37 AM
A word about the list box issue. The ListBox gets created with LBS_STANDARD checked. It is equivalent to LBS_SORT, LBS_NOTIFY and LBS_BORDERS. So it is doing what it is supposed to do.

Brad

PointOfLight
10-06-2006, 03:49 PM
My bad. Unfortunately, I don't have all of my LBS_ constants memorized yet :)