Re: [Gambas-user] external function freezes

2018-06-08 Thread Tobias Boege
On Fri, 08 Jun 2018, Demosthenes Koptsis wrote:
> Hello, i implemented a ptrace and waitpid external functions in order to
> read/write a memory address of a process.
> 
> i want to make a trainer for a game in gambas and i created a small program
> that reads and writes to a memory process.
> 
> The problem is that when i try to write to memory it freezes at waitpid
> line.
> 
> i attach the test program you have to 1) open it as root 2) run a process
> you want to hack and get the pid 3) scan memory with scanmem and locate an
> address you want to write. 4) run my test program and see it freezes.
> 
> Any help?
> 

Does the same code work in a C program? It seems like waitpid() is just what
you need to do after PTRACE_ATTACH, but anyway I'd say it's a good idea to
develop the low-level bits in C first, so that we're sure it's the translation
to Gambas which is faulty, and not the algorithm.

Three other remarks:

  * I'm certainly not running a random somebody's buggy program as root.
Can't you spawn a child process yourself and then use PTRACE_TRACEME
for debugging purposes? That shouldn't require root privileges.

  * You should also check return values of system calls.

  * THIS MAILING LIST IS DEPRECATED. USE THE NEW ONE: 
https://lists.gambas-basic.org/listinfo/user

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Format function changes date value

2018-05-19 Thread Tobias Boege
On Sat, 19 May 2018, George wrote:
> > CDate uses UTC and, without the time information in the string, it would
> store midnight. Format uses local time.
> 
> That is definitely part of the issue.  My local time is GMT-04, and here's
> what I get when specifying the time in my test:
> 
> Test date: 5/4/2018 03:59:00 Formatted: 05/03/18 Thu
> Test date: 5/4/2018 04:00:00 Formatted: 05/04/18 Fri
> 
> However, if I look at time in the results, the difference isn't exactly the
> offset:
> Test date: 5/4/2018 03:59:00 Formatted: 05/03/18 23:05:00  Difference:
> 4:54:00
> Test date: 5/4/2018 04:00:00 Formatted: 05/04/18 00:05:00  Difference:
> 3:55:00
> Test date: 5/4/2018 00:00:00 Formatted: 05/03/18 20:05:00  Difference:
> 3:55:00
> 
> The offset isn't an even number of hours. What's also odd is that this was
> never a problem before about a week ago.  This code is many years old, and
> the problem suddenly began occurring with compiled code.
> 

This has been discussed multiple times recently, the last time was [1].
So let me elaborate on T Lee's answer a bit. The official statement is
that the previous behaviour was a bug which was unfortunately not
discovered sooner. As of Gambas 3.11, you should remember that CStr()
and CDate(), being low-level conversions, assume UTC, i.e. they convert
the date "literally" (without any offset) to a date and a time integer,
which is the internal representation of a Date in Gambas.

The higher-level Str(), Val(), Format() and Date() functions take the
current locale into account. Mixing CDate() with Format() is almost always
a bug, as one honours the local timezone and the other doesn't. CDate()
produces a Date object which is 05/04/18 00:00 UTC but when you format
it using Format$(), you get a string representing the same point in time
relative to your current timezone. I'm in GMT+0200 these days so I get:

  Test date: 5/4/2018 Formatted: 05/04/18 02:00 Fri

Removing the "C" from the invocation of CDate(), you chain locale-aware
functions only and get the desired result:

  Test date: 5/4/2018 Formatted: 05/04/18 00:00 Fri

That five minute offset you mention is indeed weird, though, and I have
no explanation for that.

Regards,
Tobi

[1] https://lists.gambas-basic.org/pipermail/user/2018-May/064153.html

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] module/comp how to made like gambas normal

2017-10-15 Thread Tobias Boege
On Sun, 15 Oct 2017, PICCORO McKAY Lenz wrote:
> i want to make a component that their rutines can be uses directly and not
> "module.subrutine(arg)" i like th use as "rutine(arg)"
> 
> hoq cab i made that?
> 

AFAIK real routines have to be built into the compiler so you can't add
them with just a component. However, you can make a module, say MyFunc,
and give it the special _call method [1]. The you can use the module name
like a function, i.e. call MyFunc(), and it will call the _call() method.

Regards,
Tobi

[1] http://gambaswiki.org/wiki/cat/special

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] New git support in the IDE

2017-10-11 Thread Tobias Boege
On Wed, 11 Oct 2017, Benoît Minisini via Gambas-user wrote:
> Hi,
> 
> I have just committed git support in 'master'.
> 
> The whole IDE version control management has been redesigned. Now version
> control is managed through a sub-menu in the 'Project' menu, or an
> equivalent menu button in the main toolbar.
> 
> Everything is done except conflict management. I must understand how it
> works in git, and I'd like to have a file diff tool directly in the IDE, but
> it's a big job.
> 

Just in case you forgot, there is already the Patch class in the IDE which I
wrote for the Patch dialogs. It's not much and they don't deal with conflict
files but they do parse "diff -u" patches like the ones "git diff" produces.

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Marco?

2017-10-02 Thread Tobias Boege
On Mon, 02 Oct 2017, Moviga Technologies via Gambas-user wrote:
> Marco?

Polo!

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Fwd: [Gambas Bug Tracker] Bug #1161: Class Editor is Locked

2017-09-07 Thread Tobias Boege
On Thu, 07 Sep 2017, Fernando Cabral wrote:
> 2017-09-07 5:52 GMT-03:00 Benoît Minisini via Gambas-user <
> gambas-user@lists.sourceforge.net>:
> 
> >
> > Is it possible for you (or other people) to compare the list of your
> > environment variables between a real system (where the bug occurs) and a
> > virtual machine with the same system (where the bug does not occur)?
> >
> 
> I am attaching two files with the variables used in the virtual and real
> environments. To me they look the same except for minor details that do not
> seem related to the issue.
> 

Fernando, you should participate in this issue on the bug tracker, not on
the mailing list. None of your comments reached the person that reported
the bug, unless they are subscribed to the mailing list as well, and it's
hard for people who do use the bug tracker to address your comments.

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Fwd: [Gambas Bug Tracker] Bug #1161: Class Editor is Locked

2017-09-05 Thread Tobias Boege
On Tue, 05 Sep 2017, Fernando Cabral wrote:
> 2017-09-05 12:49 GMT-03:00 Tony Morehen :
> 
> > Some more questions / things to try:
> >
> > 1) Copy the project folder elsewhere in your home directory, but not in
> > the dropbox tree.  Try to edit.
> > 2) In the copied folder, run chmod --recursive a+w *.  Try to edit.
> > 3) Try creating a new module, class or form.  Try this in both the copied
> > folder and the original.  Try to add code and edit the new module etc.
> > 4) Can the problems be related to dropbox.
> >
> > I have already tried this all in various combinations. Some even more
> radical, like
> making every file and directory 777. I've created a user named gambas and
> everything completely open.
> 
> Now, I know it has to do with permissions because if I run "sudo gambas3"
> it will work!
> Now, if I set the user id bit (chmod u+s gambas3, for instance), it does
> not work.
> 
> How come?
> 

I'm as puzzled by this issue as you are, but about this specific question:
Becoming root opens gates other than those pertaining to file permissions.
For example, you can access all devices freely and, as with any other user,
switching to root makes programs read another set of configuration files.

If anything, your experiments indicate that it is /not/ a file permission
issue. You tried it with a+rwx, so unless file permissions are impossibly
buggy or there are some surrounding problems like, I don't know, ACLs
(which you confirmed are not) or weird mount options, we can assume it's
not the permissions. Plus, if the file was non-writable, the IDE would tell
you that by appending "[read-only]" to the file name in the tab caption.
Only then the editor would be locked and its contents non-editable. Other-
wise nothing can prevent the IDE from editing a copy of the source code in
a graphical editor.

To me it sounds more plausible that your input isn't handled correctly
somewhere in the long chain of actors that touch the input to a Gambas
process. As for the X11 input method, I learned what an input method in
general is from Wikipedia. I don't know what information exactly determines
an X11 input method, but the output of

  $ setxkbmap -print -verbose 10

is probably relevant as this is about keyboard input. Other than that,
I found https://wiki.ubuntu.com/X/Config/Input

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] OH NO - not this ? again...

2017-09-02 Thread Tobias Boege
On Sat, 02 Sep 2017, mikeB wrote:
> ***
> 
> Just to clarify a few questions that were presented in your MUCH APPRECIATED
> answers:
> 
> * when try to install the deb file on a virgin Mint 8.1 puter = the
> installer starts its "thing"
> 
> then returns an error message saying
> 
> "ERROR: Dependency is not satisfied: gambas3-runtime(>=3.10).
> 
> 
> After more research found a cmd line that says will update the runtime files
> 
> (which would be GREAT if it actually worked ;-( as expected by a very new
> Linux user.
> 
> "sudo apt-get install gambas3-runtime"
> 
> the terminal return =
> 
> mikeb@mikeb-System ~ $ sudo apt-get install gambas3-runtime
> [sudo] password for mikeb:
> Reading package lists... Done
> Building dependency tree
> Reading state information... Done
> gambas3-runtime is already the newest version (3.8.4-2ubuntu3.1).
> gambas3-runtime set to manually installed.
> 0 upgraded, 0 newly installed, 0 to remove and 325 not upgraded.
> mikeb@mikeb-System ~ $
> 
> Notice that it says "newest version 3.8.4-2 when at the same time
> 
> the installer error reports needs " gambas3-runtime(.=3.10)"
> 
> yep.. very confusing for me anyway.
> 

Don't be confused, it tells you exactly what the problem is.

You wrote a Gambas program with Gambas 3.10. If you generate an installation
package of your program, the packager will enter the Gambas runtime and all
the components your project uses as dependencies into the package, so that
the package manager (apt-get in your case) can automatically install all the
missing packages on the target system, to make sure your program will have
all the bits available to function correctly.

Since you used Gambas 3.10 to package your program, the dependencies of the
runtime and components will be >= 3.10, because the current version is the
lowest version that the Gambas IDE can assume your project works with.

Now, as is often the case, your distribution doesn't have the latest version
of Gambas in its repository. It only has access to 3.8.4, as it tells you,
so the version requirement of >= 3.10 is unsatisfiable and you cannot install
your program.

Just releasing Gambas 3.10 on our site doesn't magically make it available
in every distribution's package repository. That requires people putting in
some work to integrate the new Gambas version and it may just be that those
people are lacking for a specific distribution or that distributions have
more conservative policies of when to upgrade their software repositories.

In the case of Linux Mint, or any Ubuntu-based distribution, you can install
very recent Gambas versions through the PPA maintained by Sebastian Kulesz.
See the wiki [1] for how to do that. Essentially you have to add another
software repository (called a PPA)to your system:

  $ sudo add-apt-repository ppa:gambas-team/gambas3
  $ sudo apt-get update

and once you did that, apt-get will find the newer Gambas versions.
Your deb should install now.

NOTE however that I'm not a Linux Mint or Ubuntu user. I just copied
these commands from the wiki page linked in [1], for completeness' sake.
I can only say that those lines don't seem horribly wrong to me.

Regards,
Tobi

[1] http://gambaswiki.org/wiki/install/linux_mint

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] CRYPT function - a little help please?

2017-08-25 Thread Tobias Boege
On Thu, 24 Aug 2017, mikeB wrote:
> eGreetings,
> I THINK I understand that the "Crypt" function is used to encrypt a password
> that can be checked
> by challenging user input (asking to input the password). Verifies plain
> text against encrypted data -
> It can NOT be decrypted.
> 
> 
> ?1 = where does this encrypted file (or string) exist after created? in the
> "shadow" file perhaps?
> 
> 
> ?2 = I am using the following lines of code for testing - I must not
> understand what I'm doing
> cuz does not seem to do as expected:
> 
> userid = "xcodex"
> Crypt.MD5(userid, "abcdefgh")
> cked = Crypt.Check(userid, "abcdefgh")
> Message.Info(cked)
> 
> cked ALWAYS returns "T" no matter how the code values are changed. Doc says
> "True" = not found?
> 
> 
> ?3 = could someone give me a couple lines of code to perform this function?
> learning by example ;-)
> 
> 
> $4 = what's your opinion if this method is a secure way to store/ verify a
> users entry password?
> 
> Thank you very much for any help - it is GREATLY APPRECIATED!
> mikeB
> 

First of all, don't reply to a message from the mailing list when you want
to start a new topic. It's not enough to just change the subject line.
Write a brand new email instead. Both your questions about encryption ended
up in the humongous thread about Gambas switching to Gitlab.

Now to your questions:

(1) Crypt does not operate with files. It takes an input password and
hashes it, returning the hash. It does just this one thing and leaves
storage to you -- because a hash function should not be concerned about
storage.

(2) In light of the answer to (1), you are ignoring the return value of
Crypt.MD5(). This return value is the password hash which you need to get
into a variable and use in a call to Crypt.Check(). Crypt.MD5() doesn't
magically associate a hashed version of "abcdefgh" with "xcodex".

(3) Here:

  Public Sub Main()
Dim s As String

s = Crypt.MD5("secret", "salt5678")
Print s

Print Crypt.Check("test", s)
Print Crypt.Check("secret", s)
  End

  >> $1$salt5678$eRxLEhWQsIei43/wfY66J/
  >> True
  >> False

(4) You should have read the site about good password hashes I gave you
last time. It explicitly says that MD5 is NOT a good hash for passwords.
MD5 can be used for quick file integrity checks, not passwords.

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Switching to GitLab

2017-08-24 Thread Tobias Boege
On Thu, 24 Aug 2017, PICCORO McKAY Lenz wrote:
> 2017-08-24 1:36 GMT-04:00 Christof Thalhofer <chri...@deganius.de>:
> 
> > Hello Piccoro,
> >
> > Am 24.08.2017 um 00:07 schrieb PICCORO McKAY Lenz:
> > > yes, i reading now with calm.. all you have right in part...
> >
> > Thank you! I did not want to offend you! Maybe you could really work
> > together with ML, unfortunately I do not have the time to rewrite the
> >
> i write it in a hurry, sorry
> 
> tobias seem are writing a guide..
> 

You probably meant Adrien. I don't have the time (or expertise with git
workflows) to be writing guides at the moment.

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Database help

2017-08-22 Thread Tobias Boege
On Wed, 23 Aug 2017, Jessa wrote:
> Good day, how to create a simple database with picture in gambas?
> 

Have you seen the example project called "PictureDatabase" on the
software farm?

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Different digit number in master version

2017-08-22 Thread Tobias Boege
On Tue, 22 Aug 2017, Gianluigi wrote:
> Sorry Tobias,
> but I don't have understod.
> I refer to the f05e6bc master version code, which I get from gbx3 -V as
> compared to what is in Commit f05e6bc[0] which has one number more, in this
> case zero.
> You mean that I not extracted the latest version?
> 

I'm not sure I understand which difference you talk about, but could it be
that you're unaware that git commit IDs are SHA-1 hashes? They are pretty
long and the current commit is identified by this hash:

  f05e6bc0ca31f4211d46201618a79f65e78f16ae

Now "gbx3 -V" shortens this to the first 8 characters in the hope that these
still uniquely identify the commit, and whatever other source of the commit
hash you're looking at shortens it to 7 characters.

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Different digit number in master version

2017-08-22 Thread Tobias Boege
On Tue, 22 Aug 2017, Gianluigi wrote:
> If you have already been asked, I apologize but I haven't seen it:
> Why on git the master version has a number more than my version?
> 3.10.90 f05e6bc (master) => f05e6bc0
> 

Because it's newer. The x.y.90 version signifies the "rolling" unstable
development version of Gambas, which is all the snapshots of Gambas that
happen between two stable releases.

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Git compilation report

2017-08-18 Thread Tobias Boege
On Fri, 18 Aug 2017, Gianluigi wrote:
> Hi Tobias,
> 
> This git response does not indicate that pull worked properly?
> 
> remote: Counting objects: 12, done.
> remote: Compressing objects: 100% (12/12), done.
> remote: Total 12 (delta 10), reused 0 (delta 0)
> Unpacking objects: 100% (12/12), done.
> Da https://gitlab.com/gambas/gambas
>4aed62d..38a6017  master -> origin/master
> Aggiornamento di 4aed62d..38a6017
> Fast-forward
>  main/gbx/gbx_c_process.c | 16 ++--
>  main/gbx/gbx_c_process.h |  1 +
>  2 files changed, 15 insertions(+), 2 deletions(-)
> --
> 

This response means it was successful.

And regarding your other question:

> Why should I uninstall if I just want to update?

The act of "updating" should be: uninstalling, compiling anew and installing.
You should *not* just pull the changes, compile and overwrite your existing
installation. I'm pretty sure I have seen bug reports on this list that were
later determined to be caused by not uninstalling Gambas prior to installing
a new version.

Sometimes internals change that make the newer Gambas incompatible with the
older one on your system. Now what happens when you overwrite your old Gambas
with the new one, but due to circumstances not all old files are replaced by
new ones, so the old, incompatible parts of Gambas keep lying around?
There will be usually funny errors about incorrect types or missing symbols,
e.g. this one [1], or Gambas may straight up crash.

I shouldn't say this but I myself rarely uninstall before updating, because
in >= 98% of times it works and if it doesn't work I remember how to fix it.

Regards,
Tobi

[1] https://sourceforge.net/p/gambas/mailman/message/34320297/

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Git compilation report

2017-08-18 Thread Tobias Boege
On Fri, 18 Aug 2017, PICCORO McKAY Lenz wrote:
> you should take in consideration that a pull fetch changes.. so i noted you
> do a uninstall only after do the pull.. worng!
> 
> if the uninstall process was changed beetween pulls, your "uninstall" could
> faild and let garbage in your system..
>

worng! In the case of Gambas, the Makefiles are generated by autotools.
There are no Makefiles in the Gambas repository, so pulling changes will
never destroy your Makefiles. Having your old Makefiles intact, you can
still uninstall Gambas cleanly, even after git pull. You do have to take
care to uninstall before running your next ./configure, though.

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Balloons, everywhere but when I don't want them.

2017-08-18 Thread Tobias Boege
On Fri, 18 Aug 2017, Tony Morehen wrote:
> Gambas can talk to the notifications daemon via Dbus.  I use this code:
> 
> Private NotifyInterface As String = "org.freedesktop.Notifications"
> Private NotifyApp As String = "session://" & NotifyInterface
> Private NotifyPath As String = "/" & Replace(NotifyInterface, ".", "/")
> 
> 'does the daemon support icon, body, button to click etc
>   Dim sArray As String[] = Dbus[NotifyApp][NotifyPath,
> NotifyInterface].GetCapabilities()
> 'popup (the hintsCollection is an empty collection, iDuration = -1, use
> default)
> notifyID = Dbus[NotifyApp][NotifyPath,
> NotifyInterface].Notify(AppName, notifyID, IconPath,SummaryText, BodyText,
> [TextToSignal, ButtonText], hintsCollection, iDuration)
> 'setup dbussignal to get popup closed and and buttonpressed notifications
> 
> Private  NotifySignal as New DbusSignal(Dbus.Session,NotifyInterface, True)
> As "NotifyDbusSignal"
> 'signal handler
> Public Sub NotifyDbusSignal_Signal(Signal As String, Arguments As Variant[])
>   Select Case Signal
> Case "NotificationClosed"
> Case "ActionInvoked"
>   'Arguments[0] contains TextToSignal from above
>   End Select
> End
> 

