Re: [Gambas-user] Did anybody try to run stepper motors through paralel port

2010-04-18 Thread Les Hardy
Zelimir Ikovic wrote:
 I have VB6 program that run CNC plasma machine. It work very well and smooth 
 under win200, but in WinXP machine motion is not good. 

 It doesnot help if I set REALTIME prority for the process ...

 How about Linux and Gambas? Daes it depent on version of Linux ...

 What is resolution for Gambas Timer? Can I wait 10 microsec do something wait 
 10 microsec and so on ...

 Regards




   
Hi, First of all, I apologise for giving winxp help in a Gambas mailing 
list, I will make it brief.
Parallel port access change when winxp came along. It was not so easy to 
get direct access to the port, and some versions of winxp look for 
devices by periodically writing to the port. This is may be the cause of 
poor motion. This can be fixed by setting the 'DisableWarmPoll' key in 
the registry.






||

--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] EOF problem

2010-04-18 Thread Les Hardy
Hi Ed, After many tries, I managed to recreate your problem.
It happens with your code and the code supplied by Dimitris.
I am using Ubuntu 9.04, Kernel 2.6.28-18, Gambas 2.20.2, QT

I have not managed to figure out the cause yet.

I will do more tests and get back to you.


Regards
Les Hardy


Ed  Clare Kelm wrote:
 Hi!

 I'm having a problem reliably reading a text file.

 I am using:

 Panasonic CF-51 Toughbook
 Ubuntu 9.04 , Kernel 2.6.28-18
 Gambas 2.8, QT

 Below is the code for a test program which demonstrates the problem.  
 This is a simple form, with one button, and one label. The only code is 
 the Button1_click event shown.  The file testdat.txt contained in 
 Fname is a text file with one short line of text, created with GEDIT.

 One would expect that clicking Button1 would open the file, read the 
 line of text, and place it into label1.  Indeed, this is exactly what 
 happens roughly 4 times out of 5.  However, sometimes the file comes up 
 empty, with an immediate EOF.  When the program is first started from 
 the IDE, if it works correctly the first time, it will do so every time 
 the button is clicked.  However, if it fails (indicates EOF) the first 
 time, it will fail everytime the button is clicked.  Stopping the 
 program and restarting it will roll the dice anew.  There does not seem 
 to be any pattern to the failure.  It might happen twice in a row, it 
 might not happen for 10 starts.

 Does anybody have any ideas?  Is this an Ubuntu issue?

 Thanks!

 Ed K.


 PUBLIC SUB Button1_Click()

DIM tfile AS File
DIM Fname AS String

Fname = /home/us/Documents/testdat.txt

tfile = OPEN Fname FOR READ

label1.Text = 

IF Eof(tfile) THEN
   label1.Text = EOF
ELSE
   LINE INPUT #tfile, label1.Text
END IF

CLOSE #tfile 

 END


   












--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] EOF problem

2010-04-18 Thread Les Hardy
Hi Ed,
I figured it out.
First of all, depending how the text file was emptied/created, the 
contents may not be truely empty.
Gedit for example leaves the 0A (end-of-line) character in the 'empty' 
file. This is recognised by eof() as a character, so, end-of-file is not 
found.
I am not sure if this can be considered a bug in Gambas, but it does 
mean an eof() is only good for preventing read errors, and is not 
reliable for testing if a file is empty.

The following code gets around the problem.
It's not ideal, but it does work. Maybe someone else can improve on it.
Regards
Les Hardy

PUBLIC SUB Button1_Click()

 DIM tfile AS File
 DIM Fname AS String
 DIM t, txt AS String

 Label1.text = 
 Fname = /home/les/Documents/testdat.txt
 tfile = OPEN Fname FOR READ
  
 IF NOT Eof(tfile) THEN
  LINE INPUT #tfile, t
  txt = IIf(Trim(t)  , t, EOF)
  Label1.text = txt
 ELSE
  Label1.text = EOF
   
 ENDIF
 CLOSE #tfile
END





