[Gambas-user] Parallel Port Programming in Gambas

2009-12-16 Thread Me
Hi all,

I am new to Gambas 2.16 and also Ubuntu  9.04.
I trying to write a Gambas program to control
parallel  port's input/output in Ubuntu.

For example, 
Switch parallel port pin 2 to on or off.

From How To Use Parallel Port

http://gambasdoc.org/help/howto/parport

Solution 1:
opening /dev/port with
OPEN and read/write at a specific location.


Solution 2:
Based on a C library named 'parapin'

For solution 2, how Gambas can access the parapin library?

Thank you in advance.



  New Email names for you! 
Get the Email name you#39;ve always wanted on the new @ymail and @rocketmail. 
Hurry before someone else does!
http://mail.promotions.yahoo.com/newdomains/aa/
--
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] About financial program in Gambas

2009-12-16 Thread Jean-Yves F. Barbier
Ricardo Díaz Martín a écrit :
 Hi to all,
 
 I'm use gambas to write ERP applications. At the first, I got the same
 problem but I decided to use long integer to save currency values. First
 rigth two digits are always showed to users as decimal values.
 
 I'm rewrited all my apps from windows to gambas and they are working now
 with no problems in customers servers.
 
 I allways use a function to show values in controls in app's forms that
 convert database fields values showed in textboxes whose name started int
 dbcur (p.e. dbcurVAT) to value div 100 and works with no problems. I use
 allways the same function to write forms data to database and make the
 reverse proccess.

Hooo, thanks for the ad.

 Its simple and works

Sounds exactly like the commercial about women thin down cream we've
got on tv for months (it works!) (sorry, I couldn't resist:)

So you're truncating everything to 2 decimals, but as I said VAT (and as
a matter of fact almost all french taxes) is *legally* up to 4 decimals;
actually only 2 of them are used, but nothing's saying that tomorrow
is won't be 3 or 4 really used (especially on those times where our
gov morons (pleonasm) are desesperatly looking for money.)

BTW, how do you truncate 19.99657? Down to 19.99 or up to 20.00?
In my family's company a cent error is worth €100,000 fine...

Other PB: most of results could be predictable (as of Nb of decimals),
but some can't (ie: 92.95x1.196=111.1682 OR 145x1.196=173.42),
maths says decimals should be dN1+dN2=5 but in these cases we only have
4 and 2 because of non-significant right zeroes, so you can't obviously
truncate by adding the comma counting 5 from the right.
One of the most used manner to get a selling price is to use a coefficient
which has many decimals (usually a real), how do you determine where to
put the comma in the resultant number??

I see the possibilities, but AFAIK this is a full processor to write
based on a complex numbers model, not to mention error possibilities 
have a tremendous cataclysmic potential in a matter where tax 
administration will be more than happy to chop your head and piss 
on your brain (yeah, they're like that here: when they come it is 
not to search, it is to find; no matter if has real justification or not.)

But may be I'm totally mistaking: I always have had PBs with simple
things.

JY
-- 
God is real, unless declared integer.

--
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Showing ps files

2009-12-16 Thread Fabien Bodard
use an external application like ghostscript and include it with
embedder control

2009/12/16 Rolf-Werner Eilert eilert-sprac...@t-online.de:
 Good morning everyone,

 just a small question: Is there a control which could show the contents
 of postscript files? Maybe even scaled, so I could implement a preview
 and a bigger reading screen?

 If not, I guess this would mean calling an external application for it
 which would make this whole thing less handy.

 Thanks for your ideas.

 Rolf

 --
 This SF.Net email is sponsored by the Verizon Developer Community
 Take advantage of Verizon's best-in-class app development support
 A streamlined, 14 day to market process makes app distribution fast and easy
 Join now and get one step closer to millions of Verizon customers
 http://p.sf.net/sfu/verizon-dev2dev
 ___
 Gambas-user mailing list
 Gambas-user@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/gambas-user


--
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] About financial program in Gambas

2009-12-16 Thread Ricardo Díaz Martín
Jean,

You can use numbers of decimal as you want. I you want 4 you only need to
divide by 1000. The only you need to decide on before insert data. If you
need to add more decimals in future you only have to modify a parameter in
your app from 2 to 4 (functions that show from database/write to database
currency values must read this values before show/write info) and update
your database multiplying cur fields by 100 (to add two digit more of
precision)

You never need truncate any value if you always use this especial currency
type. For example if you set decimals to 4, number 19.99657 is no possible.

If you need to get selling prices using four decimal coefficient, define
coefficient as a currency type and set your app to use 4 decimal for all
currency values

I hope this helps you

2009/12/16 Jean-Yves F. Barbier 12u...@gmail.com

 Ricardo Díaz Martín a écrit :
  Hi to all,
 
  I'm use gambas to write ERP applications. At the first, I got the same
  problem but I decided to use long integer to save currency values. First
  rigth two digits are always showed to users as decimal values.
 
  I'm rewrited all my apps from windows to gambas and they are working now
  with no problems in customers servers.
 
  I allways use a function to show values in controls in app's forms that
  convert database fields values showed in textboxes whose name started int
  dbcur (p.e. dbcurVAT) to value div 100 and works with no problems. I use
  allways the same function to write forms data to database and make the
  reverse proccess.

 Hooo, thanks for the ad.

  Its simple and works

 Sounds exactly like the commercial about women thin down cream we've
 got on tv for months (it works!) (sorry, I couldn't resist:)

 So you're truncating everything to 2 decimals, but as I said VAT (and as
 a matter of fact almost all french taxes) is *legally* up to 4 decimals;
 actually only 2 of them are used, but nothing's saying that tomorrow
 is won't be 3 or 4 really used (especially on those times where our
 gov morons (pleonasm) are desesperatly looking for money.)

 BTW, how do you truncate 19.99657? Down to 19.99 or up to 20.00?
 In my family's company a cent error is worth €100,000 fine...

 Other PB: most of results could be predictable (as of Nb of decimals),
 but some can't (ie: 92.95x1.196=111.1682 OR 145x1.196=173.42),
 maths says decimals should be dN1+dN2=5 but in these cases we only have
 4 and 2 because of non-significant right zeroes, so you can't obviously
 truncate by adding the comma counting 5 from the right.
 One of the most used manner to get a selling price is to use a coefficient
 which has many decimals (usually a real), how do you determine where to
 put the comma in the resultant number??

 I see the possibilities, but AFAIK this is a full processor to write
 based on a complex numbers model, not to mention error possibilities
 have a tremendous cataclysmic potential in a matter where tax
 administration will be more than happy to chop your head and piss
 on your brain (yeah, they're like that here: when they come it is
 not to search, it is to find; no matter if has real justification or not.)

 But may be I'm totally mistaking: I always have had PBs with simple
 things.

 JY
 --
 God is real, unless declared integer.


 --
 This SF.Net email is sponsored by the Verizon Developer Community
 Take advantage of Verizon's best-in-class app development support
 A streamlined, 14 day to market process makes app distribution fast and
 easy
 Join now and get one step closer to millions of Verizon customers
 http://p.sf.net/sfu/verizon-dev2dev
 ___
 Gambas-user mailing list
 Gambas-user@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/gambas-user

