Discussion:
2 console questions.
(too old to reply)
Γιώργος Κ
2014-03-15 00:03:20 UTC
Permalink
Hi! :-)
Thank you very much for this wonderful project!

I just installed it and giving it a try.
I have 2 questions, console programming related.

1) Is there any command Input-like, that allows for a specific number
of characters input (without pressing Enter)?
Eg. lets say, I'm presenting the user a Y or N question. What I
expect, is a single character input (with no need, for pressing
Enter).

2) Is there any way for coloring the text (eg. presenting a question
with red or green letters), other than messing with ncurses?
Something closer to BASIC tradition, maybe?
Ncurses is more or less complicated! :-)

TIA! :-)
Giorgos.
Tobias Boege
2014-03-15 00:38:07 UTC
Permalink
Post by Γιώργος Κ
Hi! :-)
Thank you very much for this wonderful project!
I just installed it and giving it a try.
I have 2 questions, console programming related.
1) Is there any command Input-like, that allows for a specific number
of characters input (without pressing Enter)?
Eg. lets say, I'm presenting the user a Y or N question. What I
expect, is a single character input (with no need, for pressing
Enter).
2) Is there any way for coloring the text (eg. presenting a question
with red or green letters), other than messing with ncurses?
Something closer to BASIC tradition, maybe?
Ncurses is more or less complicated! :-)
Ouch! I was already typing the answer: ncurses - then I read your last
paragraph :-) But maybe we can try without:

1) There is nothing to do that. Terminal is line-buffered by default, so you
will always have to wait for Return and then read the entire line using
the Line Input instruction. In the best case, the line will only consist
of "y" or "n" or "Y" or "N".

You can change the behaviour of the terminal but that would either
require messing around with struct termios using libc or using ncurses
which wraps that for you.

2) This is easy once you get used to it. You just have to know about escape
sequences. If you have a proper man-pages install, "$ man console_codes"
is your best friend.

To switch to, say, green foreground, you write in Gambas:

Print "\e[32m";
Print "This is green foreground"

of course, you need to switch that off at some point:

Print "\e[0m";
Print "Default rendition again"

Again, ncurses would wrap that for you.

The Gambas Console (which is built into the IDE to watch a program's stdout
and stderr) is not a full-featured terminal emulator. It won't interpret
those escape sequences, so you need to enable the "Use a terminal emulator"
option in the project options.

Note also that there is already a gb.ncurses component that helps you deal
with ncurses in the Gambas way (more or less). As you said you are new to
Gambas, I thought I should let you know... (attached is a project that shows
how you could have done the stuff with gb.ncurses).

Here[0] is also a tutorial introduction to gb.ncurses which explains the
setup to run those terminal-fancy programs. Have fun with Gambas!

Regards,
Tobi

[0] http://gambaswiki.org/wiki/tutorial/ncursestut
--
"There's an old saying: Don't change anything... ever!" -- Mr. Monk
Γιώργος Κ
2014-03-15 01:33:34 UTC
Permalink
Post by Tobias Boege
Post by Γιώργος Κ
Hi! :-)
Thank you very much for this wonderful project!
I just installed it and giving it a try.
I have 2 questions, console programming related.
1) Is there any command Input-like, that allows for a specific number
of characters input (without pressing Enter)?
Eg. lets say, I'm presenting the user a Y or N question. What I
expect, is a single character input (with no need, for pressing
Enter).
2) Is there any way for coloring the text (eg. presenting a question
with red or green letters), other than messing with ncurses?
Something closer to BASIC tradition, maybe?
Ncurses is more or less complicated! :-)
Ouch! I was already typing the answer: ncurses - then I read your last
1) There is nothing to do that. Terminal is line-buffered by default, so you
will always have to wait for Return and then read the entire line using
the Line Input instruction. In the best case, the line will only consist
of "y" or "n" or "Y" or "N".
You can change the behaviour of the terminal but that would either
require messing around with struct termios using libc or using ncurses
which wraps that for you.
2) This is easy once you get used to it. You just have to know about escape
sequences. If you have a proper man-pages install, "$ man console_codes"
is your best friend.
Print "\e[32m";
Print "This is green foreground"
Print "\e[0m";
Print "Default rendition again"
Again, ncurses would wrap that for you.
The Gambas Console (which is built into the IDE to watch a program's stdout
and stderr) is not a full-featured terminal emulator. It won't interpret
those escape sequences, so you need to enable the "Use a terminal emulator"
option in the project options.
Note also that there is already a gb.ncurses component that helps you deal
with ncurses in the Gambas way (more or less). As you said you are new to
Gambas, I thought I should let you know... (attached is a project that shows
how you could have done the stuff with gb.ncurses).
Here[0] is also a tutorial introduction to gb.ncurses which explains the
setup to run those terminal-fancy programs. Have fun with Gambas!
Regards,
Tobi
[0] http://gambaswiki.org/wiki/tutorial/ncursestut
--
"There's an old saying: Don't change anything... ever!" -- Mr. Monk
------------------------------------------------------------------------------
MANY THANKS Tobi for your help!!! :-)

2) I already read the wiki, but I'm not sure that I understood much things! :-)
Now that you pointed me, at the right direction, everything becomes clearer!

I have to mess with ESC sequences for > 20y! :-)
Γιώργος Κ
2014-03-16 00:28:28 UTC
Permalink
Post by Tobias Boege
The Gambas Console (which is built into the IDE to watch a program's stdout
and stderr) is not a full-featured terminal emulator. It won't interpret
those escape sequences, so you need to enable the "Use a terminal emulator"
option in the project options.
Ooops! This option, seems to be broken here! :-(
After enabling it, nothing happens (when I'm pressing the "play"
button). Only a small empty window, appears at bottom-right.

I uninstalled the repository version and I tried to install the
subversion one, but compilation failed. :-(

I took all the steps from "Compiling the Subversion repository" page,
but after ~20min, (at the last step, after becoming root) I got this
message:

||
|| Unable to compile gb.report
|| Unable to compile gb.net.pop3
|| Unable to compile gb.map
|| Unable to compile gambas3
||


Not my lucky day, I suppose! :-)
G.
Tobias Boege
2014-03-16 13:34:25 UTC
Permalink
Post by Γιώργος Κ
Post by Tobias Boege
The Gambas Console (which is built into the IDE to watch a program's stdout
and stderr) is not a full-featured terminal emulator. It won't interpret
those escape sequences, so you need to enable the "Use a terminal emulator"
option in the project options.
Ooops! This option, seems to be broken here! :-(
After enabling it, nothing happens (when I'm pressing the "play"
button). Only a small empty window, appears at bottom-right.
I uninstalled the repository version and I tried to install the
subversion one, but compilation failed. :-(
I took all the steps from "Compiling the Subversion repository" page,
but after ~20min, (at the last step, after becoming root) I got this
||
|| Unable to compile gb.report
|| Unable to compile gb.net.pop3
|| Unable to compile gb.map
|| Unable to compile gambas3
||
Not my lucky day, I suppose! :-)
You're using OpenSuse? I don't, but IIRC (what I'm *really* not sure about!)
I've heared rumours that their repositories deliver broken Gambas...

But do you actually Print something in your program? The white window could
be your terminal which stays white because your program doesn't do anything?

About the svn compilation: 20 minutes sounds familiar. The problems are
strange, though[*]. Could you send us the build logs as described here[0]?

Regards,
Tobi

[*] Not that there are some but *what* problems is strange. I don't see any
reason-indicating similarity between them.

[0] http://gambaswiki.org/wiki/doc/report?v3
--
"There's an old saying: Don't change anything... ever!" -- Mr. Monk
Γιώργος Κ
2014-03-16 14:02:07 UTC
Permalink
Post by Tobias Boege
You're using OpenSuse? I don't, but IIRC (what I'm *really* not sure about!)
I've heared rumours that their repositories deliver broken Gambas...
It's highly possible.
Unstable repositories are "home-made" (from individuals).
They have not tested thoroughly and many of them are non-actively maintained.
I'll try to compile the stable version too and I'll be back (with the
logs in case of a failure).
G.
Γιώργος Κ
2014-03-16 14:06:27 UTC
Permalink
I forgot to post the program! :-)

' Gambas module file

Public Sub Main()
Dim X As Integer
Print "ΑΒΓ"
Input X
End


Just a Print command.
With an Input (instead of sleep), for not autoclosing.
Γιώργος Κ
2014-03-16 19:36:35 UTC
Permalink
Post by Tobias Boege
Could you send us the build logs as described here[0]?
Regards,
Tobi
I tried to compile the stable (3.5.2) version (after downloading it
from SF.NET dl page).
I couldn't and it's clearly a missing dependencies problem, but I
couldn't figure out, what packages are missing! :-(

Logs:
http://pastebin.com/37F8sTsF
http://pastebin.com/nahELQg5
http://pastebin.com/idzpPSms
http://pastebin.com/A08NqGLz
Tobias Boege
2014-03-16 19:56:18 UTC
Permalink
Post by Γιώργος Κ
Post by Tobias Boege
Could you send us the build logs as described here[0]?
Regards,
Tobi
I tried to compile the stable (3.5.2) version (after downloading it
from SF.NET dl page).
I couldn't and it's clearly a missing dependencies problem, but I
couldn't figure out, what packages are missing! :-(
http://pastebin.com/37F8sTsF
http://pastebin.com/nahELQg5
http://pastebin.com/idzpPSms
http://pastebin.com/A08NqGLz
The only critical component that's missing is gb.qt4.webkit. As indicated
here[0], you need all the QT libs of version >= 4.5.

Regards,
Tobi

[0] http://gambaswiki.org/wiki/install
--
"There's an old saying: Don't change anything... ever!" -- Mr. Monk
Γιώργος Κ
2014-03-16 21:11:53 UTC
Permalink
Post by Tobias Boege
The only critical component that's missing is gb.qt4.webkit. As indicated
here[0], you need all the QT libs of version >= 4.5.
Regards,
Tobi
Oh, seems like I installed QT5 instead! :-(
OK! I installed QT4 as well and here are the updated logs:
(This time, Gambas is running, although some parts of it are
disabled-not compiled. System specs are the same).

http://pastebin.com/b6XbZyFQ
http://pastebin.com/LWnji1pH
http://pastebin.com/f3zfssGp
http://pastebin.com/vFYPLPB7

The problem remains the same.
G.
Tobias Boege
2014-03-16 21:40:41 UTC
Permalink
Post by Γιώργος Κ
Post by Tobias Boege
The only critical component that's missing is gb.qt4.webkit. As indicated
here[0], you need all the QT libs of version >= 4.5.
Regards,
Tobi
Oh, seems like I installed QT5 instead! :-(
(This time, Gambas is running, although some parts of it are
disabled-not compiled. System specs are the same).
http://pastebin.com/b6XbZyFQ
http://pastebin.com/LWnji1pH
http://pastebin.com/f3zfssGp
http://pastebin.com/vFYPLPB7
The problem remains the same.
These missing components are non-critical to the functioning of Gambas. If
you don't plan to use them, you don't need to compile them.

If you want them anyways, look at the link I gave you in the previous mail.
There you find the dependencies of all the components. Look up the missing
components and install the listed dependencies.

Note, however, that this may not be so easy as some distributions don't
provide recent-enough packages, like gstreamer 1.0. (I'm using Arch Linux
so I can only tell what I observed from dependency problems of other list
users around here.)

Regards,
Tobi
--
"There's an old saying: Don't change anything... ever!" -- Mr. Monk
Γιώργος Κ
2014-03-16 21:59:14 UTC
Permalink
Post by Tobias Boege
These missing components are non-critical to the functioning of Gambas. If
you don't plan to use them, you don't need to compile them.
If you want them anyways, look at the link I gave you in the previous mail.
There you find the dependencies of all the components. Look up the missing
components and install the listed dependencies.
Note, however, that this may not be so easy as some distributions don't
provide recent-enough packages, like gstreamer 1.0. (I'm using Arch Linux
so I can only tell what I observed from dependency problems of other list
users around here.)
Regards,
Tobi
--
Indeed! And Open SUSE don't has exactly the same terminology like
Debian systems and I'm afraid it's a bit difficult to me, to find
out more details.
I think I'll leave it, as is. :-)

THANKS!!! :-)
G.
Rolf-Werner Eilert
2014-03-17 09:07:14 UTC
Permalink
Post by Γιώργος Κ
Post by Tobias Boege
These missing components are non-critical to the functioning of Gambas. If
you don't plan to use them, you don't need to compile them.
If you want them anyways, look at the link I gave you in the previous mail.
There you find the dependencies of all the components. Look up the missing
components and install the listed dependencies.
Note, however, that this may not be so easy as some distributions don't
provide recent-enough packages, like gstreamer 1.0. (I'm using Arch Linux
so I can only tell what I observed from dependency problems of other list
users around here.)
Regards,
Tobi
--
Indeed! And Open SUSE don't has exactly the same terminology like
Debian systems and I'm afraid it's a bit difficult to me, to find
out more details.
I think I'll leave it, as is. :-)
THANKS!!! :-)
G.
Γιώργος Κ
2014-03-17 14:11:43 UTC
Permalink
Jack
2014-03-17 07:11:44 UTC
Permalink
Hello all,

is somebody know how create a directory with Ftpclient.
I use this code :

Dim Cmdmk As New String[]
Cmdmk = ["mkdir " & "example"]
Ftpclient.Exec(Cmdmk)

I got an error 500 (unknow command)

NB : In a console ftp, mkdir example, works.

any suggestions would be greatly appreciated

Jack
RICHARD WALKER
2014-03-17 08:32:37 UTC
Permalink
Do you need a space between "mkdir" & "example"?
ISS Boss
2014-03-17 13:48:57 UTC
Permalink
He already has a space between them. Check the quoted strings closely.

RICHARD WALKER wrote, On 03/17/2014 04:32:

Do you need a space between "mkdir" & "example"?

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
[1]http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
Gambas-user mailing list
[2]Gambas-***@lists.sourceforge.net
[3]https://lists.sourceforge.net/lists/listinfo/gambas-user

References

1. http://p.sf.net/sfu/13534_NeoTech
2. mailto:Gambas-***@lists.sourceforge.net
3. https://lists.sourceforge.net/lists/listinfo/gambas-user
RICHARD WALKER
2014-03-20 17:25:20 UTC
Permalink
Got it. I'll use my glasses next time - better than squinting at a
blur on the screen.

R

Jorge Carrión
2014-03-17 10:26:55 UTC
Permalink
This

ftpc.Exec(["MKD " & "newfoldername"])

Works for me.
Hope this helps.
Regards
Post by Jack
Hello all,
is somebody know how create a directory with Ftpclient.
Dim Cmdmk As New String[]
Cmdmk = ["mkdir " & "example"]
Ftpclient.Exec(Cmdmk)
I got an error 500 (unknow command)
NB : In a console ftp, mkdir example, works.
any suggestions would be greatly appreciated
Jack
------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
Tobias Boege
2014-03-17 11:35:38 UTC
Permalink
Post by Jorge Carrión
This
ftpc.Exec(["MKD " & "newfoldername"])
Works for me.
Hope this helps.
Yeah. You must know that the program "ftp" lets you enter commands which
don't appear in the FTP specification. It then maps these strings to the
actual commands, like "mkdir" (descriptive name) which is mapped to "MKD"
(less descriptive but the actual name of the FTP command).

The Gambas FtpClient won't do that for you - be it just because it is not
standard.

Regards,
Tobi
--
"There's an old saying: Don't change anything... ever!" -- Mr. Monk
Jack
2014-03-17 13:24:30 UTC
Permalink
Post by Tobias Boege
Post by Jorge Carrión
This
ftpc.Exec(["MKD " & "newfoldername"])
Works for me.
Hope this helps.
Yeah. You must know that the program "ftp" lets you enter commands which
don't appear in the FTP specification. It then maps these strings to the
actual commands, like "mkdir" (descriptive name) which is mapped to "MKD"
(less descriptive but the actual name of the FTP command).
The Gambas FtpClient won't do that for you - be it just because it is not
standard.
Regards,
Tobi
thank you for your explanations Tobias, it is clearer to me now

Jack
Jack
2014-03-17 13:22:03 UTC
Permalink
Post by Jorge Carrión
This
ftpc.Exec(["MKD " & "newfoldername"])
Works for me.
Hope this helps.
Regards
Ah ? mkd instead of mkdir.
it's work for me too now.

Thank's Jorge
Benoît Minisini
2014-03-16 14:41:15 UTC
Permalink
Post by Γιώργος Κ
Post by Tobias Boege
The Gambas Console (which is built into the IDE to watch a program's stdout
and stderr) is not a full-featured terminal emulator. It won't interpret
those escape sequences, so you need to enable the "Use a terminal emulator"
option in the project options.
Ooops! This option, seems to be broken here! :-(
After enabling it, nothing happens (when I'm pressing the "play"
button). Only a small empty window, appears at bottom-right.
Please give details on your system ("System information" menu in the
IDE), because the external terminal emulator is chosen according to your
current desktop.
--
Benoît Minisini
Γιώργος Κ
2014-03-16 15:07:05 UTC
Permalink
Post by Benoît Minisini
Please give details on your system ("System information" menu in the
IDE), because the external terminal emulator is chosen according to your
current desktop.
--
Benoît Minisini
------------------------------------------------------------------------------
Oh I forgot to mention them!
Sorry!!! :-)

[System]
Gambas=3.5.2
OperatingSystem=Linux
Kernel=3.11.10-7-desktop
Architecture=x86_64
Distribution=openSUSE 13.1
Desktop=KDE4
Theme=Oxygen
Language=el_GR.UTF-8
Memory=1752M
[Libraries]
DBus=libdbus-1.so.3.8.2
GStreamer=libgstreamer-0.10.so.0.30.0
Rolf-Werner Eilert
2014-03-17 09:20:21 UTC
Permalink
Post by Γιώργος Κ
Hi! :-)
Thank you very much for this wonderful project!
I just installed it and giving it a try.
I have 2 questions, console programming related.
1) Is there any command Input-like, that allows for a specific number
of characters input (without pressing Enter)?
Eg. lets say, I'm presenting the user a Y or N question. What I
expect, is a single character input (with no need, for pressing
Enter).
There is getch(). Try it and tell me if it's what you're looking for.
Post by Γιώργος Κ
2) Is there any way for coloring the text (eg. presenting a question
with red or green letters), other than messing with ncurses?
Something closer to BASIC tradition, maybe?
Ncurses is more or less complicated! :-)
Long time ago, I made something like that for a Linux terminal. Let's
look into Rolf's archive :-)