Ed  Clare Kelm wrote:
 Hi!

 I'm having a problem reliably reading a text file.

 I am using:

 Panasonic CF-51 Toughbook
 Ubuntu 9.04 , Kernel 2.6.28-18
 Gambas 2.8, QT

 Below is the code for a test program which demonstrates the problem.  
 This is a simple form, with one button, and one label. The only code is 
 the Button1_click event shown.  The file testdat.txt contained in 
 Fname is a text file with one short line of text, created with GEDIT.

 One would expect that clicking Button1 would open the file, read the 
 line of text, and place it into label1.  Indeed, this is exactly what 
 happens roughly 4 times out of 5.  However, sometimes the file comes up 
 empty, with an immediate EOF.  When the program is first started from 
 the IDE, if it works correctly the first time, it will do so every time 
 the button is clicked.  However, if it fails (indicates EOF) the first 
 time, it will fail everytime the button is clicked.  Stopping the 
 program and restarting it will roll the dice anew.  There does not seem 
 to be any pattern to the failure.  It might happen twice in a row, it 
 might not happen for 10 starts.

 Does anybody have any ideas?  Is this an Ubuntu issue?

 Thanks!

 Ed K.


 PUBLIC SUB Button1_Click()

DIM tfile AS File
DIM Fname AS String

Fname = /home/us/Documents/testdat.txt

tfile = OPEN Fname FOR READ

label1.Text = 

IF Eof(tfile) THEN
   label1.Text = EOF
ELSE
   LINE INPUT #tfile, label1.Text
END IF

CLOSE #tfile 

 END


   


--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Did anybody try to run stepper motors through paralel port

2010-04-18 Thread Les Hardy
Doriano Blengino wrote:
 Les Hardy ha scritto:
   
 Zelimir Ikovic wrote:
   
 
 I have VB6 program that run CNC plasma machine. It work very well and 
 smooth under win200, but in WinXP machine motion is not good. 

 It doesnot help if I set REALTIME prority for the process ...

 How about Linux and Gambas? Daes it depent on version of Linux ...

 What is resolution for Gambas Timer? Can I wait 10 microsec do something 
 wait 10 microsec and so on ...

 Regards
 
   
 Uhm... under linux, no matter what version, you can use the parallel 
 port and high resolution timers, but... 10 us? What is the speed of your 
 motor(s)?
 Anyway, I see it difficult to do it in gambas, mainly because of tight 
 GUI integration and impossibility to use interrupts; the best way would 
 be to separate hi-level logic from lo-level timing, perhaps through a 
 library written in C.

   
Yes, I agree. I did a lot of work with parallel ports in the past, but I 
would not attempt a serious application for that job in Gambas.

Since I retired, I have been building my own hobby CNC machines, but I 
just use EMC2. It is GPL, and very efficient, so I figured I had no need 
to write my own app.

Les Hardy






--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] EOF problem

2010-04-18 Thread Les Hardy
Doriano Blengino wrote:
 Les Hardy ha scritto:
   
 Hi Ed,
 I figured it out.
 First of all, depending how the text file was emptied/created, the 
 contents may not be truely empty.
 Gedit for example leaves the 0A (end-of-line) character in the 'empty' 
 file. This is recognised by eof() as a character, so, end-of-file is not 
 found.
 I am not sure if this can be considered a bug in Gambas, but it does 
 mean an eof() is only good for preventing read errors, and is not 
 reliable for testing if a file is empty.
   
 
 Just breaking in to say that a file with a EOL in it is not an empty 
 file - it is a file with an empty line in it...
 Given such a file, at first EOF is false; doing a LINE INPUT an empty 
 line is read, then EOF turns true. Or, at least, it should go this way.

 Regards,

   
Your correct, I agree completely, but the original code Ed supplied, ' 
IF Eof(tfile) ' cannot work , as it checks eof before a read.
When I saw he was using eof() that way, and knowing empty files are not 
always empty, I thought I had found his problem, so I just added a bit 
of code that should have got around it.

I am sure you will agree, that, whatever other problems he may have,  he 
needs not to use eof() the way he is.