--
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] SDL component documentation

2009-12-16 Thread Fabien Bodard
2009/12/16 kevinfishburne kevinfishbu...@eightvirtues.com:


 Fabien Bodard-4 wrote:

 gb.sdl is incomplete ... in fact Laurent have begin to redraw all the
 gb.sdl lib by using OpenGl... but ... still incomplete ... i think the
 lack of users on this lib mess his enthusiasm


 Hi Fabien, I agree with your comments. I'm guessing that GAMBAS 3 is still
 in alpha/beta since I haven't seen any releases on the download page. I am
 looking forward to it and hope it's fairly downward-compatible so GAMBAS 2
 apps will run in it.

 That's good to hear that the new SDL component will be rewritten using
 OpenGL. I think the only thing GAMBAS is currently missing is a robust
 high-level 2D and 3D graphics library. While an OpenGL wrapper is cool,
 having to write 10 or more lines of code to create a single polygon probably
 doesn't help most people. I think it's also important to consider that
 GAMBAS need not necessarily implement literal wrappers for SDL or OpenGL,
 but rather its own unique flavor of 2D and 3D routines aimed squarely at
 delivering practical and efficient results.

i think too , so a good look at blitz will be interesring, Blitz 2D, Blitz Max


 The spirit of GAMBAS surely is to write effective apps quickly and with
 respect to modern object-oriented programming conventions, all using a
 language that is easy and familiar to BASIC-loving developers. In that
 spirit a higher-level graphics component fits right in. Here's my two cents
 for what a 2D graphics library might include:

 * Graphics Buffers
 ** Allow creation of buffers in video memory (hardware accelerated) to store
 images
 ** Allow multiple buffers with different properties
 *** Define width and height
 *** Define RGB bit-depth (8, 16, 24, 32, etc.)
 *** Define alpha-channel bit-depth (0, 2, 4, 8, etc.)

 * Image Loading
 ** Allow loading of different file types into a graphics buffer (PNG, GIF,
 JPG, etc.)
 ** Allow loading file into specific location (x1,y1) of the buffer

 * Bit Blitting
 ** Allow copying one region of a graphics buffer (x1,y1,x2,y2) to another
 graphics buffer (x1,y1)
 ** Allow arbitrary rotation when copying a region from one buffer to another
 ** Allow arbitrary scaling when copying a region from one buffer to another
 ** Allow downsampling and upsampling when copying a region to a buffer
 with a different bit-depth
 ** Allow global alpha modifier multiplied by the existing region's alpha
 channel (will allow a region to be faded in or faded out, preserving its
 existing alpha channel)

 * Effects Processing
 ** Allow various effects (brightness, contrast, hue, saturation, gaussian
 blur, etc.)
 ** Allow the results of the effects, when necessary, to extend beyond the
 region in the buffer they were applied to

 I think a 2D graphics component is far more useful than a 3D component, as
 it will appeal to a wider developer base. 3D graphics require more work and
 more skill, therefore most programmers would be more adept at 2D graphics
 than 3D. While 3D is important, it should be relegated to being more
 seriously-developed only after a robust 2D library has been implemented.

 I wish I could contribute more but will have to settle for posting in the
 forums and developing GAMBAS apps that hopefully people will find useful or
 fun. I'm very good at graphics and documentation, so if anyone has any tasks
 that need to be done that they think I could do (or help me do by acting as
 an intermediary with the source code) please let me know.

 -
 Kevin Fishburne, Eight Virtues
 www:  http://sales.eightvirtues.com http://sales.eightvirtues.com
 e-mail:  mailto:sa...@eightvirtues.com sa...@eightvirtues.com
 phone: (770) 853-6271
 --
 View this message in context: 
 http://old.nabble.com/SDL-component-documentation-tp26603936p26806675.html
 Sent from the gambas-user mailing list archive at Nabble.com.


 --
 This SF.Net email is sponsored by the Verizon Developer Community
 Take advantage of Verizon's best-in-class app development support
 A streamlined, 14 day to market process makes app distribution fast and easy
 Join now and get one step closer to millions of Verizon customers
 http://p.sf.net/sfu/verizon-dev2dev
 ___
 Gambas-user mailing list
 Gambas-user@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/gambas-user


--
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] signal SIGSEGV, Segmentation fault when using database example with ODDBC to a MSSQL Database

