[Gambas-user] RE: Gambas-user Digest, Vol 37, Issue 42

Steven James Drinnan steven at ...2097...
Thu Jun 25 10:04:55 CEST 2009


Part one loading multiple text boxes.

there is no simple way but there is this

you can go through all the controls of a form and see if is a text box.

Example:

You need one form, create 10 text boxes and one button rename the text
boxes to txt01 txt02 ..... txt10 this is important so the program can
keep track 

double click the button and put this code in it

  DIM mycontrol AS Object
  DIM mytxtbox AS TextBox
  DIM sname AS NEW String[10]
  DIM i AS Integer
  DIM ctrlNumber AS Integer
  
  'add some data to the string
  FOR i = 65 TO 74
    sname[i - 65] = Chr(i) 'this is just to fill data
  NEXT 
  
  'find each control and check it's type
  FOR EACH mycontrol IN ME.Controls
    IF mycontrol IS TextBox THEN 
      
      mytxtbox = mycontrol
      ctrlNumber = Val(Right(mytxtbox.Name, -3)) 'returns the number
part 3 being the length of the text
      mytxtbox.Tag = sname[ctrlNumber - 1] 'needs to be one less because
of the array numbering you could just number your text boxes from 00
though.
      mytxtbox.Text = sname[ctrlNumber - 1]
      i = i + 1
    END IF
    
  NEXT 
END

Or just look at the example.


By the way a tag on a control is a variant object type and therefore can
contain anything. 

As for part 2, does any else know? To my knowledge that is limitation of
Gambas sorry.