Regards
Les Hardy





--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] static const?

2010-04-15 Thread Les Hardy
Charlie Reinl wrote:
 Am Donnerstag, den 15.04.2010, 19:28 +0200 schrieb Doriano Blengino:
   
 Jussi Lahtinen ha scritto:
 
 Back to gambas - I don't know if the documentation says anything about
 short-circuit and things like that. May be we can assume it as a
 standard, that modern languages always do short-circuit, but the concept
 remains.
 
 
  Gambas doesn't have short-circuits, you have to write like this:
  IF a=1 AND IF b=2 THEN

   
   
 Ah! Thanks. So, a statement like this:

 if itabstrip1.count and tabstrip1[i].caption=

 can fail, if I understand well. Perhaps I must check a few lines of code...

 Regards,
 Doriano
 

 Salut,

 I'v never done it like that (IF a=1 AND IF b=2 THEN), are you sure ? 
   
Yes, It is clearly there in the manual.

*IF* _Expression_ [ { *AND IF* | *OR IF* } _Expression_ ... ] [ *THEN* ]
  ...
[ *ELSE IF* _Expression_ [ { *AND IF* | *OR IF* } _Expression_ ... ] [ *THEN* ]
  ... ]
[ *ELSE*
  ... ]
*ENDIF*



--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] static const?

2010-04-14 Thread Les Hardy


 The C language, in facts, does not even have CONSTs - it goes with 
 #define. So, it would be correct to forbid STATIC when declaring CONSTs.
Surely this is not correct. ANSI C uses const, and C++ also uses the 
const keyword.
#define (a preprocessor directive) is a relic from old C, and const is 
now recommended use instead.

Also, it would be correct to use static with const, the line below would 
be correct use.

static const int daysPerMonth[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31};


Having said that, The original question was not about C,  I think Fabian 
was simply asking about the scope of constants in classes (in Gambas)


Regards
Les Hardy

--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] static const?

2010-04-14 Thread Les Hardy

If you feel hurt I am sorry for that, it was not my intention to hurt 
you, and I have no wish to prove you wrong.
I do still stand by my statement.

Regards
Les Hardy



Doriano Blengino wrote:
 Les Hardy ha scritto:
   

 
 The C language, in facts, does not even have CONSTs - it goes with
 #define. So, it would be correct to forbid STATIC when declaring CONSTs.
  
   
 Surely this is not correct. ANSI C uses const, and C++ also uses the
 const keyword.
 #define (a preprocessor directive) is a relic from old C, and const is
 now recommended use instead.

 
 Surely, according to http://www.ericgiguere.com/articles/ansi-c-summary.html
   
 The declaration:
  enum colours { RED, BLUE, GREEN };


 would declare colours as an enumeration tag representing the integer 
 constants RED, BLUE and GREEN. These enumeration constants are given 
 integer values starting at 0 and increasing by 1 with each identifier.

 An enumeration constant may be used wherever an integer is expected. 
 The following is equivalent to the above enumerated type:

  #define RED   0
  #define BLUE  1
  #define GREEN 2

 

 Moreover, from http://tigcc.ticalc.org/doc/keywords.html
   
 _const_

 *Makes variable value or pointer parameter unmodifiable.*

 When |const| is used with a variable, it uses the following syntax:

 const/variable-name/  [ =/value/];


 In this case, the |const| modifier allows you to assign an initial 
 value to a variable that cannot later be changed by the program. For 
 example,

 const my_age = 32;


 Any assignments to |'my_age'| will result in a compiler error. 
 However, such declaration is quite different than using

 #define my_age 32

 In the first case, the compiler allocates a memory for |'my_age'| and 
 stores the initial value 32 there, but it will not allow any later 
 assignment to this variable. But, in the second case, all occurences 
 of |'my_age'| are simply replaced with 32 by the preprocessor 
 http://tigcc.ticalc.org/doc/cpp.html, and no memory will be 
 allocated for it.
 

 You perhaps refer to const modifier, which is different from declaring 
 a constant, like in
   
 public:
 WinEDA_VertexCtrl( wxWindow* parent, const wxString title,
wxBoxSizer* BoxSizer, int units, int 
 internal_unit );
 

   
 Also, it would be correct to use static with const, the line below would
 be correct use.

 static const int daysPerMonth[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

 
 In this case - talking about C and not C++:
   
 |static| tells that a function or data element is only known within 
 the scope of the current compile. In addition, if you use the |static| 
 keyword with a variable that is local to a function, it allows the 
 last value of the variable to be preserved between successive calls to 
 that function. 
 
 const says that data is not modifiable, so static would say the same 
 thing. Note also the ambiguity of the keyword when applied to data 
 global to a module, and data local to a function - the same keyword does 
 two very different things.

   
 Having said that, The original question was not about C,  I think Fabian
 was simply asking about the scope of constants in classes (in Gambas)

 
 Uhm... is it forbidden to cite other languages to better explain a 
 concept? So why you cited C++?

 Anyway, you are right, the original question was about scope. In gambas 
 scope is governed by PRIVATE and PUBLIC. Full stop.

 If you feel that my reply is a little hurting, excuse me; it is because 
 your reply seemed hurting to me. Prove to me that I am wrong and I will 
 publicly apologize.

 Regards,
 Doriano

   


--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] htonl equal

