Re: [Gambas-user] C Code character manipulation - alternatives

2009-05-23 Thread Doriano Blengino
nando ha scritto:
 Technically, C doesn't 'put' garbage values into variables.
 Those values just happen to be there if you don't set it to something.

 Gambas wonderfully sets numeric variables to zero.
 You can think of it as NULL, I suppose, but ZERO is a numeric
 description dealing with numbers whereas NULL is usually referred
 to as something to do with characters,
 but NULL it is the value ZERO...so it all means the same
 except how humans talk about it.
   
Because we are on the way to analyze all these such wonderful things 
about language and compilers, I want to add my contribute.

In several messages before, in this list, I found discussions about 
zero, null, initialization and so on. NUL (with only a single L) is 
the first ascii character, and has number 0 (in 8 bit). NULL (with two 
Ls) is a C word which means a pointer pointing to anything. Very often 
the NULL pointer is represented with zeroes, and very often (but not 
always) pointers are more than 8 bit long. The fact C lets you use a 
numeral 0 to indicate a NULL is a C weakness from my point of view. 
Pascal instead uses NIL and, on some (old) architectures, both the 
compiler and the runtime were able to detect uninitialized pointer this 
way. There have been around CPUs having registers with an additional bit 
to indicate wheter the register was correctly loaded or not. So, NIL was 
not 0, but a special value indicating invalid, in a way similar to 
the special floating value NaN (not a number), which is not zero, and 
not infinite, neither any other number but an invalid number. Dividing 
0 by 0 gives a NaN. Who says that a pointer of value 0 is an invalid 
pointer? It depends on the CPU; for example, the glorious 8051 had 
memory mapped at address 0, so NULL was a legal value for a pointer.



 Either I am wrong or u r:

DIM k, countVar AS Integer
PRINT k, countVar

 The output of these lines is:
 0   0

 How come u say that both integers are initialized to NULL.

 This is a super feature of Gambas versus C, which puts garbage values into
 variables of any type.
 

This is not a super feature of gambas, it is simply a different 
behaviour to make gambas more comfortable than C. The reason why C does 
not initialize variables to 0, is to gain speed. If you have 4096 
variables on the stack (extreme example), gambas will be about 4096 
times slower than C because it has to set them to zero. With a single 
CPU instruction C creates how many variables are needed. Pascal goes one 
step further - even its global variables are left uninitialized, while C 
sets them to 0. This is another speed gain (very little, though).

Neither gambas neither C/pascal are the best languages - every one has 
its features and behaviour. But (I am referring now to another message), 
Borland compilers are very mature, and they give you messages, hints, 
warnings and errors. Gambas is much younger and differently targeted; in 
the 90% of cases, who cares if a variable is declared and never used? 
Are we low in memory? Much more important is the automatic memory 
management of gambas, for example, which lacks both in traditional C and 
pascal. But if I am writing a real-time operating system for embedded 
devices, then I would choose pascal, because I can control with it every 
single byte of my scarce memory and I know how long takes a statement to 
execute. But I also have to initialize everything and adhere to its 
strict syntax. For a linux desktop and a mean graphical application, 
gambas is perfect.

In some message some day ago, KhurramM proposed a single package of 
gambas for linux, and someone else replied that a source distribution is 
the more practical one. It is true - sadly. I think this situation is 
bad - remember, Unix means unique, one for all. As long as the 
architecture does not change, it would be very practical to have binary 
packages for all the distributions - instead, linux on PC is a mess. I 
used to compile my kernel every time, on every new machine. Then, I 
discovered that there was nothing to gain for my average desktop machine 
- it was exactly the same to compile my customized kernel or to use the 
full bloated one which came with the distibution. If it works for the 
kernel, it could work any other application. But every distribution 
creator think he is doing better than the other, and the more it does 
different, better it is. Simply wrong. The author of the message than 
spoke about windows '98, XP, 2000. Well, they are different operating 
system. But 99% of applications developed by me with delphi run smoothly 
on every windows machine I tried; the remaining 1% were secondary quirks 
easily solved. I think this is the target of Unix/Linux world. This is 
freedom, without having to mess around with makefiles and configure 
scripts that get bigger than the original source itself. I suspect that 
Benoit spends a lot of time to adapt the sources to all the different 
distributions, which all share the 

Re: [Gambas-user] C Code character manipulation - alternatives

2009-05-23 Thread Benoît Minisini

 In some message some day ago, KhurramM proposed a single package of
 gambas for linux, and someone else replied that a source distribution is
 the more practical one. It is true - sadly. I think this situation is
 bad - remember, Unix means unique, one for all. As long as the
 architecture does not change, it would be very practical to have binary
 packages for all the distributions - instead, linux on PC is a mess. I
 used to compile my kernel every time, on every new machine. Then, I
 discovered that there was nothing to gain for my average desktop machine
 - it was exactly the same to compile my customized kernel or to use the
 full bloated one which came with the distibution. If it works for the
 kernel, it could work any other application. But every distribution
 creator think he is doing better than the other, and the more it does
 different, better it is. Simply wrong. The author of the message than
 spoke about windows '98, XP, 2000. Well, they are different operating
 system. But 99% of applications developed by me with delphi run smoothly
 on every windows machine I tried; the remaining 1% were secondary quirks
 easily solved. I think this is the target of Unix/Linux world. This is
 freedom, without having to mess around with makefiles and configure
 scripts that get bigger than the original source itself. I suspect that
 Benoit spends a lot of time to adapt the sources to all the different
 distributions, which all share the same kernel, same libraries, and all
 have a packaging system that keeps track of dependencies...

 Best regards,