2009-12-16 Thread Benoît Minisini
 Problem #11 when using ODBC to connect to a remote database running on MS
 SQL Server 2000.
 
 
 
 I can connect to the database and run queries using tsql from a terminal
  and isql from a root terminal and I can connect using odbc in Gambas2 if
  the ide is started from a root terminal but not if started from the
  programme shortcut.
 
 
 
 I have a small utility to run queries on a SQL server, display the results
 and optionally export them as a csv file. As soon as the programme gets to
 the line where the query is assigned to a Result the programme crashes with
 a #11.  This behaviour is identical if running the Database Sample. The
 connection is opened. connection.opened is True when tested in debug mode.
 The line where the error occurs in the sample is:-
 
 
 
   rData = $hConn.Exec(txtRequest.Text)
 
 
 
 which is the same as the one in my application where the programme crashes
 
 
 
 PUBLIC SUB FillGrid(ctl AS Control, cnn AS Connection, sqlstr AS String)
 
   DIM datout AS Result, i AS Integer, j AS Integer
 
 
 
   datout = cnn.Exec(sqlstr)   The line the crash occurs
 
 
 
 The version of gambas2 is 2.18.0
 
 The kernel is Linux 2.6.31.5-127/fc12.x86_64
 
 System is
 
   Memory 3.8 GiB
 
   Proc 0 AMD Athlon(tm) X2 Dual Core processor 5200+
 
   Proc 1 AMD Athlon(tm) X2 Dual Core processor 5200+
 
 
 
 The query is executed as can be seen from the output from Wireshark
  included after the debug output.
 
 
 
 Thanks
 
 
 
 Tony
 
 
 
 Debug data and Wireshark output from running the Database Sample Programme.
 
 
 
 [r...@fslserver Database]# cd /usr/share/gambas2/examples/Database/Database
 
 [r...@fslserver Database]# gbc2 -agt
 
 OK
 
 [r...@fslserver Database]# gdb gbx2
 
 GNU gdb (GDB) Fedora (7.0-8.fc12)
 
 Copyright (C) 2009 Free Software Foundation, Inc.
 
 License GPLv3+: GNU GPL version 3 or later
 http://gnu.org/licenses/gpl.html
 
 This is free software: you are free to change and redistribute it.
 
 There is NO WARRANTY, to the extent permitted by law.  Type show copying
 
 and show warranty for details.
 
 This GDB was configured as x86_64-redhat-linux-gnu.
 
 For bug reporting instructions, please see:
 
 http://www.gnu.org/software/gdb/bugs/...
 
 Reading symbols from /usr/bin/gbx2...(no debugging symbols found)...done.
 
 Missing separate debuginfos, use: debuginfo-install
 gambas2-runtime-2.18.0-1.fc12.x86_64
 
 (gdb) set args -p
 
 (gdb) run
 
 Starting program: /usr/bin/gbx2 -p
 
 [Thread debugging using libthread_db enabled]
 
 
 
 Program received signal SIGSEGV, Segmentation fault.
 
 0x003b3a27978c in free () from /lib64/libc.so.6
 
 (gdb) bt
 
 #0  0x003b3a27978c in free () from /lib64/libc.so.6
 
 #1  0x004050f1 in sinh ()
 
 #2  0x7fffefe013aa in SQLDisconnect ()
 
from /usr/lib64/gambas2/gb.db.odbc.so
 
 #3  0x7fffefe03a28 in ?? () from /usr/lib64/gambas2/gb.db.odbc.so
 
 #4  0x77408da2 in ?? () from /usr/lib64/gambas2/gb.db.so
 
 #5  0x7740975f in ?? () from /usr/lib64/gambas2/gb.db.so
 
 #6  0x774063c7 in ?? () from /usr/lib64/gambas2/gb.db.so
 
 #7  0x00408b32 in sinh ()
 
 #8  0x0040952f in sinh ()
 
 #9  0x0042eea5 in sinh ()
 
 #10 0x00409cf5 in sinh ()
 
 #11 0x00409fac in sinh ()
 
 #12 0x0041c4c9 in sinh ()
 
 #13 0x0041ce79 in sinh ()
 
 #14 0x7797edca in g_io_channel_unref ()
 
from /usr/lib64/gambas2/gb.gtk.so
 
 #15 0x00324020ba8e in g_closure_invoke () from
 /lib64/libgobject-2.0.so.0
 
 #16 0x003240220ec3 in ?? () from /lib64/libgobject-2.0.so.0
 
 #17 0x00324059 in g_signal_emit_valist ()
 
from /lib64/libgobject-2.0.so.0
 
 #18 0x0032402227a3 in g_signal_emit () from /lib64/libgobject-2.0.so.0
 
 #19 0x00324468d615 in ?? () from /usr/lib64/libgtk-x11-2.0.so.0
 
 ---Type return to continue, or q return to quit---
 
 #20 0x00324020ba8e in g_closure_invoke () from
 /lib64/libgobject-2.0.so.0
 
 #21 0x0032402207dc in ?? () from /lib64/libgobject-2.0.so.0
 
 #22 0x00324059 in g_signal_emit_valist ()
 
from /lib64/libgobject-2.0.so.0
 
 #23 0x0032402227a3 in g_signal_emit () from /lib64/libgobject-2.0.so.0
 
 #24 0x00324468be77 in ?? () from /usr/lib64/libgtk-x11-2.0.so.0
 
 #25 0x003244753903 in ?? () from /usr/lib64/libgtk-x11-2.0.so.0
 
 #26 0x00324020ba8e in g_closure_invoke () from
 /lib64/libgobject-2.0.so.0
 
 #27 0x003240220b8d in ?? () from /lib64/libgobject-2.0.so.0
 
 #28 0x0032402220ec in g_signal_emit_valist ()
 
from /lib64/libgobject-2.0.so.0
 
 #29 0x0032402227a3 in g_signal_emit () from /lib64/libgobject-2.0.so.0
 
 #30 0x003244875a9f in ?? () from /usr/lib64/libgtk-x11-2.0.so.0
 
 #31 0x00324474a664 in gtk_propagate_event ()
 
from /usr/lib64/libgtk-x11-2.0.so.0
 
 #32 0x00324474b7a3 in gtk_main_do_event ()
 
from /usr/lib64/libgtk-x11-2.0.so.0
 
 #33 0x7798c627 in ?? () from 

[Gambas-user] Cannot save a gif image

2009-12-16 Thread Les Hardy
Can anyone tell me how to save a gif image.
I can save other images, but  not gifs

gambas 2.18 on ubuntu 9.04

Regards
Les Hardy

--
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


[Gambas-user] problems with core functions

2009-12-16 Thread Norarg
hi

I am struggling with some nasty little things..
when I select a text or a part of a text in a textbox, and I want to 
copy this or paste from clipboard, the usual way is to use ctrl-c, 
ctrl-v. well, every software I know has a button too, making this 
possible. I tried to use the Desktop.Sendkeys, which works with \t 
f.ex., but I can not figure out how to send ctrl-c - tried ({[CTRL]C}) 
and ({[CTRL_L]C}). In the manual I get the information, all keys are 
defined in /usr/include/X11/keysymdef.h - but this file does not exist 
on my system in this folder. Will be thankful for any help.

Then I tried with .SelStart and .SelLenght to get the string - that was 
not accepted at all, get  unknown symbol.


It would be nice, if I could get this two different functions to work.

thanks and regards
norarg

--
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Cannot save a gif image

2009-12-16 Thread Fabien Bodard
have you libgif installed ?

