4
$\begingroup$

I'm trying to set up code that basically asks the user to input the values of a matrix with a certain key size. I want them to first enter the keysize and then ask for all of the entries necessary to fill the square matrix of that keysize.

$\endgroup$
3
  • $\begingroup$ Mathematica has already provided means to input a matrix. See e.g. reference.wolfram.com/language/howto/InputAMatrix.html $\endgroup$ Commented Sep 27, 2020 at 11:54
  • $\begingroup$ After you ask for the matrix size, you could present a TableView using the matrix size for the AllowedDimensions option. $\endgroup$ Commented Oct 27, 2020 at 15:03
  • $\begingroup$ Maybe one could used FormFunction, although it seem to be designed more for web applications. $\endgroup$ Commented Mar 26, 2021 at 18:07

1 Answer 1

0
$\begingroup$

This is not an answer. This Code may help you prepare your input boxes.

Panel[
country = 0;
sector = 0;
level = 0;
result = {};
While[Not[IntegerQ[country] && 1 <= country <= 64], (country = Input["Which country do you want to analyze?"])];
While[Not[IntegerQ[sector] && 1 <= sector <= 15], (sector = Input["Which sector do you want to target?"])];
While[Not[NumericQ[level] && 0.01 <= level <= 1], (level = Input["At what significance level do you want to analyze IO matrix?"])];
result = {country, sector, level};
If[
 result === {}, "", result
 ]
]
$\endgroup$
3
  • 1
    $\begingroup$ This hangs up Mma 12.2.0-Win7x64 and the dialog wouldn't go away. Perhaps it is a version related artifact. There is a comma flagged in red in the If statement at the end. $\endgroup$ Commented Mar 21, 2022 at 4:02
  • 1
    $\begingroup$ is result === {}, "", to be result === {}, "", result ? $\endgroup$ Commented Nov 11, 2023 at 20:23
  • $\begingroup$ @AsukaMinato: Yes, you are right, however, for some reason, the dialogue box does not go away as noted by Syed noted. I cannot find the reason for that. $\endgroup$ Commented Nov 11, 2023 at 21:33

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.