Nowadays, distributions mainly differ by their packaging system, the way they 
run services only. The file system organization and many other things that 
were different in the past seem to converge.

I had a bug once in SuSE that I solved by implementing the shared library 
preloading feature, but I guess that this feature is not needed anymore.

As for the way program are packaged, you have to let a distribution manage the 
packages, because:

- They sign them: nobody can easily insert some trojan inside without notice.

- They update them.

- They manage dependencies. If a security hole is found in a library, all 
programs using that library will be fixed.

On the contrary, for me, Windows is a nightmare: each program must take care 
of being updated itself, by going to the network, checking that an update is 
available, downloading it, and so on. What about all the programs installed by 
your OEM? Do they have holes? Are they updated? And when you have to reinstall 
your Windows?

On Linux everything is centralized and you can manage your system in a few 
clicks.

On the contrary, the work is more difficult for the packager. I tried in the 
Gambas IDE to make a packager easy to use, and it was not easy to do! I had to 
deal with the difference between rpm, deb, tgz, and the little details between 
distributions using the same package format.

Having a common package format need to know all the differences in the 
organization of all distributions. You cannot force that, because you will 
destroy the diversity. Just wait, things are slowly converging.

As for the GNU autoconf/automake system, I admit it was a nightmare for me 
too. I think now that all distributions have the concept of development 
packages, a configure script should be able to tell the system the libraries 
it needs, and the system should install them automagically. That's all. No 
thousands of long tests to run before starting compiling.

Regards,

-- 
Benoît

--
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers  brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing,  
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA,  Big Spaceship. http://www.creativitycat.com 
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] C Code character manipulation - alternatives

2009-05-23 Thread Doriano Blengino
Benoît Minisini ha scritto:
 In some message some day ago, KhurramM proposed a single package of
 gambas for linux, and someone else replied that a source distribution is
 the more practical one. It is true - sadly. I think this situation is
 bad - remember, Unix means unique, one for all. As long as the
 architecture does not change, it would be very practical to have binary
 packages for all the distributions - instead, linux on PC is a mess. I
 used to compile my kernel every time, on every new machine. Then, I
 discovered that there was nothing to gain for my average desktop machine
 - it was exactly the same to compile my customized kernel or to use the
 full bloated one which came with the distibution. If it works for the
 kernel, it could work any other application. But every distribution
 creator think he is doing better than the other, and the more it does
 different, better it is. Simply wrong. The author of the message than
 spoke about windows '98, XP, 2000. Well, they are different operating
 system. But 99% of applications developed by me with delphi run smoothly
 on every windows machine I tried; the remaining 1% were secondary quirks
 easily solved. I think this is the target of Unix/Linux world. This is
 freedom, without having to mess around with makefiles and configure
 scripts that get bigger than the original source itself. I suspect that
 Benoit spends a lot of time to adapt the sources to all the different
 distributions, which all share the same kernel, same libraries, and all
 have a packaging system that keeps track of dependencies...

 Best regards,
 

 Nowadays, distributions mainly differ by their packaging system, the way they 
 run services only. The file system organization and many other things that 
 were different in the past seem to converge.

 I had a bug once in SuSE that I solved by implementing the shared library 
 preloading feature, but I guess that this feature is not needed anymore.

 As for the way program are packaged, you have to let a distribution manage 
 the 
 packages, because:

 - They sign them: nobody can easily insert some trojan inside without notice.

 - They update them.

 - They manage dependencies. If a security hole is found in a library, all 
 programs using that library will be fixed.

 On the contrary, for me, Windows is a nightmare: each program must take care 
 of being updated itself, by going to the network, checking that an update is 
 available, downloading it, and so on. What about all the programs installed 
 by 
 your OEM? Do they have holes? Are they updated? And when you have to 
 reinstall 
 your Windows?
   
There are few persons on The Earth who hate windows like I do. That 
said, we must admit that windows has some pros too, and linux some cons 
either. If the average windows user had the average linux user maturity, 
even windows would have less problems. From DOS 2.11 onward, through 
windows 95, 98, 2000, and now XP, I never used an antivirus on my 
machine, and I never reinstalled my operating system. Why? Because I am 
not the average windows user - I always look critically at windows, and 
I am careful about everything happens to my computers. I repeat - I hate 
windows. But windows has automatic updates like linux, windows has an 
installer like linux, and so on. There are very few things linux can do 
that can not be made on windows - the problem is elsewhere, in the 
background philosophy: closed sources, the idea that computer 
technologies must bring money. Everything that must bring money, that 
becomes a businness, suffers from dark sides.