2009/12/16 Jussi Lahtinen jussi.lahti...@gmail.com:
 Save gif from where?
 Please show your code you are using to save other image formats.

 Jussi


 On Tue, Dec 15, 2009 at 23:57, Les Hardy l...@webmayo.com wrote:
 Can anyone tell me how to save a gif image.
 I can save other images, but  not gifs

 gambas 2.18 on ubuntu 9.04

 Regards
 Les Hardy

 --
 This SF.Net email is sponsored by the Verizon Developer Community
 Take advantage of Verizon's best-in-class app development support
 A streamlined, 14 day to market process makes app distribution fast and easy
 Join now and get one step closer to millions of Verizon customers
 http://p.sf.net/sfu/verizon-dev2dev
 ___
 Gambas-user mailing list
 Gambas-user@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/gambas-user


 --
 This SF.Net email is sponsored by the Verizon Developer Community
 Take advantage of Verizon's best-in-class app development support
 A streamlined, 14 day to market process makes app distribution fast and easy
 Join now and get one step closer to millions of Verizon customers
 http://p.sf.net/sfu/verizon-dev2dev
 ___
 Gambas-user mailing list
 Gambas-user@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/gambas-user


--
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


[Gambas-user] Custom error class

2009-12-16 Thread Jesus Guardon
Hi all

Perhaps this is an stupid question, but I'm confused at this point:

I'm trying to implement a custom error message window with information
about an error raised within a CATCH clause, using the Error class from
Gambas. Here is the code I'm not able to get it working:

_The error form 'FError'_

PRIVATE $error AS String

PUBLIC SUB Form_Open()
ME.Center
txtError.Clear
txtError.Text = $error
END

PUBLIC SUB showError(myError AS Error)
$error = [Error]\n  myError.Text
$error = \n[Where]\n  myError.Where
$error = \n[Backtrace]\n  myError.Backtrace
ME.ShowModal
END

PUBLIC SUB btnOk_Click()
IF chkReport THEN
' TODO report error to a remote db
ENDIF
ME.Close
END

_Calling in a sub after CATCH_

CATCH
FEerror.showError(Error)

-

First of all, it is not possible to write Error keyword between the
two parenthesis, being formatted into ERROR, syntactically wrong.

If I enclose the 'Error' keyword between curly brackets, as in
FErrors.showError({Error}) , no syntax error is raised, but a Gambas
error saying Type mismatch: wanted Error, got Class instead.

What am I doing wrong, or is it possible to use this class the way I'm
doing?

Help appreciated!

Regards,

Jesús

--
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Cannot save a gif image

2009-12-16 Thread Les Hardy

Yes, I have libgif-4.1.6-6. I tried reinstalling all image libraries 
that I could find.
Still no good.

Regards
Les Hardy



Fabien Bodard wrote:
 have you libgif installed ?

 2009/12/16 Jussi Lahtinen jussi.lahti...@gmail.com:
   
 Save gif from where?
 Please show your code you are using to save other image formats.

 Jussi


 On Tue, Dec 15, 2009 at 23:57, Les Hardy l...@webmayo.com wrote:
 
 Can anyone tell me how to save a gif image.
 I can save other images, but  not gifs

 gambas 2.18 on ubuntu 9.04

 Regards
 Les Hardy

   


--
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] problems with core functions

2009-12-16 Thread Norarg
hi,

thanks, but how do I get this Text I want to copy, it is selected, but 
somehow I have to make a string of it, before sending it to the 
clipboard. Somewhere I have seen SelStart, SelLength with Gambas, but 
just can not find that part any more - it seemed so clear, I did not 
give it any further notice - and that so clear part just does not work. 
:) btw. using ubuntu 09.10/gambas 2.13.

regards
norarg


Ricardo Díaz Martín schrieb:
 use Clipboard.Copy(Text you want copy) and Clipboard.Paste()

 http://gambasdoc.org/help/comp/gb.qt/clipboard



 2009/12/16 Norarg nor...@hotmail.de

   
 hi

 I am struggling with some nasty little things..
 when I select a text or a part of a text in a textbox, and I want to
 copy this or paste from clipboard, the usual way is to use ctrl-c,
 ctrl-v. well, every software I know has a button too, making this
 possible. I tried to use the Desktop.Sendkeys, which works with \t
 f.ex., but I can not figure out how to send ctrl-c - tried ({[CTRL]C})
 and ({[CTRL_L]C}). In the manual I get the information, all keys are
 defined in /usr/include/X11/keysymdef.h - but this file does not exist
 on my system in this folder. Will be thankful for any help.

 Then I tried with .SelStart and .SelLenght to get the string - that was
 not accepted at all, get  unknown symbol.


 It would be nice, if I could get this two different functions to work.

 thanks and regards
 norarg


 --
 This SF.Net email is sponsored by the Verizon Developer Community
 Take advantage of Verizon's best-in-class app development support
 A streamlined, 14 day to market process makes app distribution fast and
 easy
 Join now and get one step closer to millions of Verizon customers
 http://p.sf.net/sfu/verizon-dev2dev
 ___
 Gambas-user mailing list
 Gambas-user@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/gambas-user

 
 --
 This SF.Net email is sponsored by the Verizon Developer Community
 Take advantage of Verizon's best-in-class app development support
 A streamlined, 14 day to market process makes app distribution fast and easy
 Join now and get one step closer to millions of Verizon customers
 http://p.sf.net/sfu/verizon-dev2dev 
 ___
 Gambas-user mailing list
 Gambas-user@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/gambas-user


   

--
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


[Gambas-user] Weird Overflow error (GB_DIR)

2009-12-16 Thread Jesus Guardon
Hi all

I am experimenting with the GB_DIR environment variable, and I've made a
deb package with my program to install it in /opt. The current dir
structure is as follows:

je...@jesus:~$ tree /opt
/opt
`-- dfhlog
|-- dfhlog.gambas
`-- gambas2
|-- bin
|   |-- gbr2 - gbx2
|   `-- gbx2
`-- lib
`-- gambas2
|-- gb.component
|-- gb.corba.component
|-- ... etc
...etc...

I am calling my executable from a bash script located in /usr/local/bin

je...@jesus:~$ cat /usr/local/bin/dfhlog
#!/bin/sh
export PATH=/opt/dfhlog/gambas2/bin
export GB_DIR=/opt/dfhlog/gambas2
exec /opt/dfhlog/dfhlog.gambas

(In this case, LD_LIBRARY_PATH is not used, because they already are in
my system).

When I execute 'dfhlog' from the console the main form is shown, but I
got the error:

je...@jesus:~$ dfhlog
global.?.0: #7: Overflow

(Also a message box is displayed with the error)

However my application runs fine when using the standard paths as always.

Am I missing something? Which is Overflow error related to?

Regards,

Jesús





--
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Cannot save a gif image

2009-12-16 Thread Les Hardy
Thanks for responding Jussi,

The image is a result of an image.load previously in the code.
It may have been loaded as a gif, jpg, png or bmp.
 
'this works ok
imgfile = user.home / tmpfile.jpg
 imageout.Save(imgfile)
'--
'this works ok
imgfile = user.home / tmpfile.png
 imageout.Save(imgfile)
'--
' this does not work. error message say 'cannot save file'
imgfile = user.home / tmpfile.gif
 imageout.Save(imgfile)

I have written a few apps in gambas, with plenty of file handling, but I 
don't generally use  gifs.
I tried  it with images, pictures, pictureboxes. and in every case I can 
save anything but a gif.
Its driving me nuts. 
I cannot see any other postings about this problem. So I guess it must 
be something with my setup.

Have you any ideas of what to try next?

Regards
Les Hardy





Jussi Lahtinen wrote:
 Save gif from where?
 Please show your code you are using to save other image formats.

 Jussi


 On Tue, Dec 15, 2009 at 23:57, Les Hardy l...@webmayo.com wrote:
   
 Can anyone tell me how to save a gif image.
 I can save other images, but  not gifs

 gambas 2.18 on ubuntu 9.04

 Regards
 Les Hardy

 --
 This SF.Net email is sponsored by the Verizon Developer Community
 Take advantage of Verizon's best-in-class app development support
 A streamlined, 14 day to market process makes app distribution fast and easy
 Join now and get one step closer to millions of Verizon customers
 http://p.sf.net/sfu/verizon-dev2dev
 ___
 Gambas-user mailing list
 Gambas-user@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/gambas-user

 

 --
 This SF.Net email is sponsored by the Verizon Developer Community
 Take advantage of Verizon's best-in-class app development support
 A streamlined, 14 day to market process makes app distribution fast and easy
 Join now and get one step closer to millions of Verizon customers
 http://p.sf.net/sfu/verizon-dev2dev 
 ___
 Gambas-user mailing list
 Gambas-user@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/gambas-user

   


--
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Cannot save a gif image

2009-12-16 Thread Benoît Minisini
 Thanks for responding Jussi,
 
 The image is a result of an image.load previously in the code.
 It may have been loaded as a gif, jpg, png or bmp.
 
 'this works ok
 imgfile = user.home / tmpfile.jpg
  imageout.Save(imgfile)
 '--
 'this works ok
 imgfile = user.home / tmpfile.png
  imageout.Save(imgfile)
 '--
 ' this does not work. error message say 'cannot save file'
 imgfile = user.home / tmpfile.gif
  imageout.Save(imgfile)
 
 I have written a few apps in gambas, with plenty of file handling, but I
 don't generally use  gifs.
 I tried  it with images, pictures, pictureboxes. and in every case I can
 save anything but a gif.
 Its driving me nuts.
 I cannot see any other postings about this problem. So I guess it must
 be something with my setup.
 
 Have you any ideas of what to try next?
 
 Regards
 Les Hardy
 

In Gambas 2, the image save function is managed by the GUI component: which 
one do you use? gb.qt or gb.gtk?

I know, for example, that Qt can be compiled without GIF support. So on a 
system with Qt compiled that way, Gambas projects using gb.qt won't be able to 
deal with gif files.

Regards,

-- 
Benoît Minisini

--
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Weird Overflow error (GB_DIR)

2009-12-16 Thread Benoît Minisini
 Hi all
 
 I am experimenting with the GB_DIR environment variable, and I've made a
 deb package with my program to install it in /opt. The current dir
 structure is as follows:
 
 je...@jesus:~$ tree /opt
 /opt
 `-- dfhlog
 
 |-- dfhlog.gambas
 
 `-- gambas2
 
 |-- bin
 |
 |   |-- gbr2 - gbx2
 |
 |   `-- gbx2
 
 `-- lib
 `-- gambas2
 
 |-- gb.component
 |-- gb.corba.component
 |-- ... etc
 
 ...etc...
 
 I am calling my executable from a bash script located in /usr/local/bin
 
 je...@jesus:~$ cat /usr/local/bin/dfhlog
 #!/bin/sh
 export PATH=/opt/dfhlog/gambas2/bin
 export GB_DIR=/opt/dfhlog/gambas2
 exec /opt/dfhlog/dfhlog.gambas
 
 (In this case, LD_LIBRARY_PATH is not used, because they already are in
 my system).
 
 When I execute 'dfhlog' from the console the main form is shown, but I
 got the error:
 
 je...@jesus:~$ dfhlog
 global.?.0: #7: Overflow
 
 (Also a message box is displayed with the error)
 
 However my application runs fine when using the standard paths as always.
 
 Am I missing something? Which is Overflow error related to?
 
 Regards,
 
 Jesús
 
 

Can you compile the gambas project (dfhlog.gambas) with debugging information 
included? Then maybe you will have the line number where the overflow error 
occurs.

-- 
Benoît Minisini

--
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Custom error class

2009-12-16 Thread Benoît Minisini
 Hi all
 
 Perhaps this is an stupid question, but I'm confused at this point:
 
 I'm trying to implement a custom error message window with information
 about an error raised within a CATCH clause, using the Error class from
 Gambas. Here is the code I'm not able to get it working:
 
 _The error form 'FError'_
 
 PRIVATE $error AS String
 
 PUBLIC SUB Form_Open()
 ME.Center
 txtError.Clear
 txtError.Text = $error
 END
 
 PUBLIC SUB showError(myError AS Error)
 $error = [Error]\n  myError.Text
 $error = \n[Where]\n  myError.Where
 $error = \n[Backtrace]\n  myError.Backtrace
 ME.ShowModal
 END
 
 PUBLIC SUB btnOk_Click()
 IF chkReport THEN
 ' TODO report error to a remote db
 ENDIF
 ME.Close
 END
 
 _Calling in a sub after CATCH_
 
 CATCH
 FEerror.showError(Error)
 
 -
 
 First of all, it is not possible to write Error keyword between the
 two parenthesis, being formatted into ERROR, syntactically wrong.
 
 If I enclose the 'Error' keyword between curly brackets, as in
 FErrors.showError({Error}) , no syntax error is raised, but a Gambas
 error saying Type mismatch: wanted Error, got Class instead.
 
 What am I doing wrong, or is it possible to use this class the way I'm
 doing?
 
 Help appreciated!
 
 Regards,
 
 Jesús
 

