From 824eb1dca9eca6b520a93547866a468c6c4362fd Mon Sep 17 00:00:00 2001
From: Joshua Davidson <joshuadavidson2000@gmail.com>
Date: Wed, 20 Feb 2019 12:23:33 -0700
Subject: [PATCH] System: Fix bug in MCDU message

---
 Nasal/MCDU/MCDU.nas | 10 +++++++---
 revision.txt        |  2 +-
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/Nasal/MCDU/MCDU.nas b/Nasal/MCDU/MCDU.nas
index 64db748d..7418eb71 100644
--- a/Nasal/MCDU/MCDU.nas
+++ b/Nasal/MCDU/MCDU.nas
@@ -275,7 +275,11 @@ var rskbutton = func(btn, i) {
 			perfCRZInput("R6",i);
 		} else if ((getprop("/MCDU[" ~ i ~ "]/page") == "DATA") or (getprop("/MCDU[" ~ i ~ "]/page") == "PRINTFUNC") or (getprop("/MCDU[" ~ i ~ "]/page") == "PRINTFUNC2")) {
 			if (getprop("/MCDU[" ~ i ~ "]/scratchpad") != "AOC DISABLED") {
-				setprop("/MCDU[" ~ i ~ "]/last-scratchpad", getprop("/MCDU[" ~ i ~ "]/scratchpad"));
+				if (getprop("/MCDU[" ~ i ~ "]/scratchpad-msg") == 1) {
+					setprop("/MCDU[" ~ i ~ "]/last-scratchpad", "");
+				} else {
+					setprop("/MCDU[" ~ i ~ "]/last-scratchpad", getprop("/MCDU[" ~ i ~ "]/scratchpad"));
+				}
 			}
 			setprop("/MCDU[" ~ i ~ "]/scratchpad-msg", 1);
 			setprop("/MCDU[" ~ i ~ "]/scratchpad", "AOC DISABLED");
@@ -463,7 +467,7 @@ var button = func(btn, i) {
 				setprop("/MCDU[" ~ i ~ "]/scratchpad-msg", 0);
 			} else if (size(scratchpad) > 0) {
 				setprop("/MCDU[" ~ i ~ "]/last-scratchpad", "");
-				setprop("/MCDU[" ~ i ~ "]/scratchpad", left(scratchpad, size(scratchpad)-1));
+				setprop("/MCDU[" ~ i ~ "]/scratchpad", left(scratchpad, size(scratchpad) - 1));
 				setprop("/MCDU[" ~ i ~ "]/scratchpad-msg", 0);
 			}
 		} else if (btn == "0") {
@@ -520,7 +524,7 @@ var button = func(btn, i) {
 
 var notAllowed = func(i) {
 	if (getprop("/MCDU[" ~ i ~ "]/scratchpad") != "NOT ALLOWED") {
-		if (getprop("/MCDU[" ~ i ~ "]/scratchpad-msg") == 1) { # Messages clear after NOT ALLOWED
+		if (getprop("/MCDU[" ~ i ~ "]/scratchpad-msg") == 1) {
 			setprop("/MCDU[" ~ i ~ "]/last-scratchpad", "");
 		} else {
 			setprop("/MCDU[" ~ i ~ "]/last-scratchpad", getprop("/MCDU[" ~ i ~ "]/scratchpad"));
diff --git a/revision.txt b/revision.txt
index 3f04204e..2dc72dba 100644
--- a/revision.txt
+++ b/revision.txt
@@ -1 +1 @@
-4766
\ No newline at end of file
+4767
\ No newline at end of file