I just checked the code and this is exactly what libnotify does.

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Balloons, everywhere but when I don't want them.

2017-08-18 Thread Tobias Boege
On Fri, 18 Aug 2017, adamn...@gmail.com wrote:
> Probably obscure, but I'll give it a go anyway...
> 
> This project has about 80 or so Timers running at any given time, when they 
> fire some stuff is updated and then a balloon pops up to alert the user that 
> some update has happened.  All fantastic.  
> 
> And an added bonus is that the balloon pops up on any virtual desktop. Which 
> is even more fantastic as far as I am concerned and exactly what I have been 
> looking for for some years.
> 
> What is not so great is that when this happens on the desktop where the app 
> is running, not only does the balloon appear, but the actual form that 
> produces the balloon gets popped up to the top of the desktop. Which is 
> infuriating if the user is actually in another app on that desktop. Even 
> further, the project itself has a bunch of popup forms where the user can 
> enter manual updates of some data. When the balloon appears (and the main 
> form) the popup is lowered and you cannot bring it back to the top layer.
> 
> I'll try a more concrete example (or two), to see if I can explain what I am 
> trying to do a bit more clearly.
> 
> I have my email client (sylpheed) running, every so often it goes and checks 
> for incoming mail.  If there is some new mail a boxy looking thing appears at 
> the bottom right corner of the screen telling me I have new mail. No matter 
> which desktop I am actually on at the time.  A bit later that boxy thing 
> fades away. It doesn't interrupt what I am doing in any way, nor does it pop 
> up the main email client screen.
> Similarly, on my laptop I have Batti running which when I'm getting a bit low 
> on battery power pops up a message in the desktop panel telling me to plug 
> the damn thing in. Again this does not interrupt what I'm doing.
> 
> So, how can I achieve the same effect in gambas?
> 

Sounds like a feature of your DE (and I'm not good with DEs) but a quick
search suggests something called libnotify for sending desktop notifications.
It is said to be toolkit- and desktop-independent, but you need a conforming
notification daemon running -- which you may already have, if you can see
notifications from other programs (assuming they use the same machinery).

So, I guess you would need a gb.libnotify component (it really doesn't look
hard to do, there's only maybe 3 dozen functions in the library and it seems
you only need as few as 5 of them to show your first notification).

If you can't do that, there seems to be a tool called "notify-send" which
looks like it lets you access all the library features via the command-line.
That said, notify-send does nothing on my desktop, probably because I don't
run a fancy notification server...

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Switching to GitLab

2017-08-17 Thread Tobias Boege
On Thu, 17 Aug 2017, Gianluigi wrote:
> I had previously successfully updated using these drastic commands.
> 
> cd gambasdevel
> sudo make uninstall
> cd
> rm -rf gambasdevel/
> git clone https://gitlab.com/gambas/gambas.git gambasdevel
> cd gambasdevel
> ( ./reconf-all && LLVM_CONFIG=llvm-config-3.5 ./configure -C ) >
> ~/Scrivania/R_conf-Gambsdevel.log 2>&1
> ( make && sudo make install ) > ~/Scrivania/Make_Inst-Gambasdevel.log 2>&1
> 
> This time I tried with the git pull command (gian@gi:~gambasdevel$ git pull)
> Since there were variations I gave the usual command:
> ( ./reconf-all && LLVM_CONFIG=llvm-config-3.5 ./configure -C ) >
> ~/Scrivania/R_conf-Gambsdevel.log 2>&1
> 
> But I get this error:
> 
> libtoolize: putting auxiliary files in `.'.
> libtoolize: copying file `./ltmain.sh'
> libtoolize: putting macros in AC_CONFIG_MACRO_DIR, `m4'.
> libtoolize: copying file `m4/libtool.m4'
> libtoolize: copying file `m4/ltoptions.m4'
> libtoolize: copying file `m4/ltsugar.m4'
> libtoolize: copying file `m4/ltversion.m4'
> libtoolize: copying file `m4/lt~obsolete.m4'
> libtoolize: Remember to add `LT_INIT' to configure.ac.
> libtoolize: Consider adding `-I m4' to ACLOCAL_AMFLAGS in Makefile.am.
> autoreconf: Entering directory `.'
> autoreconf: configure.ac: not using Gettext
> autoreconf: running: aclocal
> autoreconf: configure.ac: tracing
> autoreconf: configure.ac: adding subdirectory main to autoreconf
> autoreconf: Entering directory `main'
> autoreconf: running: aclocal -I m4 --install
> autoreconf: running: libtoolize --copy
> autoreconf: running: /usr/bin/autoconf
> autoreconf: running: /usr/bin/autoheader
> autoreconf: running: automake --add-missing --copy --no-force
> Makefile.am: error: required file './ChangeLog' not found
> autoreconf: automake failed with exit status: 1
> 
> What am I doing wrong?
> 

You're not reading the commit log, despite using the development version.

40 minutes ago, Benoit deleted the ChangeLog file because he deemed it
useless. So, this explains why the file survived until this day:
it isn't useless.

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Switching to GitLab

2017-08-17 Thread Tobias Boege
On Thu, 17 Aug 2017, Christof Thalhofer wrote:
> But as you now have the complete repository on your computer you can
> easyly switch to another version, you can checkout tags and also branches:
> 
> For actual stable you would do:
> 
> git checkout v3.10.0
> 
> For an older one:
> 
> git checkout v3.7.1
> 
> I dont know much about compiling gambas, but I think, that a "make
> clean" could be neccessary between compiler runs.
> 

Usually, yes. You only have to make clean && ./reconf && ./configure if the
autoconf files of Gambas change. One source of such a change is adding a
new source file to (a C/C++ component of) Gambas, which may or may not have
happened since your last pull. If you pay attention to where files changed,
you don't have to reconfigure the whole tree (reconf-all in the root), but
only in directories where changes occured.

But if you checkout another branch it is a good bet you have to make clean
&& ./reconf-all && ./configure, because you would suspect more substantial
changes between, say, different stable releases.

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Declaring 'Public pbSwitch As Object[16]' throws error 'Syntax error in FMain.class:3'

2017-08-15 Thread Tobias Boege
On Wed, 16 Aug 2017, Doug Hutcheson wrote:
> Thanks for the explanation, Tobias. Having fixed the declaration, I am
> able to run the code, but all I see is an empty form with no controls.
> Sigh. I will keep hacking until I understand enough to make it work.
> 

In case you don't want to figure it out on your own (although you didn't
ask), this is most likely because the code uses the Picture[] cache.
It accesses Picture["imgSwtchOn.png"] and Picture["imgSwtchOff.png"],
but you probably don't have those files in your application (you don't
unless you added them on your own). Since Picture[] is the picture cache,
it won't raise an error if the named pictures aren't found and returns a
silent Null instead. Assigning Null to a PictureBox.Picture clears the
PictureBox. This is why you don't see anything.

Actually this example is horrible. Not only uses it resources which
aren't available by default, it also relies on the geometry of the
PictureBoxes and Mouse coordinates to identify which PictureBox
raised the event, instead of simply using Last. And then it needlessly
uses Object instead of PictureBox, and uses a *bitmask* to store the
on/off state of the pictures instead of just the PictureBox's Tag
property. Not to mention it isn't indented properly. There is a high
density of things I would advise to avoid here. Why did you choose
this of all to learn from? :-)

I updated the example and it should work out of the box now.

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Declaring 'Public pbSwitch As Object[16]' throws error 'Syntax error in FMain.class:3'

2017-08-15 Thread Tobias Boege
On Tue, 15 Aug 2017, Doug Hutcheson wrote:
> I have just found Gambas and have the usual learning curve. Sigh.
> 
> I have copied the code from http://gambaswiki.org/wiki/comp/gb/object/a
> ttach into a new project and tried stepping through it. The first
> statement is the declaration 'Public pbSwitch As Object[16]' and this
> throws ''Syntax error in FMain.class:3'. If I delete the array
> dimension '16', I can step through the code until the first time the
> array is used when it falls over, of course. Can someone please tell me
> what I have done wrong?
> 
> By the way, I am glad to have found Gambas, as it leverages my VB and
> LibreOffice Basic experience. Excellent application!
> 

I don't know if "Public a As x[k]" was ever valid in Gambas (the source code
in the markdown of that page looks like Gambas2). See the Array Declaration
page [1]. You have normally two types of arrays in Gambas. The normal dynamic
ones, which you can declare with

  Public a As New x[k]
  Public a As New x[](k) ' alternative

(note the NEW keyword), and so-called embedded arrays:

  Public a[k] As x

Usually you want the former (normal) arrays.

I updated the example in the Object.Attach() documentation.

Regards,
Tobi

[1] http://gambaswiki.org/wiki/lang/arraydecl

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] FProperty.class:25: error: Unknown identifier: &1 WebView

2017-08-15 Thread Tobias Boege
On Tue, 15 Aug 2017, Tobias Boege wrote:
> I'm currently running
> 
>   $ gbx3 -V
>   3.10.90 raa559edd9 (master)
> 

Which was obviously due to a bug ("r" is not a hexadecimal digit)
which I caught before pushing the commit. Correct should now be
"3.10.90 48c951987 (master)".

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] FProperty.class:25: error: Unknown identifier: &1 WebView

2017-08-15 Thread Tobias Boege
On Tue, 15 Aug 2017, Karl Reinl wrote:
> Am Dienstag, den 15.08.2017, 09:53 +0200 schrieb Moviga Technologies:
> > Hmmm no, not in the 'app/src/gambas3/' directory. Should I?
> > 
> > > Salut,
> > > 
> > > do you get a revision when making 'gbx3 -V' like '3.10.90 r8171'
> 
> on svn when checking gbx3 -V you get the revision, so my question was if
> it is the same on git.
> 

With git we lose the straightforward revision numbers of svn and get commit
hashes instead. I just made a commit that puts the (short) commit hash and
the branch name into the place of the revision number when Gambas is compiled
from git. I'm currently running

  $ gbx3 -V
  3.10.90 raa559edd9 (master)

Now I have to figure out how to propagate my change to the official tree.
I git-version almost everything I work on, but collaborating with others
on gitlab is new for me.

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] How to stop a control raising events?

2017-08-13 Thread Tobias Boege
On Mon, 14 Aug 2017, adamn...@gmail.com wrote:
> (A quicky!)
> 
> Wasn't there a way to temporarily stop a control raising events, 
> MyControl.Lock or somesuch? My memory fails!
> tia
> bruce

Object.Lock(x)

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] A couple of ?s about encryption

2017-08-13 Thread Tobias Boege
On Sun, 13 Aug 2017, mikeB wrote:
> eGreeetings,
> I am starting a project that involves encryption of passwords and user names
> - storing and recalling them.
> 
> 1st ? = i noticed Gambas can save and recall files from a ".hidden"
> directory. If the files are encrypted before
> saving to a hidden dir - how secure is this?  In other words would an
> experienced coder be able to find and
> copy these files? Would this be the secure/ recommended way/ place to store
> these files?
> 

The .hidden directory is a normal directory inside your project directory.
As the documentation states [1], it contains files that should not go into
the Gambas executable. If you store files in there you will in general NOT
have them available when your project executes.

And something else that is true for all directories in the your project:
you should not suppose that any of them is writable at runtime. You can
only use them to supply initial encrypted data that is never altered by the
program (if that's a good idea depends on your application).

[ The whole truth is: you can still access .hidden at runtime and write to
any directory in your project tree IF your project is run from the project
directory (you have to use absolute paths from Application.Path then).
There is no (sane) way to write to project directories from an executable
archive (.gambas file). The .gambas files are archives of your project
directory, which the interpreter unpacks in memory. Changing an in-memory
directory would have no effect on the actual directory stored inside the
archive, so it is forbidden from the start. ]

But yes, the interpreter can unpack executable archives, so you should
suppose that everyone will be able to figure out how to do it as well
(they just have to read the Gambas source code). Your data is not protected
whatsoever, except by the encryption you apply.

> 2nd ? = shelling out to the "gpg" command line to encrypt / decrypt the
> password files be a secure way of
> doing this or is there a better way (i.e. writing the encryption code within
> the Gambas project)?
> 

I can't tell you if it's secure. First of all because I don't know enough
about security, and second because we don't know enough about your situation.
I remember hearing that security is not a yes/no question. It depends on
where your threat comes from (and if you have identified all threats).
E.g. suppose that you call "gpg ..." from your program. I'm an attacker and
your program allows me to run it(!) (whether this is the case you didn't say).
Then I can just modify the PATH environment variable to supply my own version
of "gpg" which logs all the passwords you send to it.

To write encryption code in your project, there is gb.openssl. But be warned
that you have to know what you're doing. For example there are surprisingly
many (at least to me when I first read them) considerations to be done when
hashing passwords (have a look at [2]). Commonly used hashes are considered
*too fast* to be secure, for instance. The site recommends, among others,
scrypt for hashing passwords. OpenSSL seems to support it but gb.openssl
apparently does not. I may have to look into that sometime.

> 3rd ? = Now a GNU question from a real newbie on this subject. With this
> type of program (Protected Passwords)
> how in the heck could it be released under GNU? Or should it be? Don't
> understand how it could possibly be
> "protected" if the source code was available to all?
> 

You mean the GPL. Again, I'm no lawyer, but this shouldn't be a problem,
unless you want to ship passwords directly with your source code. Why
would you do that? Passwords are (normally) user-supplied data, so let
the user deal with them, e.g. by storing them away from your project
source code inside a directory in the user's $HOME, or something. Your
program should just contain the logic to treat passwords, not their
values. The security of modern encryption is not derived from their
*algorithm* but from *keys*, additional data that is provided to the
algorithm alongside the data to be encrypted and those keys have to
be kept secret (and not distributed with source code). This is called
Kerckhoff's principle [3]. So, if you're doing it right, your source
code should be free of sensitive information.

Regards,
Tobi

[1] http://gambaswiki.org/wiki/doc/project_structure
[2] https://crackstation.net/hashing-security.htm
[3] https://en.wikipedia.org/wiki/Kerckhoffs%27s_principle

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Two colors and two entries in a GridView

2017-08-04 Thread Tobias Boege
On Fri, 04 Aug 2017, Rolf-Werner Eilert wrote:
> Anyway, I have made so many bad experiences with RichText in the GridView
> that I thought about other ways of implementing this.
> 

I don't know how your cells would be laid out but maybe you can get away
with setting the RowSpan of the other cells in your row to 2. That would
give you two cells on your row, one above the other and next to the ones
with RowSpan=2, whose backgrounds can be set independently.

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Two colors and two entries in a GridView

2017-08-04 Thread Tobias Boege
On Fri, 04 Aug 2017, Rolf-Werner Eilert wrote:
> In a GridView, it occurs that I need two different entries with two
> different background colors in a few of the cells. So I thought about
> different solutions for this.
> 

You mean two different colors in the same cell and that's why you can't use
the Background property of the cell?

> 1. Using RichText doesn't produce any entries here on my system, don't know
> why, but it might have been an easy way to use it with a  with two
> columns. But even .Data.RichText = "Hello" doesn't show anything in the
> cell...
> 

GridView.Data is only to be used to provide data to the GridView inside its
Data event (see the documentation). To access a particular cell use

  GridView[Row, Column].RichText = ...

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] I need help to start drawing with Gambas

2017-07-30 Thread Tobias Boege
On Sun, 30 Jul 2017, Fernando Cabral wrote:
> Perhaps some of you have a little time available to point me the direction
> for this littledelineate project of mine.
> 
> I like to play with sundials. Basically, it consists in calculating some
> lines and angles and then drawing them on the ground, marble, concrete,
> etc. Things are conceptually very easy. I have line lengths and angles. I
> can use either or both to delineate the sundial face.
> 
> I would guess I will have to resort to cairo or chart, but I don't know
> where to start from. I'd appreciate a few hints.
> 

It doesn't have to be gb.cairo. You can use the Paint class of gb.qt4 if
you use gb.qt4 anyway. The interfaces of both drawing classes are very
similar either way. Use gb.cairo if you want to export your drawings to
PDF or Postscript and Paint for everything else (it allows you to draw
into windows of your Gambas process, to a printer, to svg or bitmap images).

Something that may be confusing when you first encounter it is the path-
based drawing that is used in Cairo and Paint. Most methods of the Paint
class don't paint anything but create and manipulate paths (it memorises
movements on the drawing surface). To create a drawing you have to call
Stroke() or Fill() on the path, to realise the memorised movement on the
paper, so to speak, e.g.

  Paint.Ellipse(0, 0, 10, 10)

will give you a circle of diameter 10 centered around the origin -- and by
that I mean a circle *path*. If you want a normal circle, you have to call
Stroke() afterwards. If you want a solid disc, call Fill() on the path.

To get you started, you can find the ancient AnalogWatch example on the
software farm, which draws an analog wall clock. If you're proficient
with trigonometry you can concentrate on the Paint bits of the source
code. There is also a chapter on Cairo in the German Gambas-Buch [1]
(with example projects) and many more in the Paint chapter [2].

And, as always, look into the source code of Gambas itself. Lots of
graphical controls written in Gambas (gb.form and gb.gui.base) draw
themselves with Paint. You can find examples of arbitrarily high
complexity (gb.form.terminal and the GridView from gb.gui.base come
to mind). There are also plenty of easier examples, like the Spinner
class in gb.form.

Regards,
Tobi

[1] https://gambas-buch.de/dw/doku.php?id=k25:k25.1:start
[2] https://gambas-buch.de/dw/doku.php?id=k23:k23.3:start

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] about lang/like string ? and depends

2017-07-30 Thread Tobias Boege
On Sun, 30 Jul 2017, PICCORO McKAY Lenz wrote:
> http://gambaswiki.org/wiki/lang/like
> 
> since witch version are available? its available for gambas 3.1?
> 

Since forever and ever. I found the function in Gambas 1.9.44 which is the
oldest tag in the svn history, over 10 years ago, and its implementation
/basically/ hasn't changed since then.

> depends of the pcre/ gb.pcre module? or not? i mean canuse same regular
> expressions as PCRE? (i know LIKE  its only to deal with ASCII strings)

It doesn't. The LIKE syntax is vastly less powerful and different from
the pcre syntax. The page you linked even tells you the syntax of LIKE
expressions. You can see for yourself that they are incompatible with pcre.

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] gb.pcre regexp replace does not indicate since!

2017-07-28 Thread Tobias Boege
On Fri, 28 Jul 2017, PICCORO McKAY Lenz wrote:
> http://gambaswiki.org/wiki/comp/gb.pcre/regexp/replace has a "since 3.9.X"
> but does not indicate what!
> 
> the hole "replace" or only a part functionality?
> 

The note *below* the "Since 3.9.3" marker. The Replace() method exists
since 3.5.0, as you could have found out by looking at the commit history
by yourself.

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] help with ListView code?

2017-07-28 Thread Tobias Boege
On Thu, 27 Jul 2017, mikeB wrote:
> Greetings all,
> I've got a Listview (set as Column view) with 2 columns that I'm using
> 
> for testing so I might understand how all this works so can add it to a
> project.
> 
> testCode..
> With listview1
> .Clear
> .Resizable = True
> .Columns.Count = 2
> .Columns[0].Text = "Site Name:"
> .Columns[1].Text = "Site URL:"
> End With
> ..
> I can add values to the 1st column:
> code..
> listview1.add("1", "First var entry")
> listview1.add("2", "Second var entry to test the resize ability")
> listview1.add("3", "Third var entry")
> ...
> Have spent a lot of research time trying to figure out how to add
> values to the 2nd column (Site URL:) - got me stumped.
> 
> Anyone got an example line of code to help me out?
> 
> I can't seem to find the answer in the help docs.
> 
> Would greatly appreciate any/ all help;-)
> mikeB
> 

