Author Topic: Ask: Control Character: Backspace to erase the last character printed  (Read 6759 times)

0 Members and 1 Guest are viewing this topic.

RAYAKMAL

  • Guest
I want all my Autolisp code executed from menu and I need to hide the command that is used to call the functions.
Any idea how to use backspace control character (to erase the last character printed) in Windows OS?
I tried using "\b" but it didn't work. Did I do wrong?
Thanks for your help.
« Last Edit: July 18, 2014, 09:00:23 PM by RAYAKMAL »

BlackBox

  • King Gator
  • Posts: 3770
Re: Ask: Control Character: Backspace to erase the last character printed
« Reply #1 on: September 07, 2011, 08:40:08 PM »
I do not understand your question. Are you using a macro, or LISP?

Have tried:
Code: [Select]
^C^C^P

... Then your macro?

The "^P" is what causes a macro to be "silent."
"How we think determines what we do, and what we do determines what we get."

RAYAKMAL

  • Guest
Re: Ask: Control Character: Backspace to erase the last character printed
« Reply #2 on: September 07, 2011, 08:47:14 PM »
It's Autolisp.
E.q:

(defun C:MYfunc ()
  (repeat (strlen "MYFunc")
     (princ "\b")
  );end repeat
  ..
  ..
 
)

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

I will put something in Menu file:
^C^C_MyFunc

Do you think I should write it :
^C^C^P_MyFunc ?

danallen

  • Guest
Re: Ask: Control Character: Backspace to erase the last character printed
« Reply #3 on: September 07, 2011, 09:52:37 PM »
if you want to erase a character, try this:
Code: [Select]
Command: (princ "ab\010c")(princ)
ac

^P does toggle MENUECHO on or off

Dan

BlackBox

  • King Gator
  • Posts: 3770
Re: Ask: Control Character: Backspace to erase the last character printed
« Reply #4 on: September 08, 2011, 12:28:00 AM »
Why would you write/use a function the uses princ only to "erase" the characters you sent to the command line???

Consider NOT doing all of that, and instead look into the CMDECHO, and NOMUTT system variables.
"How we think determines what we do, and what we do determines what we get."

RAYAKMAL

  • Guest
Re: Ask: Control Character: Backspace to erase the last character printed
« Reply #5 on: September 08, 2011, 07:41:38 AM »
@Dan. Thanks Dan, That's what I want  :-)
@Renderman. Thanks. My goals are:  1) If I can hide the function call (and users need to access the function through menu) this process helps users to memorize step by step instruction to accomplish things 2) I wanna 'hide' my lisp code from casual user (I still use Autolisp n Kelvinator, not VisualLisp)

danallen

  • Guest
Re: Ask: Control Character: Backspace to erase the last character printed
« Reply #6 on: September 08, 2011, 07:05:09 PM »
Why would you write/use a function the uses princ only to "erase" the characters you sent to the command line???

Try this:
Code: [Select]
(princ "\nProcessing ")
(repeat 2
  (foreach x (list "\\" "|" "/" "-")
    (prompt x)
    (command "delay" "500")
    (princ "\010")
    (princ)
  )
)

BlackBox

  • King Gator
  • Posts: 3770
Re: Ask: Control Character: Backspace to erase the last character printed
« Reply #7 on: September 08, 2011, 09:07:52 PM »
IMO - everything after the first line of code is wasted effort for some sort of 'neat' display effect (and that's fine, if you're into that). If you want that, check out DOSLib's progress bar function. :wink:
"How we think determines what we do, and what we do determines what we get."

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: Ask: Control Character: Backspace to erase the last character printed
« Reply #8 on: September 09, 2011, 04:07:08 AM »
RM, that was actually the old way of indicating that the routine is processing. In the DOS days you had a turning bar in stead of a progress bar.

Something which princ'ed to the command line replacing the same character in turn with |, then /, then -, then \, and repeating. This way you indicated to the user that something's still happening: i.e. "No. ACad hasn't frozen!"

Of course you could try this alternative progress bar of mine: http://forums.augi.com/showpost.php?p=1104539&postcount=18
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

Lee Mac

  • Seagull
  • Posts: 12915
  • London, England
Re: Ask: Control Character: Backspace to erase the last character printed
« Reply #9 on: September 09, 2011, 07:44:26 AM »
Why would you write/use a function the uses princ only to "erase" the characters you sent to the command line???

Try this:

Use the "\r" character to avoid the need to backspace  :wink:

BlackBox

  • King Gator
  • Posts: 3770
Re: Ask: Control Character: Backspace to erase the last character printed
« Reply #10 on: September 09, 2011, 11:33:00 AM »
RM, that was actually the old way of indicating that the routine is processing. In the DOS days you had a turning bar in stead of a progress bar.

Something which princ'ed to the command line replacing the same character in turn with |, then /, then -, then \, and repeating. This way you indicated to the user that something's still happening: i.e. "No. ACad hasn't frozen!"

Of course you could try this alternative progress bar of mine: http://forums.augi.com/showpost.php?p=1104539&postcount=18

No, I understand it... I've been using Land Desktop for years. I've just never found the need, desire to actually incorporate it into my limited code library.

Again, this is not about me, so my opinion on this matter is of little worth, if not irrelevant. My apologies to the OP, as I did not intend on causing this tangent.

Why would you write/use a function the uses princ only to "erase" the characters you sent to the command line???

Try this:

Use the "\r" character to avoid the need to backspace  :wink:

This is the method I use for almost every LISP function I write (perhaps I should have posted that, Doh!). You'll see this in my code posts frequently.
"How we think determines what we do, and what we do determines what we get."

danallen

  • Guest
Re: Ask: Control Character: Backspace to erase the last character printed
« Reply #11 on: September 09, 2011, 09:42:48 PM »
Use the "\r" character to avoid the need to backspace  :wink:

What is that supposed to be used for? Testing I get this surprising result:
Code: [Select]
Command: (princ "abcd\refg")(princ)
efgd

Lee Mac

  • Seagull
  • Posts: 12915
  • London, England
Re: Ask: Control Character: Backspace to erase the last character printed
« Reply #12 on: September 10, 2011, 07:59:57 AM »
e.g.:

Code: [Select]
(defun _spinner ( / c )
    (setq c (getvar 'CMDECHO))
    (setvar 'CMDECHO 0)
    (repeat 2 (foreach x '("\r-" "\r\\" "\r|" "\r/") (princ x) (command "_.delay" 200)))
    (setvar 'CMDECHO c)
    (princ)
)

Or:

Code: [Select]
(defun c:test ( / pt )
    (terpri)
    (while (setq pt (getpoint "\rPick Point: "))
        (entmakex (list (cons 0 "POINT") (cons 10 (trans pt 1 0))))
    )
    (princ)
)

danallen

  • Guest
Re: Ask: Control Character: Backspace to erase the last character printed
« Reply #13 on: September 11, 2011, 04:29:46 PM »
I see the return character \r is intended to backspace the entire line. I was confused by the end "d" from this test:
Code: [Select]
Command: (princ "abcd\refg")(princ)
efgd

I thought it was a bug until I figured out that the new text after return just overwrites:
Code: [Select]
Command: (princ "abcdefg\rABC")(princ)
ABCdefg

Thanks

Lee Mac

  • Seagull
  • Posts: 12915
  • London, England
Re: Ask: Control Character: Backspace to erase the last character printed
« Reply #14 on: September 11, 2011, 07:26:17 PM »
Not quite a 'backspace' since no text is deleted; the '\r' control character is a carriage return which instructs the output to start at the beginning of the same line, overwriting any existing text.