Categories > TinyButStrong general >

Problem with numeric formatting - error in tbs??

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Pirjo Posio
Date: 2003-06-30
Time: 23:55

Problem with numeric formatting - error in tbs??

I tried the Display by page -example in your examples set.

Because I have set error_reporting (E_ALL) I got for the price field on every line the notice:
"Notice: Uninitialized string offset: 4 in C:\Inetpub\wwwroot\includes\tbs_class.php on line 2236".
I just wonder, if  [$nPosEnd+1] should be [$nPosEnd]?
By: Skrol29
Date: 2003-07-01
Time: 00:49

Re: Problem with numeric formatting - error in tbs??

Hello Piro,

Thanks for reporting this bug.
[$nPosEnd+1] is correct because TBS just checks if there is a ending dot, which can mean that there is no decimal part.

The bug is : if the last zero is the end of the format string, then your error can occurs (it doesn't with my configuration).

I gonna fix that quik.
For the moment you can just add any character at the end of your format string. A space for example.

Could you send me (here or by email) your merge-field definition.

Thanks again,
By: Pirjo Posio
Date: 2003-07-01
Time: 01:18

Re: Problem with numeric formatting - error in tbs??

Hi again,
I'm using your own tbs_example as it is - Display by page!!!
in html:
[blk.price;frm='0.00']

in php:
$RecCnt = $TBS->MergeBlock("blk",$recset,"",$PageSize,$PageNum,$RecCnt) ;

data for example:
$recset[] = array("product"=>"Trumpet"    , "price"=>112.50) ;

- Pirjo

By: Skrol29
Date: 2003-07-01
Time: 01:25

Re: Problem with numeric formatting - error in tbs??

That's probably what I was thinking.

Your level error probably send notice message and mine doesn't.

I have to fix that bug.
By: Pirjo Posio
Date: 2003-07-01
Time: 01:39

Re: Problem with numeric formatting - error in tbs??

Isn't the $nPosEnd counted from 0? That's why I thought it can't ever become $nPosEnd+1.
Anyway, I tested by changing in tbs_class.php line 2236 like this:
if ($FrmStr[$nPosEnd]==='.') {

No error notices. All prices were correct, even if I changed some prices to values without decimals, for example '100' (not '100.00').
Now the only problem is that thousand separator is not working.
-Pirjo
By: Skrol29
Date: 2003-07-01
Time: 01:49

Re: Problem with numeric formatting - error in tbs??

in stead, try

if (($nPosEnd<strlen($FrmStr)-1) and ($FrmStr[$nPosEnd+1]==='.')) {

This line checks if there is a dot just after the last zero.
Because of the '000.' format string.
That why the +1 is correct.

Please, could you tell me if my suggestion works better.
By: Pirjo Posio
Date: 2003-07-01
Time: 02:12

Re: Problem with numeric formatting - error in tbs??

You were right (as always!) about my "correction":
Format string '000.' is not working in my version.

Your last correction is much better, it works ok in all other aspects, but even in your version the thousand separator is not working at all.
I must admire your efficiency - you are giving answers and corrections simultaneously to Mankey and me. Wow!
-Pirjo
By: Pirjo Posio
Date: 2003-07-01
Time: 02:41

Re: Problem with numeric formatting - error in tbs??

Please forgive me!
All is well with your last correction at 01.49 o'clock.
My format string was too short, that's why the thousand separator did not work.
- Pirjo