2010-04-12 Thread Les Hardy


I guess *gb.BigEndian* and *gb.LittleEndian* are what you are looking for.
*System.ByteOrder* will return the endianness of the operating system.


Regards
Les Hardy




Mohammad Razeghi wrote:
 Hi

 I am looking for c++ htonl function equal in gambas can any one help please
 ?

 Thanks ...
 --
 Download Intel#174; Parallel Studio Eval
 Try the new software tools for yourself. Speed compiling, find bugs
 proactively, and fine-tune applications for parallel performance.
 See why Intel Parallel Studio got high marks during beta.
 http://p.sf.net/sfu/intel-sw-dev
 ___
 Gambas-user mailing list
 Gambas-user@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/gambas-user

   


--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] htonl equal

2010-04-12 Thread Les Hardy

You can use htonl/ntohl from external libs.
A very quick example below. Please correct me if I got it wrong.

' Gambas module file
PUBLIC EXTERN htonl(ln AS Long) AS Long IN libc:6
PUBLIC EXTERN ntohl(ln AS Long) AS Long IN libc:6

PUBLIC SUB Main()
DIM ln, lh AS Integer

ln = 1193046

PRINT Input:   ln
PRINT Input (hex):   Hex(ln, 8)

lh = htonl(ln) ' to BigEndian
PRINT BigEndian:   lh
PRINT BigEndian (hex):   Hex$(lh, 8)

ln = ntohl(lh) ' back to LittleEndian
PRINT LittleEndian:   ln
PRINT LittleEndian (hex):   Hex$(ln, 8)
END



Regards
Les Hardy





Mohammad Razeghi wrote:
 Hi

 I am looking for c++ htonl function equal in gambas can any one help please
 ?

 Thanks ...
   


--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Parallel Port

2010-04-08 Thread Les Hardy

Hi there, I don't have a program to offer you. All my old code is in 
other languages.
I did however write a little working example for you.
You will need to use port, not parport0.
For some reason that is unknown to me, I too, am unable to get parport 
to work correctly from gambas.

I tested the code below, and it does work. I ran it a few times on a 
system with Ubuntu 9.04, gambas 2.20, and a little parallel port tester 
I made 20 years ago.

Unless you have already sorted out permission to access 'port', you will 
need to be root to run it, either start gambas as root, or compile it 
and then run the executable as root.

PUBLIC SUB Main()
' Gambas module file
DIM pport AS File
DIM bi, bo AS Byte

pport = OPEN /dev/port FOR READ WRITE

FOR bo = 32 TO 122
  SEEK #pport, 888
  WRITE #pport, bo
  SEEK #pport, 888
  READ #pport, bi
  PRINT Chr(bi)   
  WAIT 0.05
