txt is declared inside your "if (hasChanged) {" scope. Then you use it after the corresponding "}".
Yusuf Saib Android ·T· · ·Mobile· stick together The views, opinions and statements in this email are those of the author solely in their individual capacity, and do not necessarily represent those of T-Mobile USA, Inc. On Sep 27, 10:02 am, bgoody <bgoody...@gmail.com> wrote: > Hi. I am trying to hack this bit of code to save the results of a > calculation to disk but it says that the variable (txt) cannot be > resolved. > Any ideas! > > private void handleEquals(int newOperator) { > if (hasChanged) { > switch (operator) { > case 1: > num = num + Double.parseDouble(txtCalc.getText().toString()); > break; > case 2: > num = num - Double.parseDouble(txtCalc.getText().toString()); > break; > case 3: > num = num * Double.parseDouble(txtCalc.getText().toString()); > break; > case 4: > num = num / Double.parseDouble(txtCalc.getText().toString()); > break; > > } > > String txt = Double.toString(num); > txtCalc.setText(txt); > txtCalc.setSelection(txt.length()); > > readyToClear = true; > hasChanged = false; > > } > > FileOutputStream fOut = openFileOutput > ("samplefile.txt",MODE_WORLD_READABL E); > OutputStreamWriter osw = new OutputStreamWriter(fOut); > osw.write(txt); > osw.flush(); > fOut.close(); > osw.close(); > operator = newOperator; > > > > } --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Beginners" group. To post to this group, send email to android-beginners@googlegroups.com To unsubscribe from this group, send email to android-beginners-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en -~----------~----~----~----~------~----~------~--~---