HP Forums
Question about using programs in spreadsheet - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: Question about using programs in spreadsheet (/thread-20233.html)



Question about using programs in spreadsheet - nickapos - 07-27-2023 05:12 PM

Hello everyone,
Does anyone know if it is possible to use a custom program from a spreadsheet cell?
I have looked and didn’t find any way to do it, but maybe I am missing something?

Thank you very much


RE: Question about using programs in spreadsheet - froehlic - 07-27-2023 08:13 PM

If I understand that correct: You want to call a program inside a cell?

You can do that like this:
Code:

EXPORT FF_min(a, b)
BEGIN
  return IFTE(a<b, a, b);
END;

Now you can put your values for a and b in spreadsheet cells, lets say A1 and A2.
Define A3 as:
=FF_min(A1, A2)

The value in A3 is always the minimum of A1 and A2. This as a simple example. Your program can be whatever, for this special case you have to return a single object that can be stored in a cell.
You also can manipulate other cells in your program:

Code:

  Cell(1,11):=1;           // set cell K1 to 1
  Cell(1,10,7):= Col1;  // background color of J10 to color code Col1

Hope that's useful for you.


RE: Question about using programs in spreadsheet - nickapos - 07-28-2023 02:14 AM

(07-27-2023 08:13 PM)froehlic Wrote:  If I understand that correct: You want to call a program inside a cell?

You can do that like this:
Code:

EXPORT FF_min(a, b)
BEGIN
  return IFTE(a<b, a, b);
END;

Now you can put your values for a and b in spreadsheet cells, lets say A1 and A2.
Define A3 as:
=FF_min(A1, A2)

The value in A3 is always the minimum of A1 and A2. This as a simple example. Your program can be whatever, for this special case you have to return a single object that can be stored in a cell.
You also can manipulate other cells in your program:

Code:

  Cell(1,11):=1;           // set cell K1 to 1
  Cell(1,10,7):= Col1;  // background color of J10 to color code Col1

Hope that's useful for you.
This is great exactly what I was looking for, thank you very much


RE: Question about using programs in spreadsheet - matalog - 07-29-2023 08:00 PM

(07-27-2023 08:13 PM)froehlic Wrote:  
Code:

  Cell(1,11):=1;           // set cell K1 to 1
  Cell(1,10,7):= Col1;  // background color of J10 to color code Col1

Hope that's useful for you.

Where is that use of Cell() documented? I cannot find it in documentation, manual nor does it work in a program. Where should it be used?


RE: Question about using programs in spreadsheet - roadrunner - 07-29-2023 09:38 PM

It's in the online help under:

Main/HP apps/Spreadsheet app/Spreadsheet Variables/Cell References and Cell


RE: Question about using programs in spreadsheet - matalog - 07-30-2023 04:52 PM

(07-29-2023 09:38 PM)roadrunner Wrote:  It's in the online help under:

Main/HP apps/Spreadsheet app/Spreadsheet Variables/Cell References and Cell

I'd like to look at it, what is the online help?


RE: Question about using programs in spreadsheet - nickapos - 07-30-2023 05:41 PM

(07-30-2023 04:52 PM)matalog Wrote:  
(07-29-2023 09:38 PM)roadrunner Wrote:  It's in the online help under:

Main/HP apps/Spreadsheet app/Spreadsheet Variables/Cell References and Cell

I'd like to look at it, what is the online help?

It’s the manual that comes in the calculator if you click help button


RE: Question about using programs in spreadsheet - matalog - 07-30-2023 07:26 PM

That's great, thanks.


RE: Question about using programs in spreadsheet - StephenG1CMZ - 07-30-2023 10:40 PM

(07-30-2023 05:41 PM)nickapos Wrote:  
(07-30-2023 04:52 PM)matalog Wrote:  I'd like to look at it, what is the online help?

It’s the manual that comes in the calculator if you click help button
I assume he meant the On device offline help.


RE: Question about using programs in spreadsheet - froehlic - 08-03-2023 07:12 AM

(07-29-2023 08:00 PM)matalog Wrote:  Where is that use of Cell() documented? I cannot find it in documentation, manual nor does it work in a program. Where should it be used?

A little more details on that topic. If you only want to access a cell of any spreadsheet in a HPPL program or even in any other App or Homescreen you can use it like

Code:

 Spreadsheet.B3

Spreadsheet could be the "original" spreadshheet or any other new App based on spreadsheet. You can save a new spreadsheet i.E. as SpA (do not use a number at the end of the name!). Now you can access to cell C3 of that:

Code:

  SpA.C3

That is very important to use links inside a spreadsheet to other spreadsheets as you would like do in Excel.

BUT: If you want to loop through multiple cells in a spreadsheet, you have to use the cell function to access cells with a variable.For example:

Code:

LOCAL i;

FOR i:= 1 TO 10 DO
  SpA.Cell(i, 1):= i;
END;

This little example sets cells A1 to A10 to the sequence from 1 to 10. With that you can do all complex calculations on your spreadsheets.
Really ingenious about the Prime is the fact that you can use nearly everything from everywhere. As I said: A bug should be that you can't use Sp1.B2, this resolves in a error although you may name a spreadsheet Sp1!


RE: Question about using programs in spreadsheet - nickapos - 08-03-2023 02:31 PM

This is awesome and not intuitive at all. Someone needs to piece the puzzle on their own, of have it pointed to them. Thank you very much