NEXT
 CLOSE #pport

END

Just a quick mention about seek on ports.
Seek simply takes you to the port address. Notice I used a seek before 
each read or write.

888  (0x378): Data
889  (0x379): Status
890  0x37A) : Control



Hope this helps
Regards
Les Hardy


Bjorn Macintosh wrote:
 Hi all,

 Does anyone have a program that interfaces with the parallel port, one
 written in Gambas.  If you do would you be willing to share this program
 with me as I am trying to write a parallel port interface and am struggling
 to get my head around a few concepts.  mainly how to write to the port and
 how to select pin's base 0 base1 and base2.

 Any help would be greatly appreciated.  I sent a post two days ago holding
 the full details on my program and what I am trying to do if you  need any
 clarification.

 Thanks
 Bjorn Macintosh

   


--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] LostFocus() not working on ubuntu !

2010-03-13 Thread Les Hardy
zolaysoftsolutions wrote:
 Hi!

I wish to inform you that I have same problem with lostfocus().
 I has installed Gambas 2.7 and lostfocus works okay, but yesterday I made an
 upgrade to 2.20 and lostfocus() is executed when the project is start to
 run, after
 this moment is not executed anymore.
   After this experiment with my old proiect, I made a new small one and
 lostfocus() is not
 working with textbox and valuebox! 

 Regards,

 Zoli B.



 Fabien Bodard-4 wrote:
   
 i think you need to try with the same version too on suse !

 Le 13 mars 2010 00:19, Benoît Minisini gam...@users.sourceforge.net a
 écrit :
 
 the (textbox) LostFocus() routine is working on Opensuse (with Gambas
 2.17) but not on Ubuntu (with Gambas 2.19)!
 The same components of Gambas are loaded on both PCs!
 gb, gb.db, gb.db.form, gb.form, gb.image, gb.net, gb.qt, gb.qt.ext,
 gb.vb.
 
 Several differences are mixed (version and distribution), so it is hard
 to
 guess where the problem comes from!

 Is it possible for you to write a little project that isolates the
 problem? A
 little project with a LostFocus() that works on OpenSuSE with Gambas
 2.17, and
 not on Ubuntu with Gambas 2.19.

 Regards,

 --
 Benoît Minisini

   
I am using Gambas 2.20 on Ubuntu 9.04.
Lostfocus() works fine for me.
I tested on TextBox, TextArea, ListBox, GridView, SpinBox

Les Hardy




--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Currency and addition/subtraction

2010-03-12 Thread Les Hardy
Keith Clark wrote:
 I have a TableView object and have imported some data into it that is
 formatted as currency.  How can I know take that and add it to a Float
 variable?

 Keith



   
dim cur as string = £
dim floatvar as float

floatvar = Val(Replace(TableView1[TableView1.row, 1].Text, cur, ))


--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] TableView.text conversion

2010-03-12 Thread Les Hardy
Keith Clark wrote:
 I have input a value into a TableView cell, and now I want to read it.
 The problem is that I want to read it as a text string.  The 'number' is
 actually an ISBN code.  It can sometimes be a string, as it can contain
 an 'X' or a 10 digit number, but starting with a 0.

 For example, 0123456789, 1234567891, and 012345678X are all valid values
 for the cell.

 So, when the cell value is say 0123456789 and I convert it with str$, I
 get 123456789, the zero is dropped.  Is there an easy way around this or
 do I have to check the leading character each time for a '0'?

 Thanks,

 Keith

   
Hi Keith, Since Jan 2007 ISBN numbers have been 13 digits and should 
consist of 5 parts with each section being separated by spaces or hyphens.
Because of this, your ISBN numbers will always be stored and displayed 
as strings.
There is no conversion needed.


--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] TableView.text conversion

2010-03-12 Thread Les Hardy
Keith Clark wrote:
 Les,

 Thanks, but I found that that was not actually my problem.  The problem
 showed up in sending data to a field in my database.  I just forgot to
 surround the field with single quotes!  Sometimes the simplest problem
 is hard to see!

 Keith

   
