148 views

# Math report example

1. 3 months ago

### Lucas P

is not verified May 13 Brazil

I'm coding some engineering stuff, and I want to export a report file (.txt);
I'm searching for better ways to do that, and so far this is what I got:

```Dim a, b, c As Double

a=3
b=4
c=Sqrt(a^2+b^2)

Dim f As FolderItem
Dim t As TextOutputStream
f = GetSaveFolderItem("", "report.txt")
If f <> Nil Then
t = TextOutputStream.Create(f)
t.WriteLine("This is a simple math report")
t.WriteLine("Pythagoras Theorem:")
t.WriteLine("Side a:= " + a.StrF )
t.WriteLine("Side b:= " + b.StrF )
t.WriteLine("c^2:= a^2 + b^2")
t.WriteLine("c= sqrt(" + a.StrF +"^2 + " + b.StrF + "^2)" )
t.WriteLine("c= " + c.StrF )
t.Close
End If```

Most of what I need it's this: `t.WriteLine("c^2 =" + a.StrF +"^2 + " +b.StrF+ "^2" )` , applying the variables to the equation to be as obvious as possible about how the calculation was done.
Is there any tips to improve that? For instance, to combine the variables with operators I used: `a.StrF +"^2 + "`. I'm looking for something like: `t.WriteLine("c= " + magicmethod(a^2+b^2) )` or Sign Up to reply!