I added a variable named 'strfilename' as a process global variable. In one of my activity modules (Start) I use it as follows:
Now in another module (Input) I used it again like this:
The first code seems to accept strfilename. The second does not but complains that strfilename is an undeclared variable. I thought that it was declared in the Start module. In order to test, I had to give the file a literal name (jimtest). Even then I cannot get it to append the data. It only displays the last entry when I use the following code in another module (embed). The code itself my be flawed.
There must be something I am not seeing about global variables because I have a similar problem when I declare something like coord(4) or use a type like
Type coord(point as string, north as double, east as double,desc as string)
Dim point, north,east,desc
In my app coord(4) means 4 elements like coord(0), coord(1), etc. It doesn't mean that a variable named 'coord' has 4 items. Maybe that is not correct. My app will use globals between modules quite extensively so it is critical I fully understand what is happening.
I have tons of global variables used in my PPC version that I have transferred to b4A but won't know if they work as I anticipate until I actually use them.
It is also important that I am able to append data to my files. I also experimented with other scenarios in addition to the code above, thinking each time that I had the solution but did not. I essentially followed what I did in b4ppc but it had a file.close command.
I am not very good at explaining things so please ask questions if you are not clear on what I am talking about. Thanks for your willingness to help.
Jim
B4X:
Sub btnOK_click
strfilename=txtFileName.text
File.OpenOutput (File.DirInternal ,strfilename,True) 'should append data
End Sub
Now in another module (Input) I used it again like this:
B4X:
Sub btnSave_click
coord(0)=txtPoint.Text (This is repeated with new values multiple times)
coord(1)=txtNorth.Text
coord(2)=txtEast.Text
coord(3)=txtDesc.Text
File.OpenOutput (File.DirInternal,strfilename,True) 'shouldn't have to open again since it was opened in the start module
File.WriteString (File.DirInternal ,strfilename,coord(0) & "," & coord(1) & "," & coord(2) & "," & coord(3) & CRLF)
End Sub
The first code seems to accept strfilename. The second does not but complains that strfilename is an undeclared variable. I thought that it was declared in the Start module. In order to test, I had to give the file a literal name (jimtest). Even then I cannot get it to append the data. It only displays the last entry when I use the following code in another module (embed). The code itself my be flawed.
B4X:
txtdisplay.Text=File.GetText (File.DirInternal ,"jimtest")
OR
txtdisplay.text=File.ReadString(File.DirInternal,"jimtest")
There must be something I am not seeing about global variables because I have a similar problem when I declare something like coord(4) or use a type like
Type coord(point as string, north as double, east as double,desc as string)
Dim point, north,east,desc
In my app coord(4) means 4 elements like coord(0), coord(1), etc. It doesn't mean that a variable named 'coord' has 4 items. Maybe that is not correct. My app will use globals between modules quite extensively so it is critical I fully understand what is happening.
I have tons of global variables used in my PPC version that I have transferred to b4A but won't know if they work as I anticipate until I actually use them.
It is also important that I am able to append data to my files. I also experimented with other scenarios in addition to the code above, thinking each time that I had the solution but did not. I essentially followed what I did in b4ppc but it had a file.close command.
I am not very good at explaining things so please ask questions if you are not clear on what I am talking about. Thanks for your willingness to help.
Jim