Yes, if its a string it will be ok.
I have some very simple gambas code for a 10 to 13 digit conversion, if 
it is of any use to you.

Regards
Les


--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Ambiguous expression?

2010-03-10 Thread Les Hardy
Benoît Minisini wrote:
 Alessandro Rinaldi ha scritto:
 
 I really think yes.
 Standard symbol for fractions is /, why should you use \?
   
 Backslash is integer division, and should yeld an integer result.
 Slash is float division, and yelds a float number (this is Basic
 syntax; other languages use different methods).

 The expression 1\2*3 is not really ambiguous, it is only for Gambas
 (don't ask me why); it should be seen as take an integer number,
 integer-divide it for another integer number, and multiply the result
 for another integer number, giving an integer result.

 About integer division, there are other reasons apart from wanting an
 *integer* division: for example is faster.

 Regards,
 Doriano

 

 I noticed that operator evaluation order differ between languages, even if 
 they agree on most parts.

 So I decided to raise an error when the compiler encounters different 
 operators having the same evaluation order weight, and when I thought that 
 the 
 interpreter may not do what the user thinks.

 By compelling the user to add brackets, I make the source code less ambiguous 
 for another reader, so this is a good thing.

 But the test is not perfect, and I don't remember why I do not raise the 
 error 
 for 1/2*3 and I raise it for 1\2*3.

 Maybe because that mixing * and / is usual in mathematics, but mixing an 
 integer division with a normal multiplication not, and I wanted to force the 
 use of brackets.

 Morever, that error is actually just a warning. I can suppress it, and Gambas 
 will just apply its operator evaluation order without telling anything. But I 
 don't think I will do it!

 Regards,

   
You are correct to not suppress it. The warning is correct.
The actual value of the numbers is not important.
The expression is ambiguous without the brackets.
 5 \ (2 * 3) = 0
 (5 \ 2) * 3 = 6

This is also ambiguous
5/2*3

 5 / (2 * 3) = 0.8333
 (5 / 2) * 3 = 7.5

Regards
Les Hardy



--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Property expand in Tabstrip

2010-03-06 Thread Les Hardy
craf wrote:
 Hi.

 How can I set a textbox to the width of a tastrip?.The property does not
 expand.

 Regards


   
I assume the tabstrip is arrange by the form.
With TextBox1 in TabStrip1

PUBLIC SUB Form_Arrange()
  TextBox1.Move(5, TextBox1.top, TabStrip1.width - 10, TextBox1.height)
END

Regards
Les Hardy

--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Property expand in Tabstrip

2010-03-06 Thread Les Hardy
craf wrote:
 Hi.

 How can I set a textbox to the width of a tastrip?.The property does not
 expand.

 Regards


   
You can also do it directly on the tabstrip...

PUBLIC SUB TabStrip1_Arrange()

  TextBox1.Move(5, TextBox1.top, TabStrip1.width - 10, TextBox1.height)

END

Les Hardy

--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Shell sudo

2009-12-24 Thread Les Hardy

sudo allows you to pass a password to the shell with -S
The following should do it.

sudo -S apt-get install PACKAGENAME  EOF
PASSWORD
EOF


Regards
Les Hardy


M. Cs. wrote:
 I'd like to make my app able to download and install packages via apt-get
 (or any other command-line package manager). How can I do that? I know it
 will need the user's password but how can I pass the command?
 The simple SHELL sudo apt-get install ... won't do the thing!
 Thanks!
 --
 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] 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


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] 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 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


Re: [Gambas-user] Really dumb question about dialog forms

2009-12-11 Thread Les Hardy
richard terry wrote:
 On Friday 11 December 2009 17:22:54 you wrote:
 2009/12/11 richard terry rte...@pacific.net.au:
 Hi List,

 My really stupid question for the week.
 I'm sorry. You've already done that three times this week.

 If I had a textbox on the form and wanted to return its contents, what
 would be the change in syntax required?
 None whatsoever.

 Create a public variable in a common module. Set the variable from
 within your modal form and read it from somewhere else, such as the
 code that called the form, for example.

 Thanks in anticipation.
 I'll send you the bill.

 I've already done that and its the method I use, so no $ accrue to you, 
 however I wondered if there was  way of returning it via the modal form.