But we should take a look at some linux problems. First of all, the 
quality of applications; average windows apps are better than average 
linux ones. It is true that linux software is normally free but, apart 
from few exceptions, there is a lot to do. I am very satisfied of Open 
Office, The Gimp, Gambas, KiCad, Firefox and companions, Synaptic. But 
try to find something like Dreamweaver, Corel draw, Delphi, Orcad (an 
electronics CAD like KiCAD), Cakewalk and others I can't remember now. 
Think this: I still have to find a text editor which does not annoy me. 
I even poked Gambas to add some feature in the editor.
The other problems of linux are the same of windows - sometimes you 
install something, and it screws up something else. No news here. Last 
time I upgraded xorg, I spent about half a day to correct the problems.

I dream a Linux world where things are more unified, like windows, but 
keeping the open source basis, the underlaying community and the freedom 
of choice. But freedom does not mean that everything must be compiled 
from sources. Freedom means that if I find something I don't like, I can 
change it. Or, if I want to see how things are made, I can take a look 
at the sources. This also spreads knowledge in the strategic field of 
software.

 On Linux everything is centralized and you can manage your system in a few 
 clicks.
   
Are you really really 

Re: [Gambas-user] C Code character manipulation - alternatives

2009-05-23 Thread KhurramM

Thanks a lot : Doriano Blengino and Benoît Minisini :handshake:

It was really informative for me. :working:

I just had a little curiosity in my mind. Its not related to Gambas
directly. I do not have that much programming depth. But anyhow (now its
off-topic) :thinking:

IS it possible that a C based CRE or CVM just like javas' JRE or JVM, is
made. Then ...  would the package installation issue be over in all the
unix-like distros? Is it possible? Is it feasible? But JVM consumes a lot of
ram! :confused:
-- 
View this message in context: 
http://www.nabble.com/C-Code-character-manipulation---alternatives-tp23611042p23686958.html
Sent from the gambas-user mailing list archive at Nabble.com.


--
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers  brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing,  
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA,  Big Spaceship. http://www.creativitycat.com 
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] C Code character manipulation - alternatives

2009-05-23 Thread nando
If you're looking for something CAD
OpenOffice comes with Draw
which is very similar to Corel in many ways.
I use it to make PC Boards and drawings/etc.  It works very well!!
You might not have a link to it, so at the text prompt, type oodraw
-Fernando


-- Original Message ---
From: Doriano Blengino doriano.bleng...@fastwebnet.it
To: mailing list for gambas users gambas-user@lists.sourceforge.net
Sent: Sat, 23 May 2009 20:13:05 +0200
Subject: Re: [Gambas-user] C Code character manipulation - alternatives

 Benoît Minisini ha scritto:
  In some message some day ago, KhurramM proposed a single package of
  gambas for linux, and someone else replied that a source distribution is
  the more practical one. It is true - sadly. I think this situation is
  bad - remember, Unix means unique, one for all. As long as the
  architecture does not change, it would be very practical to have binary
  packages for all the distributions - instead, linux on PC is a mess. I
  used to compile my kernel every time, on every new machine. Then, I
  discovered that there was nothing to gain for my average desktop machine
  - it was exactly the same to compile my customized kernel or to use the
  full bloated one which came with the distibution. If it works for the
  kernel, it could work any other application. But every distribution
  creator think he is doing better than the other, and the more it does
  different, better it is. Simply wrong. The author of the message than
  spoke about windows '98, XP, 2000. Well, they are different operating
  system. But 99% of applications developed by me with delphi run smoothly
  on every windows machine I tried; the remaining 1% were secondary quirks
  easily solved. I think this is the target of Unix/Linux world. This is
  freedom, without having to mess around with makefiles and configure
  scripts that get bigger than the original source itself. I suspect that
  Benoit spends a lot of time to adapt the sources to all the different
  distributions, which all share the same kernel, same libraries, and all
  have a packaging system that keeps track of dependencies...
 
  Best regards,
  
 
  Nowadays, distributions mainly differ by their packaging system, the way 
  they 
  run services only. The file system organization and many other things that 
  were different in the past seem to converge.
 
  I had a bug once in SuSE that I solved by implementing the shared library 
  preloading feature, but I guess that this feature is not needed anymore.
 
  As for the way program are packaged, you have to let a distribution manage 
  the 
  packages, because:
 
  - They sign them: nobody can easily insert some trojan inside without 
  notice.
 
  - They update them.
 
  - They manage dependencies. If a security hole is found in a library, all 
  programs using that library will be fixed.
 
  On the contrary, for me, Windows is a nightmare: each program must take 
  care 
  of being updated itself, by going to the network, checking that an update 
  is 
  available, downloading it, and so on. What about all the programs installed 
  by 
  your OEM? Do they have holes? Are they updated? And when you have to 
  reinstall 
  your Windows?

 There are few persons on The Earth who hate windows like I do. That 
 said, we must admit that windows has some pros too, and linux some cons 
 either. If the average windows user had the average linux user maturity, 
 even windows would have less problems. From DOS 2.11 onward, through 
 windows 95, 98, 2000, and now XP, I never used an antivirus on my 
 machine, and I never reinstalled my operating system. Why? Because I am 
 not the average windows user - I always look critically at windows, and 
 I am careful about everything happens to my computers. I repeat - I hate 
 windows. But windows has automatic updates like linux, windows has an 
 installer like linux, and so on. There are very few things linux can do 
 that can not be made on windows - the problem is elsewhere, in the 
 background philosophy: closed sources, the idea that computer 
 technologies must bring money. Everything that must bring money, that 
 becomes a businness, suffers from dark sides.
 
 But we should take a look at some linux problems. First of all, the 
 quality of applications; average windows apps are better than average 
 linux ones. It is true that linux software is normally free but, apart 
 from few exceptions, there is a lot to do. I am very satisfied of Open 
 Office, The Gimp, Gambas, KiCad, Firefox and companions, Synaptic. But 
 try to find something like Dreamweaver, Corel draw, Delphi, Orcad (an 
 electronics CAD like KiCAD), Cakewalk and others I can't remember now. 
 Think this: I still have to find a text editor which does not annoy me. 
 I even poked Gambas to add some feature in the editor.
 The other problems of linux are the same of windows - sometimes you 
 install something, and it screws up something else. No news here. Last 
 time I

Re: [Gambas-user] C Code character manipulation - alternatives

2009-05-23 Thread KhurramM


TO: nando-7

where did I mention I need drawing/ drafting tools?
-- 
View this message in context: 
http://www.nabble.com/C-Code-character-manipulation---alternatives-tp23611042p23687610.html
Sent from the gambas-user mailing list archive at Nabble.com.


--
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers  brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing,  
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA,  Big Spaceship. http://www.creativitycat.com 
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] C Code character manipulation - alternatives

2009-05-23 Thread Doriano Blengino
nando ha scritto:
 If you're looking for something CAD
 OpenOffice comes with Draw
 which is very similar to Corel in many ways.
 I use it to make PC Boards and drawings/etc.  It works very well!!
 You might not have a link to it, so at the text prompt, type oodraw
 -Fernando
   
Thanks for your interest. I know Open office Draw. In some aspect is 
better than CorelDraw, but... its value is about 15% of Corel. Correctly 
the OpenOffice guys aimed first, may be, at 90% of users. Corel draw 
still can do things well beyond. I used oodraw once to make a depliant 
about a product of mines, and the result was surprisingly fast and easy. 
But if you want more... you discover soon its limits. It is only a 
matter of time - even the oowrite word processor was limited at first, 
but at this time is superior to its counterpart - it lacks only in 
documentation (not to say that the m$ docs are far better... you got it...)

Cheers and... long life to open source. We will win - no doubt.

-- 
Doriano Blengino

Listen twice before you speak.
This is why we have two ears, but only one mouth.


--
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers  brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing,  
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA,  Big Spaceship. http://www.creativitycat.com 
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] C Code character manipulation - alternatives

2009-05-23 Thread Doriano Blengino
KhurramM ha scritto:
 Thanks a lot : Doriano Blengino and Benoît Minisini :handshake:

 It was really informative for me. :working:

 I just had a little curiosity in my mind. Its not related to Gambas
 directly. I do not have that much programming depth. But anyhow (now its
 off-topic) :thinking:

 IS it possible that a C based CRE or CVM just like javas' JRE or JVM, is
 made. Then ...  would the package installation issue be over in all the
 unix-like distros? Is it possible? Is it feasible? But JVM consumes a lot of
 ram! :confused:
   
Uhm... I don't want to say that... your ideas are... few but... well 
confused! :-)

The runtime of C is called libc under linux. It interfaces a C program 
with the kernel (which is responsible for everything happens in a 
computer), and it works well for simple programs.
Pure (and relatively simple) C programs are those at the base of the 
system - /bin/ls, for example, and more generally all those in /bin and 
/sbin (and others). But this runtime does not offer all the services a 
more complex program needs. If a GUI is needed, for example, a program 
must interface with X11 (under linux). But X11 is a complex matter, and 
to make a simple window appear several lines of code are required. So, 
some library comes in place, to simplify things - libraries like GTK or 
QT. The problem is that while the C library (and X11) are a well known 
standard, GTK and QT (and others) are still under heavy development, and 
so they change frequently. Users don't want to stay behind for more than 
few months, so there are around different versions of the same library, 
and different versions of the same program which use different version 
of the libraries, and some library requires other libraries and so on. 
You understand...

All of that then has something to do with package installation. If you 
have a program X version 1.1, which uses library Y version 3.2, then you 
must insure that that library is present, to run program X. If you want 
to upgrade your program to version 1.2, surely it will use library Y 
version 3.3. But if you change your library Y, then your programs A, B, 
C, D will not run anymore. So you must upgrade them too. And this is the 
package manager duty.

A java runtime does not escape from this rule, it is just a program or a 
library which needs other libraries. Perhaps a little step ahead is 
done, because the java runtime is mantained only by two major players, 
and realeases are not so frequent. But this is not an argument I know well.

Hope this helps to answer your doubts. But I must add that new ideas 
like yours should be appreciated, even when not viable. Once upon a 
time, a wise man said something like: The reasonable man adapts himself 
to the world around him; the crazy one tries instead to adapt the world 
to himself. Therefore, all the human progresses and conquests are due to 
crazy men.

Cheers and good night (at least for me),

-- 
Doriano Blengino

Listen twice before you speak.
This is why we have two ears, but only one mouth.


--
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers  brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing,  
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA,  Big Spaceship. http://www.creativitycat.com 
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] C Code character manipulation - alternatives

2009-05-22 Thread KhurramM

I made a little bluder, my code:

PUBLIC SUB Main()

   ' Declare AND initialize variables.
   DIM count AS Integer
   ' The values are initialized at Zero, by above command
   
   DIM c AS String
 
   ' READ , PRINT , AND count characters.
   PRINT Enter characters (Ctrl+D to quit): 
   LINE INPUT c
   PRINT c
   count += Len(c)
   WHILE NOT Eof  ' This works excellent
  'PRINT c1
  LINE INPUT c
  count += Len(c)
  PRINT c
   WEND 

   ' PRINT the number OF characters printed.
   PRINT count   characters printed.
   
END


Works as I require it to on CLI gnome-terminal.

It was a mis-print that EOF is not working. In my last post, every thing
works as I want it to.

Regarding Code from Ron_1st:

It has two errors:
1 WHILE (cha  \n) works instead of WHILE (cha  KEY.Return)
 It doesnt recognise KEY.Return
2 It doesnt gives me the result I need. It moves endlessly.

Ron_1st: If u think my above code needs to be re-adjusted, pls give
suggestion, but it running absolutely fine, just like its C code, above. But
your code needs more examination than that. I am still working on to run it.

Thanks for all the suggestions and help.

Best Regards
-- 
View this message in context: 
http://www.nabble.com/C-Code-character-manipulation---alternatives-tp23611042p23670597.html
Sent from the gambas-user mailing list archive at Nabble.com.


--
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers  brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing,  
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA,  Big Spaceship. http://www.creativitycat.com 
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] C Code character manipulation - alternatives

2009-05-22 Thread nando
Technically, C doesn't 'put' garbage values into variables.
Those values just happen to be there if you don't set it to something.

Gambas wonderfully sets numeric variables to zero.
You can think of it as NULL, I suppose, but ZERO is a numeric
description dealing with numbers whereas NULL is usually referred
to as something to do with characters,
but NULL it is the value ZERO...so it all means the same
except how humans talk about it.
-Fernando



-- Original Message ---
From: KhurramM kms...@gmail.com
To: gambas-user@lists.sourceforge.net
Sent: Fri, 22 May 2009 21:22:33 -0700 (PDT)
Subject: Re: [Gambas-user] C Code character manipulation - alternatives

 TO: Ron_1st
 
 Either I am wrong or u r:
 
DIM k, countVar AS Integer
PRINT k, countVar
 
 The output of these lines is:
 0   0
 
 How come u say that both integers are initialized to NULL.
 
 This is a super feature of Gambas versus C, which puts garbage values into
 variables of any type.
 
 Correct me if I am wrong.
 
 Best Regards
 -- 
 View this message in context: http://www.nabble.com/C-Code-character-
 manipulation---alternatives-tp23611042p23681295.html Sent from the 
 gambas-user 
 mailing list archive at Nabble.com.
 
 --
 Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
 is a gathering of tech-side developers  brand creativity professionals. Meet
 the minds behind Google Creative Lab, Visual Complexity, Processing,  
 iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
 Group, R/GA,  Big Spaceship. http://www.creativitycat.com 
 ___
 Gambas-user mailing list
 Gambas-user@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/gambas-user
--- End of Original Message ---


--
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers  brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing,  
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA,  Big Spaceship. http://www.creativitycat.com 
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] C Code character manipulation - alternatives

2009-05-22 Thread KhurramM

Thanks for all the cooperation for this mini coding of mines. :handshake:

Best Regards
-- 
View this message in context: 
http://www.nabble.com/C-Code-character-manipulation---alternatives-tp23611042p23681537.html
Sent from the gambas-user mailing list archive at Nabble.com.


--
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers  brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing,  
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA,  Big Spaceship. http://www.creativitycat.com 
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] C Code character manipulation - alternatives

2009-05-21 Thread Doriano Blengino
KhurramM ha scritto:
 Thanks Sir.

 You have given me tips better then the book I am following on C. :working:

 My two queries:
 1 Can I implement ctrl+D or ^D, which I am not able to here, as in C?
 2 The program works with INPUT and LINE INPUT. But Line Input also takes
 blank space as input, while INPUT ends the program over here. And I use
 string here, but in C it was integer?

 --- Just for reference:
 Well I made my program final as:

 PUBLIC SUB Main()

' Declare AND initialize variables.
DIM c, count AS Integer

DIM c1 AS String
  
' READ , PRINT , AND count characters.
PRINT Enter characters (or Press Carriage Return to quit): 
LINE INPUT c1
count += Len(c1)

WHILE (c1  )' This is the best solution
   PRINT c1
   LINE INPUT c1
   count += Len(c1)
WEND 

' PRINT the number OF characters printed.
PRINT count   characters printed.

 END
   
I put the following code in a program; the code is invoked by pressing 
Button1:

PUBLIC SUB Button1_Click()
   ' Declare AND initialize variables.
   DIM c, count AS Integer
  
   DIM c1 AS String
 
   ' READ , PRINT , AND count characters.
   PRINT Enter characters (or Press Carriage Return to quit): 

   WHILE NOT Eof
  LINE INPUT c1
  PRINT c1
  count += Len(c1)
   WEND

   ' PRINT the number OF characters printed.
   PRINT count   characters printed.
END

Running the program inside the IDE, and using the internal console, no 
EOF is generated, but your version (which tested for empty lines) 
worked. Then I made an executable (Project menu - Generate - 
Executable) and launched it from a terminal. It runs correctly; you 
repeatedly type some text + ENTER, or you type Ctrl-D. The behaviour is 
correct and, as I was supposing, no Ctrl-D is detected inside the line 
input, but it is if you type ^D alone. As the routine is invoked every 
time Button1 is pressed, I tried to press Button1 again: after the first 
^D no more characters are detected. This makes sense, because you cannot 
go past the EOF...
Then I launched the following shell command: echo ciao |./dand.gambas
Doing so, the standard input for the program is redirected elsewhere 
(the output of the echo command). The program works as expected - it 
counts 4 characters and senses the EOF correctly.

Now, I suppose you are disappointed by INPUT and LINE INPUT, which are 
multi-char statements. If you want to process single characters, then 
you must use the READ statement (perhaps there is also a INKEY$) -- see 
the docs. Anyway, gambas does not have chars like C - you can use 
strings (of length 1); the ASC() function returns the numerical code of 
a character, and CHR() returns a char (a string of len 1)  by giving its 
ascii code. There is no character to designate EOF - you must use the 
Eof() function.

If you want to be a real gambas programmer, stop to put parenthesis 
around tests, like while (c1...)! :-)

If you have a goal in mind, perhaps could be better you tell it, so we 
can help you more precisely.

Cheers,

-- 
Doriano Blengino

Listen twice before you speak.
This is why we have two ears, but only one mouth.


--
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers  brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing,  
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA,  Big Spaceship. http://www.creativitycat.com 
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] C Code character manipulation - alternatives

2009-05-20 Thread KhurramM

I am converting the at the end C code to gambas code. But I seem to be
getting nowhere, currently. I am trying. Hope u guide me thru this.

' Gambas module file

' This program demonstrates the relationship
' between a text stream AND character I / O by
' reading characters FROM the keyboard AND THEN
' printing them TO the screen.

PUBLIC SUB Main()

   ' Declare AND initialize variables.
   DIM c, count AS Integer
   ' The values are initialized at Zero, by above command
 
   ' READ , PRINT , AND count characters.
   PRINT Enter characters (ctrl d to quit): 
   INPUT c
   count += 1
   WHILE NOT (c = Eof)
   
  PRINT Chr$(c)
  INPUT c
  count += 1
   WEND 

   ' PRINT the number OF characters printed.
   PRINT (count - 1)   characters printed.
   
END

' Original C Code:

'/ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - * /
'/ * * /
'/ * This program demonstrates the relationship * /
'/ * between a text stream AND character I / O by * /
'/ * reading characters FROM the keyboard AND THEN * /
'/ * printing them TO the screen. * /

'#include  stdio.h 
'#include  stdlib.h 

'main()
'{
'   / * Declare AND initialize variables. * /
'   Int c, count = 0;

'   / * READ , PRINT , AND count characters. * /
'   printf(Enter characters (ctrl d to quit): \n);
'   c = getchar();
'   count + +;
'   WHILE (c! = Eof)
'   {
'  putchar(c);
'  c = getchar();
'  count + +;
'   }

'   / * PRINT the number OF characters printed. * /
'   printf(%i characters printed. \n, count - 1);

'   / * EXIT Program. * /
'   RETURN EXIT_SUCCESS;
'}
'/ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - * /

'/ / NOTE:
'/ / FOR most OF the unix systems: Eof IS done by: ctrl d


The output in C cdoe is:

Enter characters (ctrl d to quit):
e
e
re
re
tyui
tyui
jhg mnkl
jhg mnkl
19 characters printed.
-- 
View this message in context: 
http://www.nabble.com/C-Code-character-manipulation---alternatives-tp23611042p23629486.html
Sent from the gambas-user mailing list archive at Nabble.com.


--
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables 
unlimited royalty-free distribution of the report engine 
for externally facing server and web deployment. 
http://p.sf.net/sfu/businessobjects
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] C Code character manipulation - alternatives

2009-05-20 Thread KhurramM

The Code:

PUBLIC SUB Main()

   ' Declare AND initialize variables.
   DIM c, count AS Integer
   ' The values are initialized at Zero, by above command
   
   DIM c1 AS String
 
   ' READ , PRINT , AND count characters.
   PRINT Enter characters (Press Carriage Return Twice to quit): 
   LINE INPUT c1
   PRINT c1
   count += Len(c1)
   WHILE NOT (c1 = Eof)

  LINE INPUT c1
  count += Len(c1)
  PRINT c1
   WEND 

   ' PRINT the number OF characters printed.
   PRINT count   characters printed.
   
END

Gives me output:

Enter characters (Press Carriage Return Twice to quit): 
657uyguig
657uyguig
   uyt876896
   uyt876896



21 characters printed.

Is it OKAY, should I leave it here?

I still dont get the feel of the C code here. I cant use ^Z to end the
program and print output. :confused:

-- 
View this message in context: 
http://www.nabble.com/C-Code-character-manipulation---alternatives-tp23611042p23631663.html
Sent from the gambas-user mailing list archive at Nabble.com.


--
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables 
unlimited royalty-free distribution of the report engine 
for externally facing server and web deployment. 
http://p.sf.net/sfu/businessobjects
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] C Code character manipulation - alternatives

2009-05-20 Thread Doriano Blengino
KhurramM ha scritto:
 The Code:

 PUBLIC SUB Main()

' Declare AND initialize variables.
DIM c, count AS Integer
' The values are initialized at Zero, by above command

DIM c1 AS String
  
' READ , PRINT , AND count characters.
PRINT Enter characters (Press Carriage Return Twice to quit): 
LINE INPUT c1
PRINT c1
count += Len(c1)
WHILE NOT (c1 = Eof)

   LINE INPUT c1
   count += Len(c1)
   PRINT c1
WEND 

' PRINT the number OF characters printed.
PRINT count   characters printed.

 END

 Gives me output:

 Enter characters (Press Carriage Return Twice to quit): 
 657uyguig
 657uyguig
uyt876896
uyt876896



 21 characters printed.

 Is it OKAY, should I leave it here?

 I still dont get the feel of the C code here. I cant use ^Z to end the
 program and print output. :confused:
   
Gambas and C are two very different beasts.

Looking at your source, I can say the following:

- LINE INPUT. This reads from stdin an entire line of text, terminated 
by an LF. It is different from INPUT because it reads a whole line, 
while INPUT tries to match number and words. It returns a string, which 
is different from C strings.

- WHILE NOT (c1 = Eof). Gambas does not require to embed tests in 
parenthesis. Better to write while c1eof. Then, the EOF (end of 
file) is not a character, but a condition of a stream. A stream (or a 
file) is in EOF condition when there is no more data left to read. Sorry 
for this, but to see this as a character is a C stupid thing; it works, 
but it is inelegant. In the source you wrote Press enter twice to 
quit, so I would test for an empty string: while c1. Anyway, you 
can test for the end-of-file condition using Eof(), like you did. The 
Eof() is a function which tells if a stream is at end. It returns a 
boolean (true/false) value, and can not be compared to a string. If 
gambas does not gives you an error, then it is its fault. Gambas does 
not require parenthesis to invoke functions, so writing Eof is the 
same as writing Eof(). If Eof is invoked with a parameter, like 
Eof(myfile), it tests the indicated stream; if invoked without 
parameters, it tests the standard input. I am not sure how it couples 
with input/line input; you could also try while not eof instead of 
while c1Eof.

The original C source you provided was not totally correct, and so is 
not id gambas descendant.
Perhaps a better way to write the program could be:

   PRINT Enter characters (Press Carriage Return Twice to quit): 
   do
 LINE INPUT c1
 if c1= then break

 PRINT c1
 count += Len(c1)
   loop

   PRINT count   characters printed.

This assumes to enter a null line to terminate. May be this also works 
(testing for eof):

   PRINT Enter characters (press ^D to terminate): 
   while not eof
 LINE INPUT c1
 PRINT c1
 count += Len(c1)
   wend

   PRINT count   characters printed.


First note that on unix, the eof character is not Ctrl-Z but Ctrl-D. 
After that, I don't know how ^D works when coupled with LINE INPUT, 
which reads a full line. I did'nt test, but I suspect that you have to 
press ^D and Enter; it could work, but it could not... it depends on how 
LINE INPUT is implemented.

Hope this helps - ask more if you need.

Best regards,
Doriano




--
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables 
unlimited royalty-free distribution of the report engine 
for externally facing server and web deployment. 
http://p.sf.net/sfu/businessobjects
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] C Code character manipulation - alternatives

2009-05-20 Thread KhurramM

Thanks Sir.

You have given me tips better then the book I am following on C. :working:

My two queries:
1 Can I implement ctrl+D or ^D, which I am not able to here, as in C?
2 The program works with INPUT and LINE INPUT. But Line Input also takes
blank space as input, while INPUT ends the program over here. And I use
string here, but in C it was integer?

--- Just for reference:
Well I made my program final as:

PUBLIC SUB Main()

   ' Declare AND initialize variables.
   DIM c, count AS Integer
   
   DIM c1 AS String
 
   ' READ , PRINT , AND count characters.
   PRINT Enter characters (or Press Carriage Return to quit): 
   LINE INPUT c1
   count += Len(c1)

   WHILE (c1  )' This is the best solution
  PRINT c1
  LINE INPUT c1
  count += Len(c1)
   WEND 

   ' PRINT the number OF characters printed.
   PRINT count   characters printed.
   
END
-- 
View this message in context: 
http://www.nabble.com/C-Code-character-manipulation---alternatives-tp23611042p23646969.html
Sent from the gambas-user mailing list archive at Nabble.com.


--
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers  brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing,  
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA,  Big Spaceship. http://www.creativitycat.com 
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


[Gambas-user] C Code character manipulation - alternatives

2009-05-19 Thread KhurramM

Hi all!

I am still learning gambas.

I need a little help in character manipulation. I C there are functions:

getchar
putchar
fgetc
isdigit

Can these be implemented now in gambas. I failed to use the first two using
chr and chr$.

Thanks in advance for tips/ solution.
-- 
View this message in context: 
http://www.nabble.com/C-Code-character-manipulation---alternatives-tp23611042p23611042.html
Sent from the gambas-user mailing list archive at Nabble.com.


--
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables 
unlimited royalty-free distribution of the report engine 
for externally facing server and web deployment. 
http://p.sf.net/sfu/businessobjects
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] C Code character manipulation - alternatives

2009-05-19 Thread Emil Tchekov
Hi,

getchar/putchar (as the name is saying) are for read/write single char to
stdin/out

chr(i) eg. chr$(i) will return char from ASCII code - sth. like itoa or
(char)i in C, this has nothing to do with both above...

You will need one of the input functions in gambas to get similar
functionality in your gambas app. Some info on what you are trying to reach
will be helpfull...


kind regards


Emil


-Ursprungliche Nachricht-
Von: KhurramM [mailto:kms...@gmail.com]
Gesendet: Dienstag, 19. Mai 2009 09:24
An: gambas-user@lists.sourceforge.net
Betreff: [Gambas-user] C Code character manipulation - alternatives



Hi all!

I am still learning gambas.

I need a little help in character manipulation. I C there are functions:

getchar
putchar
fgetc
isdigit

Can these be implemented now in gambas. I failed to use the first two using
chr and chr$.

Thanks in advance for tips/ solution.
--
View this message in context:
http://www.nabble.com/C-Code-character-manipulation---alternatives-tp2361104
2p23611042.html
Sent from the gambas-user mailing list archive at Nabble.com.



--
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables
unlimited royalty-free distribution of the report engine
for externally facing server and web deployment.
http://p.sf.net/sfu/businessobjects
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


--
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables 
unlimited royalty-free distribution of the report engine 
for externally facing server and web deployment. 
http://p.sf.net/sfu/businessobjects
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] C Code character manipulation - alternatives

2009-05-19 Thread Sergio A. Hernandez
String Functions in Gambas see http://gambas.sourceforge.net/ for detailed
info about them.

   * *Asc* Returns the ASCII code of a character in a string.
   * *Chr$* Returns a character from its ASCII code.
   * *Comp* Compares two strings.
   * *InStr* Searches a string into another string.
   * *LCase$* Converts a string to lowercase.
   * *Left$* Returns the first characters of a string.
   * *Len* Returns the length of a string.
   * *LTrim$* Strips white spaces from the left of a string.
   * *Mid$* Returns a part of a string.
   * *Replace*$ Replaces in a string a substring by another one.
   * *Right*$ Returns the last characters of a string.
   * *RInStr* Searches a string into another string from its right.
   * *RTrim*$ Strips white spaces from the right of a string.
   * *Scan* Splits a string against a regular expression pattern.
   * *Space*$ Returns a string containing only space.
   * *Split* Splits a string into substrings.
   * *String*$ Returns the same string concatenated many times.
   * *Subst*$ Substitutes strings in a pattern.
   * *Trim*$ Strips white spaces from a string.
   * *UCase*$ Converts a string to uppercase.


On Tue, May 19, 2009 at 1:23 AM, KhurramM kms...@gmail.com wrote:

 Hi all!

 I am still learning gambas.

 I need a little help in character manipulation. I C there are functions:

 getchar
 putchar
 fgetc
 isdigit

 Can these be implemented now in gambas. I failed to use the first two
using
 chr and chr$.

 Thanks in advance for tips/ solution.
 --
 View this message in context:
http://www.nabble.com/C-Code-character-manipulation---alternatives-tp23611042p23611042.html
 Sent from the gambas-user mailing list archive at Nabble.com.



--
 Crystal Reports - New Free Runtime and 30 Day Trial
 Check out the new simplified licensing option that enables
 unlimited royalty-free distribution of the report engine
 for externally facing server and web deployment.
 http://p.sf.net/sfu/businessobjects
 ___
 Gambas-user mailing list
 Gambas-user@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/gambas-user

--
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables 
unlimited royalty-free distribution of the report engine 
for externally facing server and web deployment. 
http://p.sf.net/sfu/businessobjects
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user