help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: "Permanent" variables


From: Sergei Steshenko
Subject: Re: "Permanent" variables
Date: Wed, 27 Jan 2016 22:03:50 +0000 (UTC)






>________________________________
> From: grg <address@hidden>
>To: address@hidden 
>Sent: Wednesday, January 27, 2016 10:39 PM
>Subject: "Permanent" variables
> 
>
>Hi there,
>
>I often have at the beginning of my script a series of variable declarations
>that I use as shortcuts later in the script.
>
>For example, I may declare
>
>
>lw = "linewidth";
>ms = "markersize";
>mfc = "markerfacecolor";
>
>
>and then use them as
>
>plot(x, y, 'bo-', lw, 2, ms, 5, mfc, 'r')
>
>This works well, but I need to add these declarations at the beginning of
>every script and they are not readily available if I need, for example, to
>issue a "clear all" command.
>
>So I was wondering if it could be possible to somehow declare these
>variables (outside of octave?) in a way that they remain in memory even if I
>"clear all".
>
>Many thanks in advance for any help.
>
>Cheers,
>grg


Use functions returning constant values, e.g.

function s = lw()
  s = "linewidth";

endfunction

and then call it as

lw()

instead of

lw

you have.

Applies to practically all languages, by the way.


--Sergei.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]