[Gambas-user] C component declaration

tercoide tercoide at ...67...
Tue Dec 29 23:48:02 CET 2015


How to declare arrays when making a component, ie :
C declaration in library
void glVertexPointer(GLint size, GLenum type, GLsize stride, const GLvoid*array)

C gb component

GB_STATIC_METHOD( ......??

DECLARE_METHOD(.....?



Ing. Martín P. Cristiá


-------- Mensaje original --------
De: gambas-user-request at lists.sourceforge.net
Fecha:29/12/2015  14:15  (GMT-03:00)
A: gambas-user at lists.sourceforge.net
Asunto: Gambas-user Digest, Vol 115, Issue 66

Send Gambas-user mailing list submissions to
        gambas-user at lists.sourceforge.net

To subscribe or unsubscribe via the World Wide Web, visit
        https://lists.sourceforge.net/lists/listinfo/gambas-user
or, via email, send a message with subject or body 'help' to
        gambas-user-request at lists.sourceforge.net

You can reach the person managing the list at
        gambas-user-owner at lists.sourceforge.net

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Gambas-user digest..."


Today's Topics:

   1. Re: POSSIBLE!   bug in while loop (Stephen)
   2. Re: non printable char "?" how to remove from string!!!!!
      (Ru Vuott)
   3. SimpleEval (Charlie)
   4. Re: non printable char "?" how to remove from string!!!!! (ML)
   5. Re: non printable char "?" how to remove from string!!!!!
      (Fabien Bodard)
   6. Re: non printable char "?" how to remove from string!!!!!
      (Fabien Bodard)
   7. Re: Global variables (was: POSSIBLE! bug in while loop)
      (Tobias Boege)


----------------------------------------------------------------------

Message: 1
Date: Tue, 29 Dec 2015 08:37:14 -0500
From: Stephen <sbungay at ...3301...>
Subject: Re: [Gambas-user] POSSIBLE!   bug in while loop
To: Robert Boykin <rsboykin at ...2755...>,   mailing list for gambas users
        <gambas-user at lists.sourceforge.net>
Message-ID: <56828C8A.7060508 at ...3301...>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Reading this, in addition to seeing the need for a "Wait", I thought the
following;

   Does putting the desired global variable in a class mean the class
needs to be instantiated within the scope of the code example given? i.e.

PUBLIC GlobalVar as globalVars ' Change the name of the class to keep
the var name within the example unchanged.

within the code of the form which contains the GObtn and exitBtn objects?

The above would make GlobalVars.iexit visible to all classes outside of
the scope of where it was instantiated, so all forms in the project
could then see it.

However this can be avoided if the variable "iexit" is declared in a
"module" as opposed to a "class". Doing this it instantly becomes global
within the scope of the project, requiring only the addition of the
"Wait" to process the exitBtn_Click() event and exit the loop.

The change to the code is minimal;

' Gambas class file

' Static Private iexit As Integer = 0
Public Sub _new()
End

Public Sub Form_Open()
  GlobalVars.iexit = 0
End

Public Sub GObtn_Click()
  Dim n As Integer

  n = 0

  While n < 100000
        Print n
        n = n + 1
        Wait ' This is new
        If GlobalVars.iexit > 0 Then Break
  Wend
End

Public Sub exitBtn_Click()
   GlobalVars.iexit = 10
End

   This works, tested under GAMBAS 3 on Fedora 14.


On 12/28/2015 09:55 PM, Robert Boykin wrote:
> Test Program code is:
> ' Gambas class file
>
> ' Static Private iexit As Integer = 0
> Public Sub _new()
> End
>
> Public Sub Form_Open()
>   GlobalVar.iexit = 0
> End
>
> Public Sub GObtn_Click()
>   Dim n As Integer
>   n = 0
>   While n<  100000
>   Print n
>   n = n + 1
>   If GlobalVar.iexit>  0 Then Break
>   Wend
> End
> Public Sub exitBtn_Click()
>   GlobalVar.iexit = 10
> End
>
> This is gambas3 on linux mint 17.3 using gb.qt4
> running on a generic desktop PC
>
> The simple form has two buttons,
> one to start a while loop
> that prints numbers to the console, and
> one to set a global variable to a value which
> should cause a break in the while loop.
>
> The global variable is defined in the class GlobalVar
> ' Gambas class file
>
> Static Public iexit As Integer = 0
>
> The program begins printing numbers upon clicking the Gobtn
> but will not stop printing when the exitBtn is cliked.
>
> It appears that the exitBtn _Click() event is not recognized
>   during execution of the while loop.
>
> I am just learning gambas on my own using
>   what examples and tutorials I can find on the internet
> and believe I may have left something out.
>
> Robert S. Boykin
> ------------------------------------------------------------------------------
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>


--
Kindest Regards
Stephen A. Bungay, Prop.
Smarts On Site Information Systems




------------------------------

Message: 2
Date: Tue, 29 Dec 2015 14:53:06 +0000 (UTC)
From: Ru Vuott <vuott at ...325...>
Subject: Re: [Gambas-user] non printable char "?" how to remove from
        string!!!!!
To: mailing list for gambas users <gambas-user at lists.sourceforge.net>,
        Fabien Bodard <gambas.fr at ...626...>
Message-ID:
        <1123045648.7112215.1451400786758.JavaMail.yahoo at ...3424...>
Content-Type: text/plain; charset=UTF-8

Tchao Fabien,


> Ru ..? Characters > to 127 are printable...

uhmmm... excuse me, but I do not understand.
If I test the "printability" :-)  of "characters > to 127" by using C "isprint()" function (that checks whether the passed character is printable), I obtain only zero results.
Where: "isprint()" function returns a non-zero value (true) if character is printable, else zero (false) if character is NOT printable.

*****************************************************
#include <stdio.h>


int main() {

        int i, c;

        for (i=128; i <= 255; ++i) {
                c = isprint(i);
                printf("%d     %d\n", i, c);
        }

   return (0);

}
*****************************************************

So, it seems resulting that "characters > to 127" are NOT printable characters.


Ciao



------------------------------

Message: 3
Date: Tue, 29 Dec 2015 07:18:36 -0700 (MST)
From: Charlie <charlie at ...2793...>
Subject: [Gambas-user] SimpleEval
To: gambas-user at lists.sourceforge.net
Message-ID: <1451398716924-55114.post at ...3046...>
Content-Type: text/plain; charset=us-ascii

Hi Fabian,
I presume that you wrote the code in SimpleEval. I can't work out how to use
it. I thought it might work with my gbCalculator (see Gmabas Farm). There
are quite a few compile warning errors.
<http://gambas.8142.n7.nabble.com/file/n55114/CompileErrors.png>
*The main thing is some examples on how to use it please.*
Thanks.



--
View this message in context: http://gambas.8142.n7.nabble.com/SimpleEval-tp55114.html
Sent from the gambas-user mailing list archive at Nabble.com.

------------------------------

Message: 4
Date: Tue, 29 Dec 2015 12:35:43 -0300
From: ML <d4t4full at ...626...>
Subject: Re: [Gambas-user] non printable char "?" how to remove from
        string!!!!!
To: gambas-user at lists.sourceforge.net
Message-ID: <5682A84F.1080800 at ...626...>
Content-Type: text/plain; charset=utf-8

All,

I might be utterly wrong, but since Linux normally uses UTF-8, any
high-bit-set char may be interpreted as one of the "multibyte char" flags.
If isprint() takes this into account, then it's dead right that char by
itself is not printable!

Hope that helps and makes sense...

On 2015-12-29 11:53, Ru Vuott wrote:
> Tchao Fabien,
> Ru ..  Characters > to 127 are printable...
> uhmmm... excuse me, but I do not understand.
> If I test the "printability" :-)  of "characters > to 127" by using C "isprint()" function (that checks whether the passed character is printable), I obtain only zero results.
> Where: "isprint()" function returns a non-zero value (true) if character is printable, else zero (false) if character is NOT printable.
>
> *****************************************************
> #include <stdio.h>
> int main() {
>       int i, c;
>       for (i=128; i <= 255; ++i) {
>               c = isprint(i);
>               printf("%d     %d\n", i, c);
>       }
>    return (0);
> }
> *****************************************************
> So, it seems resulting that "characters > to 127" are NOT printable characters.
> Ciao



------------------------------

Message: 5
Date: Tue, 29 Dec 2015 16:39:28 +0100
From: Fabien Bodard <gambas.fr at ...626...>
Subject: Re: [Gambas-user] non printable char "?" how to remove from
        string!!!!!
To: mailing list for gambas users <gambas-user at lists.sourceforge.net>
Message-ID:
        <CAFkCsL4daC-rrNjUVgjF3CYr6OWH_vS1O9NCmHdmWiFY=sPL_Q at ...627...>
Content-Type: text/plain; charset=UTF-8

But is print just take into account the old asci table


2015-12-29 16:35 GMT+01:00 ML <d4t4full at ...626...>:
> All,
>
> I might be utterly wrong, but since Linux normally uses UTF-8, any
> high-bit-set char may be interpreted as one of the "multibyte char" flags.
> If isprint() takes this into account, then it's dead right that char by
> itself is not printable!
>
> Hope that helps and makes sense...
>
> On 2015-12-29 11:53, Ru Vuott wrote:
>> Tchao Fabien,
>> Ru ..  Characters > to 127 are printable...
>> uhmmm... excuse me, but I do not understand.
>> If I test the "printability" :-)  of "characters > to 127" by using C "isprint()" function (that checks whether the passed character is printable), I obtain only zero results.
>> Where: "isprint()" function returns a non-zero value (true) if character is printable, else zero (false) if character is NOT printable.
>>
>> *****************************************************
>> #include <stdio.h>
>> int main() {
>>       int i, c;
>>       for (i=128; i <= 255; ++i) {
>>               c = isprint(i);
>>               printf("%d     %d\n", i, c);
>>       }
>>    return (0);
>> }
>> *****************************************************
>> So, it seems resulting that "characters > to 127" are NOT printable characters.
>> Ciao
>
> ------------------------------------------------------------------------------
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user



--
Fabien Bodard



------------------------------

Message: 6
Date: Tue, 29 Dec 2015 16:54:29 +0100
From: Fabien Bodard <gambas.fr at ...626...>
Subject: Re: [Gambas-user] non printable char "?" how to remove from
        string!!!!!
To: mailing list for gambas users <gambas-user at lists.sourceforge.net>
Message-ID:
        <CAFkCsL7n0WVu6oV5KH5Y831djg++0H7N4yYAHVFKQr7T1ztVUg at ...627...>
Content-Type: text/plain; charset=UTF-8

To resume ... in the old past of ascii all standart printer or monitor
can manage ascii and print 32 to 127 chars. So Ansi C provide a
standart function named IsPrint that allow to say if a char was able
to be printed.

IN 2015... Ascii is known in it's 8 bit format so printable chars are
from 32 to 255.

Characters lower than 32 are for monitor, modem and printer management.

Thanks to my terminal studie i'm now able to understand all of that :-).

It's really interresting to study the past ...

2015-12-29 16:39 GMT+01:00 Fabien Bodard <gambas.fr at ...626...>:
> But is print just take into account the old asci table
>
>
> 2015-12-29 16:35 GMT+01:00 ML <d4t4full at ...626...>:
>> All,
>>
>> I might be utterly wrong, but since Linux normally uses UTF-8, any
>> high-bit-set char may be interpreted as one of the "multibyte char" flags.
>> If isprint() takes this into account, then it's dead right that char by
>> itself is not printable!
>>
>> Hope that helps and makes sense...
>>
>> On 2015-12-29 11:53, Ru Vuott wrote:
>>> Tchao Fabien,
>>> Ru ..  Characters > to 127 are printable...
>>> uhmmm... excuse me, but I do not understand.
>>> If I test the "printability" :-)  of "characters > to 127" by using C "isprint()" function (that checks whether the passed character is printable), I obtain only zero results.
>>> Where: "isprint()" function returns a non-zero value (true) if character is printable, else zero (false) if character is NOT printable.
>>>
>>> *****************************************************
>>> #include <stdio.h>
>>> int main() {
>>>       int i, c;
>>>       for (i=128; i <= 255; ++i) {
>>>               c = isprint(i);
>>>               printf("%d     %d\n", i, c);
>>>       }
>>>    return (0);
>>> }
>>> *****************************************************
>>> So, it seems resulting that "characters > to 127" are NOT printable characters.
>>> Ciao
>>
>> ------------------------------------------------------------------------------
>> _______________________________________________
>> Gambas-user mailing list
>> Gambas-user at lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/gambas-user
>
>
>
> --
> Fabien Bodard



--
Fabien Bodard



------------------------------

Message: 7
Date: Tue, 29 Dec 2015 18:14:14 +0100
From: Tobias Boege <taboege at ...626...>
Subject: Re: [Gambas-user] Global variables (was: POSSIBLE! bug in
        while loop)
To: mailing list for gambas users <gambas-user at lists.sourceforge.net>
Message-ID: <20151229171414.GA6720 at ...2774...>
Content-Type: text/plain; charset=us-ascii

On Tue, 29 Dec 2015, Stephen wrote:
> Reading this, in addition to seeing the need for a "Wait", I thought the
> following;
>
>    Does putting the desired global variable in a class mean the class
> needs to be instantiated within the scope of the code example given? i.e.
>

Strictly speaking, yes.

> PUBLIC GlobalVar as globalVars ' Change the name of the class to keep
> the var name within the example unchanged.
>
> within the code of the form which contains the GObtn and exitBtn objects?
>
> The above would make GlobalVars.iexit visible to all classes outside of
> the scope of where it was instantiated, so all forms in the project
> could then see it.
>

Not really. If Form1 is the form where the Public declaration above is made,
then another class would have to use Form1.GlobalVar.iexit to access the
iexit variable. It cannot directly *see* the GlobalVar object.

> However this can be avoided if the variable "iexit" is declared in a
> "module" as opposed to a "class". Doing this it instantly becomes global
> within the scope of the project, requiring only the addition of the
> "Wait" to process the exitBtn_Click() event and exit the loop.
>

I take it that your question is "why?". You can think of a module as a class
which has an implicit

  Create Static

statement in its header and where every symbol is implicitly Static. [ Note
that you *can* instantiate a module using New, i.e. it is not implicitly
Create Private, but you cannot do anything with an instance of a module
because every symbol is static (accessing any symbol from the instance
throws a "<class>.<symbol> is static" error). ]

Read about the Create Static statement here[0]. To explain my first comment
above: You need to have an object of your global variables class available
to use those variables. But employing Create Static you can basically make a
class name (and class names are project-global) refer to an object (the
automatic instance of that class). The result is that you have a globally
accessible object.

Regards,
Tobi

[0] http://gambaswiki.org/wiki/lang/createstatic

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



------------------------------

------------------------------------------------------------------------------


------------------------------

_______________________________________________
Gambas-user mailing list
Gambas-user at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


End of Gambas-user Digest, Vol 115, Issue 66
********************************************



More information about the User mailing list