Forgive my stupidity, but I must be missing something here. I don't
understand the problem.
My understanding is that when form controls are set public, you just
access the contents of any form from the form you are in. Modal or not.
Or have I been doing it wrong?


Sorry, I get it now. No export from Dialog.




--
Return on Information:
Google Enterprise Search pays you back
Get the facts.
http://p.sf.net/sfu/google-dev2dev
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Really dumb question about dialog forms

2009-12-11 Thread Les Hardy
richard terry wrote:
 On Friday 11 December 2009 17:22:54 you wrote:
 2009/12/11 richard terry rte...@pacific.net.au:
 Hi List,

 My really stupid question for the week.
 I'm sorry. You've already done that three times this week.

 If I had a textbox on the form and wanted to return its contents, what
 would be the change in syntax required?
 None whatsoever.

 Create a public variable in a common module. Set the variable from
 within your modal form and read it from somewhere else, such as the
 code that called the form, for example.

 Thanks in anticipation.
 I'll send you the bill.

 I've already done that and its the method I use, so no $ accrue to you, 
 however I wondered if there was  way of returning it via the modal form.


Forgive my stupidity, but I must be missing something here. I don't 
understand the problem.
My understanding is that when form controls are set public, you just 
access the contents of any form from the form you are in. Modal or not.
Or have I been doing it wrong?



--
Return on Information:
Google Enterprise Search pays you back
Get the facts.
http://p.sf.net/sfu/google-dev2dev
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Cliboard-Problem

2009-12-10 Thread Les Hardy
Norarg wrote:
 Hi,
 
 I have a problem with the clipboard,
 using ubuntu 9.10, gambas 2.13
 
 following code works ONE time:
 
 PUBLIC SUB CLIP_B_Click()
   DIM S AS String
   DIM I AS Integer
   DIM TR AS Result
   TR = M.ReadRecord(OPVDM!tabelle, OPVDM!TBID, OPVDM!TBIDWert)
   IF TR.Count = 0 THEN
 Message.Info(Daten nicht gefunden, Ok)
 RETURN
   ENDIF
   Clipboard.Clear
   S = Datenausgabe   OPVDM!betreff  CRLF
   S = S  String(75, _)  CRLF
   S = S  Left(Feld  String(25,  ), 25)  Left(Wert  String(40, 
  ), 40)  Datentyp  CRLF
   S = S  String(75, _)  CRLF
   OPVDF.MoveFirst
   TR.MoveFirst
   FOR I = 1 TO OPVDF.Count
 S = S  Left(OPVDF!feldbezeichnung  String(25,  ), 25)
 S = S  Left(TR[OPVDF!feldname]  String(50,  ), 40)
 S = S  OPVDF!feldtyp  CRLF
 OPVDF.MoveNext
   NEXT 
   S = S  String(75, _)  CRLF
   Clipboard.Copy(S)
 END
 
 I am sure there is no data-problem, the print of S is ok.
 The second time I call this procedure, I get a message in the direct-window:
 
 *QClipboard: cannot transfer data, no data available
 *
 I hope someone can help me with this. Oh, I also tried the following, to 
 get sure nothing is wrong with the string (removed all data):
 
 PUBLIC SUB CLIP_B_Click()
   DIM S AS String
   Clipboard.Clear
   S = Datenausgabe   CRLF
   S = S  String(75, _)  CRLF
   S = S  Left(Feld  String(25,  ), 25)  Left(Wert  String(40, 
  ), 40)  Datentyp  CRLF
   S = S  String(75, _)  CRLF
   S = S  String(75, _)  CRLF
   Clipboard.Copy(S)
 END
 
 CRLF ist just CHR(10)
 
 Same error.
 
 Thanks in advance
 