You don't really have a ListView but a ColumnView, do you? A ColumnView is
a ColumnView and not "a Listview (set as Column view)". The ListView control
doesn't have a Columns property.

I have to say that when I tried to answer your question, I noticed that
I had no clue how ListView, its sibling ColumnView or their mutual parent
_TreeView work, so I read their source code (see gb.gui.base) -- and I
still had no clue. And let me say that this happens rarely to me these days.
I had to dig up an example (the FileView class in gb.form is very nice)
to see what they actually do with their columns. Since I get it now, I want
to give an explanation of these classes first, so bear with me.

To understand ColumnView you have to understand _TreeView, because
ColumnView is basically a _TreeView with some code added to manage columns,
but the columns are already available from _TreeView.

To add to the confusion, a _TreeView is internally basically a GridView,
i.e. a square grid of cells in which you can put strings and pictures,
but you can't access these cells /that/ freely from a _TreeView. The key
information is that each _TreeView item is an entire *row* in the GridView.

By calling ColumnView.Add("1", "First var entry") you create a new row
in the GridView, identified by the key "1", and set the text of the first
column of that row to "First var entry". The return value of the Add()
method is a _TreeView_Item object which allows you to set the texts of
all other columns:

  ColumnView.Add("1", "First var entry")[1] = "second column"

Wrap it in a With or store it in a variable if you want to set many other
columns:

  Dim hItem As _TreeView_Item

  hItem = ColumnView.Add("1", "First var entry")
  hItem[1] = "second column"
  hItem[2] = "third column"

The asymmetric treatment of the first vs. the other columns is most likely
because you always want to set at least the first column's text, and maybe
of technical nature as the Add() method has optional parameters which make
it uglier to add a variable argument list (Param in gb) to Add().

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] ho to use code snipes

2017-07-13 Thread Tobias Boege
On Thu, 13 Jul 2017, PICCORO McKAY Lenz wrote:
> i see for constructor "_new" the "_n" but how to use it?
> 

http://gambaswiki.org/wiki/ide/idesnippets :

  Entering a code shortcut at the beginning of a line and pressing the TAB
  key will automatically expand the shortcut into a defined piece of code.

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] how to log to stdout/stderr

2017-07-13 Thread Tobias Boege
On Thu, 13 Jul 2017, PICCORO McKAY Lenz wrote:
> hello toby, when i set the gambas binary to backgroud to runs as daemon
> ...and lauch other gambas process from that gambas ...
> 
> then the stdout and stderr does not have that behaviour you said!
> so then?
> 

You're wrong, it does exactly what you wanted and specifically asked about:
print to stdout and stderr.

As we discussed recently [1], stdout and stderr are redirected to /dev/null
when you daemonise, so there is not really any value in wanting to print
there if you want to make a daemon.

If you still want the output of your system daemon to arrive somewhere, you
have to point stdout and stderr to somewhere meaningful again, like your
syslog. You can also make your own log files as was discussed in [1], if you
don't have a real *system* daemon that should be integrated into the systemd
(or what have you) ecosystem. There is information available about this on
the net [2], which is completely independent of Gambas, BTW.

There's an(other) old saying: If you want a good answer you have to ask a
very good question.

Regards,
Tobi

[1] 
https://sourceforge.net/p/gambas/mailman/gambas-user/thread/1498036647346-59450.post%40n7.nabble.com/#msg35904830
[2] https://stackoverflow.com/questions/17954432/creating-a-daemon-in-linux

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] how to log to stdout/stderr

2017-07-13 Thread Tobias Boege
On Thu, 13 Jul 2017, PICCORO McKAY Lenz wrote:
> how can i log to stdout and stderr my program actions/methods/things ?
> 
> note that due vendor/client i cannot use gambas 3.5+ only 3.4... due its
> the already installed..
> 
> some time ago benoit respond me that recent version of gambas implements
> something similar already,
> but i cannot find the main in the horrible sourgeforce heavyweith web
> interface
> 

The PRINT instruction writes to stdout (by default) and the ERROR
instruction to stderr (by default). There is also DEBUG which writes
to stderr and includes the filename, function name and line number
where it is executed at the beginning of the output. It is for print-
style debugging and if you don't compile the project with gbc3's
"-g" switch the DEBUG statements will NOT be compiled, so don't do
anything in those statements which could have side effects.

You can change the default stream PRINT and ERROR/DEBUG operate on
by OUTPUT TO and ERROR TO.

Those things must have been in Gambas since forever, there is by far
no 3.x version requirement. The more sophisticated (by always broken
when I tried it, IIRC) component gb.logging was added in Gambas 3.5,
but if you just want to print to stdout and stderr, there is no reason
to use it.

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Best ways to format float values

2017-07-13 Thread Tobias Boege
On Thu, 13 Jul 2017, Gianluigi wrote:
> I would not be misunderstood.
> I had understood that Alex wanted a forced increase "Round".
> 
> To recap:
> 
>   Dim n As Float = 26.66016
>   Dim b As Byte
> 
>   Print Int(n * 100) / 100  ' Normal truncate, as already
> mentioned by other
>   Print Round(n, -2)' Normal round, as already
> mentioned by other
>   If Len(CStr(Frac(n))) > 4 Then
> b = Val(Mid(CStr(Frac(n)), 5, 1))
> If b >= 5 Then
>   Print Round(n, -2)
> Else
>   Print Round(n + 0.01, -2) ' Forced increase round, as
> proposed by me
> Endif
>   Endif
> 

I would avoid arithmetic operations involving even more floats, such as you
proposed. Consider this:

  $ gbx3 -e 'Round(0.8099950+0.1,-9)'
  0.90999
  $ gbx3 -e 'Round(0.8099951+0.1,-9)'
  0.91

I only changed the very last digit (of order 10^-11) from 0 to 1 which
shouldn't influence the rouding to 9 decimals at all -- but it does!

The problem here is, famously, that the decimal 0.1 has no finite binary
representation, so *storing* the value that is represented in decimal by
the string "0.1" in a binary float already gives you an unavoidable error.
Whenever you use 0.1 in your program, this error propagates. Specifically,
the error when storing 0.1 in a Single is about 1.49*10^-9, which is how
I arrived at that example above.

Of course, the same applies to the 0.01 you use above. You can think
by yourself about a similar example where float addition with 0.01 makes
the result of a later rounding unreliable.

The other method

  Floor(n*100)/100  ' round down to two decimals
  Ceil(n*100)/100   ' round up to two decimals

is reliable, since the *integer* 100 can be stored without error in a
float and IEEE754 requires the outcome of float arithmetic to be the
same as if the operation was performed exactly and then rounded to the
limited precision of the float datatype [1].

Regards,
Tobi

[1] http://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html#865

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] gambas for MAC OS ppc/intel ?

2017-07-10 Thread Tobias Boege
On Mon, 10 Jul 2017, PICCORO McKAY Lenz wrote:
> any news/notes about MAC port of gambas? where download etc? if any!

I'm not aware of any news but you may want to contact Francois Gallo who
was able to run the Gambas IDE on OS X back in 2011 [1]. I'm sure you can
dig up his email address in the archives.

Regards,
Tobi

[1] http://gambaswiki.org/wiki/doc/screenshot

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] RichText in Gambas

2017-07-10 Thread Tobias Boege
On Mon, 10 Jul 2017, Rolf-Werner Eilert wrote:
> Is there an information about the RichText property? I mean, which HTML tags
> are accepted etc.?
> 

GridView is in gb.gui.base (written in Gambas) and you can see that it uses
the Paint class to draw its cells. To draw RichText it uses 
Paint.DrawRichText().
If you use gb.qt4 as Paint backend you can trace its source code to see that
ultimately rich text is put into a QTextDocument (by setHTML()) and drawn from
there. The supported HTML is then documented over at QT [1].

> I could imagine at least Benoit should know where to get information about
> it.
> 
> In my GridView example, I tried RichText for the cell. Pure font style tags
> run well, like bold, italics etc. But I had a problem with center.
> 
>  results in not showing the text in the cell at all.
> 
> Same thing happens if I try GridView1.Data.Alignment = Align.Center and then
> give RichText.
> 
> When I use simple Text instead, Align.Center will run. But then I cannot
> vary the fontstyles anymore...
> 
> Any idea how to solve this?
> 

The GridViewData.Alignment seems to be passed to the DrawRichText() call
and, at least in gb.qt4, the rich text drawing routine constructs an
alignment div out of the Alignment parameter, so I don't know what the
problem is. You could try the  tag?

Regards,
Tobi

[1] https://doc.qt.io/qt-4.8/richtext-html-subset.html

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Isn't bracket regular expression compatible with UTF8?

2017-07-05 Thread Tobias Boege
On Tue, 04 Jul 2017, Fernando Cabral wrote:
> I have been trying something like *poder[^[:alpha:]*  so I  could find the
> word "poder " ("poder" followed by an space) but not "poderão" ("ã" being
> an alpha character in Portuguese.)
> 
> In English it could be like finding "power" but not "powerless".
> 
> Problem is that it seems [^[alpha]] includes accented characters like "á",
> "é", "ã".
> 
> That is, accented characters are not understood as alpha, but not alpha.
> 
> Please, note that I have compiled it with the UTF8 flag:
> *   re.Compile(poder[^[:alpha]], RegExp.utf8)*
> 
> Any hints?
> 

In your mail I can see three distinct attempts at writing down a
negative character class: [^[:alpha:], [^[alpha]], and [^[:alpha]],
but the correct syntax is

  [[:^alpha:]]

You want to check this first.

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] System.Language (gb)

2017-07-03 Thread Tobias Boege
On Tue, 04 Jul 2017, bb wrote:
> On 04/07/17 07:13, Tobias Boege wrote:
> > On Tue, 04 Jul 2017, bb wrote:
> > > >Static Property Language As String
> > > >
> > > >Returns or sets the current language setting.
> > > >
> > > >But which one?  LANG? LC_ALL? LANGUAGE? ...
> > > >
> > According to source code it returns:
> > 
> >1. LC_ALL if that's non-empty, next
> >2. LANG if that's non-empty, or otherwise
> >3. en_US.
> > 
> > Regards,
> > Tobi
> 
> Thanks Tobi,
> 
> ( I looked but couldn't find it in main ???)
> 

It's in main/gbx/gbx_c_system.c (which carries you to gbx_local.c).

> WIki updated.
> 
> Any comment on the UTF-8 bit?
> 

Sorry, I have no clue about locales. All I can say is that the interpreter
seems to only give you the value of the environment variables.

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] System.Language (gb)

2017-07-03 Thread Tobias Boege
On Tue, 04 Jul 2017, bb wrote:
> Static Property Language As String
> 
> Returns or sets the current language setting.
> 
> But which one?  LANG? LC_ALL? LANGUAGE? ...
> 

According to source code it returns:

  1. LC_ALL if that's non-empty, next
  2. LANG if that's non-empty, or otherwise
  3. en_US.

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] who to detect if are running inside IDE

2017-07-03 Thread Tobias Boege
On Mon, 03 Jul 2017, Karl Reinl wrote:
> Am Montag, den 03.07.2017, 20:40 +0200 schrieb Tobias Boege:
> > On Mon, 03 Jul 2017, PICCORO McKAY Lenz wrote:
> > > a piece of code to who to detect if are running inside IDE?  any ideas how
> > > to?
> > > 
> > 
> > Exact same question here: 
> > https://sourceforge.net/p/gambas/mailman/message/34204796/
> > 
> > If I may add something to the things said in the above thread: you could try
> > to get the parent PID of your Gambas process and determine if it's the IDE.
> > 
> > If you always run on Linux you can probably use the /proc filesystem to get
> > the path to the executable of your parent process or its command line. Then
> > it depends on if you want to trust that the user always installs the IDE as
> > "gambas3.gambas", for instance. Examining the parent process will probably
> > not work anymore if you run your process *from the IDE* but through gb.httpd
> > or through xterm (which are options in the IDE).
> > 
> > I'm convinced that no matter how you try to detect if you're run by the IDE
> > or not, someone can create an environment where your test gives the wrong
> > answer. I still stand by my statement from two years ago: you shouldn't care
> > where your program is run from in the first place. What problem are you
> > trying to solve by knowing that?
> > 
> > Regards,
> > Tobi
> > 
> 
> Salut Tobi,
> 
> I use (since gambas1) the project Arguments from the IDE. I set a ISIDE.
> 
> Sub chkIfIsIDE()
> Dim nI As Integer
> bIsIDE = False
> For nI = 0 To Application.Args.Count - 1
> 'PRINT Application.Args[nI]
> If InStr(UCase(Application.Args[nI]), "ISIDE") > 0 Then
> bIsIDE = True
> Endif
> Next
> End
> 
> So if I don't call my project with a parameter called ISIDE, I can be
> sure .I ran in the IDE.
> 
> And the use is, I set the first key of my DB to  that is my
> Test-Mandant that's just a copy from one of my Mandants in my DB. 
> So no problems with crashing DB-data, that's the problem I solved with!.
> 
> Sorry : Mandant = mandator 
> 

Yes, and, in my opinion, you solved it the right way, by introducing
a proper interface which the user has to know and respect. Your program
doesn't guess, it is instructed.

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] who to detect if are running inside IDE

2017-07-03 Thread Tobias Boege
On Mon, 03 Jul 2017, PICCORO McKAY Lenz wrote:
> a piece of code to who to detect if are running inside IDE?  any ideas how
> to?
> 

Exact same question here: 
https://sourceforge.net/p/gambas/mailman/message/34204796/

If I may add something to the things said in the above thread: you could try
to get the parent PID of your Gambas process and determine if it's the IDE.

If you always run on Linux you can probably use the /proc filesystem to get
the path to the executable of your parent process or its command line. Then
it depends on if you want to trust that the user always installs the IDE as
"gambas3.gambas", for instance. Examining the parent process will probably
not work anymore if you run your process *from the IDE* but through gb.httpd
or through xterm (which are options in the IDE).

I'm convinced that no matter how you try to detect if you're run by the IDE
or not, someone can create an environment where your test gives the wrong
answer. I still stand by my statement from two years ago: you shouldn't care
where your program is run from in the first place. What problem are you
trying to solve by knowing that?

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Any (easy) way to render RTF or HTML with gambas?

2017-07-02 Thread Tobias Boege
On Sun, 02 Jul 2017, PICCORO McKAY Lenz wrote:
> 2017-07-02 14:09 GMT-04:00 Fernando Cabral :
> 
> > Lentz, it is not a HTTPD project. It is not a web project. I need no
> > webserver (and I don't want one). I just want to display some nicely
> > formatted text. HTML will do it; RTF will do
> >
> 
> its does not matter, ... with pdf works due its the same idea.. that using
> pdf..
> 
> 
> but as Fabien said.. may change in the future.. gbr3 -http as html does
> not... i'll explain more easy.. using your solution:
> 
> rtf-text -> pdf -> viewer(embebed or not)
> 
> in my words its the same..
> 
> trf-text -> thml -> mini-httpd(embebed)
> 
> how do you think how ide shows to you the inline help ?  gambas has a http
> web server that runs only when view the little help and stop it..
> 

No, the IDE does *not* use the built-in HTTP server. Delivering HTML
documents via HTTP is something entirely different from rendering them.
The IDE uses gb.gui.qt.webkit's WebView to display help pages. It doesn't
need an HTTP server. Your web browser is not a web server either.

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] I need a hint on how to deleted duplicate items in a array

2017-06-30 Thread Tobias Boege
On Fri, 30 Jun 2017, Gianluigi wrote:
> What was wrong in my example which meant this?
> 
> Public Sub Main()
> 
>   Dim sSort As String[] = ["A", "B", "B", "B", "C", "D", "D", "E", "E",
> "E", "E", "F"]
>   Dim s As String
> 
>   For Each s In ReturnArrays(sSort, 0)
> Print s
>   Next
>   For Each s In ReturnArrays(sSort, -1)
> Print s
>   Next
> 
> End
> 
> Private Function ReturnArrays(SortedArray As String[], withNumber As
> Boolean) As String[]
> 
>   Dim sSingle, sWithNumber As New String[]
>   Dim i, n As Integer
> 
>   For i = 0 To SortedArray.Max
> ' You can avoid with Tobias's trick (For i = 1 To ...)
> If i < SortedArray.Max Then
>   If SortedArray[i] = SortedArray[i + 1] Then
> Inc n
>   Else
> Inc n
> sSingle.Push(SortedArray[i])
> sWithNumber.Push(n & SortedArray[i])
> n = 0
>   Endif
> Endif
>   Next
>   Inc n
>   sSingle.Push(SortedArray[SortedArray.Max])
>   sWithNumber.Push(n & SortedArray[SortedArray.Max])
>   If withNumber Then
> Return sWithNumber
>   Else
> Return sSingle
>   Endif
> 
> End
> 

I wouldn't say there is anything *wrong* with it, but it also has quadratic
worst-case running time. You use String[].Push() which is just another name
for String[].Add(). Adding an element to an array (the straightforward way)
is done by extending the space of that array by one further element and
storing the value there. But extending the space of an array could potentially
require you to copy the whole array somewhere else (where you have enough
free memory at the end of the array to enlarge it). Doing worst-case analysis,
we have to assume that this bad case always occurs.

If you fill an array with n values, e.g.

  Dim a As New Integer[]
  For i = 1 To n
a.Add(i)
  Next

then you loop n times and in the i-th iteration there will be already
i-many elements in your array. Adding one further element to it will,
in the worst case, require i copy operations to be performed. 9-year-old
C.F. Gauss will tell you that the amount of store operations is about n^2.

And your function does two jobs simultaneously but only returns the result
of one of the jobs. The output you get is only worth half the time you spent.

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] I need a hint on how to deleted duplicate items in a array

