Hi there everyone! So, I've made an array for coins, like how you would put a coin in a slot and I was just wondering, how can I get the array to be done by a keypress function? This is what I have so far for the array:
-----------------------------------------------------------------------------------
program inputcash;
uses
crt,math,sysutils;
var
total:integer
input:array[1..9] of integer;
begin
input[1]:=1;
input[2]:=2;
input[3]:=5;
input[4]:=10;
input[5]:=20;
input[6]:=50;
input[7]:=100;
input[8]:=200;
input[9]:=0;
------------------------------------------------------------------------------
As you can see I've basically declared the array, now, each of the array values, like [1] is 1p, right?
How do I create it so that when I actually push the 1 button on my keyboard, that it adds the value of [1] into the total variable? Is there a specific code? Maybe something like...
Input:=keypress;
(further down the code)
total:=total+input; <<< May need another variable, opinions?
or something similar like that? Just so that I don't have to type '1' and hit enter for it to add one to the total?
Just to clarify if unsure, I want each button, so say for instance I pressed 5 on my keyboard.. Me physically pushing 5 on my keyboard, would then add the variable [5] into the total, if that makes sense?
I'm new to pascal coding, so please don't judge me because I have little understanding haha.