Just put a WAIT after Clipboard.Clear and it will be ok.

Clipboard.Clear
WAIT


Regards
Les Hardy


--
Return on Information:
Google Enterprise Search pays you back
Get the facts.
http://p.sf.net/sfu/google-dev2dev
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Serial port data being changed ????

2009-12-09 Thread Les Hardy
Benoît Minisini wrote:

 
 I'm not a serial port user at all, and I find that behaviour a bit strange.
 
 Would it be useful to make a property for that? Or maybe it does already 
 exist 
 in the SerialPort class, and I didn't see it.
 

Nothing strange really. Its been like that as long as I can remember.
It is not possible to tranfer binary data correctly without setting the
icrnl and ocrnl flags off.

Its been a long time since I was near C, but I'm fairly sure they are
included in termios.h, and are the c_iflag and c_oflag.

(sent this twice. mail is bouncing back)








--
Return on Information:
Google Enterprise Search pays you back
Get the facts.
http://p.sf.net/sfu/google-dev2dev
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Serial port data being changed ????

2009-12-08 Thread Les Hardy


mike wrote:
 I'm having trouble with Gambas and the serial ports.
 Something is changing binary h0d to h0a when received
 from a serial port. I noticed it in a program that I've
 been working on that receives packets of binary data
 from a microprocessor. I wrote a little test program to
 demonstrate the problem and have included it below. I also
 reprogrammed the micro to simply send h0d as long a
 pushbutton is held depressed. I have verified that the
 correct data is indeed being sent using CuteCom to display
 the binary data.
 An interesting thing that I noticed when I ran CuteCom to
 test the data being received is that if I close CuteCom without
 closing the serial port first then run my Gambas program, it works
 fine until I restart the system. If I close the port before closing
 CuteCom then my Gambas program fails.
 
 
 This is the code for the test program.
 
 ' Gambas class file
 ' Using Gambas 2.18 on a system running
 ' Fedora Kernel (26.30.9-102.fc11.x86_64)
 ' It also fails running Gambas 2.11
 ' on my laptop running
 ' Fedora Kernel (2.6.27.25-78.2.56.fc9.i686)
 
 PUBLIC SUB Form_Open()
 
ME.Center
 
 ' Setup the serial port - 9600,8,N,1
 
 '  SerPort1.PortName = /dev/ttyS0 ' Both ports fail
SerPort1.PortName = /dev/ttyUSB0' This the port I'll eventually use
SerPort1.Speed = 9600   ' because the laptop has no 
 serial port.
SerPort1.DataBits = 8
SerPort1.Parity = 0
SerPort1.StopBits = 1
SerPort1.Open
 
TextArea1.Text = SerPort1.PortName  Chr$(10)
 END
 
 PUBLIC SUB SerPort1_Read()
 
 ' A microprocessor is connected to the serial port and
 ' continuously sends h0d (CR) as long a push button is held down.
 
 DIM InByte AS Byte
 
READ #SerPort1, InByte
TextArea1.Insert(Hex$(InByte)   )
 ' The textarea displays a series of A  (LF) instead of D  (CR)
 END
 
 PUBLIC SUB ExitBtn_Click()
 
SerPort1.Close
QUIT
 END
 
 PUBLIC SUB ClearBtn_Click()
 
TextArea1.Clear
 END



This is a Linux thing. Not Gambas. The icrnl flaf is set as standard.
Easiest way is to use stty to change it.

SHELL stty -F   SerPort1.PortName   -icrnl



--
Return on Information:
Google Enterprise Search pays you back
Get the facts.
http://p.sf.net/sfu/google-dev2dev
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Serial port data being changed ????

2009-12-08 Thread Les Hardy
Kadaitcha Man wrote:
I first have to figure out if icrnl flaf is a typo or an esoteric 
command line :)
 
Yes, esoteric, makes me feel special. Only a few know about flafs.

Then again, it could just be flag.


--
Return on Information:
Google Enterprise Search pays you back
Get the facts.
http://p.sf.net/sfu/google-dev2dev
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user