Ok, maybe this helps. Here is one module I made which is for some screen
functions. In a Linux terminal, you need Esc[ strings to handle this,
and these strings are produced here. What you do is calling the
functions and building the strings into the string you send to the
terminal. If you have more questions, no problem...

Rolf


' Gambas module file

PRIVATE esc AS String = Chr$(27) & "["

PUBLIC CONST Black AS String = "0"
PUBLIC CONST Red AS String = "1"
PUBLIC CONST Green AS String = "2"
PUBLIC CONST Yellow AS String = "3"
PUBLIC CONST Blue AS String = "4"
PUBLIC CONST Magenta AS String = "5"
PUBLIC CONST Cyan AS String = "6"
PUBLIC CONST White AS String = "7"

PUBLIC CONST Foreground AS String = "3"
PUBLIC CONST Background AS String = "4"


PUBLIC FUNCTION Cls() AS String

RETURN esc & "2J" & esc & "H"

END

PUBLIC FUNCTION Normal() AS String

RETURN esc & "0m"

END

PUBLIC FUNCTION Bold() AS String

RETURN esc & "1m"

END

PUBLIC FUNCTION Gray() AS String

RETURN esc & "2m"

END


PUBLIC FUNCTION Underline() AS String

RETURN esc & "4m"

END

PUBLIC FUNCTION Blink() AS String

RETURN esc & "5m"

END


PUBLIC FUNCTION Reverse() AS String

RETURN esc & "7m"

END


PUBLIC FUNCTION MoveTo(row AS Integer, col AS Integer) AS String

IF row < 1 THEN row = 1
IF row > 25 THEN row = 25
IF col < 1 THEN col = 1
IF col > 80 THEN col = 80

RETURN esc & CStr(row) & ";" & CStr(col) & "f"

END


PUBLIC FUNCTION Color(FgBg AS String, Colorvalue AS String) AS String

RETURN esc & FgBg & Colorvalue & "m"

END
Rolf-Werner Eilert
2014-03-17 09:47:42 UTC
Permalink
Stop! Forget about getch(), that's a C function, of course...

Try something like this:

PUBLIC SUB Application_Read()
DIM t$ AS String
PRINT "hello there"
READ #LAST, t$, -256

't$ = READ -256

IF t$ <> "" THEN
PRINT t$ & " : ";
END IF

txt = txt & t$

SELECT CASE txt
CASE "b"
PRINT Chr$(27) & "[1m";
CASE ELSE
PRINT "gedrückt:" & txt;
END SELECT

txt = ""

END
Post by Γιώργος Κ
Hi! :-)
Thank you very much for this wonderful project!
I just installed it and giving it a try.
I have 2 questions, console programming related.
1) Is there any command Input-like, that allows for a specific number
of characters input (without pressing Enter)?
Eg. lets say, I'm presenting the user a Y or N question. What I
expect, is a single character input (with no need, for pressing
Enter).
2) Is there any way for coloring the text (eg. presenting a question
with red or green letters), other than messing with ncurses?
Something closer to BASIC tradition, maybe?
Ncurses is more or less complicated! :-)
TIA! :-)
Giorgos.
------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
Continue reading on narkive:
Loading...