At the moment Error is a static class, you cannot instanciate it, and using it 
as a datatype is uselss. So don't use an argument, use the Error class 
everywhere.

The caveats of this design is that should save or use the Error class contents 
as soon as possible, otherwise another error or a function call may reset it.

Regards,

-- 
Benoît Minisini

--
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Weird Overflow error (GB_DIR)

2009-12-16 Thread Jesus Guardon
Benoît Minisini escribió:
 Hi all

 I am experimenting with the GB_DIR environment variable, and I've made a
 deb package with my program to install it in /opt. The current dir
 structure is as follows:

 je...@jesus:~$ tree /opt
 /opt
 `-- dfhlog

 |-- dfhlog.gambas

 `-- gambas2

 |-- bin
 |
 |   |-- gbr2 - gbx2
 |
 |   `-- gbx2

 `-- lib
 `-- gambas2

 |-- gb.component
 |-- gb.corba.component
 |-- ... etc

 ...etc...

 I am calling my executable from a bash script located in /usr/local/bin

 je...@jesus:~$ cat /usr/local/bin/dfhlog
 #!/bin/sh
 export PATH=/opt/dfhlog/gambas2/bin
 export GB_DIR=/opt/dfhlog/gambas2
 exec /opt/dfhlog/dfhlog.gambas

 (In this case, LD_LIBRARY_PATH is not used, because they already are in
 my system).

 When I execute 'dfhlog' from the console the main form is shown, but I
 got the error:

 je...@jesus:~$ dfhlog
 global.?.0: #7: Overflow

 (Also a message box is displayed with the error)

 However my application runs fine when using the standard paths as always.

 Am I missing something? Which is Overflow error related to?

 Regards,

 Jesús


 
 Can you compile the gambas project (dfhlog.gambas) with debugging information 
 included? Then maybe you will have the line number where the overflow error 
 occurs.
 

Thanks Benoît

Surprisingly, after a recompile, it works as expected! May be I was
using an old executable file (dfhlog.gambas). Sorry for my mistake 8-(

Regards

Jesús

--
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Custom error class

2009-12-16 Thread Jesus Guardon
Benoît Minisini escribió:
 Hi all

 Perhaps this is an stupid question, but I'm confused at this point:

 I'm trying to implement a custom error message window with information
 about an error raised within a CATCH clause, using the Error class from
 Gambas. Here is the code I'm not able to get it working:

 _The error form 'FError'_

 PRIVATE $error AS String

 PUBLIC SUB Form_Open()
 ME.Center
 txtError.Clear
 txtError.Text = $error
 END

 PUBLIC SUB showError(myError AS Error)
 $error = [Error]\n  myError.Text
 $error = \n[Where]\n  myError.Where
 $error = \n[Backtrace]\n  myError.Backtrace
 ME.ShowModal
 END

 PUBLIC SUB btnOk_Click()
 IF chkReport THEN
 ' TODO report error to a remote db
 ENDIF
 ME.Close
 END

 _Calling in a sub after CATCH_

 CATCH
 FEerror.showError(Error)

 -

 First of all, it is not possible to write Error keyword between the
 two parenthesis, being formatted into ERROR, syntactically wrong.

 If I enclose the 'Error' keyword between curly brackets, as in
 FErrors.showError({Error}) , no syntax error is raised, but a Gambas
 error saying Type mismatch: wanted Error, got Class instead.

 What am I doing wrong, or is it possible to use this class the way I'm
 doing?

 Help appreciated!

 Regards,

 Jesús

 
 At the moment Error is a static class, you cannot instanciate it, and using 
 it 
 as a datatype is uselss. So don't use an argument, use the Error class 
 everywhere.
 
 The caveats of this design is that should save or use the Error class 
 contents 
 as soon as possible, otherwise another error or a function call may reset it.
 
 Regards,
 

M, I though so... I was trying to encapsulate it in a single
function, but I must reconsider this in other way.

Thanks anyway!

Regards,

Jesús

--
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] About financial program in Gambas

2009-12-16 Thread nando
For your info only...
I always use INT or LONG for accounting and money.
So, (here in Canada), $42.87 is 4287
I keep the tax (8%) as a float, therefore 8.25% is 8.25
This is ok for tax because rounding is needed.
For example:

4287 * 8.25 = 35367.75 / 100 = 353.6775
add .5 for 5/4 round up down
= 354.1775
Plase result into INT var which becomes 354

4287 + 354 = 4641

Using Float for taxes allows for many decimal places.
Using 100 for /100 process allows for any currencies where 
you want more than 2 decimal places.

For correct printing without rounding errors, do not do 4287/100.
but rather take the STR$(4287),
then split the right two off, and place a decimal in that place.
Perfect math and exact calculations every single time!!!

-Fernando


-- Original Message ---
From: Ricardo Díaz Martín oceanosoftlapa...@gmail.com
To: mailing list for gambas users gambas-user@lists.sourceforge.net
Sent: Wed, 16 Dec 2009 10:46:40 +
Subject: Re: [Gambas-user] About financial program in Gambas

 Jean,
 
 You can use numbers of decimal as you want. I you want 4 you only need to
 divide by 1000. The only you need to decide on before insert data. If you
 need to add more decimals in future you only have to modify a parameter in
 your app from 2 to 4 (functions that show from database/write to database
 currency values must read this values before show/write info) and update
 your database multiplying cur fields by 100 (to add two digit more of
 precision)
 
 You never need truncate any value if you always use this especial currency
 type. For example if you set decimals to 4, number 19.99657 is no possible.
 
 If you need to get selling prices using four decimal coefficient, define
 coefficient as a currency type and set your app to use 4 decimal for all
 currency values
 
 I hope this helps you
 
 2009/12/16 Jean-Yves F. Barbier 12u...@gmail.com
 
  Ricardo Díaz Martín a écrit :
   Hi to all,
  
   I'm use gambas to write ERP applications. At the first, I got the same
   problem but I decided to use long integer to save currency values. First
   rigth two digits are always showed to users as decimal values.
  
   I'm rewrited all my apps from windows to gambas and they are working now
   with no problems in customers servers.
  
   I allways use a function to show values in controls in app's forms that
   convert database fields values showed in textboxes whose name started int
   dbcur (p.e. dbcurVAT) to value div 100 and works with no problems. I use
   allways the same function to write forms data to database and make the
   reverse proccess.
 
  Hooo, thanks for the ad.
 
   Its simple and works
 
  Sounds exactly like the commercial about women thin down cream we've
  got on tv for months (it works!) (sorry, I couldn't resist:)
 
  So you're truncating everything to 2 decimals, but as I said VAT (and as
  a matter of fact almost all french taxes) is *legally* up to 4 decimals;
  actually only 2 of them are used, but nothing's saying that tomorrow
  is won't be 3 or 4 really used (especially on those times where our
  gov morons (pleonasm) are desesperatly looking for money.)
 
  BTW, how do you truncate 19.99657? Down to 19.99 or up to 20.00?
[WINDOWS-1252?]  In my family's company a cent error is worth €100,000 fine...
 
  Other PB: most of results could be predictable (as of Nb of decimals),
  but some can't (ie: 92.95x1.196=111.1682 OR 145x1.196=173.42),
  maths says decimals should be dN1+dN2=5 but in these cases we only have
  4 and 2 because of non-significant right zeroes, so you can't obviously
  truncate by adding the comma counting 5 from the right.
  One of the most used manner to get a selling price is to use a coefficient
  which has many decimals (usually a real), how do you determine where to
  put the comma in the resultant number??
 
  I see the possibilities, but AFAIK this is a full processor to write
  based on a complex numbers model, not to mention error possibilities
  have a tremendous cataclysmic potential in a matter where tax
  administration will be more than happy to chop your head and piss
  on your brain (yeah, they're like that here: when they come it is
  not to search, it is to find; no matter if has real justification or not.)
 
  But may be I'm totally mistaking: I always have had PBs with simple
  things.
 
  JY
  --
  God is real, unless declared integer.
 
 
  --
  This SF.Net email is sponsored by the Verizon Developer Community
  Take advantage of Verizon's best-in-class app development support
  A streamlined, 14 day to market process makes app distribution fast and
  easy
  Join now and get one step closer to millions of Verizon customers
  http://p.sf.net/sfu/verizon-dev2dev
  ___
  Gambas-user mailing list
  Gambas-user@lists.sourceforge.net
  https://lists.sourceforge.net/lists/listinfo/gambas-user
 
 

Re: [Gambas-user] Cannot save a gif image

2009-12-16 Thread Les Hardy
Yes, You have it.  Just checked. Looks like QImageIO was compiled 
without gif support on ubuntu 9.04 , and I am using gb.qt.

My Thanks to all that responded.

Regards
Les Hardy



Benoît Minisini wrote:

 
 In Gambas 2, the image save function is managed by the GUI component: which 
 one do you use? gb.qt or gb.gtk?
 
 I know, for example, that Qt can be compiled without GIF support. So on a 
 system with Qt compiled that way, Gambas projects using gb.qt won't be able 
 to 
 deal with gif files.
 
 Regards,
 



--
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


[Gambas-user] How to force a normal number output?

2009-12-16 Thread M. Cs.
I need to have a normal decimal output without E+degree notation. How to
force Gambas to use 153879 instead of 1.53879E+5?
--
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] About financial program in Gambas

2009-12-16 Thread Steven James Drinnan
Sorry - 

AS for mySQL it also has round() and you use the same as the gambas
function.

Steven

On Wed, 2009-12-16 at 16:13 -0500, nando wrote:

 For your info only...
 I always use INT or LONG for accounting and money.
 So, (here in Canada), $42.87 is 4287
 I keep the tax (8%) as a float, therefore 8.25% is 8.25
 This is ok for tax because rounding is needed.
 For example:
 
 4287 * 8.25 = 35367.75 / 100 = 353.6775
 add .5 for 5/4 round up down
 = 354.1775
 Plase result into INT var which becomes 354
 
 4287 + 354 = 4641
 
 Using Float for taxes allows for many decimal places.
 Using 100 for /100 process allows for any currencies where 
 you want more than 2 decimal places.
 
 For correct printing without rounding errors, do not do 4287/100.
 but rather take the STR$(4287),
 then split the right two off, and place a decimal in that place.
 Perfect math and exact calculations every single time!!!
 
 -Fernando
 
 
 -- Original Message ---
 From: Ricardo Díaz Martín oceanosoftlapa...@gmail.com
 To: mailing list for gambas users gambas-user@lists.sourceforge.net
 Sent: Wed, 16 Dec 2009 10:46:40 +
 Subject: Re: [Gambas-user] About financial program in Gambas
 
  Jean,
  
  You can use numbers of decimal as you want. I you want 4 you only need to
  divide by 1000. The only you need to decide on before insert data. If you
  need to add more decimals in future you only have to modify a parameter in
  your app from 2 to 4 (functions that show from database/write to database
  currency values must read this values before show/write info) and update
  your database multiplying cur fields by 100 (to add two digit more of
  precision)
  
  You never need truncate any value if you always use this especial currency
  type. For example if you set decimals to 4, number 19.99657 is no possible.
  
  If you need to get selling prices using four decimal coefficient, define
  coefficient as a currency type and set your app to use 4 decimal for all
  currency values
  
  I hope this helps you
  
  2009/12/16 Jean-Yves F. Barbier 12u...@gmail.com
  
   Ricardo Díaz Martín a écrit :
Hi to all,
   
I'm use gambas to write ERP applications. At the first, I got the same
problem but I decided to use long integer to save currency values. First
rigth two digits are always showed to users as decimal values.
   
I'm rewrited all my apps from windows to gambas and they are working now
with no problems in customers servers.
   
I allways use a function to show values in controls in app's forms that
convert database fields values showed in textboxes whose name started 
int
dbcur (p.e. dbcurVAT) to value div 100 and works with no problems. I use
allways the same function to write forms data to database and make the
reverse proccess.
  
   Hooo, thanks for the ad.
  
Its simple and works
  
   Sounds exactly like the commercial about women thin down cream we've
   got on tv for months (it works!) (sorry, I couldn't resist:)
  
   So you're truncating everything to 2 decimals, but as I said VAT (and as
   a matter of fact almost all french taxes) is *legally* up to 4 decimals;
   actually only 2 of them are used, but nothing's saying that tomorrow
   is won't be 3 or 4 really used (especially on those times where our
   gov morons (pleonasm) are desesperatly looking for money.)
  
   BTW, how do you truncate 19.99657? Down to 19.99 or up to 20.00?
 [WINDOWS-1252?]  In my family's company a cent error is worth €100,000 
 fine...
  
   Other PB: most of results could be predictable (as of Nb of decimals),
   but some can't (ie: 92.95x1.196=111.1682 OR 145x1.196=173.42),
   maths says decimals should be dN1+dN2=5 but in these cases we only have
   4 and 2 because of non-significant right zeroes, so you can't obviously
   truncate by adding the comma counting 5 from the right.
   One of the most used manner to get a selling price is to use a coefficient
   which has many decimals (usually a real), how do you determine where to
   put the comma in the resultant number??
  
   I see the possibilities, but AFAIK this is a full processor to write
   based on a complex numbers model, not to mention error possibilities
   have a tremendous cataclysmic potential in a matter where tax
   administration will be more than happy to chop your head and piss
   on your brain (yeah, they're like that here: when they come it is
   not to search, it is to find; no matter if has real justification or not.)
  
   But may be I'm totally mistaking: I always have had PBs with simple
   things.
  
   JY
   --
   God is real, unless declared integer.
  
  
   --
   This SF.Net email is sponsored by the Verizon Developer Community
   Take advantage of Verizon's best-in-class app development support
   A streamlined, 14 day to market process makes app distribution fast and
   easy
   Join now and get one step closer to 

Re: [Gambas-user] About financial program in Gambas

2009-12-16 Thread Steven James Drinnan
Just to add my two cents worth, 

This problem has been around for eons and it does not only apply to
Gambas. When I was programming in Access and VB I had the same problem
even using the currency type.

I just use the Round function

Value = Round ( Number [ , Digits ] )


And I use this return variable in my database. 
 
This is the only way to make sure that rounding is done right. I found
that even with a currency data type it tended to truncate rather than
round.

By the way you should be able to insert into a stored procedure. I did
so in Access. In MySql I found that it has the TRUNCATE() command so you
can do this


SELECT Truncate( ((YourNumber * 10^dp) + 0.5) / (10^dp) , dp )  *this
will round correctly where dp is the number of dp that you need.

You will have to check the sql manual to see what command is supported
for your database.






On Wed, 2009-12-16 at 16:13 -0500, nando wrote:

 For your info only...
 I always use INT or LONG for accounting and money.
 So, (here in Canada), $42.87 is 4287
 I keep the tax (8%) as a float, therefore 8.25% is 8.25
 This is ok for tax because rounding is needed.
 For example:
 
 4287 * 8.25 = 35367.75 / 100 = 353.6775
 add .5 for 5/4 round up down
 = 354.1775
 Plase result into INT var which becomes 354
 
 4287 + 354 = 4641
 
 Using Float for taxes allows for many decimal places.
 Using 100 for /100 process allows for any currencies where 
 you want more than 2 decimal places.
 
 For correct printing without rounding errors, do not do 4287/100.
 but rather take the STR$(4287),
 then split the right two off, and place a decimal in that place.
 Perfect math and exact calculations every single time!!!
 
 -Fernando
 
 
 -- Original Message ---
 From: Ricardo Díaz Martín oceanosoftlapa...@gmail.com
 To: mailing list for gambas users gambas-user@lists.sourceforge.net
 Sent: Wed, 16 Dec 2009 10:46:40 +
 Subject: Re: [Gambas-user] About financial program in Gambas
 
  Jean,
  
  You can use numbers of decimal as you want. I you want 4 you only need to
  divide by 1000. The only you need to decide on before insert data. If you
  need to add more decimals in future you only have to modify a parameter in
  your app from 2 to 4 (functions that show from database/write to database
  currency values must read this values before show/write info) and update
  your database multiplying cur fields by 100 (to add two digit more of
  precision)
  
  You never need truncate any value if you always use this especial currency
  type. For example if you set decimals to 4, number 19.99657 is no possible.
  
  If you need to get selling prices using four decimal coefficient, define
  coefficient as a currency type and set your app to use 4 decimal for all
  currency values
  
  I hope this helps you
  
  2009/12/16 Jean-Yves F. Barbier 12u...@gmail.com
  
   Ricardo Díaz Martín a écrit :
Hi to all,
   
I'm use gambas to write ERP applications. At the first, I got the same
problem but I decided to use long integer to save currency values. First
rigth two digits are always showed to users as decimal values.
   
I'm rewrited all my apps from windows to gambas and they are working now
with no problems in customers servers.
   
I allways use a function to show values in controls in app's forms that
convert database fields values showed in textboxes whose name started 
int
dbcur (p.e. dbcurVAT) to value div 100 and works with no problems. I use
allways the same function to write forms data to database and make the
reverse proccess.
  
   Hooo, thanks for the ad.
  
Its simple and works
  
   Sounds exactly like the commercial about women thin down cream we've
   got on tv for months (it works!) (sorry, I couldn't resist:)
  
   So you're truncating everything to 2 decimals, but as I said VAT (and as
   a matter of fact almost all french taxes) is *legally* up to 4 decimals;
   actually only 2 of them are used, but nothing's saying that tomorrow
   is won't be 3 or 4 really used (especially on those times where our
   gov morons (pleonasm) are desesperatly looking for money.)
  
   BTW, how do you truncate 19.99657? Down to 19.99 or up to 20.00?
 [WINDOWS-1252?]  In my family's company a cent error is worth €100,000 
 fine...
  
   Other PB: most of results could be predictable (as of Nb of decimals),
   but some can't (ie: 92.95x1.196=111.1682 OR 145x1.196=173.42),
   maths says decimals should be dN1+dN2=5 but in these cases we only have
   4 and 2 because of non-significant right zeroes, so you can't obviously
   truncate by adding the comma counting 5 from the right.
   One of the most used manner to get a selling price is to use a coefficient
   which has many decimals (usually a real), how do you determine where to
   put the comma in the resultant number??
  
   I see the possibilities, but AFAIK this is a full processor to write
   based on a complex numbers model, not to mention error