[Top][All Lists]

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

Re: [Bug-apl] Reading and updating the content of a variable

From: Juergen Sauermann
Subject: Re: [Bug-apl] Reading and updating the content of a variable
Date: Tue, 07 Jan 2014 14:32:57 +0100
User-agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130330 Thunderbird/17.0.5


say the name of a user-defined variable is contained in some UCS_string:

UCS_string varname;

Step 1: ----------------------------------------------

You first get a Symbol *:

Symbol * var_symbol = Workspace::lookup_existing_symbol(varname);

The pointer is 0 if varname does not exist. If the variable is system-defined, then it has a direct access method Workspace::get_v_quad_IO() for ⎕IO that returns the Symbol &
of the symbol and it is guaranteed to exist.

Symbol * quad_IO =_symbol &Workspace::get_v_quad_IO();

Step 2: ----------------------------------------------

Once you have the Symbol * or &, you can assign or reference it:

Value_P new_value;
var_symbol->assign(new_value, LOC);

Value_P value = var_symbol->get_apl_value();

In the second example, DO NOT optimize the creation of Value_P value away, because
this may break the shared pointer based memory allocation.

/// Jürgen

On 01/07/2014 07:12 AM, Elias Mårtenson wrote:
I'm currently looking to adding the ability to read and update variables via the backend connection. This will eventually be used to display arrays in separate buffers (and perhaps a spreadsheet-like editor for such values).

I would like to advice on how to best do this without using too much low-level stuff in the interpreter. I was thinking that perhaps I could leverage some of the code in the workspace save and load functions?

All I really need is to be able to get and update a limited set of data. I.e. Scalars, and 1 and 2-dimensional arrays where the elements are either scalars or strings.

I'm currently looking at doing this "manually", but before I get too far I wanted to know if you had any opinions.


reply via email to

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