# assigning an xloper

 Wiki Link: [discussion:322785]
 ekoome Feb 17, 2012 at 12:30 PM Edited Feb 17, 2012 at 12:38 PM I'm learning to use this xll class and i would like to obtain an xltypemulti from excel, and do stuff as follows:   ```LPOPERX WINAPI xll_square(const LPOPERX x) { #pragma XLLEXPORT static OPERX o; if (x==NULL) return NULL; o = x; double sz; sz = o.size(); for (int i=0; i < sz; i++) { o[i] = pow(o[i], 2); } return &o; }``` `But when doing the assignment o=x where x has an array from an excel range ({1.44, 1.45;3.33,1.22}) it calls the ﻿XOPER& operator=(bool xbool) which is strange and retuens 1.` `What am i doing wrong?` `I know i can use FP but what's wrong with the above use? ` `Secondly, I would also like to take in an xloper do stuff with it and return results to a certain number of cells without using array formulas. Does this require a macro to get current cell and offsets?` `thanks` `Eric` keithalewis Coordinator Feb 17, 2012 at 12:47 PM In your code x is a pointer to an OPER, i.e., 'LPOPER' is the same as 'OPER*'. After your line 'o = x;' you should expect o to be an xltypeNum with o.val.num equal to the pointer value. If you use 'o = *x' then you will get the value passed in from Excel as a xltypeMulit if you pass in a range. ekoome Feb 17, 2012 at 1:05 PM Thanks Keith. Relating to my second question, how do i return results to multiple cells with mixed type data - doubles & string  (probably xltypeSref or xltyperef) without entering as array formula. ﻿First output 2.0736 5.4289 17.8084 99.8001 The next output 2.0736 5.4289 17.8084 99.8001 etc That is the output size depends on the input for example coefficients from regression etc. Do i need to get the activecell and compute offsets to get the correct sized range? Eric keithalewis Coordinator Feb 17, 2012 at 1:11 PM Sorry, I don't understand what you are trying to do. You can do static OPERX o; o.resize(2,2); o(0,0) = 1.23; o(0,1) = _T("a string"); o(1,0) = false; o(1,1) = ErrX(xlerrNA); and return &o to get a 2x2 output from the function. ekoome Feb 17, 2012 at 1:25 PM apologies Keith. Using your example, it will retun 1.23 on the current cell and nothing else unless i entered the formula with Ctrl-Shift-Enter (as an array formula) with the right number of cells selected. What i would prefer to do is to return  "1.23" directly to cell "A1" "a string" to cell "B1", "false" to cell "A2" etc. Similar to VBA activecell.offset (...)   Hope this makes sense. keithalewis Coordinator Feb 17, 2012 at 1:35 PM Don't do that. It breaks the zen of Excel. ekoome Feb 17, 2012 at 1:47 PM I thought xltypeSref or XltypeRef XLOPER would be able to do that by specifying rowfirst ... columnlast and assigning. If not how would you construct and return ﻿xltypeSref/ xltypeRef XLOPER? keithalewis Coordinator Feb 17, 2012 at 1:49 PM You need to learn the difference between a function and a macro. ekoome Feb 17, 2012 at 2:26 PM will do. I do i run the macro.cpp?  you mentioned Alt-F8  and typing xll_macro, but that does not enable the run button (i'm using excel 2003). Do i need to create a sub and call xll_macro() instead? Also are there plans for detailed documentation? At the moment i'm having to study code to get by... keithalewis Coordinator Feb 17, 2012 at 2:33 PM You need to type the Excel name "XLL.MACRO", not the C function name. The library is intended for people that have spent some time learning the Excel SDK. I can recommend Steve Dalton's book for that. Let me know what you think is missing from http://xll.codeplex.com/wikipage?title=User&referringTitle=Documentation. ekoome Feb 17, 2012 at 3:37 PM I have Steve's book. I will look at Macros. My argument descriptions are being truncated. For example this addin   ```static AddInX xai_function( FunctionX(XLL_LPOPERX, _T("?xll_square"), _T("XLL.SQUARE")) .Arg(XLL_LPOPERX, "Test",_T("is a test")) // .Arg(...) // add more args here .Category(CATEGORY) .FunctionHelp(_T("Description of what function does.")) .Documentation(_T("Optional documentation for function.")) ); ```   will display "Test is a tes" missing the last character in Excel formula dialog. keithalewis Coordinator Feb 17, 2012 at 3:41 PM It is a known bug in the Excel SDK. You have to feed the character monster an extra character in the last argument.