Cristofayre
Member
This is probably "blindingly obvious" to a regular user, but it's thrown me! (Programming 3 days!) Upfront, I'll say I'm using the debugger, and not a physical device if that is causing error.
Dim SavedUserData As String
Dim inUserData As List
Dim savedCopy As String ' Tried as string and as object
Dim savedTitle As Object
Dim savedKey As Object
Dim savedDesc As Object
SavedUserData = File.DirRootExternal & "user.db"
SavedUserData = File.DirRootExternal & "/user.db" 'Both options tried
If File.Exists(SavedUserData, "") = False Then
Dim userList As List
userList.Initialize
userList.AddAll(Array As String("Enter your copyright details","Enter your title","Enter your keywords","Enter your description"))
File.OpenOutput(File.DirRootExternal,"user.db",True) ' Append to list / create list
File.WriteList(File.DirRootExternal,"user.db",userList)
Else
File.OpenInput(File.DirRootExternal,"user.db")
inUserData.Initialize
inUserData=File.ReadList(File.DirRootExternal,"user.db") As List
>> photo_copy_in.Text=inUserData.Get(0)
title_in.Text=inUserData.Get(1)
key_in.Text=inUserData.Get(2)
desc_in.Text=inUserData.Get(3)
End If
LOG:
photo_copy_in.Text=inUserData.Get(0)
javac 1.7.0_76
shell\src\b4a\example\main_subs_0.java:83: error: ';' expected
_inuserdata = main.mostCurrent.__c.getField(false,"File").runMethod(false,"ReadList",(Object)(main.mostCurrent.__c.getField(false,"File").runMethod(true,"getDirRootExternal")),(Object)(RemoteObject.createImmutable("user.db")));Debug.locals.put("inUserData", _inuserdata)} BA.debugLineNum = 80;BA.debugLine="photo_copy_in.Text=inUserData.Get(0)";
What SHOULD happen is that if "user.db" doesn't exist, it creates a list, and writes that out to ???
If it DOES exist, it loads that database, and then reads the four values into strings / objects (tried both) and in the latter 4 lines loads it into EditText fields on a panel
I tried it with "DirInternal", but still stops at same line. I think it's 90% correct, just keeps fouling up with a syntax errror or something at >> These four variables are declared in Globals, and this is within Activity_Create within a FirstTime block (Report says it's missing a ";" ... but where's that coming from??
Shame, as I was going so well until this hit!!
Sorry to forum users. Just noticed there is an edit button on the original posting - presumably to add updates etc. I wil know to do that in future!
OK I ADMIT DEFEAT!!
Seems it's impossible to write back to a EditText field. Hope someone can advise whether this is simply because I need to upgrade from FREE to PAID, or whether such an action is impossible with B4A. (I've seen on StackOverflow an option called "SetText" ... but that's not on the freebie!)
Dim SavedUserData As String
Dim inUserData As List
Dim savedCopy As String ' Tried as string and as object
Dim savedTitle As Object
Dim savedKey As Object
Dim savedDesc As Object
SavedUserData = File.DirRootExternal & "user.db"
SavedUserData = File.DirRootExternal & "/user.db" 'Both options tried
If File.Exists(SavedUserData, "") = False Then
Dim userList As List
userList.Initialize
userList.AddAll(Array As String("Enter your copyright details","Enter your title","Enter your keywords","Enter your description"))
File.OpenOutput(File.DirRootExternal,"user.db",True) ' Append to list / create list
File.WriteList(File.DirRootExternal,"user.db",userList)
Else
File.OpenInput(File.DirRootExternal,"user.db")
inUserData.Initialize
inUserData=File.ReadList(File.DirRootExternal,"user.db") As List
>> photo_copy_in.Text=inUserData.Get(0)
title_in.Text=inUserData.Get(1)
key_in.Text=inUserData.Get(2)
desc_in.Text=inUserData.Get(3)
End If
LOG:
photo_copy_in.Text=inUserData.Get(0)
javac 1.7.0_76
shell\src\b4a\example\main_subs_0.java:83: error: ';' expected
_inuserdata = main.mostCurrent.__c.getField(false,"File").runMethod(false,"ReadList",(Object)(main.mostCurrent.__c.getField(false,"File").runMethod(true,"getDirRootExternal")),(Object)(RemoteObject.createImmutable("user.db")));Debug.locals.put("inUserData", _inuserdata)} BA.debugLineNum = 80;BA.debugLine="photo_copy_in.Text=inUserData.Get(0)";
What SHOULD happen is that if "user.db" doesn't exist, it creates a list, and writes that out to ???
If it DOES exist, it loads that database, and then reads the four values into strings / objects (tried both) and in the latter 4 lines loads it into EditText fields on a panel
I tried it with "DirInternal", but still stops at same line. I think it's 90% correct, just keeps fouling up with a syntax errror or something at >> These four variables are declared in Globals, and this is within Activity_Create within a FirstTime block (Report says it's missing a ";" ... but where's that coming from??
Shame, as I was going so well until this hit!!
Sorry to forum users. Just noticed there is an edit button on the original posting - presumably to add updates etc. I wil know to do that in future!
OK I ADMIT DEFEAT!!
Seems it's impossible to write back to a EditText field. Hope someone can advise whether this is simply because I need to upgrade from FREE to PAID, or whether such an action is impossible with B4A. (I've seen on StackOverflow an option called "SetText" ... but that's not on the freebie!)
Last edited: