Re: [Gambas-user] Weather app in Software Farm

2017-07-16 Thread Tony Morehen

I just uploaded a version that uses the gb.gui component instead of

gb.qt5.  It also has a workaround that may fix your error. That error
arises when your system does not have a systray enabled.  See:

https://unix.stackexchange.com/questions/278104/app-icons-dont-appear-in-system-tray-on-linux-mint-17-3

I haven't been able to test since I'm running Manjaro.  What version of
Mint are you using : Cinnamon, Mate Xfce? 17.? 18.?


On 2017-07-15 09:39 AM, Charlie wrote:

Tony Morehen wrote

I just uploaded a Weather systray app to the software farm.
Comments/suggestions welcome.  Enjoy.

Hi Tony,

I tried your program on a computer at work and got it working after adding
*gb.qt4*. Linux Mint does not have QT5 yet. I tried it a home but even after
fixing QT I got: -

*"sni-qt/5871" WARN  12:51:31.765 void
StatusNotifierItemFactory::connectToSnw() Invalid interface to SNW_SERVICE *

After 20 seconds FMain appeared but with no data.

Not sure what the problem is.




-
Check out www.gambas.one
--
View this message in context: 
http://gambas.8142.n7.nabble.com/Weather-app-in-Software-Farm-tp59768p59771.html
Sent from the gambas-user mailing list archive at Nabble.com.

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




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

2017-07-16 Thread T Lee Davidson

On 07/16/2017 06:57 AM, Shane wrote:

given this example

PRIVATE SUB BinaryRead(FilePath AS String)
   DIM binaryFile AS File
   DIM i AS Integer
   DIM b AS Byte
   DIM s AS Short
   DIM s1 AS String
   DIM s2 AS String
   ' Read binary file
   binaryFile = OPEN FilePath FOR READ
   READ #binaryFile, i
   READ #binaryFile, b
   READ #binaryFile, s
   READ #binaryFile, s1
   READ #binaryFile, s2
   CLOSE #binaryFile
   ' Display results
   PRINT i
   PRINT b
   PRINT s
   PRINT s1
   PRINT s2
END


is there a way for gambas to read a struct of all these variables
in one read ?




You may have hinted at the solution within your question. Have you considered 
using a Structure?

http://gambaswiki.org/wiki/lang/read :
"... reads the stream Stream as binary data whose type is specified by the Datatype 
argument."

"The returned datatype can be one of the following: NULL, Boolean, Byte, Short, Integer, Long, Pointer, Single, Float, Date, 
String, Variant, any Array, Collection or structure."


http://gambaswiki.org/wiki/lang/structdecl


--
Lee

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

2017-07-16 Thread Gianluigi
Hi Adrien,

Thank you very much for the detailed answer.
Now I know how to behave the next time I'm wrong :)

Regards
Gianluigi

2017-07-16 16:03 GMT+02:00 Adrien Prokopowicz 
:

> Le Sun, 16 Jul 2017 15:10:55 +0200, Gianluigi  a
> écrit:
>
> Thanks Adrien,
>> I was able to mistake my first insertion (I left useless code) :(.
>> Can I fix it? [0]
>>
>> Regards
>> Gianluigi
>>
>> [0]
>> http://gambas.8142.n7.nabble.com/Best-ways-to-format-float-v
>> alues-td59733.html
>>
>>
> Hi Gianluigi,
>
> You can't edit anonymous Gists once they are created, but a bit of extra
> code is
> no big deal, you can just edit your code in the playground and generate a
> new link.
> (GitHub has plenty of storage space. :) )
>
> As a side note, if you happen to accidentally share sensitive data inside
> a code link
> (such as passwords), you can contact the GitHub team[0] and ask them to
> delete it.
> The playground itself does not store anything, so you don't need to worry
> about it.
>
> If, in the future, you want to share some code on the playground and be
> able to edit
> it later, you can log in in GitHub, create a Gist from there and then
> manually craft
> a link to the playground like this :
> https://gambas-playground.proko.eu/?gist=your_gist_id_here
>
> Hope this helps. :)
>
> [0] https://help.github.com/articles/deleting-an-anonymous-gist/
> --
> Adrien Prokopowicz
>
> 
> --
> 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
>
--
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 Playground

2017-07-16 Thread Adrien Prokopowicz
Le Sun, 16 Jul 2017 15:10:55 +0200, Gianluigi  a  
écrit:



Thanks Adrien,
I was able to mistake my first insertion (I left useless code) :(.
Can I fix it? [0]

Regards
Gianluigi

[0]
http://gambas.8142.n7.nabble.com/Best-ways-to-format-float-values-td59733.html



Hi Gianluigi,

You can't edit anonymous Gists once they are created, but a bit of extra  
code is
no big deal, you can just edit your code in the playground and generate a  
new link.

(GitHub has plenty of storage space. :) )

As a side note, if you happen to accidentally share sensitive data inside  
a code link
(such as passwords), you can contact the GitHub team[0] and ask them to  
delete it.
The playground itself does not store anything, so you don't need to worry  
about it.


If, in the future, you want to share some code on the playground and be  
able to edit
it later, you can log in in GitHub, create a Gist from there and then  
manually craft

a link to the playground like this :
https://gambas-playground.proko.eu/?gist=your_gist_id_here

Hope this helps. :)

[0] https://help.github.com/articles/deleting-an-anonymous-gist/
--
Adrien Prokopowicz

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

2017-07-16 Thread Gianluigi
Thanks Adrien,
I was able to mistake my first insertion (I left useless code) :(.
Can I fix it? [0]

Regards
Gianluigi

[0]
http://gambas.8142.n7.nabble.com/Best-ways-to-format-float-values-td59733.html

2017-07-16 11:11 GMT+02:00 Karl Reinl :

> Am Sonntag, den 16.07.2017, 01:37 +0200 schrieb Adrien Prokopowicz:
> > Hello Everyone !
> >
> > These past few days I had fun putting together an online playground for
> > Gambas !
> > You can find it here : https://gambas-playground.proko.eu/ :)
> >
> > The playground is a little place to write and run Gambas code snippets,
> > which I
> > think could be very useful in the mailing-list where codes flies around
> > everywhere. :)
> >
> > You can also directly share a link of your code in the playground using
> the
> > "Share" button, which will generate a link like this :
> >
> > https://gambas-playground.proko.eu/?gist=07db52169ef8b747d26f8bee4a4a19
> e9
> >
> > The code is actually stored in a GitHub Gist, rather than in the
> playground
> > itself, which makes it completely stateless.
> >
> > Of course, since this is a web service (i.e. not your computer ! :) ),
> > there are
> > a few limitations :
> >
> > - Your code cannot run for more than 2 seconds, or it will get SIGKILL'd
> > - It cannot use more than 16 megabytes of RAM (it segfaults if you use
> too
> > much)
> > - You cannot make any network access whatsoever (there are no network
> > cards,
> >and the process does not have permission to open sockets).
> > - You *can* read, write or delete any file, but all changes to the
> > filesystem
> >are discarded when the process ends.
> > - There are probably a few edge cases I didn't think of, so please don't
> > abuse
> >it. :)
> >
> > However, a few components are available, just add the USE instruction to
> > load
> > it, just like you would in a Gambas script. Here is an example :
> >
> > https://gambas-playground.proko.eu/?gist=8a49aae5f5e24569c3f7f7e55c619f
> 05
> >
> > The following components are available in the playground :
> >
> >gb.args, gb.clipper, gb.complex, gb.compress, gb.data, gb.debug,
> gb.draw,
> >gb.eval, gb.eval.highlight, gb.geom, gb.image.effect, gb.image,
> > gb.inotify,
> >gb.markdown, gb.option, gb.settings, gb.signal, gb.term, gb.util,
> > gb.util.web,
> >gb.vb, gb.xml, gb.xml.html
> >
> > (Basically, any component that doesn't depend on networking or GUI, tell
> > me if
> > any is missing :) )
> >
> > Behind the scenes, it is a simple Gambas application serving a REST API,
> > which takes the code as input. It then spins up a Docker container, which
> > has
> > a simple "runner" Gambas application as its init process, which takes the
> > code,
> > feeds it to the Gambas Scripter (gbs3) and then returns its output.
> >
> > The app is still a bit rough on the edges (for instance, I should make a
> > proper
> > Gambas highlighter for the editor, instead of using the VBScript one :p),
> > but I think it is good enough to see some use.
> >
> > Tell me if you have some ideas to improve it, and have fun with it ! :)
> >
>
> Salut Adrien,
>
> now we can discuss 'Best ways to format float values' like this
>
> look here you can test Nando's way
>
> https://gambas-playground.proko.eu/?gist=037e17d22f3ac93cd3da3d6ad681f713
>
> Thanks
> --
> Amicalement
> Charlie
>
>
> 
> --
> 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
>
--
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-16 Thread Gianluigi
The street indicated by Tobias should be the safest, right?

I try to attach Adrien's link instead of the code:
https://gambas-playground.proko.eu/?gist=f5dbde82ee8f5f1f5799184108fd57c1

Regards
Gianluigi

2017-07-16 11:47 GMT+02:00 Gianluigi :

> Hi Nando,
>
> good explanation, suitable for a guys with an elementary school
> preparation like me.
>
> Thank you very much
>
> Gianluigi
>
> 2017-07-16 10:07 GMT+02:00 :
>
>> Rounding depends on what rounding you want.
>> Most people think of 5/4 rounding.
>> I prefer to round manually 5/4... 5 up, 4 down.
>>
>> Dim n as Float = 26.6601
>>
>> n = n * 100.  'n = 2666.01   ' 2 decimal points rounding
>> n = n + 0.5   'n = 2666.51 <(516)%20666->   ' 5/4 rounding*
>> n = CLong(n)  'n = 2666
>> n = n / 100.  'n = 26.66
>>
>>
>> *If you wish to round down, do not add 0.5.  (add 0.0)
>> *If you wish to round up, add 0.9
>>
>> If you wish to do 3 digits, then *1000 and /1000.
>> This works for any type of rounding scheme and any reasonable number of
>> digits.
>>
>> -Nando(Canada)
>>
>>
>> --
>> Open WebMail Project (http://openwebmail.org)
>>
>>
>> -- Original Message ---
>> From: Gianluigi 
>> To: mailing list for gambas users 
>> Sent: Thu, 13 Jul 2017 12:30:23 +0200
>> Subject: Re: [Gambas-user] Best ways to format float values
>>
>> > One thing that could be useful?
>> >
>> > Public Sub Main()
>> >
>> >   Dim n As Float = 26.66016
>> >   Dim b As Byte
>> >
>> >   b = Val(Mid(CStr(Frac(n)), 5, 1))
>> >   Print Round(n, -2)
>> >   If b >= 5 Then
>> > Print Round(n, -2)
>> >   Else
>> > Print Round(n + 0.01, -2)
>> >   Endif
>> >
>> > End
>> >
>> > Regards
>> > Gianluigi
>> >
>> > 2017-07-13 7:39 GMT+02:00 alexchernoff :
>> >
>> > > Peace to all,
>> > >
>> > > this might a bit silly but what is the best way to format float
>> values like
>> > > 26.66016 into having two digits AND/OR  with rounding them?
>> > >
>> > > e.g.
>> > >
>> > > 26.66016 becomes 26.66 shortened
>> > > 26.66016 becomes 26.67 rounded
>> > >
>> > > cheers!
>> > >
>> > >
>> > >
>> > >
>> > >
>> > > --
>> > > View this message in context: http://gambas.8142.n7.nabble.
>> > > com/Best-ways-to-format-float-values-tp59733.html
>> > > Sent from the gambas-user mailing list archive at Nabble.com.
>> > >
>> > > 
>> > > --
>> > > 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
>> > >
>> > 
>> --
>> > 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
>> --- End of Original Message ---
>>
>>
>> 
>> --
>> 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
>>
>
>
--
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] My quest for efficiency

2017-07-16 Thread Fernando Cabral
Thank you, Caveat [emptor?].
The code you proposed worked very, very well.
In fact, I timed it against two versions of the C program and the result
was quite good.
In C, reading from the standard input and writing to the standard output
took a trifle beyond half a second (0.6?? real time).

Meanwhile, your version in Gambas ran in 2.5?? (real time). The question
mark means little variation from trial to trial.

Out of curiosity, I wrote a Gambas version similar to the C version. Here
are the two codes:

  *Dim b As Byte*




*  While Not Eof()b = Read As ByteWrite (b + 11) As Byte  Wend*

- - - - -  - -





*  int c;  while((c = getchar()) != EOF) putchar(c + 11);*

The C version ran in 0.59 against the Gambas version that ran in 7.6
seconds (real time). Not too bad in my opinion!

Then I tried to stretch it a little bit and wrote:


*  Write (( Read As Byte) + 11) As Byte*
Alas! this is something Gambas does not understand.

These are just for the sake of experience. I am happy with the solution
Caveat proposed.
Thank you.

2017-07-15 17:28 GMT-03:00 Caveat :

> Something is horribly wrong, or you're running on a 286 :-)
>
> I just tested here, and the program runs on a 51 MB test file in about 5
> seconds.
>
> Some reasonably well commented code for you...
>
> Public Sub Main()
>
>   Dim inFile, outFile As File
>   Dim buff As New Byte[1024]
>   Dim idx, remBytes, readSize As Integer
>
>   ' CHANGE THIS to your input file
>   inFile = Open "/home/caveat/Downloads/mytestfile" For Read
>
>   ' CHANGE THIS to your output file
>   outFile = Open "/home/caveat/Downloads/mytestfile.out2" For Create
>
>   ' Remaining bytes starts as the total length of the file
>   remBytes = Lof(inFile)
>
>   ' Until we reach the end of the input file...guess you could instead
> check on remBytes...
>   While Not Eof(inFile)
> If remBytes > buff.length Then
>   ' Limit reading to the size of our buffer (the Byte[])
>   readSize = buff.length
> Else
>   ' Only read the bytes we have left into our buffer (the Byte[])
>   readSize = remBytes
> Endif
> ' Read from the input file into our buffer, starting at offset 0 in
> the buffer
> buff.Read(inFile, 0, readSize)
> ' Update the number of bytes remaining...
> remBytes = remBytes - readSize
> ' Run round each byte in our buffer
> For idx = 0 To buff.length - 1
>   ' Dunno if you need any conditions, I check for > 30 as I can put
> newlines in the file to make it more readable for testing
>   If buff[idx] > 30 Then
> ' This is the 'trick' you need to apply... subtract 11 from every
> byte in the file
> ' Not sure how you deal with edge cases... if you have a byte of
> 5, is your result then 250?
> buff[idx] = buff[idx] - 11
>   Endif
> Next
> ' Write the whole buffer out to the output file
> buff.Write(outFile, 0, readSize)
>   Wend
>
>   Close #inFile
>   Close #outFile
>
> End
>
>
> Kind regards,
> Caveat
>
> On 15-07-17 21:24, Benoît Minisini via Gambas-user wrote:
>
>> Le 15/07/2017 à 20:49, Tony Morehen a écrit :
>>
>>> Did you try Benoit's suggestion:
>>>
>>> Public Sub Main()
>>>
>>>Dim sIn as String
>>>Dim sOut as String
>>>
>>>sIn = File.Load("/home/fernando/temp/deah001.dhn")
>>>sOut = Add11(sIn)
>>>File.Save("/home/fernando/temp/deah001.11Added.dhn", sOut)
>>>
>>> End
>>>
>>> Public Sub Add11(InputString as String) as String
>>>Dim bArray As Byte[]
>>>Dim String11 As String
>>>Dim i As Integer
>>>
>>>bArray = Byte[].FromString(InputString)
>>>For i = 0 To bArray.Max
>>>  bArray[i] += 11
>>>Next
>>>   Return bArray.ToString
>>> End
>>>
>>>
>>>
>> Just a remark:
>>
>> You don't have to use Byte[].FromString.
>>
>> You can use the Bute[].Read() method instead, to load the file directly
>> into the array. You save an intermediate string that way.
>>
>> Regards,
>>
>>
>
>
> 
> --
> 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
>



-- 
Fernando Cabral
Blogue: http://fernandocabral.org
Twitter: http://twitter.com/fjcabral
e-mail: fernandojosecab...@gmail.com
Facebook: f...@fcabral.com.br
Telegram: +55 (37) 99988-8868
Wickr ID: fernandocabral
WhatsApp: +55 (37) 99988-8868
Skype:  fernandojosecabral
Telefone fixo: +55 (37) 3521-2183
Telefone celular: +55 (37) 99988-8868

Enquanto houver no mundo uma só pessoa sem casa ou sem alimentos,
nenhum político ou cientista poderá se gabar de nada.
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! 

[Gambas-user] reading files

2017-07-16 Thread Shane

given this example

PRIVATE SUB BinaryRead(FilePath AS String)
  DIM binaryFile AS File
  DIM i AS Integer
  DIM b AS Byte
  DIM s AS Short
  DIM s1 AS String
  DIM s2 AS String
  ' Read binary file
  binaryFile = OPEN FilePath FOR READ
  READ #binaryFile, i
  READ #binaryFile, b
  READ #binaryFile, s
  READ #binaryFile, s1
  READ #binaryFile, s2
  CLOSE #binaryFile
  ' Display results
  PRINT i
  PRINT b
  PRINT s
  PRINT s1
  PRINT s2
END


is there a way for gambas to read a struct of all these variables
in one read ?


--
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-16 Thread Gianluigi
Hi Nando,

good explanation, suitable for a guys with an elementary school preparation
like me.

Thank you very much

Gianluigi

2017-07-16 10:07 GMT+02:00 :

> Rounding depends on what rounding you want.
> Most people think of 5/4 rounding.
> I prefer to round manually 5/4... 5 up, 4 down.
>
> Dim n as Float = 26.6601
>
> n = n * 100.  'n = 2666.01   ' 2 decimal points rounding
> n = n + 0.5   'n = 2666.51   ' 5/4 rounding*
> n = CLong(n)  'n = 2666
> n = n / 100.  'n = 26.66
>
>
> *If you wish to round down, do not add 0.5.  (add 0.0)
> *If you wish to round up, add 0.9
>
> If you wish to do 3 digits, then *1000 and /1000.
> This works for any type of rounding scheme and any reasonable number of
> digits.
>
> -Nando(Canada)
>
>
> --
> Open WebMail Project (http://openwebmail.org)
>
>
> -- Original Message ---
> From: Gianluigi 
> To: mailing list for gambas users 
> Sent: Thu, 13 Jul 2017 12:30:23 +0200
> Subject: Re: [Gambas-user] Best ways to format float values
>
> > One thing that could be useful?
> >
> > Public Sub Main()
> >
> >   Dim n As Float = 26.66016
> >   Dim b As Byte
> >
> >   b = Val(Mid(CStr(Frac(n)), 5, 1))
> >   Print Round(n, -2)
> >   If b >= 5 Then
> > Print Round(n, -2)
> >   Else
> > Print Round(n + 0.01, -2)
> >   Endif
> >
> > End
> >
> > Regards
> > Gianluigi
> >
> > 2017-07-13 7:39 GMT+02:00 alexchernoff :
> >
> > > Peace to all,
> > >
> > > this might a bit silly but what is the best way to format float values
> like
> > > 26.66016 into having two digits AND/OR  with rounding them?
> > >
> > > e.g.
> > >
> > > 26.66016 becomes 26.66 shortened
> > > 26.66016 becomes 26.67 rounded
> > >
> > > cheers!
> > >
> > >
> > >
> > >
> > >
> > > --
> > > View this message in context: http://gambas.8142.n7.nabble.
> > > com/Best-ways-to-format-float-values-tp59733.html
> > > Sent from the gambas-user mailing list archive at Nabble.com.
> > >
> > > 
> > > --
> > > 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
> > >
> > 
> --
> > 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
> --- End of Original Message ---
>
>
> 
> --
> 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
>
--
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 Playground

2017-07-16 Thread Karl Reinl
Am Sonntag, den 16.07.2017, 01:37 +0200 schrieb Adrien Prokopowicz:
> Hello Everyone !
> 
> These past few days I had fun putting together an online playground for  
> Gambas !
> You can find it here : https://gambas-playground.proko.eu/ :)
> 
> The playground is a little place to write and run Gambas code snippets,  
> which I
> think could be very useful in the mailing-list where codes flies around
> everywhere. :)
> 
> You can also directly share a link of your code in the playground using the
> "Share" button, which will generate a link like this :
> 
> https://gambas-playground.proko.eu/?gist=07db52169ef8b747d26f8bee4a4a19e9
> 
> The code is actually stored in a GitHub Gist, rather than in the playground
> itself, which makes it completely stateless.
> 
> Of course, since this is a web service (i.e. not your computer ! :) ),  
> there are
> a few limitations :
> 
> - Your code cannot run for more than 2 seconds, or it will get SIGKILL'd
> - It cannot use more than 16 megabytes of RAM (it segfaults if you use too  
> much)
> - You cannot make any network access whatsoever (there are no network  
> cards,
>and the process does not have permission to open sockets).
> - You *can* read, write or delete any file, but all changes to the  
> filesystem
>are discarded when the process ends.
> - There are probably a few edge cases I didn't think of, so please don't  
> abuse
>it. :)
> 
> However, a few components are available, just add the USE instruction to  
> load
> it, just like you would in a Gambas script. Here is an example :
> 
> https://gambas-playground.proko.eu/?gist=8a49aae5f5e24569c3f7f7e55c619f05
> 
> The following components are available in the playground :
> 
>gb.args, gb.clipper, gb.complex, gb.compress, gb.data, gb.debug, gb.draw,
>gb.eval, gb.eval.highlight, gb.geom, gb.image.effect, gb.image,  
> gb.inotify,
>gb.markdown, gb.option, gb.settings, gb.signal, gb.term, gb.util,  
> gb.util.web,
>gb.vb, gb.xml, gb.xml.html
> 
> (Basically, any component that doesn't depend on networking or GUI, tell  
> me if
> any is missing :) )
> 
> Behind the scenes, it is a simple Gambas application serving a REST API,
> which takes the code as input. It then spins up a Docker container, which  
> has
> a simple "runner" Gambas application as its init process, which takes the  
> code,
> feeds it to the Gambas Scripter (gbs3) and then returns its output.
> 
> The app is still a bit rough on the edges (for instance, I should make a  
> proper
> Gambas highlighter for the editor, instead of using the VBScript one :p),
> but I think it is good enough to see some use.
> 
> Tell me if you have some ideas to improve it, and have fun with it ! :)
> 

