Prompt line number

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Prompt line number

vlad777
For example, my octave prompt is showing line number 7 octave...:7>
Is there a way to delete 4th line so that now it shows 6.
Or can I cancel all my previous lines and reset this counter?

Many Thanks
Reply | Threaded
Open this post in threaded view
|

Re: Prompt line number

James Sherman
On Tue, Dec 6, 2011 at 2:41 PM, vlad777 <[hidden email]> wrote:
For example, my octave prompt is showing line number 7 octave...:7>
Is there a way to delete 4th line so that now it shows 6.
Or can I cancel all my previous lines and reset this counter?

Many Thanks

 
Hi,

First, I don't believe it is possible.

Second, why would you want to?  The counter (AFAIK) is there simply as a way to identify the line you're on usually when debugging something.  Particularly at the prompt, it doesn't serve much of a purpose (I think you can hide it, but I don't know the details).

I think you have a misconception of how the prompt works.  After you type in a command, say:
octave:1> a= 5;
Then octave creates a variable called "a" that is assigned the value 5.  Then that variable is available to use as you see fit, but the line itself has executed and gone (well except as an entry in the history).  You could undo the line in some sense by clearing the variable like:
octave:2> clear a;
but this isn't what (I think) you mean by "deleting" a line.

Perhaps you could clarify what you're trying to do and why?

_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: Prompt line number

vlad777
This post was updated on .
Yes you are right, I am just starting learning octave and how this prompt works.

Thing is octave remembers what I entered previously so there must be a way
to rewrite or delete it from octaves memory.
(EDIT) Does "clear a;" just does a:=0 ,or does it frees memory and no a anymore?

I just want to learn about prompt before I use editor(notepad++) for coding.

There are few prompts I encountered.
DOS type where command is executed and nothing is related to the next command.
Old Commodore  prompt which remembers everything by line number, and you
manipulate everything by line number.

(i am not that old though, and i program in C++)
Reply | Threaded
Open this post in threaded view
|

Re: Prompt line number

Jordi Gutiérrez Hermoso-2
On 6 December 2011 16:18, vlad777 <[hidden email]> wrote:
> I just want to learn about prompt before I use editor(notepad++) for coding.

It's a readline prompt. Does this documentation help?

    http://cnswww.cns.cwru.edu/php/chet/readline/rluserman.html

- Jordi G. H.
_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: Prompt line number

vlad777
I guess my main question is:

How do I manipulate objects in memory created on previous lines?

(BTW many thanks for replies)
Reply | Threaded
Open this post in threaded view
|

Re: Prompt line number

James Sherman
On Tue, Dec 6, 2011 at 4:36 PM, vlad777 <[hidden email]> wrote:
I guess my main question is:

How do I manipulate objects in memory created on previous lines?

(BTW many thanks for replies)

--
Think of it as writing code one line at a time:
octave-3.2.4.exe:1> a = 5
a =  5
octave-3.2.4.exe:2> b = a^2
b =  25

Note that as you want to code anything substantial, you'll want to put all the lines you want to execute in a script in a file, say foo.m with the lines in foo.m:

a = 5;
b = a^2;

Then when you type "foo", it will execute those lines just like you had typed them in.

Hope this helps.

_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: Prompt line number

Doug Stewart-4
In reply to this post by vlad777
If you type 
whos
at the prompt you can see all the variable that you have previously made.

All these variables are still there ready to use again. If you really want to remove one or more of them try the clear command.

type 
help clear

Doug


On Tue, Dec 6, 2011 at 4:36 PM, vlad777 <[hidden email]> wrote:
I guess my main question is:

How do I manipulate objects in memory created on previous lines?

(BTW many thanks for replies)

--
View this message in context: http://octave.1599824.n4.nabble.com/Prompt-line-number-tp4166202p4166579.html
Sent from the Octave - General mailing list archive at Nabble.com.
_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave



--
DAS

https://linuxcounter.net/user/206392.html

_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: Prompt line number

vlad777
Yes whos and clear seem to do it.

Clear deallocates and deletes so variable doesn't show up again in whos.
Reply | Threaded
Open this post in threaded view
|

Re: Prompt line number

pathematica
You can change the prompt and remove the line numbers, if you wanted to do that for some reason.

You need the command:

PS1('What you put here becomes the prompt')

This might be illustrated in the following lines. For each case, I have made the change then pressed return once to see the new prompt without a command. Note the requirement for quotation marks, and for the need to insert spaces or other characters, such as the >, if required (I forgot with one of the changes so that the prompt collided with the command, which is obviously not very sensible).

octave:1> PS1('>')
>
>PS1('Octave rules')
Octave rules
Octave rulesPS1('Octave rules>')
Octave rules>
Octave rules>PS1('Octave rules >')
Octave rules >
Octave rules >PS1('>>')
>>
However good you think Octave is, it's much, much better.