2017-06-30 Thread Tobias Boege
On Fri, 30 Jun 2017, Fernando Cabral wrote:
> 2017-06-30 7:44 GMT-03:00 Fabien Bodard :
> 
> > The best way is the nando one ... at least for gambas.
> >
> > As you have not to matter about what is the index value or the order,
> > the walk ahead option is the better.
> >
> >
> > Then Fernando ... for big, big things... I think you need to use a DB.
> > Or a native language maybe a sqlite memory structure can be good.
> >
> 
> Fabien, since this is a one-time only thing, I don't think I'd be better
> off witha database.
> Basically, I read a text file an then break it down into words, sentences
> and paragraphs.
> Next I  count the items in each array (words, sentences paragraphs).
> Array.count works wonderfully.
> After that, have to eliminate the duplicate words (Array.words). But in
> doing it, al also have to count
> how many times each word appeared.
> 
> Finally I sort the Array.Sentences and the Array.Paragraphs by size
> (string.len()). The Array.WOrds are
> sorted by count + lenght. This is all woring good.
> 
> So, my quest is for the fastest way do eliminate the words duplicates while
> I count them.
> For the time being, here is a working solution based on system' s sort |
> uniq:
> 
> Here is one of the versions I have been using:
> 
> Exec ["/usr/bin/uniq", "Unsorted.txt", "Sorted.srt2"] Wait
> Exec ["/usr/bin/uniq", "-ci", "SortedWords.srt2",  SortedWords.srt3"] Wait
> Exec ["/usr/bin/sort", "-bnr", SortedWords.srt3] To UniqWords
> 

Are those temporary files? You can avoid those by piping your data into the
processes and reading their output directly. Otherwise the Temp$() function
gives you better temporary files.

> WordArray = split (UniqWords, "\n")
> 
> So, I end up with the result I want. It's effective. Now, it would be more
> elegant If I could do the same
> with Gambas. Of course, the sorting would be easy with the builting
> WordArray.sort ().
> But how about te '"/usr/bin/uniq", "-ci" ...' part?
> 

I feel like my other mail answered this, but I can give you another version
of that routine (which I said I would leave as an exercise to you):

  ' Remove duplicates in an array like "uniq -ci". String comparison is
  ' case insensitive. The i-th entry in the returned array counts how many
  ' times aStrings[i] (in the de-duplicated array) was present in the input.
  ' The data in ~aStrings~ is overridden. Assumes the array is sorted.
  Private Function Uniq(aStrings As String[]) As Integer[]
Dim iSrc, iLast As Integer
Dim aCount As New Integer[](aStrings.Count)

If Not aStrings.Count Then Return []
iLast = 0
aCount[iLast] = 1
For iSrc = 1 To aStrings.Max
  If String.Comp(aStrings[iSrc], aStrings[iLast], gb.IgnoreCase) Then
Inc iLast
aStrings[iLast] = aStrings[iSrc]
aCount[iLast] = 1
  Else
Inc aCount[iLast]
  Endif
Next

' Now shrink the arrays to the memory they actually need
aStrings.Resize(iLast + 1)
aCount.Resize(iLast + 1)
Return aCount
  End

What, in my opinion, is at least theoretically better here than the other
proposed solutions is that it runs in linear time, while nando's is
quadratic[*]. (Of course, if you sort beforehand, it will become n*log(n),
which is still better than quadratic.)

Attached is a test script with some words. It runs the sort + uniq utilities
first and then Array.Sort() + the Uniq() function above. The program then
prints the *diff* between the two outputs. I get an empty diff, meaning that
my Gambas routines produce exactly the same output as the shell utilities.

Regards,
Tobi

[*] He calls array functions Add() and Find() inside a For loop that runs
over an array of size n. Adding elements to an array or searching an
array have themselves worst-case linear complexity, giving quadratic
overall. My implementation reserves some more space in advance to
avoid calling Add() in a loop. Since the array is sorted, we can go
without Find(), too. Actually, as you may know, adding an element to
the end of an array can be implemented in amortized constant time
(as C++'s std::vector does), by wasting space, but AFAICS Gambas
doesn't do this, but I could be wrong.

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk
#!/usr/bin/gbs3

Private Const WORDS As String = ""
"Are those temporary files You can avoid those by piping your data into the "
"processes and reading their output directly Otherwise the Temp function "
"gives you better temporary files "
"Fabien since this is a onetime only thing I dont think Id be better "
"off witha database Basically I read a text file an then break it down into "
"words sentences and paragraphs Next I  count the items in each array "
"words sentences paragraphs Arraycount works wonderfully After that "
"have to eliminate the duplicate words Arraywords But in doing it al "
"also have to count how many times each word appeared"

Public Sub Main()
  Dim aStrings 

Re: [Gambas-user] I need a hint on how to deleted duplicate items in a array

2017-06-27 Thread Tobias Boege
On Tue, 27 Jun 2017, Fernando Cabral wrote:
> So, my question is basically if Gambas has some built in method do
> eliminate duplicates.
> The reason I am asking this is because I am new to Gambas, so I have found
> myself coding
> things that were not needed. For instance, I coded some functions to do
> quicksort and bubble sort and then I found Array.sort () was available.
> Therefore, I waisted my time coding those quicksort and bubble sort
> functions :-(
> 

Ah, ok. I'm almost sure there is no built-in "uniq" function which gets
rid of consecutive duplicates, so you can go ahead and write your own :-)

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] I need a hint on how to deleted duplicate items in a array

2017-06-27 Thread Tobias Boege
On Tue, 27 Jun 2017, Fernando Cabral wrote:
> Hi
> 
> I have a sorted array that may contain several repeated items scattered all
> over.
> 
> I have to do two different things at different times:
> a) Eliminate the duplicates leaving a single specimen from each repeated
> item;
> b) Eliminate the duplicates but having a count of the original number.
> 
> So, if I have, say
> 
> A
> B
> B
> C
> D
> D
> 
> In the first option, I want to have
> A
> B
> C
> D
> In the second option, I want to have
> 1 A
> 2 B
> 1 C
> 2 D
> 
> Any hints on how to do this using some Gambas buit in method?
> 
> Note; Presently I have been doing it using external calls to
> the utilities sort and uniq.
> 

Your first sentence is a bit confusing. First you say that your array is
sorted but then you say that duplicates may be scattered across the array.
There are notions of order (namely *preorder*) which are so weak that this
could happen, but are you actually dealing with a preorder on your items?
What are your items, anyway?

When I hear "sorted", I think of a partial order and if you have a partial
order, then sorted implies that duplicates are consecutive! Anyway, I don't
want to bore you with elementary concepts of order theory. There are ways
to handle preorders, partial orders and every stronger notion of order,
of course, from within Gambas. You simply have to ask a better question,
by giving more details.

If you have a sorting where duplicates are consecutive, the solution is
very easy: just go through the array linearly and kick out these consecutive
duplicates (which is precisely what uniq does), e.g. for integers:

  Dim aInts As Integer[] = ...
  Dim iInd, iLast As Integer

  If Not aInts.Count Then Return
  iLast = aInts[0]
  iInd = 1
  While iInd < aInts.Count
If aInts[iInd] = iLast Then ' consecutive duplicate
  aInts.Remove(iInd, 1)
Else
  iLast = aInts[iInd]
  Inc iInd
Endif
  Wend

Note that the way I wrote it to get the idea across is not a linear-time
operation (it depends on the complexity of aInts.Remove()), but you can
achieve linear performance by writing better code. Think of it as an
exercise. (Of course, you can't hope to be more efficient than linear
time in a general situation.)

The counting task is solved with a similar pattern, but while you kick
an element out, you also increment a dedicated counter:

  Dim aInts As Integer[] = ...
  Dim aDups As New Integer[]
  Dim iInd, iLast As Integer

  If Not aInts.Count Then Return
  iLast = aInts[0]
  iInd = 1
  aDups.Add(0)
  While iInd < aInts.Count
If aInts[iInd] = iLast Then ' consecutive duplicate
  aInts.Remove(iInd, 1)
  Inc aDups[aDups.Max]
Else
  iLast = aInts[iInd]
  aDups.Add(0)
  Inc iInd
Endif
  Wend

After this executed, the array aInts will not contain duplicates (supposing
it was sorted before) and aDups[i] will contain the number of duplicates of
the item aInts[i] that were removed.

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] usage of too much GOTO can be bad pracitce or make influence in the code?

2017-06-25 Thread Tobias Boege
PICCORO, read this mail at your own risk. I won't accept invoices for
wasting your professional time.

On Sun, 25 Jun 2017, PICCORO McKAY Lenz wrote:
> due to many inconsistence responses i must spend time (again) to
> investigating..
> 
> the problem of goto comes from C to object conversion compilation..
> 
> many goto's produce many labels and "jump"'s in assembler code translation
> when a C program are compling.. so the resulting program will be more
> slower due too many "jumps"
> 
> this are poor ilustrated to most of users here in the list due i think
> nobody here know (in experience) code in assemble like me..
> 

Oh wow, that's a high footstool you're sitting on.

> so i'm very frustrating due when i try to use gambas in professional way
> (due are very promisess and usefully) many questions require spend of time
> due situations like that... please users.. dont make conjetures of things
> that not known, causes spend of time of otheers
> 

What most people talked about were the usual readability concerns which
are the first thing that's brought forward in every one of the countless
"GOTO considered harmful" essays out there. Supposing you asked a general
question about good practices regarding GOTO (which you were, just look
at your opening message!) they also said that it was up to personal
preference in the end. Therefore I don't see the too many inconsistencies
you speak of.

The only one who said anything about performance, which you bring up above,
was nando:

> Sometimes GOTO is needed...especially if you want your code to run faster.

and here I agree with you. The last part is certainly debatable and depends
on the platform (using goto in C is wildly different from using GOTO in
Gambas, see below). *The* standard example, and *perhaps* what he thought
of, is jumping out of 4 nested loops without GOTO. You can do it but at
least the obvious two solutions introduce new functions (i.e. calls and
returns) or some more IFs, both of which are forms of jumps.

> i case of gambas analizing the code seems are not the same.. due gambas
> fist make their own bycode that runtime inderstand and then that runtime
> pass to object mahine.. so many things change and its not the same... in
> easy words..
> 

Exactly, so why do you think your concerns about pipelining and branch
prediction at the C -> machine level are relevant at all in Gambas?
The program execution loop in the interpreter is a gigantic jump table.
The execution of every instruction in a Gambas program involves at
least two goto's in C, while the actual Gambas GOTO instruction is
implemented as an arithmetic operation on the program counter!

And no, I'm not conjecturing this; it's right there in the source code.
It should be natural that you read it if you require a deeper understanding
for your professional tasks than what others can provide. Your time is
not more precious than anyone else's on this list.

On a tangent I'm surprised nobody took the opportunity to scold Benoit
in this thread yet :-) Have you never tried modifying one of his parsers,
e.g. gb.markdown:

  $ cd ~/src/gambas3/comp/src/gb.markdown/.src
  // Count non-empty, non-comment lines
  $ egrep -cv "^[ ]*'|^[ ]*$" Markup.module
  798
  // Count labels, GOTO and GOSUB lines which are not commented out
  $ egrep -i ":[ ]*$|GOTO|GOSUB" Markup.module | grep -cv "^[ ]*'"
  75
  // Percentage of directly GOTO-related lines in the markdown parser
  $ pcalc 100*75/798
9.398496240601503   0x9 0y1001

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Logging errors in apps running as Application.Daemon

2017-06-23 Thread Tobias Boege
On Thu, 22 Jun 2017, alexchernoff wrote:
> Anyone know if there is a wrapper to daemonize apps while keeping them in
> regular console mode? That way maybe it will be possible to log fatal
> interpreter errors?
> 

Why do you want to daemonise then? From the manpage of daemon():

  The daemon() function is for programs wishing to detach themselves from
  the controlling terminal and run in the background as system daemons.

Maybe it's time to ask what you want to accomplish, because it's probably
not running a daemon.

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Errors compiling on Ubuntu 17.04 zesty

2017-06-21 Thread Tobias Boege
On Wed, 21 Jun 2017, Gianluigi wrote:
> After the configuration he gets this result:
> ||
> || THESE COMPONENTS ARE DISABLED:
> || - gb.jit
> || - gb.openssl
> ||
> expected for gb.jit but not for gb.openssl.
> Gambas installs but he continues to be unable to use it either by clicking
> on the icon or with the gambas3 command from the terminal.
> Any suggestions?
> At follow the final output of the installation
> 

The stuff you give is not relevant to gb.openssl. You only showed the
installation phase of the components written in Gambas, which doesn't
include gb.openssl.

I have a very unpleasant memories [1] about the last time I changed the
configure.ac of gb.openssl. Please make sure first that the openssl
development packages are installed.

Regards,
Tobi

[1] 
https://sourceforge.net/p/gambas/mailman/gambas-user/thread/BUG984:20160829225438...@gambaswiki.org/

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Logging errors in apps running as Application.Daemon

2017-06-21 Thread Tobias Boege
On Wed, 21 Jun 2017, Tobias Boege wrote:
> Attached are two scripts

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk
#!/usr/bin/gbs3

Public Sub Main()
  Print "a"
  Application.Daemon = True
  Wait 0.1 ' ensure we daemon'd(?)
  Print "b"
  Print 1 / 0
  Print "c"
End
#!/usr/bin/gbs3

Public Sub Main()
  Dim h, g As File

  h = Open "/tmp/log" For Write Create
  Output To #h
  g = Open "/tmp/log2" For Write Create
  Error To #g

  Print "a"
  Application.Daemon = True
  Wait 0.1 ' ensure we daemon'd(?)
  Print "b"
  Print 1 / 0
  Print "c"

  Close #h
  Close #g
End
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Logging errors in apps running as Application.Daemon

2017-06-21 Thread Tobias Boege
On Wed, 21 Jun 2017, adamn...@gmail.com wrote:
> On Wed, 21 Jun 2017 02:17:27 -0700 (MST)
> alexchernoff  wrote:
> 
> > Peace to all,
> > 
> > I have some Gb projects that are in Application.Daemon mode. But sometimes
> > if process dies for whatever reason, I can't see what the last error was. I
> > have to run it in a console without daemonizing and wait for it to die and
> > show last reason (like "#13: Null object" or something).
> > 
> > Can this be logged to a file? So at least the last output the interpreter
> > spits out is logged...
> > 
> > Cheers!
> > 
> > 
> > 
> > 
> > 
> or now that I think of it, you could just:
> 
> $ yourdeamonstarter > output.txt 2>&1
> 
> :-)
> 
> (Oh where might I have seen that somewhere before ???)
> B
> 

I doubt this works, because Application.Daemon = True calls daemon(3) which
redirects stdout and stderr (which were previously set by the shell to your
log files) to /dev/null, so you won't find anything in your files.

Output To and Error To should still work because they don't replace stdout
and stderr (which are killed by daemon()) but change the default file the
Print and Error statements operate on, at the Gambas level.

I don't know if it's possible to capture interpreter errors this way though.
Generally the interpreter would use fprintf(stderr, ...) to report errors
(fixed on stderr which, again, is sent to /dev/null after daemon()).

Attached are two scripts which showcase these reflections. Both scripts have
three stages: (1) print something, (2) daemonise and print something, and
(3) raise an error and then print something. daemon1.gbs3 uses normal Print
and relies on the shell redirection:

  $ ./daemon1.gbs3
  a
  $ ./daemon1.gbs3 >/tmp/log 2>&1
  $ cat /tmp/log

Of course, only the output after the first stage is shown as stdout is
closed after daemonising. The interpreter error is not shown. Curiously
the shell redirection results in an empty file, so not even the first
stage output arrives(?)

Whereas daemon2 creates its own log files (one for stdout and stderr each)
and uses Output To and Error To:

  $ ./daemon2.gbs3
  $ cat /tmp/log*
  a
  b

It can at least store its output after the daemonisation (the "b"), but
the interpreter error is not logged. To get this, you could look into
using the global error handler Static Public Sub Application_Error() [1]
in your startup class or using the C library via Extern to force your
log files into the standard fds again (this latter one would be the
least intrusive for the code you may have already written).

Regards,
Tobi

[1] http://gambaswiki.org/wiki/comp/gb/application

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] missing wiki gridview.rows.selection

2017-06-20 Thread Tobias Boege
On Tue, 20 Jun 2017, PICCORO McKAY Lenz wrote:
> NOW I HAVE ANOTHER QUUESTION, since what gambas version was implemented? in
> 3.1 this are not!.. in 3.5 exist! so 3.4? 3.3?
> 

I doubt anyone remembers this. You'll have to ask subversion.

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] old question: detect gambas version in code

2017-06-20 Thread Tobias Boege
On Tue, 20 Jun 2017, PICCORO McKAY Lenz wrote:
> i want to make a piece of software work in both gambas olders (gambas3 <<
> 3.5) and gambas newers (gambas >> 3.5.1)
> 
> by example, the smtp has some changes depending on the version, also the
> gridview too..
> 
> example:
> 
> SMTP was rewriten in 3.6 so Body are not present in 3.5
> http://gambaswiki.org/wiki/comp/gb.net.smtp/smtpclient/body?nh
> this makes some of my code not work in embebed devices that does not run
> modern versions of linux and some libs required by gambas 3.9
> 
> same behaviour with new rows.selection that are since 3.4
> http://gambaswiki.org/wiki/comp/gb.qt4/_gridview_rows/selection
> 
> so there's a way to detect gambas version and paste code respect that? (was
> answered some time ago, but i cannot find the mail)
> 

You can do a run-time check with System.FullVersion [1]. A compile-time
check is also possible by using the #If preprocessor syntax [2].

Regards,
Tobi

[1] http://gambaswiki.org/wiki/comp/gb/system/fullversion
[2] http://gambaswiki.org/wiki/lang/.if

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Help needed from regexp gurus / String.Mid() and Mid$() implementation

2017-06-18 Thread Tobias Boege
On Sat, 17 Jun 2017, Fernando Cabral wrote:
> Tobi
> 
> One more thing about the way I wish it could work (I remember having done
> this in C perhaps 30 years ago). The pseudo-code bellow is pretty
> schematic, but I think it will clarify the issue.
> 
> Let p and l be arrays of integers and s be the string "abc defg hijkl"
> 
> So, after traversing the string we would have the following result:
> p[0] = offset of "a" (0)
> l[0] = length of "abc" (3)
> p[1] = offset of "d" (4)
> l[1] = lenght of "defg" (4)
> p[2] = offset of "h" (9)
> l[2] = lenght of "hijkl" (5).
> 
> After this, each word could be retrieved in the following manner:
> 
> for i = 0 to 2
> print mid(s, p[i], l[i])
> next
> 
> I think this would be the most efficient way to do it. But I can't find how
> to do it in Gambas using Regex.
> 

As I said before, the Gambas String.Mid() and Mid$() functions do just that.
The internal representation of a string is some base data (which is usually
shared among many strings, via reference counting), an offset and a length.
If you apply String.Mid() or Mid$() to a string, no copying takes place, only
the offset and length members of the Gambas string structure are adjusted.
This is why Gambas strings are sometimes called "read-only" in the wiki (the
same string base data is shared by many strings, so you can't have external
libraries modify the data behind a Gambas string). Even the statement

  s = String.Mid$(s, 10, 20)

will *not* require a copy operation. You simply add 10 (UTF-8 positions) to
the offset member of the string structure and set the length member to 20
(UTF-8 positions) (or to the remaining length of s if it's smaller than 20).

String.Mid() and Mid$() are implemented exactly by manipulating offsets and
lengths, like you want to do. In fact there are multiple places in the Gambas
source tree where those two are used in place of a C-style

  for (i = 0; i < len; i++)
do something with str[i];

loop. I suggest you look at the implementations yourself if you don't
believe it:

  String datatype: 
https://sourceforge.net/p/gambas/code/HEAD/tree/gambas/trunk/main/share/gambas.h#l126
  Mid$():  
https://sourceforge.net/p/gambas/code/HEAD/tree/gambas/trunk/main/gbx/gbx_exec_loop.c#l3820
  String.Mid():
https://sourceforge.net/p/gambas/code/HEAD/tree/gambas/trunk/main/gbx/gbx_c_string.c#l399

(I recommend downloading the source tree and using ctags or something to
navigate through it, of course, instead of the SF web interface.)

You should also try the following: create a console project with this code
in the Main.module:

   1 ' Gambas module file
   2
   3 Public Sub Main()
   4   Dim s As String = ""
   5   Dim i As Integer
   6
   7   For i = 1 To 5
   8 s = String.Mid$(s, i, 2*i)
   9   Next
  10   s &= "a"
  11 End

It will call String.Mid$() multiple times. Now compile and run this program
through callgrind:

  $ cd /path/to/project
  $ gbc3 -ga
  $ valgrind --tool=callgrind gbx3

and use kcachegrind to visualise the callgraph. I'll attach the two
interesting graphs to this mail. One shows that the single invocation
of SUBR_cat (the &= operation at the end) needed a malloc() and hence
did something like copying the string, whereas the multiple invocations
of String_Mid do not lead to malloc or any other means of allocating
memory, meaning no copy operation takes place.

Assuming you aren't prematurely optimising here and performance is actually
poor with Gambas code you should look into doing it in C and possibly avoid
regular expressions altogether. If you always just want all the words in a
given string, you can do it in a single linear pass through your text.

But honestly, I would be surprised if you have bad performance by using
String.Mid$(), since it is really just using a map of offsets and lengths
on a single shared base string.

Regards,
Tobi

PS: Again about the definition of "word in a string". My point was that if
you say "a word in a string is a sequence of alphabetic characters followed
by a non-alphabetic character", then "c", "bc" and "abc" will be words in
the string "abc.", right? "c" is a (length-1) sequence of alphabetic
characters which is followed by the non-alphabetic character "." in the
string. But you don't want to call "c" alone a word because there are further
alphabetic characters in front of it. You want any *longest* sequence of
alphabetic characters which is followed by a non-alphabetic one, which in
the string above, would only be "abc".

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Help needed from regexp gurus

2017-06-17 Thread Tobias Boege
On Sat, 17 Jun 2017, Fernando Cabral wrote:
> Still beating my head against the wall due to my lack of knowledge about
> the PCRE methods and properties... Because of this, I have progressed not
> only very slowly but also -- I fell -- in a very inelegant way. So perhaps
> you guys who are more acquainted with PCRE might be able to hint me on a
> better solution.
> 
> I want to search a long string that can contain a sentence, a paragraph or
> even a full text. I wanna find and isolate every word it contains. A word
> is defined as any sequence of alphabetic characters followed by a
> non-alphatetic character.
> 

The Mathematician in me can't resist to point this out: you hopefully wanted
to define "word in a string" as "a *longest* sequence of alphabetic characters
followed by a non-alphabetic character (or the end of the string)". Using your
definition above, the words in "abc:" would be "c", "bc" and "abc", whereas
you probably only wanted "abc" (the longest of those).

> The sample code bellow does work, but I don't feel it is as elegant and as
> fast as it could and should be.  Especially the way I am traversing the
> string from the beginning to the end. It looks awkward and slow. There must
> be a more efficient way, like working only with offsets and lengths instead
> of copying the string again and again.
> 

You think worse of String.Mid() than it deserves, IMHO. Gambas strings
are triples of a pointer to some data, a start index and a length, and
the built-in string functions take care not to copy a string when it's
not necessary. The plain Mid$() function (dealing with ASCII strings only)
is implemented as a constant-time operation which simply takes your input
string and adjusts the start index and length to give you the requested
portion of the string. The string doesn't even have to be read, much less
copied, to do this.

Now, the String.Mid() function is somewhat more complicated, because
UTF-8 strings have variable-width characters, which makes it difficult
to map byte indices to character positions. To implement String.Mid(),
your string has to be read, but, again, not copied.

Extracting a part of a string is a non-destructive operation in Gambas
and no copying takes place. (Concatenating strings, on the other hand,
will copy.) So, there is some reading overhead (if you need UTF-8 strings),
but it's smaller than you probably thought.

> Dim Alphabetics as string "abc...zyzABC...ZYZ"
> Dim re as RegExp
> Dim matches as String []
> Dim RawText as String
> 
> re.Compile("([" & Alphabetics & "]+?)([^" & Alphabetics & "]+)",
> RegExp.utf8)
> RawText = "abc12345def ghi jklm mno p1"
> 
> Do While RawText
>  re.Exec(RawText)
>  matches.add(re[1].text)
>  RawText = String.Mid(RawText, String.Len(re.text) + 1)
> Loop
> 
> For i = 0 To matches.Count - 1
>   Print matches[i]
> Next
> 
> 
> Above code correctly finds "abc, def, ghi, jlkm, mno, p". But the tricks I
> have used are cumbersome (like advancing with string.mid() and resorting to
> re[1].text and re.text.
> 

Well, I think you can't use PCRE alone to solve your problem, if you want
to capture a variable number of words in your submatches. I did a bit of
reading and from what I gather [1][2] capturing group numbers are assigned
based on the verbatim regular expression, i.e. the number of submatches
you can receive is limited by the number of "(...)" constructs in your
expression; and the (otherwise very nifty) recursion operator (?R) does
not give you an unlimited number of capturing groups, sadly.

Anyway, I think by changing your regular expression, you can let PCRE take
care of the string advancement, like so:

   1 #!/usr/bin/gbs3
   2
   3 Use "gb.pcre"
   4
   5 Public Sub Main()
   6   Dim r As New RegExp
   7   Dim s As string
   8
   9   r.Compile("([[:alpha:]]+)[[:^alpha:]]+(.*$)", RegExp.UTF8)
  10   s = "abc12345def ghi jklm mno p1"
  11   Print "Subject:";; s
  12   Do
  13 r.Exec(s)
  14 If r.Offset = -1 Then Break
  15 Print " ->";; r[1].Text
  16 s = r[2].Text
  17   Loop While s
  18 End

Output:

  Subject: abc12345def ghi jklm mno p1
   -> abc
   -> def
   -> ghi
   -> jklm
   -> mno
   -> p

But, I think, this is less efficient than using String.Mid(). The trailing
group (.*$) _may_ make the PCRE library read the entire subject every time.
And I believe gb.pcre will copy your submatch string when returning it.
If you care deeply about this, you'll have to trace the code in gb.pcre
and main/gbx (the interpreter) to see what copies strings and what doesn't.

Regards,
Tobi

[1] http://www.regular-expressions.info/recursecapture.html (Capturing Groups 
Inside Recursion or Subroutine Calls)
[2] http://www.rexegg.com/regex-recursion.html (Groups Contents and Numbering 
in Recursive Expressions)

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the 

Re: [Gambas-user] DesktopWindow.Name; Unexpected result

2017-06-17 Thread Tobias Boege
On Sat, 17 Jun 2017, Gianluigi wrote:
> 2017-06-17 13:51 GMT+02:00 adamn...@gmail.com :
> 
> >
> > Ah! Now I see where your confusion lies...
> > 1) DesktopWindow.Name : "i.e. its title as specified by the application
> > that owns this window."
> > 2) DesktopWindow.VisibleName : " i.e. the window title as displayed by the
> > window manager."
> >
> > The difference is subtle and not easy to find an example for, but it does
> > happen I can assure you.
> >
> 
> OK, I'll take your word for it.
> 

I can get something like this here easily by opening two konqueror windows
and pointing them to the same directory (see screenshot). However, the
properties of the DesktopWindow objects look like this:

  $ ./konqueror-windows.gbs3
  Name: var - Konqueror   VisibleName: var - Konqueror
  Name: var - Konqueror   VisibleName:

So, apparently this can happen, too.

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk
#!/usr/bin/gbs3

Use "gb.desktop"

Public Sub Main()
  Dim w As DesktopWindow

  For Each w In Desktop.Windows
If w.Name Not Like "*konqueror*" Then Continue
Print "Name:";; w.Name, "VisibleName:";; w.VisibleName
  Next
End
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] sqlite3 component can't seem to handle very large numbers

2017-06-16 Thread Tobias Boege
On Sat, 17 Jun 2017, Herman Borsje wrote:
> When I retrieve a result from a sqlite3 database which holds very large
> numbers in some fields, I get weird results. Up to 10 digits works okay, but
> larger numbers are incorrect. Any ideas as to what's going wrong?
> 
> I am using Gambas 3.9.2 on Linux Mint 18.1
> 
> Tabledef: id INTEGER, name TEXT;
> 
> Database records:
> 
> id name
> 
> 1234567890test1
> 
> 12345678901  test2
> 
> 123456789010test3
> 
> 
> Public Sub Button1_Click()
> 
>   Dim rs As Result
>   Dim con As New Connection
>   con.Name = "test.db"
>   con.Type = "sqlite3"
>   con.Open
> 
>   rs = con.Exec("select * from test")
> 
>   For Each rs
> Debug Cstr(rs!id) & ": " & rs!name
>   Next
> 
>   con.Close
> 
> End
> 
> Debug results:
> 
> FMain.Button1_Click.14: 1234567890: test1
> FMain.Button1_Click.14: 0: test2
> FMain.Button1_Click.14: 6714656: test3
> 

The SQLite documentation tells me that SQLite3's INTEGER datatype can
consist of 1, 2, 3, 4, 6 or 8 bytes, depending on the magnitude of the
value to be stored, whereas Gambas' normal Integer type is always four
bytes, or 32 bits.

What you call "larger numbers" are most likely just numbers that cross
the boundaries of 32 bits. At least the two numbers you listed above,
where the retrieval appears to fail, have 34 and 37 bits respectively.

In the attached script, I tried CLong() (Long is always 8 bytes in
Gambas), but to no avail. It seems that the faulty conversion is already
done in the database driver and has to be fixed there. From glancing
at the source code, the mapping between SQLite and Gambas datatypes is:

  Gambas ->  SQLite3 SQLite3->Gambas
  +--+--
 Integer  |INT4 INTEGER, | \
   Long   |   BIGINTINT, INT4, INT2, |  |
SMALLINT,|  |- Integer
MEDIUMINT| /
  BIGINT, INT8   | Long

I would suggest to map INTEGER to Long instead of Integer, but Benoit,
being the driver author, has to confirm.

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk
#!/usr/bin/gbs3

Use "gb.db"

Public Sub Main()
  Dim h As New Connection
  Dim t As Table, r As Result

  h.Type = "sqlite3"
  h.Host = Null
  h.Name = Null
  h.Open()

  h.Exec("CREATE TABLE test(int INTEGER PRIMARY KEY)")

  r = h.Create("test")
  r!int =  ' 5 byte integer
  r.Update()

  r = h.Find("test")
  ' Notice that the "98" hex digits are lost although SQLite3's
  ' INTEGER type can store 8 bytes.
  Print Hex$(r!int), Hex$(CStr(r!int)), Hex$(CLong(r!int))
End
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] sqlite gambas table info?

2017-06-16 Thread Tobias Boege
On Fri, 16 Jun 2017, PICCORO McKAY Lenz wrote:
> its there some code to get BEFORE send the query the fields of the table?
> 
> i mean, in the following code example i already know the column name, but i
> need firts detect column name to send amount of filters
> 
> sCriteria *=* "id = &1"iParameter *=* *1012*$hConn*.*Begin' Same as
> "SELECT * FROM tblDEFAULT WHERE id = 1012"hResult *=*
> $hConn*.*Edit*(*"tblDEFAULT"*,* sCriteria*,* iParameter*)*
> 
> 
> in this case, the column "id" was previously knowed! but in my case i need
> to detect all the column names firts before send the filters/parameters
> criteria
> 
> please any help?
> 

Look again at the properties of the Connection object. To get information
about a table, the "Tables" property is a good start. If your Connection
is called h you can list all tables, their fields and datatypes like this:

  ' h is an open connection to a database
  Dim t As Table, f As Field

  For Each t In h.Tables
Print t.Name
For Each f In t.Fields
  Print "  "; f.Name;; f.Type
Next
  Next

Use

  t = h.Tables[""]

in place of the outer loop if you only care about a specific table.

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] static ? in variables

2017-06-16 Thread Tobias Boege
On Fri, 16 Jun 2017, PICCORO McKAY Lenz wrote:
> tested was a cache doc problem maybe.. thanks ...
> 
> i now understand clarelly about class using static and private.. but for
> variables:
> wiki was:
> "If the static keyword is specified, the same variable will be shared with
> every object of this class."
> 
> well seems "Public var" and "Static public var" are equal and there's no
> difference? so where are the logic with public static?
> 
> please iluminate me...
> 

"Public" or "Private" control the visibility of a symbol, whereas "Static"
(or leaving out "Static") controls the storage type of the variable.
A static variable is stored in the *class* and shared by all objects.
If you modify a static variable from one object, it will change for all
objects. This is orthogonal to visibility. You can combine Static with
Public or Private. Neither implies the other.

You should be familiar with this concept if you know Java and PHP.
It's about the same there, although I don't think Gambas has static
local variables, which is another place where the word "static" is
used in those languages.

In case you are confused because "Static" appears in two places (the
CREATE STATIC flag for classes and the STATIC keyword for variable/
property/method declaration), those two things aren't necessarily
related. For example, CREATE PRIVATE has no relation to private variable
declaration (where you also use PRIVATE) and no relation to the CREATE
flag you specify with the OPEN instruction for files. It's just that
those two words "CREATE" and "PRIVATE" already exist in Gambas and they
together kind of convey the meaning of "CREATE PRIVATE", namely that
you can't create objects of the class using NEW.

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] static ? in variables

2017-06-16 Thread Tobias Boege
On Fri, 16 Jun 2017, adamn...@gmail.com wrote:
> On Fri, 16 Jun 2017 12:38:50 +0200
> Tobias Boege <tabo...@gmail.com> wrote:
> 
> > Can you give a full project? The attached project contains everything
> > you said about your class, and it works. It is instantiable. Is the
> > *error message* really that the class cannot be instantiated or is
> > there another error which just prevents objects from being created,
> > e.g. you use the "status" variable in the _new method?<---?
> > 
> > Regards,
> > Tobi
> > 
> > -- 
> > "There's an old saying: Don't change anything... ever!" -- Mr. Monk
> 
> Eh? You can use static variables in dynamic methods... or Constants would 
> never work.
> (You cannot access dynamic variables from static methods.)
> 

Right :-/ (in my defense, this was the first thing I did after waking up)

I should've just said: give a full project.

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] static ? in variables

2017-06-16 Thread Tobias Boege
On Thu, 15 Jun 2017, PICCORO McKAY Lenz wrote:
> tobias..now making a library  in the ide, the class that not have the
> "create static" now not permits instanciate the class
> 
> i only put a variable static, rest of class not have create static
> 
> Export
> 
> Private dblocal As String = "file1.txt"
> Static Public status As Integer = 0
> 
> now the class "dbcontext" said cannot be instanciate, i do not have
> the CREATE PRIVATE declaration inside it!
> 

Can you give a full project? The attached project contains everything
you said about your class, and it works. It is instantiable. Is the
*error message* really that the class cannot be instantiated or is
there another error which just prevents objects from being created,
e.g. you use the "status" variable in the _new method?

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk


test-0.0.1.tar.gz
Description: Binary data
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] static ? in variables

2017-06-15 Thread Tobias Boege
On Thu, 15 Jun 2017, PICCORO McKAY Lenz wrote:
> hi tobias, *the documentation are totally wrong.. due the documentation
> makes a explicit citation to the concep in wikipedia*,that's why i ask so
> many about it
> 
> now i propose to change by myselft that documentation to a proper paragraph
> that translators can understand without transliterate the meaning..
> 
> and in any case thanks to your explication now i can understand the right
> usage..
> 
> with this specific problem i can point the importance of a documentation,
> i'll practice some all of your said and then try to correct better the wiki
> doc
> 

Well, I read the wiki page again after you pointed this out and, technically
speaking, the wiki is correct:

  This feature allows you to implement the object-oriented programming 
singleton pattern.

Indeed CREATE STATIC allows you to implement the familiar singleton pattern,
but CREATE STATIC *alone* does not suffice. To get the singleton you have to
use

  CREATE STATIC
  CREATE PRIVATE

together (CREATE PRIVATE is linked on the CREATE STATIC page and it
disallows the creation of objects of a class, except for the automatic
instance, because the interpreter can and will bypass the CREATE PRIVATE
limit to fulfill the CREATE STATIC flag).

Maybe this is all that's needed for the clarification. If you agree that
CREATE STATIC + CREATE PRIVATE = singleton pattern, then I can change
the wiki page, with slightly better English I believe.

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Working with .so library

2017-06-15 Thread Tobias Boege
> > > > What I don't understand is how I construct the code in my
> > > > particular case.
> > > > 
> > > > To make an interface to the library I declare external pointer
> > > > like this:
> > > > 
> > > >  Extern CreateFptrInterface(ver As Integer) As Pointer
> > > > 
> > > > Then I declare some pointers that I'll use with help of the interface I
> > > > created:
> > > > 
> > > >  Extern put_DeviceEnable(p as Pointer, mode as Integer)
> > > > 
> > > >  Extern GetStatus(p as Pointer, StatRequest as String)
> > > > 
> > > > Then I declare the pointer which will be that interface:
> > > > 
> > > >  Public kkmDrv as Pointer
> > > > 
> > > > So then in sub I can do
> > > > 
> > > > kkmDrv = CreateFptrInterface(12) ' this establishes the interface
> > > > 
> > > > put_DeviceEnabled(kkmDrv, 1) ' this transfers the comand to the library
> > > > through the interface.
> > > > 
> > > > And it works great.
> > > > 
> > > > But then If I want to get some data from the library, as I
> > > > understand, I
> > > > have to declare another pointer, allocate ram for it and pass my
> > > > request.
> > > > 
> > > > I don't understand how should I pass that pointer to GetStatus()
> > > > while also
> > > > passing my interface pointer to it, let alone reading data back.
> > > > Totally
> > > > confused.
> > > > 
> > > This entirely depends on how the C functions in your library are
> > > declared.
> > > I don't know about your specific library but commonly the occurence
> > > of an
> > > error is indicated by an integer return code, e.g. this might be the
> > > signature of one of the functions in your library:
> > > 
> > >int myfunction(void *interface, int argument)
> > > 
> > > If the documentation says that the return value (int) of this function
> > > indicates an error, then you just need to get that return value back
> > > into
> > > your Gambas program, which you accomplish by declaring the function in
> > > Gambas as
> > > 
> > >Extern myfunction(interface As Pointer, argument As Integer) As
> > > Integer
> > > 
> > > (notice the trailing "As Integer"). Then you can use "myfunction" in
> > > your
> > > Gambas code like any other function and get and interpret its return
> > > value.
> > > 
> > > So, if this convention for error reporting is used, it is much
> > > simpler to
> > > get information about errors, without using Alloc() and co. Your library
> > > may use a different convention which actually involves pointers, but
> > > I wouldn't know.
> > > 
> > > Regards,
> > > Tobi
> > > 
> > I should've said it in the beginning. Ofcourse any function returns
> > integer value of 0 as success or -1 as error, but that only indicates
> > that function was successfully executed or not. So GetStatus() will
> > always return 0 because it shurely ran, nothing can go wrong here. But
> > that's not the result I want. GetStatus() actually gives back a string
> > with the status I asked for. Not that I fully understand how it does
> > that. I already gave links to the libfptr.so library itself
> > (http://allunix.ru/back/atol.tar.gz) and it's header files
> > (http://allunix.ru/back/atol-header.tar.gz) so that it's clearer, what
> > I'm talking about, unfortunately I am absolute zero in C to figure
> > things out myself.
> > 
> > For example I can see that to get serial number of the device driven by
> > that library i can use a function described like this:
> > 
> > get_SerialNumber(void *ptr, wchar_t *bfr, int bfrSize);
> > 
> > As far as I can tell what it does is it gets data needed and puts it
> > into some buffer. The result of executing this function through
> > put_SerialNumber(kkmDrv) will always be returned to me as 0.
> > 
> > So to see what's in that buffer, I have to then invoke GetStatus(kkmDrv)
> > describe in .h file like GetStatus(void *ptr); and the integer result of
> > this operation will also always be 0, which means that GetStatus itself
> > ran successfully, but I don't care about that, I want to see what it
> > actually told me, not that if it told me it successfully or not. So
> > that's the main confusion. If all this is too complicated and lamely
> > explained then nevermind, I expect it to be so and I'm sorry, that's the
> > best I can do. I'm just really confused that I recieve two answers, one
> > boolean telling if function successfully invoked and one string,
> > carrying the actual data I want.
> > 
> > 
> > Best Regards,
> > 
> > Dmitry.
> > 
> UPD: you know, I can be fundamentally wrong about all this library's
> functionality. Maybe it does not give me any data afterall, I'm beginning to
> think that this integer (or rather boolean) value is all it gives me back,
> and the "real" data is just written into it's log file. Which is sufficient
> to me, so, I guess, nevermind. Sorry about wasting your time.
> 

Don't worry about wasting my time. If I didn't want to use it, I wouldn't
have looked at your mail.

Let's have a look at fptrexample.cpp in atol-header.tar.gz 

Re: [Gambas-user] static ? in variables

2017-06-15 Thread Tobias Boege
On Thu, 15 Jun 2017, PICCORO McKAY Lenz wrote:
> thanks in advance, but i have now more questions:
> 2017-06-15 8:41 GMT-04:00 Tobias Boege <tabo...@gmail.com>:
> 
> > No, the word "singleton" here just means you get an automatic instance of
> > your class, i.e. you can use the class name as if it were an object. You
> >
> automatic instance?
> 
> maybe its a translation problem, but i try to understant: wiki said here:
> http://gambaswiki.org/wiki/lang/createstatic
> in a tip:
> "allows you to implement the object-oriented programming singleton pattern
> <http://en.wikipedia.org/wiki/Singleton_pattern>."
> and i understand by singleton pattern that a only one instance du i was a
> J2EE programer:
> "restricts the instantiation
> <https://en.wikipedia.org/wiki/Instantiation_%28computer_science%29> of a
> class <https://en.wikipedia.org/wiki/Class_%28computer_programming%29> to
> one object <https://en.wikipedia.org/wiki/Object_%28computer_science%29>.
> This is useful when exactly one object is needed to coordinate actions
> across the system"
> 
> so here are some things that i cannot understant and i think its something
> with translation or?
> 

It's not a translation error, it is that "singleton" has a different meaning
in the paragraph you cite than it has in Gambas. Actually, the documentation
should probably avoid the word "singleton", because it creates confusion with
a more established notion of "singleton" (the one you cite).

Now, let me tell you again what the documentation means when it says
"singleton". When you put the CREATE STATIC keyword into the top of your
class, then the class will be made "auto-creatable". This means that if
your Gambas program uses the class name like an object, e.g. by accessing
a non-static property or method over the *class* name (which doesn't make
sense), then the interpreter will create an object out of this class
(the so-called automatic instance -- because the interpreter creates it
automatically for you in the background as soon as you need it) and uses
this object in place of the class name.

CREATE STATIC does *not* ensure that you can create *only* one instance
of the class. This is not what "singleton" means in Gambas. You can create
multiple objects out of a CREATE STATIC class.

There are two famous examples of auto-creatable (CREATE STATIC) classes,
which I can think of off the top of my head:

  (1) Settings (gb.settings), if you ever worked with it, is a class of
  which you can create as many objects as you like, right? But you can
  also use the class name "Settings" as if it were an object, e.g.

Print Settings["Key"]

  Here it looks you access a key "Key" of the class Settings, but this
  doesn't make sense as the array accessors aren't static methods of the
  Settings class. In fact, Settings, in this case, behaves as if you
  created as Settings object behind the scenes which is linked to the
  default configuration file path $XDG_CONFIG_HOME &/ Application.Name & 
".conf".
  This is precisely the automatic instance of the Settings class.

  (2) An even more prominent example: every Form class is auto-creatable.
  Have you ever wondered why, if you start your GUI project with startup
  form "FMain", a window pops up? You only have a Form class but you
  never created an object of this Form class, so where does this window
  come from? This also is the automatic instance of your class FMain,
  showing itself on startup. You can also write

FMain.Center()

  to center your main window on the screen. The class name "FMain"
  does not refer to the class, but to the automatic instance, an
  *object* of class FMain that the interpreter created and that is
  used behind the scenes.

This is the "singleton" behaviour that the documentation describes.

> 
> > Nothing extraordinary happens. You have a dynamic class with a static
> > variable and you can use the class like an object (as well as create new
> > objects of that class).
> >
> for the variable:
> 
> public statis var as string
> 
> vs
> 
> public var as strings
> 
> doc wiki said "will be shared with all the class" seems that there's no
> diference based on your answer
> 
> 

I don't understand your objection at all. Maybe the above explanation clears
things up for you?

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] static ? in variables

2017-06-15 Thread Tobias Boege
On Thu, 15 Jun 2017, PICCORO McKAY Lenz wrote:
> "This keyword is used for declaring static variables, static methods and
> singleton classes."
> 
> About singleton clases, that mean guarantee a unique instance of..
>

No, the word "singleton" here just means you get an automatic instance of
your class, i.e. you can use the class name as if it were an object. You
do *not* get a unique instance. You have to use the CREATE PRIVATE keyword
for non-instantiable classes.

> but if
> the class are not static and have one variable static, what that's means?
> 

Nothing extraordinary happens. You have a dynamic class with a static
variable and you can use the class like an object (as well as create new
objects of that class).

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Working with .so library

2017-06-15 Thread Tobias Boege
> All your help was very important for me, I now have completed my cash
> register software to the point where it does everything my company needs. I
> must say Gambas is a great language, it's very easy to learn from scratch,
> I'm surprised how obvious everything is. But there is a lot of work for me
> left to do mostly in terms of managing wrong human actions. My software
> works good if the employee doesn't do any mistakes, but that's unrealistic,
> so there's a lot of things I want to control and check. And that's where I'm
> stuck.
> 
> This library (which still calls itself a driver) theoretically is able to
> return a lot of values that I need, but I can't understand basic rules of
> how do we take output from a C-lib in Gambas.
> 
> From http://gambaswiki.org/wiki/howto/extern I understood that I need to
> locate a space in memory and pass a pointer to a library so that it can
> write data into that place in ram, which I would then read and set free.
> 
> So I have to declare a pointer, then Alloc(8) it, then pass it to my library
> and then read from it like it is a stream. Does this principle still work in
> current version of Gambas?
> 

If you do Alloc(8), then you get 8 bytes of memory. You most likely *don't*
want to read that like a stream, but use Integer@() or similar functions.

> What I don't understand is how I construct the code in my particular case.
> 
> To make an interface to the library I declare external pointer like this:
> 
> Extern CreateFptrInterface(ver As Integer) As Pointer
> 
> Then I declare some pointers that I'll use with help of the interface I
> created:
> 
> Extern put_DeviceEnable(p as Pointer, mode as Integer)
> 
> Extern GetStatus(p as Pointer, StatRequest as String)
> 
> Then I declare the pointer which will be that interface:
> 
> Public kkmDrv as Pointer
> 
> So then in sub I can do
> 
> kkmDrv = CreateFptrInterface(12) ' this establishes the interface
> 
> put_DeviceEnabled(kkmDrv, 1) ' this transfers the comand to the library
> through the interface.
> 
> And it works great.
> 
> But then If I want to get some data from the library, as I understand, I
> have to declare another pointer, allocate ram for it and pass my request.
> 
> I don't understand how should I pass that pointer to GetStatus() while also
> passing my interface pointer to it, let alone reading data back. Totally
> confused.
> 

This entirely depends on how the C functions in your library are declared.
I don't know about your specific library but commonly the occurence of an
error is indicated by an integer return code, e.g. this might be the
signature of one of the functions in your library:

  int myfunction(void *interface, int argument)

If the documentation says that the return value (int) of this function
indicates an error, then you just need to get that return value back into
your Gambas program, which you accomplish by declaring the function in
Gambas as

  Extern myfunction(interface As Pointer, argument As Integer) As Integer

(notice the trailing "As Integer"). Then you can use "myfunction" in your
Gambas code like any other function and get and interpret its return value.

So, if this convention for error reporting is used, it is much simpler to
get information about errors, without using Alloc() and co. Your library
may use a different convention which actually involves pointers, but
I wouldn't know.

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] gambas 3 and mysql

2017-06-14 Thread Tobias Boege
On Wed, 14 Jun 2017, Unaise EK wrote:
> hai,
> i worte these code for storing data into mysql database, all data stored
> into database except date_ad.
> 
> 
> Public Sub Save_button_Click()
> Dim InsertDb As String
> 'Dim Dx As Date
> 'Format(Dx, "dd/mm/")
> InsertDb = "INSERT INTO name_tbl (adm, name, place, date_ad) VALUES ('" &
> (TextBox1.Text) & "','" & (TextBox2.Text) & "', '" & (TextBox3.Text) & "',
> '" & DateBox1.Value & "' )"
> MODMain.MyConn.Exec(InsertDb)
> message("Data saved")
> clear1
> 
> 
> pls help

I think the error comes from the fact that you take DateBox1.Value and
concatenate it to a string. This triggers an implicit converion of the
Date value into a string -- but the way Gambas does this conversion is
not compatible with how MySQL excepts dates to be formatted:

  $ gbx3 -e '"|" & Now() & "|"'
  |06/14/2017 14:16:29.291|

Above is how Gambas serialises a date when concatenating it with a string
(apparently it is independent of the locale, at least), but the MySQL
documentation [1] tells you that the date separator should not be a "/"
slash, as in Gambas, but a "-" hyphen (there may be other incompatibilities,
but one is enough already for the insert to fail).

How to fix this? Writing your own "INSERT INTO" statement is already a
bad idea. Gambas' database drivers can write those statements correctly
for you already. They also prevent SQL injection attacks, such as the one
that is blatantly present in your code. Something like this would be
preferable:

  Dim hInsert As Result

  hInsert = MODMain.MyConn.Create("name_tbl")
  With hInsert
!adm = TextBox1.Text
!name= TextBox2.Text
!place   = TextBox3.Text
!date_ad = DateBox1.Value
  End With
  hInsert.Update()

If you haven't seen this before, look up the corresponding documentation
[2][3], or ask more specific questions.

Regards,
Tobi

[1] https://dev.mysql.com/doc/refman/5.5/en/date-and-time-literals.html
[2] http://gambaswiki.org/wiki/comp/gb.db/connection/create
[3] http://gambaswiki.org/wiki/comp/gb.db/result/update

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] OT: Is this junk or really a sourforge mail?

2017-06-12 Thread Tobias Boege
On Mon, 12 Jun 2017, Rolf-Werner Eilert wrote:
> This morning, I got a mail asking for confirmation of my mailing list
> accounts with sourceforge.
> 
> They have never ever done this before, so I am somewhat sceptical if this
> might be just a junk mail and I will start receiving tons of spams over that
> account.
> 

It seems to have been announced here: 
https://sourceforge.net/blog/sourceforge-project-e-mail-policy-update/

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] How can I force linux mint to upgrade gambas3 to the last update?

2017-06-11 Thread Tobias Boege
On Sun, 11 Jun 2017, Fernando Cabral wrote:
> Tobi
> 
> Excuse both my ignorance and poor communication ability. I prefer using the
> latest stable version, which I expect be the case when I resort to the PPA
> I am presently using. Now, I was not aware that those revisions are still
> considered unstable. So, I expected (wrongly, I see) that they would be
> incorporated into the stable version.
> 
> So, I will stay with the stable version and wait until the changes are made
> available for general use. Meanwhile, I'll keep using the workaround for
> the keyboard locking issue.
> 

Ok, but just a quick remark. "Unstable" is an unclear term. I, for one,
always run an unstable version of Gambas (compiled from source) and usually
have no problems. But once in a while it happens that something is broken
in the development version because of a change that was not fully thought
through; or you install a revision in the middle of someone making a bunch
of commits, before he is done with all his changes, and Gambas doesn't even
compile completely.

If you want to test a bug fix (or go on bug hunt yourself), you have to use
the unstable version, because the stable version is supposed(TM) to not have
bugs but to have confirmed bug fixes. Unstable usually isn't as bad as it
sounds.

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] How can I force linux mint to upgrade gambas3 to the last update?

2017-06-11 Thread Tobias Boege
On Sun, 11 Jun 2017, Fernando Cabral wrote:
> I have gambas3 3.9.2 running Linux Mint 18.1. I have installed gambas using
> a PPA. Is there a way I can use to force apt-get to download and install
> the last stable version? I've tried removing, purging and installing anew,
> but it seems I ended up with the same version.  From this fact I would
> guess the PPA does not represent last revision we can find at the
> sourceforge repository [r8142].
> 
> Is my understanding right?
> 
> I tried to download and compile, but there were so many modules disabled
> that I concluded gambas would barely work -- if at all.
> 
> I guess my practical question is: is there a way for me to get the latest
> revision without having to go thru the pains of finding out how to overcome
> the issues with the disabled modules and compiling from source?
> 

If you want the latest *stable* version, as you say in your first paragraph,
then you got it. 3.9.2 is the latest stable Gambas release.

On the other hand, if you want the latest SVN revision (aka "/trunk", or
more verbosely "unstable development snapshot"), as you say in the remainder
of your mail, you have to use a different PPA, called "gambas-daily".
Before I explain it with my own words, did you read the wiki page [1] ?

Regards,
Tobi

[1] http://gambaswiki.org/wiki/install/ubuntu

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Regex - expert opinion requested

2017-05-31 Thread Tobias Boege
On Wed, 31 May 2017, Fernando Cabral wrote:
> This is only for those who like to work with regular expressions.
> It is a performance issue. I am using 26 different regular expressions of
> this kind:
> 
> txt = RegExp.Replace(TextoBruto, NaoNumerais, "&1\n", RegExp.UTF8)
> txt = RegExp.Replace(Txt, "\n\n+?", "\n", RegExp.UTF8)
> txt = RegExp.Replace(Txt, "^\n+?", "", RegExp.UTF8)
> txt = RegExp.Replace(Txt, "\n+?$", "", RegExp.UTF8)
> 
> Those are pretty fast. Less than one second for a text with 415KB (about
> six thousand lines).
> 
> But the following code is quite slow. About 27 seconds each:
> 
> ttDigitos = String.Len(RegExp.Replace(TextoBruto, "[^0-9]", "",
> RegExp.UTF8)) ' 27 segundos
> ttPontuacao = String.Len(RegExp.Replace(TextoBruto, "[^.:;,?!]", "",
> RegExp.UTF8))  ' 27 segundos
> ttBrancos = String.Len(RegExp.Replace(TextoBruto, "[^ \t]", "",
> RegExp.UTF8))   ' 27 segundos
> Print "Especial antigo", Now
> 'ttEspeciais = String.Len(RegExp.Replace(TextoBruto,
> "[^-[\\](){}\"@#$%&*_+=<>/|ºª§“”‘’]", "", RegExp.UTF8))  ' 27 segundos
> Print "Especial novo", Now
> ttEspeciais = String.Len(RegExp.Replace(TextoBruto,
> "[-aeiouãáéíóúâõàbcçdfghjlmnpqrstvxyz
> ,.:;!?()0-9êôwkèìòùäÄÁÉÍÓÚÀÈÌÒÙÂÔÂÊÔÇABCDEFGHIJKLMNOPQRSTUVWXYZ]", "",
> RegExp.UTF8))  ' 27 segundos
> Print "fim especial novo", Now
> 
> Quite slow. The whole programm takes 2 minutes to run. The above lines
> alone consume 108 seconds (108:120).
> 
> I tried some variations. For instance, ttEspeciais =  has two versions.
> One negates what to leave in, the other describes what to take out. End
> result is the same. And so is the time spent.
> 
> I have also written a much longer code that does the same thing using loops
> and searching for the characters I want in or want out. The whole thing
> runs in about 5 seconds (but this code took me much, much longer do write).
> 
> I wonder if any of you could suggest potentially faster RegExp that could
> replace the specimens above.
> 

This sounds interesting, because for one thing I can't imagine a pipe chain
of "sed" invocations to take this long on just 500 KiB input (but I could
be wrong).

Also, in case you didn't know, the IDE also has a very handy profiler
(Debug > Activate profiling menu). It lets you take a somewhat closer look
at where your code spends its time, but it may not be of much help here.

About your regular expressions: I think the key point is that you are really
just erasing characters of character classes. Your expressions are extremely
simple in that regard. You mentioned that avoiding regular expressions gives
you a big speedup but the code took you longer to write. I don't see why.
You should be able to write a general function

  Private Function EraseClass(sStr As String, sClass As String) As String

which erases from sStr every character that is in sClass, using a simple
loop and String.InStr().

You can probably even abuse the Split() function for this. To remove any
single character in sClass from the string sStr, do:

  Split(sStr, sClass).Join("")

Split() probably won't behave well with multibyte characters, though, such
as the UTF-8 you require above. With both attempts it is harder to implement
the "[^...]" inverse character class syntax.

Regardless, I would be a little interested in getting a sample project which
includes your regular expressions and such a text file, to see for myself
where the time is exactly spent. Can you send a version of your project that
contains only the parts relevant to these regular expressions?

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Form listener

2017-05-29 Thread Tobias Boege
On Mon, 29 May 2017, Leon Davis wrote:
> Using Gambas v3.9.2 and GTK+3
> 
> I have added a form to another form:
> 
> Dim NForm as Form
> NForm = new MyForm(ME) as "MyForm"
> 
> The problem I'm having is none of the Key events, i.e. (keypress, keyup,
> keydown) for either form do anything. Also the Form_Resize for NForm
> doesn't fire. In my search I found an item that mentioned doing a search
> for listener in the Gambas wiki but that search was unsuccessful. Searched
> the mailing list with the same result. Any suggestions?

What is your problem exactly; where does the event not fire? But let me make
a guess to what question you are asking and answer that question.

You want to know why the Form_Resize event in your MyForm class does not
fire? The reason for this is that you give your NForm instance of the MyForm
class an event name "MyForm" explicitly (by using As "MyForm").

I'll assume that the above code is executed inside another Form called, say,
FParent. If you create an object inside FParent and give it an event name,
as you do above, FParent will become the *default event observer* for that
object. It will intercept all the events that the object NForm raises and
these events will be issued under the event name "MyForm" you specified.

Why is this a problem? Normally, forms are their own default event observer,
under the event name "Form". This is a mechanic hidden inside the Form class
code -- when a form object is created and detects that it hasn't gotten an
explicit default event observer, it makes itself its own event observer.
This is what enables you to normally intercept a Form's Resize event inside
its own class code, by defining the Form_Resize event handler.

To summarise: because you use the As "MyForm" syntax, you give NForm a new
default event observer (namely FParent). You can now intercept the events of
NForm inside the code of FParent, by using the event name MyForm, but you
*cannot* intercept the events in the MyForm code using the event name Form
anymore.

The solution is: don't use the As "MyForm" syntax if you want to continue
receiving NForm's events inside MyForm's class code. Instead you should
*duplicate* all the events by using an Observer:

  Dim NForm As MyForm
  Dim hObs As Observer

  NForm = New MyForm
  hObs = New Observer(NForm) As "MyForm"

Now you have NForm which is its default event observer (so Form_Resize will
fire inside the MyForm class) and you duplicate all the events that happen
through the observer, so you also receive the events in FParent, such as
MyForm_Resize. I believe this is what you mean by "listener", but the
appropriate Gambas term is "observer".

The article "The Gambas Object Model" [1] in the wiki should be mandatory
reading for everyone. It feels like I spend more time citing this page than
anything else I do on this mailing list.

Regards,
Tobi

[1] http://gambaswiki.org/wiki/doc/object-model#t10

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Reg expression still beating me up

2017-05-28 Thread Tobias Boege
On Sun, 28 May 2017, Fernando Cabral wrote:
> In the piece of code bellow, RegExp.Replace will never return.
> 
> Sentencas[i] = "Test string."
> Print "Before replacing"
> Sentencas[i] = RegExp.Replace(Sentencas[i], "[.:!?;]*[ ]*?\n*?", "",
> RegExp.UTF8)
> Print "After replacing"
> 
> It beats me, because what it should do is very simple: optionally find one
> of the punction marks (.:?!;) optionally followed by any number of white
> space, optionally followed by any number of "\n" (end of line). Replace
> whatever is found with an empty string.
> 
> In the text string, it should find the dot (.) and replace it with nothing.
> So, the returned string should be "Test string".
> 
> Alas! It will never come back. Same if I replace the test string with
> "Test string. \n" or "Test string.\n"
> 
> Now, this works as expected, but this is not what I need:  "[.:!?;][
> ]*?\n*?", ""
> To my eyes, "[.:!?;]*[ ]*?\n*?" is a perfectly valid regular expression.
> 
> Any hints?
> 

RegExp.Replace() wants to replace *all* occurences of the expression.
It is basically a loop of RegExp.Exec() followed by a substitution, as
long as the RegExp.Exec() call finds something.

Now look at your expression. Since everything is optional, your expression
matches the empty string. RegExp.Exec() will always find the empty string
and replace it with itself, giving you an infinite loop.

I think that the behaviour of RegExp.Replace() in this case is sound and
you should use a better expression, that is guaranteed to match a string
of positive length or not match at all.

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] rdir returns unwanted directories

2017-05-28 Thread Tobias Boege
On Sun, 28 May 2017, Gianluigi wrote:
> Hi Tobias,
> if I have in my home a directory named image with a subfolder named
> my-image, containing both images, and I write:
> 
> Public Sub Main()
> 
>   Dim sFileArray As String[]
>   Dim s As String
>   Dim sPath As String = "~/image"
>   ' Run directory e sub-directory
>   sFileArray = RDir(sPath, "*.{png,jpg}", gb.File)
>   For Each s In sFileArray
> Print s
>   Next
> 
> End
> 
> I obtain this:
> 
> my-image/actress.png
> my-image/alfa.jpg
> my-image/lamb.jpg
> snail.jpg
> horse.jpg
> oggy.png
> sparkle.png
> homer.jpg
> 
> 
> In the first three cases, to get the only file name, I need your suggestion.
> 
> Do not work so RDir to you?
> 

Oh, now the whole thread makes sense to me! I thought your problem was that
if you have a *directory* named "x.jpg" and issued

  RDir(..., "*.{png,jpg}", gb.File)

the gb.File filter was ignored and you were reported the directory "x.jpg",
because the "*.{png,jpg}" pattern matched. But you just wanted to get rid of
the directory component. Then you have your solution (use File.Name on s)
and there is no problem. Our RDir()s behave the same.

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] rdir returns unwanted directories

2017-05-28 Thread Tobias Boege
On Sun, 28 May 2017, Charlie wrote:
> I presume you just want the file name not the folder details. If so try this,
> sFiles will contain just the file name: -
> *Public Sub Form_Open()
> Dim sFileArray As New String[]
> Dim sFiles As New String[]
> Dim sTemp As String
> sFileArray = RDir(User.Home, "*", gb.File) 
> For Each sTemp In sFileArray
>   sFiles.Add(Mid(sTemp, RInStr(sTemp, "/") + 1))
> Next
> End*

Instead of Mid(sTemp, RInStr(sTemp, "/") + 1) you may want to use the
appropriately named function File.Name(sTemp).

Still, using RDir(..., "*", gb.File) only gives me files, no directories,
so I can't reproduce your original problem here.

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] gb.debug: Unable to open fifo

2017-05-23 Thread Tobias Boege
On Tue, 23 May 2017, T Lee Davidson wrote:
> Hello folks,
> 
> I am trying to see if gb.debug will help me diagnose why HttpClient does not 
> properly expose redirect response codes on my 
> system (and reportedly Tobi's system) while it does so correctly on Benoît's 
> system.
> 
> However, the documentation for gb.debug is so sparse that I am having to 
> experiment and, of course, having a problem.
> 
> With the following command-line application code (using the gb.debug 
> component):
> ' Gambas module file
> 
> Public Sub Main()
> 
>Dim sName As String
> 
>sName = Debug.Begin()
>Print sName
>Debug.Start ' Unable to open fifo
>Debug.Write("Hello world")
>Debug.Stop
>Debug.End
> 
> End
> 
> Public Sub Debug_Read(Data As String)
> 
>Print Data
> 
> End
> ' End Gambas module file
> 
> Debug.Start causes an exception: "Unable to open fifo". By looking in 
> /tmp/gambas.1000/, I can see that the process id input and 
> output pipes are successfully created with the correct file mode permissions 
> (600) for my user as owner. But, the Start 
> procedure apparently cannot open the output fifo (ref. 
> https://sourceforge.net/p/gambas/code/HEAD/tree/gambas/trunk/main/lib/debug/CDebug.c).
> 
> Am I attempting to use this component incorrectly?
> 

I think you're attempting to use the wrong component. gb.debug is meant for
the Gambas IDE to debug a Gambas project. You can look at the source code of
the IDE to try to figure out how to use it. I don't understand its protocol
at all. My wild guess is that your error comes from not having started the
application in debug mode (gbx3 -g)?

In any case, I doubt debugging your *Gambas* code will give you any insight
into the gb.net.curl issue, as gb.net.curl and curl itself are not written
in Gambas.

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] What is the maximum text we can put on a TextArea?

2017-05-23 Thread Tobias Boege
On Tue, 23 May 2017, Fernando Cabral wrote:
> How much text can we display on TextArea?
> Even after performing serval tests I couldn' t find out.
> It seems sometimes I can display 7000 characters,
> sometimes  twice as much.
> 
> Perhaps someone can point me the proper documentation.
> 

Whatever the answer is, it is not to be found in the Gambas documentation.
Gambas borrows its primitive graphical controls from toolkits, Gtk and QT,
in (meanwhile) multiple versions. Their documentation is where you should
start looking. (I would *assume* that the answer is: as much as memory
permits.)

I don't know where your problems with text input controls come from but I
just generated a 10^6 characters long string and inserted it into a TextArea
without any problems.

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Split: misleading Wiki

2017-05-22 Thread Tobias Boege
On Mon, 22 May 2017, Matti wrote:
> If I have a string sStr="hello##12345" and want to split it:
> 
> Dim aSplit as String[]
> aSplit = Split(sStr, "##")
> Print aSplit[0], aSplit[1]
> 
> Returns always only "hello". Maybe "12345" is excluded because being an 
> integer?
> 

It is not an integer in this case. It's a string of characters and Split()
doesn't interpret it as an integer. Consequently it has nothing to do with
IgnoreVoid in my book.

If anything is wrong, it is your use of the separator. According to the
documentation (and the implementation!), the Separator argument is a *list*
of separator characters, i.e. "##" will not split against the string "##",
but it will split against "#" or "#".

To give a different example, if you had given the string "abc#123,456" and
separators "#," you would have gotten the array ["abc", "123", "456"].

> Now the Wiki says "StringArray = Split ( String [ , Separators , Escape , 
> IgnoreVoid , KeepEscape ] )"
> Where "IgnoreVoid" means "a boolean that tells Split() *not* to return void 
> elements."
> 
> By trial and error I found out that "IgnoreVoid" has to be set to 'True' to 
> return "12345". Exactly the opposite.
> 
> The Wiki should be corrected here.
> 

I don't know what's the problem with your installation but on mine I get:

  $ gbx3 -e 'Split("hello##12345", "##").Join("|")'
  hello||12345

i.e. it works. Notice the empty string between "hello" and "12345"
in the context of what I explained about the separators above!

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] can a result database object be copy to other database (of different type)

2017-05-22 Thread Tobias Boege
On Mon, 22 May 2017, PICCORO McKAY Lenz wrote:
> umm usefully, but the source its odbc.. was my faul...
> 
> in any case, there's posible to cpy between results object of differents
> connections? that the right quiestion!
> 

Ok, after I formulated my answer, I can see how you may want to use Gambas
for this task.

Assume you have hSrc and hDst two Connections -- hSrc is the source database
and hDst is the destination database. The DB types don't matter! I would do
the conversion in two stages:

  1. Copy the database users (Connection.Users), then the databases
 (Connection.Databases) and after that the table schemas (Connection.Tables)
 for each database. I don't think you can expect to transfer anything
 else like permissions because it is not supported by the gb.db
 interface (sqlite doesn't even support users).

 You can use the gb.db objects for this, e.g. to copy the schema of a
 database table, you get the corresponding Table object and iterate
 through its Fields member to get all the fields. Luckily the field
 types are db.String, db.Integer, etc., i.e. *Gambas* constants. You
 can easily transfer this common representation of the table schema to
 your destination database.

  2. Copy all the records. hSrc.Find(tablename) (or so) gives you all the
 records in the given table. Recreate all the records in the appropriate
 destination database table, using hDst.Create(tablename).

I'm reasonably sure that there is no less manual way. But beware that you
might run into problems of all thinkable kinds, e.g. with auto-increment
fields which you may or may not be allowed to set on your own when you
create a record, or maybe one database type stores milliseconds together
with a date while the other is incapable of that. What do I know?

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] can a result database object be copy to other database (of different type)

2017-05-22 Thread Tobias Boege
On Mon, 22 May 2017, PICCORO McKAY Lenz wrote:
> i mean, due the now well knowed problem of odbc,
> 
> i have two databases, db1 can be mysql, odbc, etc, and the other target db
> must be sqlite..
> 
> can be possible to port from the db1 to the memory table in sqlite3 db2 ?
> or at leas ina normal sqlite3 table?
> 

This is not a Gambas problem anymore is it? Did you consider the solutions
that the obvious web search yields, e.g. [1] ?

Regards,
Tobi

[1] https://stackoverflow.com/questions/3890518/convert-mysql-to-sqlite

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Passing arguments between WebPages

2017-05-18 Thread Tobias Boege
On Thu, 18 May 2017, Tobias Boege wrote:
> Hi Benoit (or gb.web experts),
> 
> I have two questions about argument passing with WebPages (gb.web),
> when I include one webpage into another with the <> syntax.
> 
> (1) The first situation is that I have a small widget encapsulated in a
> WebPage, let's say it is a specially formatted button MyButton.webpage.
> It expects to be included with a text to put on the button:
> 
>   <>
> 
> I want to be able to pass the value of a local variable of my parent
> WebPage inside this argument like this (which doesn't work):
> 
>   <% For Each iInd = 0 To AllButtons - 1 %>
> <>
>   <% Next %>
> 
> Is this possible? A workaround here would be to define a function in the
> parent WebPage which creates and renders an instance of MyButton and call
> that, resulting in something like:
> 
>   <% For Each iInd = 0 To AllButtons - 1 %>
> <%= RenderButton(Subst$("Button #&1", iInd)) %>
>   <% Next %>
> 
> This is good enough but I'm curious if the <> syntax admits
> the other kind of argument passing somehow, as I think it would make
> the parent WebPage prettier.
> 

Hrrm, so after reading main/gbc/gbc_form_webpage.c more attentively, I have
learned that this is also possible without weird hacks, and the syntax is
also sound, just a small bit different from what I imagined it would look
like above. *Instead of*

  <>

you have to wrap the expression you want to evaluate inside <%=%>, so this
works as I wanted it to:

  <>>

(On a tangent, I once designed a very simple (yet Turing-complete) text
substitution "programming language" on top of Gambas. The abundance of
angular brackets and special symbols above kind of reminds me of it --
you could only produce "write-only" code in that language.)

Sorry for the noise, but there's still hope that this can still help others
in the future.

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Passing arguments between WebPages

2017-05-18 Thread Tobias Boege
On Thu, 18 May 2017, Tobias Boege wrote:
> (2) The other question is about receiving arguments. If I'm a child page
> and the parent included me by setting the "text" argument (like in (1)),
> then I can print the "text" value via the special syntax
> 
>   <%!text>
> 
> But I want to use this value inside a <% Code %> or <%= Expr %> section,
> to evaluate or manipulate it (this also doesn't work, but hopefully gets
> my question across):
> 
>   <%= Subst$(!text, "#", "No. ") %>
> 
> For instance, is there a hidden Collection containing all the passed
> arguments somewhere in the scope in which <% Code %> and <%= Expr %>
> execute?
> 

Turns out there is and it's called _Arg. (It didn't occur to me before that
I should look at gb.web's source code as well; I only tried to understand
gbc_form_webpage.c). So the following demonstrates that what I wanted is
possible (although not documented, so nobody should use it, of course):

  <%= _Arg!text %>

is the same as

  <%! text %>

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Class startup?

2017-05-18 Thread Tobias Boege
On Thu, 18 May 2017, PICCORO McKAY Lenz wrote:
> 2017-05-18 9:13 GMT-04:00 Tobias Boege <tabo...@gmail.com>:
> 
> > You can also specify parameters to the _new() method like
> >
> >   ' In MyClass.class:
> >   Public Sub _new(X As Integer)
> > ' ...
> >   End
> >
> 
> a question: can be "Optional" allowed in constructor arguments..?
> 
> its possible, so its the same as override in C:
> 
> Public Sub _new(Optional x As String = "pepe")
> 
>   Print " es " & x
> 
> End
> 
> gambas its wonderfull
> 

Yes, they can be optional.

If you use optional constructor arguments you have to be careful with
inheritance, though! Along the inheritance lineage, all constructor
arguments are divided into two camps: mandatory and optional arguments.
When the final inherited constructor signature is computed, both camps
are sorted separately with the elders' arguments first and then all the
mandatory arguments precede the optional arguments, e.g.

  ' Parent.class
  Public Sub _new(ParentArg, ParentArg2, Optional ParentOpt)

  ' Child.class
  Inherits Parent
  Public Sub _new(ChildArg, Optional ChildOpt)

results in the following complete signature for Child._new():

  _new(ParentArg, ParentArg2, ChildArg, ParentOpt, ChildOpt)

Note that the optional argument of the parent comes *after* the mandatory
argument of the child. There is an extra section in the object model wiki
page about this [1].

Regards,
Tobi

[1] http://gambaswiki.org/wiki/doc/object-model#t18

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


[Gambas-user] Passing arguments between WebPages

2017-05-18 Thread Tobias Boege
Hi Benoit (or gb.web experts),

I have two questions about argument passing with WebPages (gb.web),
when I include one webpage into another with the <> syntax.

(1) The first situation is that I have a small widget encapsulated in a
WebPage, let's say it is a specially formatted button MyButton.webpage.
It expects to be included with a text to put on the button:

  <>

I want to be able to pass the value of a local variable of my parent
WebPage inside this argument like this (which doesn't work):

  <% For Each iInd = 0 To AllButtons - 1 %>
<>
  <% Next %>

Is this possible? A workaround here would be to define a function in the
parent WebPage which creates and renders an instance of MyButton and call
that, resulting in something like:

  <% For Each iInd = 0 To AllButtons - 1 %>
<%= RenderButton(Subst$("Button #&1", iInd)) %>
  <% Next %>

This is good enough but I'm curious if the <> syntax admits
the other kind of argument passing somehow, as I think it would make
the parent WebPage prettier.

(2) The other question is about receiving arguments. If I'm a child page
and the parent included me by setting the "text" argument (like in (1)),
then I can print the "text" value via the special syntax

  <%!text>

But I want to use this value inside a <% Code %> or <%= Expr %> section,
to evaluate or manipulate it (this also doesn't work, but hopefully gets
my question across):

  <%= Subst$(!text, "#", "No. ") %>

For instance, is there a hidden Collection containing all the passed
arguments somewhere in the scope in which <% Code %> and <%= Expr %>
execute?

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Class startup?

2017-05-18 Thread Tobias Boege
On Thu, 18 May 2017, alexchernoff wrote:
> Good day all,
> 
> is there a way to have a routine execute in a class as soon as a new
> instance of it is created? I have a Public Sub Main() but it doesn't seem to
> run. 
> 
> I come to Gambas from Xojo and there classes have a Constructor() sub which
> runs on init.
> 
> thanks!
> 

The constructor is called _new in Gambas (see [1]):

  Public Sub _new()
' runs on object creation
  End

You can also specify parameters to the _new() method like

  ' In MyClass.class:
  Public Sub _new(X As Integer)
' ...
  End

which demands that an Integer be given on object instantiation:

  Dim h As New MyClass(10) ' X = 10

Regards,
Tobi

[1] http://gambaswiki.org/wiki/cat/special

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] 16 bit value in hex with MSB and LSB?

2017-05-18 Thread Tobias Boege
On Thu, 18 May 2017, alexchernoff wrote:
> Good day all,
> 
> In a serial string I receive a 16 bit value split into MSB and LSB in hex,
> for example 15000 (3A 98) is sent as 2 bytes containing decimal values  of
> 3A and 98.
> 
> To convert that to decimal, I have to convert each to hex strings, join
> them, add  to it and then convert "" to decimal. 
> 
> Maybe there is an easier way? 
> 
> Thanks! 
> 

Yes, there is. Above you go from a number over a string to a number. Ditch
the string and use the Integer bit manipulation functions:

  Dim a, b As Integer

  a = 
  b = 
  Print a, b, Lsl(a, 8) Or b

Declaring a and b as Integer (not as Byte) is important here because you are
going to use the left shift function and you want to be sure that you don't
shift your bits to nirvana. Output is as expected:

  58  152 15000

Also note that with numerical values there is no distinction between
"decimal" and "hex" or any other base you may imagine. A number is a number,
independent of a representation to a particular basis.

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] result from select can be movefirts from ODBC?

2017-05-17 Thread Tobias Boege
On Thu, 18 May 2017, Cristiano Guadagnino wrote:
> If your complaint is due to the fact that the only native implementation
> for Gambas is the Mysql one, you have to understand that Mysql (usually in
> the form of MariaDB) is available on all linux distributions and it is
> free.
> One other free DBMS available for all linuxes is Postgresql, but this is
> not even nearly as widely used as Mysql. I would not be very surprised if,
> in fact, the great majority of Gambas developers were using Mysql. What's
> wrong with that?
> 

(Just a quick interjection: Gambas does have a native PostgreSQL driver.)

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] result from select can be movefirts from ODBC?

2017-05-17 Thread Tobias Boege
On Wed, 17 May 2017, PICCORO McKAY Lenz wrote:
> i try to filla gridview at demand, so due ODBC limitations i cannot count
> so inside my bean-like object i count and tehen return properties..
> 
> the problem goes when i try to move to the fitrs record, i implement the
> code in wrong way? :
> 
> Try resulobj = $conexionodbc.Exec(exisqueryrequest)
> 
>   While (resulobj.Available)
> 
> If resulobj.MoveNext() Then
>   resulhowmany = resulhowmany + 1
> Else
>   Break
> Endif
> 
>   Wend
> 
>   resulobj.MoveFirst ' <--- here said that its foward only, that's true if
> comes from a simple select ?
> 

I don't understand your last question (and I have no idea about bean-like
objects outside of gardening) but according to the Result.MoveNext()
documentation [1]:

  Returns TRUE if the result is void or if there is no next record.

You seem to increment your counter when the move *fails*, which will give
you a wrong count. I usually do something like:

  ' Modifies the internal Result record pointer!
  Private Sub CountResult(hRes As Result) As Integer
