file open question

scott93727

Member
Licensed User
With the below code why does the file contents like fine in the explorer (date) only but show a large number when viewed the code way ?

Sub Globals
'Declare the global variables here.
regdt=Date(Now)
End Sub
Sub App_Start
Form1.Show
reg
End Sub
Sub reg
ErrorLabel(Err1)
If FileExist ("c:\windows\colorbn.txt") = true Then
FileOpen (c1,"c:\windows\colorbn.txt",cRead)
r = FileRead (c1)
Do Until r = EOF
sum = sum + r
r = FileRead (c1)
Loop
textbox1.Text=sum
FileClose (c1)
Else
regdt=Date(Now)
FileOpen (c1,"c:\windows\colorbn.txt",cWrite)
FileWrite (c1,regdt)
FileClose (c1)
End If
Goto sbed
err1:
Msgbox("Error")
sbed:
End Sub
 

klaus

Expert
Licensed User
You should replace your code by this one.

B4X:
Sub Globals
' Declare the global variables here.
  regdt=Date(Now)
End Sub

Sub App_Start
  Form1.Show
  reg
End Sub

Sub reg
  ErrorLabel(Err1)
  If FileExist ("c:\windows\colorbn.txt") = true Then 
    FileOpen (c1,"c:\windows\colorbn.txt",cRead) 
    r = FileRead (c1) 
    FileClose (c1) 
    textbox1.Text=r 
  Else 
    regdt=Date(Now)
    FileOpen (c1,"c:\windows\colorbn.txt",cWrite) 
    FileWrite (c1,regdt) 
    FileClose (c1)
  End If
  Return
err1:
  Msgbox("Error")
End Sub
I don't understand why you dit the sum ?

Best regards.
 

scott93727

Member
Licensed User
another question

any idea why I getting an error on this code and how to complete it, thanks !!!

Sub Globals
'Declare the global variables here.
regdt=Date(Now)
rc=0
End Sub
Sub App_Start
Form1.Show
reg
End Sub
Sub reg
Dim regexp
ErrorLabel(Err1)
If FileExist ("c:\windows\clrbn.txt") = true Then
FileOpen (c1,"c:\windows\clrbn.txt",cRead)
r = FileRead (c1)
FileClose (c1)
Else
regdt=Date(Now)
FileOpen (c1,"c:\windows\clrbn.txt",cWrite)
FileWrite (c1,regdt)
FileClose (c1)
End If
textbox1.Text=r ' Displays Registration Date
textbox3.text=Date(Now) ' Displays Today Date
rd=DateAdd(r, 0, 1, 0)'sets reg duration (Ticks, Years, Months, Days)for one month
textbox2.text=rd ' Displays Registration Expires Date
dn=Date(Now)
If dn > rd Msgbox("Registration Expired, Contact Support for Registered Version, Contact scott93727@aol.com"):rc=1 ' if date now later then regdate by 1 month
Goto sed
err1:
Msgbox("Registration Error, Contact Support, scott93727@aol.com")
sed:
'if rc=1 then (Control code (what to disable after reg. expires))
End Sub
 

agraham

Expert
Licensed User
You have posted this question in a separate thread. In the politest possible way (not easy for me I know :) ) could I point out that cross-posting is considered bad form in most forums/newgroups.

P.S. Your answer is in the other thread ;)
 
Top