Salut Adrien,

now we can discuss 'Best ways to format float values' like this 

look here you can test Nando's way

https://gambas-playground.proko.eu/?gist=037e17d22f3ac93cd3da3d6ad681f713 

Thanks 
-- 
Amicalement
Charlie


--
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-16 Thread nando_f
Rounding depends on what rounding you want.
Most people think of 5/4 rounding.
I prefer to round manually 5/4... 5 up, 4 down.

Dim n as Float = 26.6601

n = n * 100.  'n = 2666.01   ' 2 decimal points rounding
n = n + 0.5   'n = 2666.51   ' 5/4 rounding*
n = CLong(n)  'n = 2666
n = n / 100.  'n = 26.66


*If you wish to round down, do not add 0.5.  (add 0.0)
*If you wish to round up, add 0.9

If you wish to do 3 digits, then *1000 and /1000.
This works for any type of rounding scheme and any reasonable number of digits.

-Nando(Canada)


--
Open WebMail Project (http://openwebmail.org)


-- Original Message ---
From: Gianluigi 
To: mailing list for gambas users 
Sent: Thu, 13 Jul 2017 12:30:23 +0200
Subject: Re: [Gambas-user] Best ways to format float values

> One thing that could be useful?
> 
> Public Sub Main()
> 
>   Dim n As Float = 26.66016
>   Dim b As Byte
> 
>   b = Val(Mid(CStr(Frac(n)), 5, 1))
>   Print Round(n, -2)
>   If b >= 5 Then
> Print Round(n, -2)
>   Else
> Print Round(n + 0.01, -2)
>   Endif
> 
> End
> 
> Regards
> Gianluigi
> 
> 2017-07-13 7:39 GMT+02:00 alexchernoff :
> 
> > Peace to all,
> >
> > this might a bit silly but what is the best way to format float values like
> > 26.66016 into having two digits AND/OR  with rounding them?
> >
> > e.g.
> >
> > 26.66016 becomes 26.66 shortened
> > 26.66016 becomes 26.67 rounded
> >
> > cheers!
> >
> >
> >
> >
> >
> > --
> > View this message in context: http://gambas.8142.n7.nabble.
> > com/Best-ways-to-format-float-values-tp59733.html
> > Sent from the gambas-user mailing list archive at Nabble.com.
> >
> > 
> > --
> > 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
> >
> --
> 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
--- End of Original Message ---


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