Dim iCount As Integer

If hRes.MoveFirst() Then Return 0
iCount = 1
While Not hRes.MoveNext()
  Inc iCount
Wend
Return iCount
  End

Regards,
Tobi

[1] http://gambaswiki.org/wiki/comp/gb.db/result/movenext

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Huge data in gridview documentation wiki does not explain how

2017-05-16 Thread Tobias Boege
On Tue, 16 May 2017, PICCORO McKAY Lenz wrote:
> umm so then as you said, the rs number 3 does not load until i get down
> the gridview to the row 3! ?
> 

Yes, why don't you try it yourself?

> if this the case, how can i implement a search input that retrieve data
> when i put strings!?
> 

At the risk that I didn't understand your question: The GridView does
not store the data permanently, so you can't search it, but your data
is stored somewhere, right? In your case your data comes from a data-
base, so you search the database.

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Huge data in gridview documentation wiki does not explain how

2017-05-16 Thread Tobias Boege
On Tue, 16 May 2017, PICCORO McKAY Lenz wrote:
> In gambas wiki documentation said:
> 
> You can fill the grid explicitly, or implement the Data
>  event to display
> the grid contents on demand.
> 
> You should use the last method if you have a lot of rows to display. The
> control can handle millions of lines gracefully.
> 
> but i try to set gridview.data event and set GridView1*.*Data*.*Text but
> when comes the object said it null (Data) ...
> 
> its there any example to load? i have a CSV and also a table db.. please
> its the documentation wrong?
> 

It's not. This method is so fast and easy on memory because you load the
GridView contents *on demand*. Read the text carefully: it tells you that
the GridView will raise the Data *event* (not the Data property; it even
links to the Data event documentation [1] which is IMHO comprehensive
enough) when it needs the contents of certain cells.

So, when the GridView control detects that it should display a certain cell,
identified by a Row and a Column number, it will raise the GridView_Data
event with just these Row and Column arguments. *During* such a Data event,
the GridView.Data property will contain a valid object and you have to
retrieve the cell data somehow (from your CSV file or database or ...) and
store it inside the GridView.Data property. You may only use the Data
property during the Data event.

If you still need an example, the IDE source code has some. You can also
look at the implementation of the ListBox control in gb.gui.base. It uses
the Data event of a GridView internally, too. (Who would've thought that
the ListBox is also just a GridView in disguise?)

Regards,
Tobi

[1] http://gambaswiki.org/wiki/comp/gb.qt4/gridview/.data

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Serial I/O with byte data

2017-05-14 Thread Tobias Boege
On Sun, 14 May 2017, alexchernoff wrote:
> Good day all, 
> 
> Anyone know how to read data received on serial port into an array of bytes
> instead of string?
>

I think that's not possible.

> String gets unreadable binary characters, so how can I 
> put them into byte[] or so? 
> 

This shouldn't be a problem. Gambas Strings are not null-terminated and can
contain any sequence of bytes, which includes non-printable characters (which
I think is what you meant by "unreadable" characters).

If you insist on a Byte[], read it into a String and use Byte[].FromString(),
but there is no way to go around the String, AFAICT (and that is because
there is no need to, as Strings can handle binary data just fine).

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Keyboard locked -- insisting one more time

2017-05-13 Thread Tobias Boege
On Sat, 13 May 2017, Fernando Cabral wrote:
> Using IDE I can't edit my source code. It seems locked up. To no avail, I
> have followed every hint I' ve received from you guys. I've done more. I
> have uninstalled the whole gambas package. I have even searched every file
> using find and locate so as not to leave any remains behind. I compressed
> and save source code and moved all of them to a different directory.
> 
> After that, I installed gambas3. The First time, I used apt-get and got an
> older version. It did not work. I uninstalled and proceeded to full removal
> again.
> Then installed one more time using PPA. Again, it dis not work.
> 
> I even tried using a virtual keyboard (Florence). Same problem.
> 
> I am at a complete lost. I have no idea where else, or what else to look
> for.
> 
> Will someone be kind enough to tell me what the IDE looks for to decide if
> the source code is locked or not for edition?
> 
> One more note: I can use cut, copy and paste. Everything that can be done
> with a mouse click works, but the keys used for editing are all locked
> (arrows, character, pgdn, pgup, etc.)
> 
> I've created a virtual machine with the same environment (linux mint 18.1).
> There I can install gambas and change my source code.
> 
> Any hints, no matter how crazy, will be much appreciated. I have already
> lost a bunch of hours trying to figure this out, but have made no progress
> so far.
> 

I haven't been closely attending the other thread(s) but from this summary
it sounds to me like the problem is somewhere between your keyboard and the
IDE and not inside of the IDE. This would explain why chmod'ing didn't cure
the symptom. I'll try to convince you of that below.

It might still be a problem inside the graphical Gambas components, for
instance, which handle keyboard input, but since you completely removed and
re-installed Gambas multiple times and confirm it works under another
installation of the same distribution, this sounds less likely than, say,
an incompatibility or misconfiguration of another package. Then again this
is also unlikely since Gambas is the only program that misbehaves, right?

So, I have no other hints to give. But I can answer your question:

> Will someone be kind enough to tell me what the IDE looks for to decide if
> the source code is locked or not for edition?

There are two ways to make files non-editable in the IDE: the first is
making the project globally read-only, the other is locking specific files.

For project-wide locking, quoting Project.module:Open() in the IDE source:

   467 Public Function Open(sDir As String, Optional bInAnotherWindow As 
Boolean) As Boolean
   ...
   523   ReadOnly = Not Access(sDir, gb.Write)
   524
   525   If Not ReadOnly Then
   526 If Exist(sDir &/ ".startup") And If Not Access(sDir &/ ".startup", 
gb.Write) Then ReadOnly = True
   527   Endif
   528
   529   Try hLock = Lock sDir &/ ".lock"
   530
   531   If Not ReadOnly And ((bConvert And Exist(sDir &/ ".lock")) Or Not 
hLock) Then
   532 If Message.Warning(("This project seems to be already 
opened.\n\nOpening the same project twice can lead to data loss."),
   533 ("Open after all"), ("Do not open")) = 2 Then
   534   Return True
   535 Endif
   536   Endif

sDir is the project directory. So it first checks whether the project
directory is writable by the current user. If the directory can be written
to but the .startup file exists and is not writable, the project is also
considered read-only.

Looking further at line 531: the bConvert Boolean is not important (it is
set when opening a Gambas 2 project inside the Gambas 3 IDE) and we can
suppose it is False. Then the next condition is that hLock is Null. This
happens precisely when the Lock instruction in line 529 fails, i.e. when
the project is already opened by another instance of the IDE or the lock
file was not removed by a previous IDE accessing the project (because it
terminated abnormally for instance).

The presence of the lock file does *not* set read-only mode. It just makes
the IDE confirm that you know you're opening a locked project and you may
do so and edit the project. If the project is globally read-only (by the
project directory or .startup not being writable), the IDE tells you this
after opening the project: see the attached screenshot.

Locking individual files works basically the same. The locking mechanism
is invoked from the Gambas form/code editor with the "Lock / unlock file"
button, which you can see in the other attached screenshot. If a file is
locked like this, the IDE displays an indication besides the file name,
which the screenshot also shows.

How does this type of locking work? Look at Editor/Code/FEditor.class:

  3745 Public Sub Action_Activate((Key) As String) As Boolean
  3746
  3747   Select Case Key
  3748
  3749 Case ".locked"
  3750   Project.SetReadOnly(Path, Action[Key, Me].Value)

and then

  5749 Public Sub SetReadOnly(sPath As String, 

Re: [Gambas-user] String[].Find finds nothing

2017-05-10 Thread Tobias Boege
On Wed, 10 May 2017, Matti wrote:
> Yes. But as I don't know [iIndex], I have to iterate through the (huge) array 
> with 'For...Next'.
> I hoped to make it faster with 'Find'.

You can make the code smaller by using the optional Mode parameter to
String[].Find() (cf. the docs [1]). The following will work as you wanted:

  Dim aNames As New String[]

  aNames.Add("Anna")
  aNames.Add("Berta")
  aNames.Add("Christa")
  aNames.Add("Dora")

  Print aNames.Find("Chr*", gb.Like)
  ' will print 2

but it will probably make the code slower because the gb.Like mode makes the
Find() operation significantly more complex. I would recommend you test it
out though. Also let me say that Gambas can't perform wonders. Just because
you call a single built-in function doesn't make the operation fast. If your
array is huge and unsorted, all searches will be slow. In fact, the Find()
method is implemented as a For-Next loop (in C, admittedly).

Regards,
Tobi

[1] http://gambaswiki.org/wiki/comp/gb/string[]/find

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Gambas binary to ELF?

2017-05-05 Thread Tobias Boege
On Fri, 05 May 2017, alexchernoff wrote:
> Well thanks Tobias, that's a great idea. 
> 
> The "AXprotector" ELF protector encrypts the executable so it should be
> safe. 
> 
> Any suggestions how to build such a self-extractor ELF? 
> 
> thanks!
> 

Try the attached archive. It contains 3 things:

  * a simple Gambas project called gbdigest: it uses gb.openssl to hash
its input using a digest algorithm that is installed on your system.
It also uses gb.args to let you specify the digest algorithm through
its -m command-line switch and the output format through the -o switch.
The string to hash is the list of all the non-options you specify
on the command-line or, if that list is empty, it reads each line
from stdin.

These mechanics serve to demonstrate a lot of things: the ELF wrapper
allows you to execute a Gambas program that was compiled into it.
Loading Gambas components written in C (gb.openssl) and in Gambas (gb.args)
works. The command-line arguments and standard file descriptors are
properly passed from the ELF wrapper to the Gambas process.

  * mkelf-template.c: template C code for the ELF wrapper.

  * mkelf.sh: uses the xxd utility (included in the vim package) and
mkelf-template.c to compile an ELF program which executes a given
Gambas program. The executable Gambas archive (.gambas file) is
embedded into the ELF file.

Here is an example usage:

  ## Unpack the archive
  [~]$ tar -zxf gambaself.tar.gz
  [~]$ cd gambaself

  ## Create an ELF wrapper "mydigest" for the Gambas program "gbdigest.gambas"
  [gambaself]$ ./mkelf.sh gbdigest.gambas mydigest
  [gambaself]$ file mydigest
  mydigest: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically 
linked, [...]

  ## Start the program, request its --help. As you can see the program name is 
set to "gbdigest.gambas"
  [gambaself]$ ./mydigest --help
  Usage: gbdigest.gambas  

  Options:
   -m --method  Digest method
   -o --outformat Output format of digest: 
raw|hex|base64
   -V --version   Display version
   -h --help  Display this help

  ## You can verify its output by using md5sum from coreutils
  [gambaself]$ ./mydigest -o hex abc   # Arguments passing test
  900150983cd24fb0d6963f7d28e17f72
  [gambaself]$ echo "abc" | ./mydigest -o hex  # Reading from stdin test
  900150983cd24fb0d6963f7d28e17f72
  [gambaself]$ echo -n "abc" | md5sum
  900150983cd24fb0d6963f7d28e17f72  -

  ## Again with sha256sum
  [gambaself]$ ./mydigest -m sha256 -o hex abc
  ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad
  [gambaself]$ echo -n abc | sha256sum
  ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad  -

There is one big problem though. The Gambas interpreter (gbr3 for .gambas
files) requires, AFAIK, a real file as input. I included a long comment in
the mkelf-template.c file about that, but I might as well parrot its
contents here. I think this is because the interpreter, when loading an
archive file, uses mmap() on it. This is probably what makes it impossible
to use a FIFO to pass the Gambas archive file, which resides in memory
in the "mydigest" process, on to the gbr3 process to have it executed.

Currently the template takes the Gambas archive and puts it into a temporary
file which is then read by a gbr3 process and after that the temporary file
is removed. But there is a very long window where the Gambas executable is
somewhere on disk, which makes all your protection of the ELF file useless.

I bet you can change the interpreter into accepting Gambas executables
from FIFOs, but you have to decide for yourself if you want to do that.
It may just be that you have to replace that particular mmap() call in
main/share/gb_arch_temp.h:load_arch() with a read() or so, but it could
also require much more effort -- I haven't look into it. Or you get
another idea for avoiding the temporary file. But this has reached a
point of hackiness where I should probably stop giving you ideas.

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk


gambaself.tar.gz
Description: Binary data
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Close If Clicked Outside Form

2017-05-04 Thread Tobias Boege
On Thu, 04 May 2017, herberth guzman wrote:
> Hi
> 
> Close If Clicked Outside Form
> 
> Is there any way to close a form if it is clicked outside the main form?
> 
> For example, just as applets on the network or audio volume or KDE menu.
> 

Try the Deactivate event. The documentation doesn't really state what it
means for a window to be "deactivated" but a quick test shows that this
event is raised when the window ceases to be... the active one, e.g. when
you click outside of it or select another window by Alt+Tab (on my desktop
at least).

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Math Operation

2017-05-04 Thread Tobias Boege
On Thu, 04 May 2017, cheikh diabang wrote:
> hello. i have write this code below on gambas 3.9.2 and when i run that, he 
> indique syntaxe error
> 
> 
> Function calcul_coefficients(x As Integer, y As Integer, degre As Integer) As 
> Float
>   'Dim ak As Float
>   Dim a As Float
>   Dim b As Float
>   Dim c As Float
>   Dim nbr_coef As Integer
>   Dim k As Integer
> 
>   nbr_coef = degre + 1
>For k = 0 To degre
> If k == 0
> 'ak = (nbr_coef ^ k * ((x ^ (2(1 / (k + 1 * y) - (x * (y * (x ^ (- (k 
> - 1)) / ((nbr_coef * x ^ 2) - ((x) ^ 2))
>   c = (nbr_coef ^ k * ((x ^ (2(1 / (k + 1 * y) - (x * (y * (x ^ (- (k 
> - 1)) / ((nbr_coef * x ^ 2) - ((x) ^ 2))
> Else If k == 1
>   b = ((nbr_coef ^ k) * ((x ^ (2(1 / (k + 1 * y) - (x * (y * (x ^ (- 
> (k - 1)) / ((nbr_coef * x ^ 2) - ((x) ^ 2))
> Else If k == 2
>   a = ((nbr_coef ^ k) * ((x ^ (2(1 / (k + 1 * y) - (x * (y * (x ^ (- 
> (k - 1)) / ((nbr_coef * x ^ 2) - ((x) ^ 2))
> Else
>   Message.Info("unavalaible coefficients")
>Next
>Return a, b, c
> End
> 
> 
> But i see nothing as error. I need help please

Look closer:

>   a = ((nbr_coef ^ k) * ((x ^ (2(1 / (k + 1 * y) - (x * (y * (x ^ (- 
> (k - 1)) / ((nbr_coef * x ^ 2) - ((x) ^ 2))
>   2(1 / (k + 1))

Since "2" is not a function, you have to write

  2*(1 / (k + 1))

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Gambas binary to ELF?

2017-05-04 Thread Tobias Boege
On Thu, 04 May 2017, alexchernoff wrote:
> Good day all,
> 
> anyone know of a way to make an ELF format file from Gambas executable?
> 
> I try a "software protection" system (WIBU KEY), to protect a Gambas project
> from unwanted copying, but it can only protect ELF binaries and doesn't
> recognize a Gambas executable.
> 
> Cheers!
> 

The, AFAIK, only Gambas compiler, gbc3, produces Gambas bytecode files which
are not ELF, as you know. There is a gb.jit component with an LLVM-based JIT
compiler. Maybe this contains all the necessary gears already to compile a
Gambas project's instructions to host system opcodes. But then you would
still have to take care of linking, especially interfacing with components
written in Gambas. It sounds like some work.

This may look like a trivial answer, but if you can protect absolutely every
ELF file as long as it's in the ELF format, just pack an archive of the
Gambas bytecode together with a copy of the interpreter executable inside
an ELF executable. That outer executable works like a self-extracting
archive: it extracts the Gambas bytecode and the interpreter and runs the
interpreter on the bytecode. Voila, the working Gambas program inside ELF.

You can easily achieve this by writing some template code for the self-
extracting archive and then embedding the compiler and the archive into
its .data section.

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] Help wanted for aspell installation

2017-05-01 Thread Tobias Boege
On Sun, 30 Apr 2017, Fernando Cabral wrote:
> Hello
> 
> After downloading gb.aspell I tried to install the package running ./reconf
> as indicated. Nevertheless, it has not worked. Any help much appreciates.
> Error messages follow.
> 
> hostname  ~/Downloads/gambas3-3.9.2/gb.aspell $ ./reconf
> autoreconf: Entering directory `.'
> autoreconf: configure.ac: not using Gettext
> autoreconf: running: aclocal
> configure.ac:6: error: AC_INIT should be called with package and version
> arguments
> /usr/share/aclocal-1.15/init.m4:29: AM_INIT_AUTOMAKE is expanded from...
> acinclude.m4:65: GB_INIT_AUTOMAKE is expanded from...
> acinclude.m4:124: GB_INIT_SHORT is expanded from...
> acinclude.m4:163: GB_INIT is expanded from...
> configure.ac:6: the top level
> autom4te: /usr/bin/m4 failed with exit status: 1
> aclocal: error: echo failed with exit status: 1
> autoreconf: aclocal failed with exit status: 1
> 

gb.aspell is ancient. The last update to the sourceforge repository was in
2008 if I'm not mistaken. The error above tells you that its configure.ac
file is meanwhile incompatible with your version of the GNU autotools.
You can fix that by yourself by looking at the configure.ac's of components
inside the Gambas source tree and making gb.aspell's look like them.
Note that this error happens at the "reconf" stage. After that are still
the "configure" and "make" stages where less trivial errors could pop up.

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] RegExp.Replace() question

2017-04-29 Thread Tobias Boege
On Sat, 29 Apr 2017, Fernando Cabral wrote:
> Benoît
> 
> I am prety new to Gambas, but quite an old hand with regular expression
> (almost from the time when sed, awk and vi were created. All of them allow
> heavy use of regular expression). It took me many hours to understand that,
> contrary to customs,
> Gambas regex are ungreedy. It took me some more hours to find out that "?"
> could be used to make the operators
> + and * to work as usual (I mean, for old hands like me). And half an hour
> more to find out that "&1" replace the older "\1" and not so old "$1".
> Those things are annoying when you are getting used to a new lingo.
> 

But these two things could have been cleared up by looking at the right
portion(!) of the documentation, which is often hard to find in the
beginning, I know.

RegExp.Replace() is a method of the RegExp class which resides in the
gb.pcre component. Its main page in the wiki [1] tells you that PCRE are
Perl-Compatible Regular Expressions and links to the libpcre [2] page
for its syntax. The Replace() method page [3] itself tells you to use
"&1" for backreferences. This is for consistency with the Subst$()
intrinsic function and other substitution functions in Gambas which
came before RegExp.Replace() -- all of them use "&1".

And for the future: you will encounter another type of regular expressions
much more often in Gambas than the PCREs, namely the LIKE expressions [4].
You will notice that they are very primitive, maybe too primitive if you're
used to sed-style expressions, and have an incompatible syntax.

Regards,
Tobi

[1] http://gambaswiki.org/wiki/comp/gb.pcre
[2] http://gambaswiki.org/wiki/doc/pcre
[3] http://gambaswiki.org/wiki/comp/gb.pcre/regexp/replace
[4] http://gambaswiki.org/wiki/lang/like

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


  1   2   3   4   5   6   7   8   9   10   >