On Wed, 2009-06-24 at 23:39 -0700, sktan007 at ...43... wrote:
> Dear Sir,
> Thank you for Mr. Steven solve my problem, my program can work now!!!
> But I've another two problem, the first is that I've a input form , there is
> ten textbox belong to a group, I wish to initial the the ten textbox by a string
> array, like this
> dim sName[10] as string
> dim i as integer
> ..
> ..
> ..
> for i = 0 to 9
>           textBox[i].tag.text = sName[i]
> next
> How do I write it ?, the tag can't work here.
> The second is about string define style, usually we define a string array like 
> that,  
> public ss as string[] = ["jjk", "000", "hjkh", "y9879"]
> if there is just a little string element, It can work normally, but if I've 50 or 100
> string to initial the array, the program become hard to write, like this
> public ss as string[] = ["jkl||", "uoiu", "rew", "tw", "vvvc", "trt||", "uiou", "qe09", "jkfl;", "r8dvh"......"jkljl=u9r"]
> Gambas can't write to the next line, just write to one line, If there is something
>  wrong,
> it hard to edit. I can write it like this
> public ss[100] as string
> ss[0] = "lkjl"
> ss[1] = "j8r"
> ss[2] = "mn"
> ..
> ..
> ..
> -.
> ..
> ss[50] = "4ioj"
> ..
> ..
> ..
> ss[99] = "4nlk"
> This style can work, but it is very stupid, How do I wirte it smart ?
> Thank you
> 
> -- 09/6/24 (三),gambas-user-request at lists.sourceforge.net <gambas-user-request at lists.sourceforge.net> 寫道:
> 
> 寄件者: gambas-user-request at lists.sourceforge.net <gambas-user-request at lists.sourceforge.net>
> 主旨: Gambas-user Digest, Vol 37, Issue 42
> 收件者: gambas-user at lists.sourceforge.net
> 日期: 2009年6月24日,三,下午8:09
> 
> Send Gambas-user mailing list submissions to
>     gambas-user at lists.sourceforge.net
> 
> To subscribe or unsubscribe via the World Wide Web, visit
>     https://lists.sourceforge.net/lists/listinfo/gambas-user
> or, via email, send a message with subject or body 'help' to
>     gambas-user-request at lists.sourceforge.net
> 
> You can reach the person managing the list at
>     gambas-user-owner at lists.sourceforge.net
> 
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Gambas-user digest..."
> 
> 
> Today's
>  Topics:
> 
>    1. Swee Kwang Tan: postgresql (Steven James Drinnan)
>    2. Charlie Reinl: postgresql (sorry wrong name)
>       (Steven James Drinnan)
>    3. Format$ with different LANG (Pino Zollo)
>    4. Tar-1.3 for Slackware (Pino Zollo)
>    5. Re: Format$ with different LANG (Beno?t Minisini)
>    6. Access a property via string (Introspection like)
>       (Juan Jose Costello Levien)
>    7. Re: Access a property via string (Introspection like)
>       (Beno?t Minisini)
>    8. Re: Tar-1.3 for Slackware (Stefano Palmeri)
> 
> 
> ----------------------------------------------------------------------
> 
> Message: 1
> Date: Wed, 24 Jun 2009 09:33:35 +0800
> From: Steven James Drinnan <steven at ...2097...>
> Subject: [Gambas-user] Swee Kwang Tan: postgresql
> To: mailing list for gambas users <gambas-user at lists.sourceforge.net>
> Message-ID: <1245807217.2966.71.camel at ...2011...>
> Content-Type: text/plain
> 
> Hi, 
> 
> What is exactly happening. I use F11 and running gambas2.13.1 
> 
> As I never used postgresql before I prefer mysql but never mind.
> 
> I tried to use the example "Picture Database' and changed to postgresql
> by opening the main forms code and uncommenting the postgresql part.
> 
> It did not work - but I realized that postgresql was not installed.
> 
> So I installed postgresql and postgresql server
>  by
> 
> su
> yum install postgresql postgresql-server
> 
> then once installed i ran 
> code:
>     chkconfig postgresql on
>     service postgresql initdb
>     service postgresql start
> endcode:
> 
> to make sure it was started i ran
> service postgresql restart
> 
> I ran the example again but still no luck, but after some digging I
> found this.
> 
> Need to change this file to 'trust'
> 
> as su
> code:
>     gedit /var/lib/pgsql/data/pg_hba.conf
> end code:
> 
> find this section 
> 
> # TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD
> 
> # "local" is for Unix domain socket connections only
> local   all         all                               ident
>  sameuser
> # IPv4 local connections:
> host    all         all         127.0.0.1/32          ident sameuser
> # IPv6 local connections:
> host    all         all         ::1/128               ident sameuser
> 
> and change ident to trust like so
> 
> # TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD
> 
> # "local" is for Unix domain socket connections only
> local   all         all                               trust sameuser
> # IPv4 local connections:
> host    all         all     
>     127.0.0.1/32          trust sameuser
> # IPv6 local connections:
> host    all         all         ::1/128               ident sameuser
> 
> 
> Restart postgresql
> code:
>  service postgresql restart
> end code:
> 
> I tried again and now I can connect.
> 
> So have a look at your setup. Fedora may have the rpm packages set up
> wrong but they do all work i.e they are complete. Just make sure you
> have the gambas db component installed
> 
> Tell me how you get on.
> 
> Steven
> 
> 
> 
> 
> 
> 
> 
> 
> On Tue, \
> 2009-06-23 at 13:01 +0200, Charlie Reinl wrote:
> > Am Dienstag, den 23.06.2009, 03:25 -0700 schrieb Swee Kwang Tan:
> > > fedora 11
> > 
> > Salut, 
> > 
> > I do not know where fedora 11 stores its' gambas lib files
> >
>  (normaly /usr/local/lib/gambas<VERSION>)
> > nor witch gambas version you use ?
> > 
> > but look at your box if this files or links  :  
> >     gb.db.postgresql.component
> >     gb.db.postgresql.la
> >     gb.db.postgresql.so -> gb.db.postgresql.so.0.0.0
> >     gb.db.postgresql.so.0 -> gb.db.postgresql.so.0.0.0
> >     gb.db.postgresql.so.0.0.0
> > 
> > If not you can not open a postgresql DB.
> > 
> 
> 
> 
> 
> ------------------------------
> 
> Message: 2
> Date: Wed, 24 Jun 2009 09:35:08 +0800
> From: Steven James Drinnan <steven at ...2097...>
> Subject: [Gambas-user] Charlie Reinl: postgresql (sorry wrong name)
> To: mailing list for gambas users <gambas-user at lists.sourceforge.net>
> Message-ID: <1245807310.2966.72.camel at ...2011...>
> Content-Type: text/plain
> 
> Hi, 
> 
> What is exactly happening. I use F11 and running gambas2.13.1 
> 
> As I never used postgresql before I prefer mysql but never mind.
> 
> I tried to use the example "Picture Database' and changed to postgresql
> by opening the main forms code and uncommenting the postgresql part.
> 
> It did not work - but I realized that postgresql was not installed.
> 
> So I installed postgresql and postgresql server by
> 
> su
> yum install postgresql postgresql-server
> 
> then once installed i ran 
> code:
>     chkconfig postgresql on
>     service postgresql initdb
>    
>  service postgresql start
> endcode:
> 
> to make sure it was started i ran
> service postgresql restart
> 
> I ran the example again but still no luck, but after some digging I
> found this.
> 
> Need to change this file to 'trust'
> 
> as su
> code:
>     gedit /var/lib/pgsql/data/pg_hba.conf
> end code:
> 
> find this section 
> 
> # TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD
> 
> # "local" is for Unix domain socket connections only
> local   all         all                               ident sameuser
> # IPv4 local connections:
> host    all         all         127.0.0.1/32          ident sameuser
> # IPv6 local
>  connections:
> host    all         all         ::1/128               ident sameuser
> 
> and change ident to trust like so
> 
> # TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD
> 
> # "local" is for Unix domain socket connections only
> local   all         all                               trust sameuser
> # IPv4 local connections:
> host    all         all         127.0.0.1/32          trust sameuser
> # IPv6 local connections:
> host    all         all     
>     ::1/128               ident sameuser
> 
> 
> Restart postgresql
> code:
>  service postgresql restart
> end code:
> 
> I tried again and now I can connect.
> 
> So have a look at your setup. Fedora may have the rpm packages set up
> wrong but they do all work i.e they are complete. Just make sure you
> have the gambas db component installed
> 
> Tell me how you get on.
> 
> Steven
> 
> 
> 
> 
> 
> 
> 
> 
> On Tue, \
> 2009-06-23 at 13:01 +0200, Charlie Reinl wrote:
> > Am Dienstag, den 23.06.2009, 03:25 -0700 schrieb Swee Kwang Tan:
> > > fedora 11
> > 
> > Salut, 
> > 
> > I do not know where fedora 11 stores its' gambas lib files
> > (normaly /usr/local/lib/gambas<VERSION>)
> > nor witch gambas version you use ?
> > 
> > but look at your box if this files or links  :  
> >    
>  gb.db.postgresql.component
> >     gb.db.postgresql.la
> >     gb.db.postgresql.so -> gb.db.postgresql.so.0.0.0
> >     gb.db.postgresql.so.0 -> gb.db.postgresql.so.0.0.0
> >     gb.db.postgresql.so.0.0.0
> > 
> > If not you can not open a postgresql DB.
> > 
> 
> 
> 
> 
> ------------------------------
> 
> Message: 3
> Date: Wed, 24 Jun 2009 09:54:52 -0400
> From: Pino Zollo <pinozollo at ...626...>
> Subject: [Gambas-user] Format$ with different LANG
> To: mailing list for gambas users <gambas-user at lists.sourceforge.net>
> Message-ID: <200906240954.52914.pinozollo at ...626...>
> Content-Type: text/plain;  charset="us-ascii"
> 
> 
> For LANG="POSIX"
> 
> ? Format$(Val("14555888") / 1000, "#,###.000")
> 14,555.888
> 
> ....this is OK
> 
> LANG="es_ES.utf8" and for LANG="it_IT.utf8"
> 
> ? Format$(Val("14555888") / 1000, "#,###.000")
> 14 555,888
> 
> There is a space  where should be a . but I can cope with it
> 
> For LANG="ru_RU.utf8"  
> 
> ? Format$(Val("14555888") / 1000, "#,###.000")
> 14??555,888
> 
>   where ?? are 3F3F . These are not recognised as UTF-8 valid characters.
> 
> In my GAMBAS program actually the two "3F" are rapresented by squares.
> 
> ( http://www.qsl.nqt/zp4kfx/Linux/dblog.html )
> 
> Best regards
> 
> Pino
> -- 
> Key ID: 0xF6768208 
> Key fingerprint = B16D 0A7C 5B29
>  A334 CE6A  71F6 EAF8 3D88 F676 8208
> Key server: hkp://wwwkeys.eu.pgp.net
> 
> 
> 
> ------------------------------
> 
> Message: 4
> Date: Wed, 24 Jun 2009 10:19:31 -0400
> From: Pino Zollo <pinozollo at ...626...>
> Subject: [Gambas-user] Tar-1.3 for Slackware
> To: mailing list for gambas users <gambas-user at lists.sourceforge.net>
> Message-ID: <200906241019.31535.pinozollo at ...626...>
> Content-Type: text/plain;  charset="us-ascii"
> 
> Please where can I find tar-1.3 ?
> 
> yahoo and google did not find it.
> 
> It is required for generating the Slackware installation
>  package.
> 
> (Gambas 2.13 on Debian 5.0.1)
> 
> Regards
> 
> Pino
> -- 
> Key ID: 0xF6768208 
> Key fingerprint = B16D 0A7C 5B29 A334 CE6A  71F6 EAF8 3D88 F676 8208
> Key server: hkp://wwwkeys.eu.pgp.net
> 
> 
> 
> ------------------------------
> 
> Message: 5
> Date: Wed, 24 Jun 2009 16:45:08 +0200
> From: Beno?t Minisini <gambas at ...1...>
> Subject: Re: [Gambas-user] Format$ with different LANG
> To: pinozollo at ...626...,    mailing list for gambas users
>     <gambas-user at lists.sourceforge.net>
> Message-ID: <200906241645.09067.gambas at ...1...>
> Content-Type: Text/Plain;  charset="iso-8859-1"
> 
> > For LANG="POSIX"
> >
> > ? Format$(Val("14555888") / 1000, "#,###.000")
> > 14,555.888
> >
> > ...this is OK
> >
> > LANG="es_ES.utf8" and for LANG="it_IT.utf8"
> >
> > ? Format$(Val("14555888") / 1000, "#,###.000")
> > 14 555,888
> >
> > There is a space  where should be a . but I can cope with it
> >
> > For LANG="ru_RU.utf8"
> >
> > ? Format$(Val("14555888") / 1000, "#,###.000")
> > 14??555,888
> >
> >   where ?? are 3F3F . These are not recognised as UTF-8 valid characters.
> >
> > In my GAMBAS program actually the two "3F" are rapresented by squares.
> >
> > ( http://www.qsl.nqt/zp4kfx/Linux/dblog.html )
> >
> > Best regards
> >
> > Pino
> 
> On my Mandriva 2009, for es_ES.UTF-8, it_IT.UTF-8 and ru_RU.UTF-8 I get "14 
> 555,888".
> 
> Maybe this is a bug in the GNU spanish locale if you get a space whereas you 
> want a point. I'm not spanish, so I can't be sure.
> 
> And "3F3F" is a perfect valid UTF-8 byte sequence. It is actually ascii: "??"
> 
> -- 
> Beno?t
> 
> 
> 
> ------------------------------
> 
> Message: 6
> Date: Wed, 24 Jun 2009 13:41:43 -0300
> From: Juan Jose Costello Levien <jclevien at ...626...>
> Subject: [Gambas-user] Access a property via string (Introspection
>     like)
> To: mailing list for gambas users <gambas-user at lists.sourceforge.net>
> Message-ID: <1245861703.14499.84.camel at ...2222...>
> Content-Type: text/plain
> 
> Hello,
> 
> I want to set a property value using strings for, accesing a form, then
> a grid, then a cell inside the grid, the text property and finally set
> the value for it.
> 
> Here a wannabe code that obviously is failing to do the idea:
> 
> 
> PUBLIC SUB setMatrix(path AS String, dims AS Integer[], prop AS String,
> Valor AS String)
>   
>     ' Divido a path por los puntos
>     
>     DIM s AS String[]
>     DIM cad AS String
>     DIM c AS Control
>     DIM g AS GridView
>     DIM f AS Form
>     DIM o AS Object
>     DIM i AS Integer
> 
>     
>     s = Split(path, ".")
>     
>     
>  
>    IF s.Count = 0 THEN 
>         Message("Revisar argumentos")
>     END IF
> 
>     FOR i = 0 TO Windows.Count - 1
>         IF (Lower(s[0]) = Lower(Windows[i].Name)) THEN 
>             f = Windows[i]
>             EXIT 
>         END IF
>     NEXT 
>     
>     IF NOT IsNull(f) THEN 
>     
>         g = f[s[1]]
>     
>            
>         g.row = dims[0]
>         g.column = dims[1]
>         
>          
>     
>         Object.SetProperty(g.Current, prop, Valor)
>     END IF
>     
> 
>   
> END
> 
> As you can imagine, Gambas
>  stops on the "Object.SetProperty" line,
> complaining about that it cannot use the "virtual" class that g.Current
> belongs to.
> 
> I need this because the idea is to access in runtime to any
> object/property/method from outside gambas (for example, a Python
> script).
> 
> Any help would be greatly appreciated.
> 
> 
> 
> 
> -- 
> Juan Jose Costello Levien
> jclevien at ...626...
> 
> "Not good, not bad, only reasonable"
> "Ni bueno ni malo, solo razonable"
> 
> ASCII ribbon campaign ( )
>  against HTML e-mail   X
>                       / \
> 
> 
> 
> 
> 
> 
> ------------------------------
> 
> Message: 7
> Date: Wed, 24 Jun 2009 18:51:17 +0200
> From: Beno?t Minisini <gambas at ...1...>
> Subject: Re: [Gambas-user] Access a property via string (Introspection
>     like)
> To: jclevien at ...626...,    mailing list for gambas users
>     <gambas-user at lists.sourceforge.net>
> Message-ID: <200906241851.17948.gambas at ...1...>
> Content-Type: Text/Plain;  charset="iso-8859-1"
> 
> > Hello,
> >
> > I want to set a property value using strings for, accesing a form, then
> > a grid, then a cell inside the grid, the text property
>  and finally set
> > the value for it.
> >
> > Here a wannabe code that obviously is failing to do the idea:
> >
> >
> > PUBLIC SUB setMatrix(path AS String, dims AS Integer[], prop AS String,
> > Valor AS String)
> >
> >     ' Divido a path por los puntos
> >
> >     DIM s AS String[]
> >     DIM cad AS String
> >     DIM c AS Control
> >     DIM g AS GridView
> >     DIM f AS Form
> >     DIM o AS Object
> >     DIM i AS Integer
> >
> >
> >     s = Split(path, ".")
> >
> >
> >     IF s.Count = 0 THEN
> >         Message("Revisar argumentos")
> >     END IF
> >
> >     FOR i = 0 TO
>  Windows.Count - 1
> >         IF (Lower(s[0]) = Lower(Windows[i].Name)) THEN
> >             f = Windows[i]
> >             EXIT
> >         END IF
> >     NEXT
> >
> >     IF NOT IsNull(f) THEN
> >
> >         g = f[s[1]]
> >
> >
> >         g.row = dims[0]
> >         g.column = dims[1]
> >
> >
> >
> >         Object.SetProperty(g.Current, prop, Valor)
> >     END IF
> >
> >
> >
> > END
> >
> > As you can imagine, Gambas stops on the "Object.SetProperty" line,
> > complaining about that it cannot use the "virtual" class that
>  g.Current
> > belongs to.
> >
> > I need this because the idea is to access in runtime to any
> > object/property/method from outside gambas (for example, a Python
> > script).
> >
> > Any help would be greatly appreciated.
> 
> In the development version, you have an Assign() function that evaluates an 
> assignment expression. It allows you to do what you want.
> 
> -- 
> Beno?t
> 
> 
> 
> ------------------------------
> 
> Message: 8
> Date: Wed, 24 Jun 2009 22:08:58 +0200
> From: Stefano Palmeri <rospolosco at ...152...>
> Subject: Re: [Gambas-user] Tar-1.3 for Slackware
> To: pinozollo at ...626...,    mailing list for gambas users
>     <gambas-user at lists.sourceforge.net>
> Message-ID: <200906242208.58662.rospolosco at ...152...>
> Content-Type: text/plain;  charset="iso-8859-1"
> 
> Il mercoled? 24 giugno 2009 16:19:31 Pino Zollo ha scritto:
> > Please where can I find tar-1.3 ?
> >
> > yahoo and google did not find it.
> >
> > It is required for generating the Slackware installation package.
> >
> > (Gambas 2.13 on Debian 5.0.1)
> >
> > Regards
> >
> > Pino
> 
> I think you're talking about tar-1.13. It's still maintained 
> by Slackware because this is the version used to generate
> Slackware packages. It's still in current, even if Slackware is going to 
> change the package archiver. Anyway, you find the source here:
> 
> ftp://elektroni.phys.tut.fi/slackware-12.2/source/a/tar/
> 
> In order to use it, you have to apply the patch you find there, then 
> compile it and rename the tar executable as tar-1.13, because for
> sure you've already a tar installed on your system. I suggest, 
> you *don't* install tar-1.13, but only copy the renamed executable somewhere 
> in your PATH so Gambas can find it.
> 
> Ciao,
> 
> Stefano  
> 
> 
> 
> ------------------------------
> 
> ------------------------------------------------------------------------------
> 
> 
> ------------------------------
> 
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
> 
> 
> End of Gambas-user Digest, Vol 37, Issue 42
> *******************************************
> 
> 
> _______________________________________
>  辣茩妏蚚閉湮⺍講捇誥蚘眊 
>  http://cn.mail.yahoo.com 
> ------------------------------------------------------------------------------
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
-------------- next part --------------
A non-text attachment was scrubbed...
Name: txtboxexample.tar.gz
Type: application/x-compressed-tar
Size: 9522 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20090625/ccfc1f58/attachment.bin>


More information about the User mailing list