Uses consoleG
'
function isnumeric(string a) as int 'is_numeric2
select asc(a)
case 0x30 to 0x39 : return 1 '0 to 9
case 45 : return 1 '-
end select
end function
function irnd(int z1, z2) as int
================================
mov eax,z2
sub eax,z1
inc eax
imul edx,Seed,0x8088405
inc edx
mov Seed,edx 'store new seed
mul edx 'multiply eax by edx
return edx+z1
end Function
redim string dat[3,3] static 'dat[5,5] static
redim int ytot[3,1] static '[5,1]
redim int xtot[3] static
procedure main()
================
sys a,i,p
static string ins
static string s
if opening
'INTIAL EXAMPLE DATA
int x,y
for y=lbound(dat,1) to ubound(dat,1)
for x=lbound(dat,2) to ubound(dat,2)
dat[y,x]=str irnd(1,9) 'Changed range to 1-9 for better visibility
next
next
'
endif
'
if closing
del ytot
del dat
del xtot
'mbox "closed"
exit procedure
endif
cls .10,.10,.20
'
'GRID INPUTS
------------
scale 1.5
int x,y
pushstate
move 4,-0.25
scale 1.5
print "Calculations"
popstate
move 0,-2
'
for x=lbound(dat,2) to ubound(dat,2)
PushState
move x*4
print "Col " chr(x+64)
PopState
next
PushState
move x*4
print "Total"
PopState
'
for y=lbound(dat,1) to ubound(dat,1)
PushState
move 1, -y*2
print "Row" str(y)
PopState
next
PushState
move 1, -y*2
print "Total"
PopState
'
int v,v2
int gtot=1
for x=lbound(dat,2) to ubound(dat,2)
ytot[x]=1
next
'
'------------------------------------------- //
int selectedX=-1, selectedY=-1
for y=lbound(dat,1) to ubound(dat,1)
xtot[y]=1
for x=lbound(dat,2) to ubound(dat,2)
' multiply go ------------
v=val(dat[y,x])
xtot[y]*=v
ytot[x]*=v
============================
============================
PushState
move x*4,-y*2
if pick
'MARK PICKING AREA
picklabel y*10+x
move 0,0,-.01
PutBoxArea 3,1
else 'not pick
if picked=y*10+x
'DATA EDITING
color 0.9,.9,0.9
a=input dat[y,x]
lastkey=0
lastchar=0
else 'not picked
'DATA DISPLAY
move 0,0,-.01
color .2,.6,.3
PutBoxArea 3,1
move 0.2,0.2,.01
color .8,.8,.6
print dat[y,x]
endif
endif
PopState
============================
============================
/*
' multiply go ------------
PushState
move x*4,-y*2
if pick or (selectedX=x and selectedY=y)
'MARK PICKING AREA
picklabel y*10+x
move 0,0,-.01
PutBoxArea 3,1
if lastkey=13 'Enter key
selectedX=x
selectedY=y
endif
else 'not pick
if selectedX=x and selectedY=y
'DATA EDITING
color 0.9,.9,0.9
'------------------------------ input doesnt work here ---- //
a=input dat[y,x]
print "a: "+a ' first cell top left
if not isnumeric(a)
color 1,0,0 'Red color for invalid input
print "Invalid input"
else
dat[y,x]=a
endif
lastkey=0
lastchar=0
else 'not selected
'------------------------------ input doesnt work here ---- //
' color added
'DATA DISPLAY
move 0,0,-.01
'Color coding based on value
if v<3
color .2,.6,.3 'Green for low values
elseif v<7
color .6,.6,.2 'Yellow for medium values
else
color .6,.2,.2 'Red for high values
endif
'------------------------------------- //
PutBoxArea 3,1
move 0.2,0.2,.01
color .8,.8,.6
print dat[y,x]
'print "#.##", val(dat[y,x])
endif
endif
PopState
*/
next 'x
'----------------------- // multiply
gtot*=xtot[y]
'----------------------- // multiply
PushState
move x*4,-y*2
color .9,.9,.6
print "xtot " + xtot[y]
'print "#.##" + xtot[y]
PopState
next 'y
'--------------------------------------- //
'COL TOTALS
for x=lbound(dat,2) to ubound(dat,2)
PushState
move x*4,-y*2
color .9,.9,.6
print ytot[x]
PopState
next 'col totals
PushState
move x*4,-y*2
color .9,.9,.6
print gtot
PopState
scale 1/1.5
'printl str(picked)
'
end procedure
EndScript
Page created in 0.118 seconds with 14 queries.