I'd like to be able to output some text to a file (a debug log
essentially). For some reason I am unable to on both my HTC One and my
Samsung Galaxy tablet. Could someone post a small and simple snippet of
code just so I can be sure I've understood the PDF manual correctly.
I think it should be:
open "O", #1, "testfile.txt"
print #1; "test string"
close #1
Thank-you for any help.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Seems I'm having the same problem. After many tries, and some permutations, I cannot find a data file on my phone. I also cannot apparently read back data that I supposedly wrote.
Here is an excerpt of my code dealing with this:
OPEN "O",#1,"spl.dat"
PRINT #1,"ABCD"
PRINT #1,"EFGH"
PRINT #1,"IJKL"
PRINT #1,"MNOP"
PRINT #1,"0"
CLOSE #1
PAUSE 1
'
x%=50
y%=1350
OPEN "I",#1,"spl.dat"
more:
INPUT #1,A$
IF A$="0"
goto done
ENDIF
text x%,y%,A$
Y%=Y%=50
goto more
'
done:
showpage
CLOSE #1
PAUSE 5
QUIT
So when I've tried this, nothing at all appears on the screen. Very possible that this code is bad since I've changed it many times, but no errors. Maybe my phone is incompatible, but just looking for a little help if possible. Thanks! Kevin
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
Anonymous
-
2019-02-03
The wrong line is the "Y%=X%=50", also Y%=1350 might well be outside of your screen, so you would not see any text.
Maybe better simply use a PRINT a$ to show what you have read from the file.
Have fun.
....Markus
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Both the test and the in-work DAT files showed up last night. I know I had had some problems, and had to shut down my phone and re-power... maybe that's an explanation, not sure. But nice to know that I now have access to the file from outside X-11. Thanks again!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I continue to have problems with my Android phone when attempting to output data to a file. The problems can be locking up, showing the internal storage to be empty, displaying apps not selected, etc. , and sometimes can take several restarts to correct. I've alluded to it in a previous post mentioning that I had to rest my phone. Tow questions if I may...1) and I don't think this would explain my test file results, but in outputting to a file, is it necessary that all records be the same length? And 2) aside from different phone and Android variations, and run-awy programs, are there any other considerations to take into account that might cause these typees of problems?
Thanks for anything you might be able to offer!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
Anonymous
-
2019-02-07
Well I am sorry, I do not know. I have not heard of this kind of problem so far. But ... who knows.
1) no, not necessary. Maybe you want to have a look into the quite huge sample program collection: https://gitlab.com/kollo/X11-Basic_examples/tree/master many of them use the file functions.
2) I do not know. I never faced these kind of problems with my devices (running rather old Android versions, however). Thats all I can tell.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Take a look at the stepdir.bas sample or my own take on it, which has yet to actually run to completion on my Android 5.1.1 phone. Newer Android versions could have gone even further down the everything-is-a-file philosophy rabbit hole and thus have even more hundreds of thousands of subdirectories in /proc, /dev, /sys, etc., so be patient, very patient.
ProgramFindFilesPattern$="*Scan*.PDF"PMFlags%=16AllDirs$()=["d /"]!Areyoureadyforadventure?Matches$()=["B0rk"]!Whatevercomesourway?DirCount%=1MatCount%=0CurDir%=0WhileCurDir%<DirCount%ClrP$,F$P$=AllDirs$(CurDir%)PrintCurDir%;" ";P$' Pause 0.1S%=InStr(P$," ")' Print "FindFirst '"; Mid$(P$, S% + 1, Len(P$) - S%); ; "'"ClrF$OnErrorGoSubMulligan!WegetoneMulliganperdirectoryF$=FSFirst$(Mid$(P$,S%+1,Len(P$)-S%),"*","dfa")IfLen(F$)=0Then!No-opElseIfLeft$(P$,2)="d "Then!No-opElseIfLeft$(P$,2)="s "Then!No-opElsePrint"Weird dir ";P$;" contains files like ";F$Pause5EndIf' Discard the path's "d " or "s " prefixP$=Mid$(P$,S%+1,Len(P$)-S%)WhileLen(F$)S%=InStr(F$," ")F$=Left$(F$,S%)+P$+Mid$(F$,S%+1,Len(F$)-S%)' Print F$!Pause0.1IfGlob(F$,Pattern$,PMFlags%)ThenDimMatches$(MatCount%+1)Matches$(MatCount%)=F$IncMatCount%Print"Match ";MatCount%;" found ";F$Pause5EndIfIf(Left$(F$,2)="d ")Or(Left$(F$,2)="s ")Then' Directory, or symbolic link to maybe a directory?' Could following symlinks cause an infinite loop? How to detect?IfDirCount%=UBound(AllDirs$())ThenPrint"REDIM PRESERVE AllDirs$(";DirCount%+(DirCount%Div4)+8;")"DimAllDirs$(DirCount%+(DirCount%Div4)+8)EndIfAllDirs$(DirCount%)=F$+"/"IncDirCount%ElseIfLeft$(F$,2)="- "Then' Ordinary file!No-opElse' We found something new!DimMatches$(MatCount%+1)Matches$(MatCount%)=F$IncMatCount%Print"Weird ";MatCount%;" found ";F$Pause5EndIfClrF$' Is our Mulligan above still installed?F$=FSNext$()WendIncCurDir%WendPrintDirCount%,MatCount%Fori%=0To(MatCount%-1)PrintMatches$(i%)Nexti%Print"OK"EndProcedureMulligan()E%=ErrPrint"B0rkage ";E%;" ";Err$(E%)SelectE%Case-13!Permissiondenied!No-opCase-33!Filenotfound(symlinktomissingfile/dir?)!No-opCase-20!Notadirectory(symlinktoordinaryfile?)!No-opDefaultStopEndSelect' Pause 0.5' Resume NextReturn
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
FOR THE LOVE OF GOD DO NOT FOLLOW SYMLINKS IN A FILESYSTEM WALKER!!1!
This version actually halts eventually.
ProgramDirWalkOnTheWildSide' Can match all symbolic links with "s *" etc.Pattern$="*Basic*.PDF"PMFlags%=16AllDirs$()=["d /"]!LookingforadventureMatches$()=["B0rk"]!InwhatevercomesourwayDirCount%=1MatCount%=0CurDir%=0WhileCurDir%<DirCount%ClrP$,F$P$=AllDirs$(CurDir%)PrintCurDir%,"'";P$;"'"' Pause 0.1S%=InStr(P$," ")' Print "FindFirst '"; Mid$(P$, S% + 1, Len(P$) - S%); ; "'"ClrF$OnErrorGoSubMulligan!WegetoneMulliganperdirectoryF$=FSFirst$(Mid$(P$,S%+1,Len(P$)-S%),"*","dfa")IfLen(F$)=0Then!No-opElseIfLeft$(P$,2)="d "Then!No-opElseIfLeft$(P$,2)="s "Then!No-opElsePrint"Weird dir '";P$;"' contains files like '";F$;"'"Pause5EndIf' Discard the path's "d " or "s " prefixP$=Mid$(P$,S%+1,Len(P$)-S%)WhileLen(F$)S%=InStr(F$," ")F$=Left$(F$,S%)+P$+Mid$(F$,S%+1,Len(F$)-S%)' Print "'"; F$; "'"' Pause 0.1IfGlob(F$,Pattern$,PMFlags%)ThenDimMatches$(MatCount%+1)Matches$(MatCount%)=F$IncMatCount%Print"Match ";MatCount%;" found '";F$;"'"' Pause 5EndIfIf(Left$(F$,2)="d ")!Or(Left$(F$,2)="s ")Then' Directory, or symbolic link to maybe a directory?' Could following symlinks cause an infinite loop? How to detect?IfDirCount%=UBound(AllDirs$())Then' Hundreds of thousands of subdirectories!!!1!Print"REDIM PRESERVE AllDirs$(";DirCount%+(DirCount%Div8)+4;")"DimAllDirs$(DirCount%+(DirCount%Div8)+4)EndIfAllDirs$(DirCount%)=F$+"/"IncDirCount%ElseIf(Left$(F$,2)="- ")Or(Left$(F$,2)="s ")Then' Ordinary file (or symlink into who knows where)!No-opElse' We found something new!DimMatches$(MatCount%+1)Matches$(MatCount%)=F$IncMatCount%Print"Weird ";MatCount%;'" found "; F$; "'"Pause5EndIfClrF$' If we get here, our Mulligan above should still be installedF$=FSNext$()WendIncCurDir%WendPrintUBound(AllDirs$()),DirCount%,MatCount%Fori%=0To(MatCount%-1)!Needsparensorit's a syntax errorPrinti%,"'";Matches$(i%);"'"Nexti%PrintMatCount%;" match(es) found."Print"OK"EndProcedureMulligan()E%=ErrPrint"B0rkage ";E%;" ";Err$(E%)SelectE%Case-13!Permissiondenied!No-opCase-33!Filenotfound(symlinktomissingfile/dir?)!No-opCase-20!Notadirectory(symlinktoordinaryfile?)!No-opDefaultStopEndSelect' Pause 0.5' Resume NextReturn
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'd like to be able to output some text to a file (a debug log
essentially). For some reason I am unable to on both my HTC One and my
Samsung Galaxy tablet. Could someone post a small and simple snippet of
code just so I can be sure I've understood the PDF manual correctly.
I think it should be:
open "O", #1, "testfile.txt"
print #1; "test string"
close #1
Thank-you for any help.
Exactly that should do it. You should be able to read that file later again with
open "I",#1,"testfile.txt"
LINEINPUT #1,t$
print t$
close #1
Seems I'm having the same problem. After many tries, and some permutations, I cannot find a data file on my phone. I also cannot apparently read back data that I supposedly wrote.
Here is an excerpt of my code dealing with this:
OPEN "O",#1,"spl.dat"
PRINT #1,"ABCD"
PRINT #1,"EFGH"
PRINT #1,"IJKL"
PRINT #1,"MNOP"
PRINT #1,"0"
CLOSE #1
PAUSE 1
'
x%=50
y%=1350
OPEN "I",#1,"spl.dat"
more:
INPUT #1,A$
IF A$="0"
goto done
ENDIF
text x%,y%,A$
Y%=Y%=50
goto more
'
done:
showpage
CLOSE #1
PAUSE 5
QUIT
So when I've tried this, nothing at all appears on the screen. Very possible that this code is bad since I've changed it many times, but no errors. Maybe my phone is incompatible, but just looking for a little help if possible. Thanks! Kevin
The wrong line is the "Y%=X%=50", also Y%=1350 might well be outside of your screen, so you would not see any text.
Maybe better simply use a PRINT a$ to show what you have read from the file.
Have fun.
....Markus
Good catches! Thanks much! The test file now works, but I still cannot find that file on my phone, but it must be there somewhere.
Well,
PRINT DIR$(0) should print you the current working directory.
Thats where the files go.
Both the test and the in-work DAT files showed up last night. I know I had had some problems, and had to shut down my phone and re-power... maybe that's an explanation, not sure. But nice to know that I now have access to the file from outside X-11. Thanks again!
I continue to have problems with my Android phone when attempting to output data to a file. The problems can be locking up, showing the internal storage to be empty, displaying apps not selected, etc. , and sometimes can take several restarts to correct. I've alluded to it in a previous post mentioning that I had to rest my phone. Tow questions if I may...1) and I don't think this would explain my test file results, but in outputting to a file, is it necessary that all records be the same length? And 2) aside from different phone and Android variations, and run-awy programs, are there any other considerations to take into account that might cause these typees of problems?
Thanks for anything you might be able to offer!
Well I am sorry, I do not know. I have not heard of this kind of problem so far. But ... who knows.
1) no, not necessary. Maybe you want to have a look into the quite huge sample program collection: https://gitlab.com/kollo/X11-Basic_examples/tree/master many of them use the file functions.
2) I do not know. I never faced these kind of problems with my devices (running rather old Android versions, however). Thats all I can tell.
Thought I'd correct a couple of typos and provide the snippet of code that is causing my problems.
Typo #1: "I had to rest my phone" = I had to restart my phone.
Typo #2: "Tow questions if I may" = Two questions if I may
Here is the code segment:
button_wait:
MOUSEEVENT locx%
locx%=mousex
locy%=mousey
'check each box
FOR x%=1 to nbtns%
gosub checkbox(bx%(x%),by%(x%),bx%(x%)+100,by%(x%)+50)
IF inbox%=1
pause .2
a$=TIME$
d$=DATE$
hr$=LEFT$(a$,2)
mn$=MID$(a$,4,2)
a$=hr$+":"+mn$
text bx%(x%)+10,by%(x%)+95,a$
showpage
'
mo$=MID$(d$,4,2)
day$=LEFT$(d$,2)
'
OPEN "A",#2,"spl.log"
'log date, time, reason
PRINT #2, mo$+"/"+day$+" "+a$+" "+label$(x%)
CLOSE #2
ENDIF
NEXT x%
This actually seems to work ok except for the problems it causes my phone.
Thanks again for your input! -K
15 days seems a long time to wait for a response, although I'm not complaining.
Hope all is OK with Markus.-Kevin
sorry, I forgot to log in. My post was anonymous.
Take a look at the stepdir.bas sample or my own take on it, which has yet to actually run to completion on my Android 5.1.1 phone. Newer Android versions could have gone even further down the everything-is-a-file philosophy rabbit hole and thus have even more hundreds of thousands of subdirectories in /proc, /dev, /sys, etc., so be patient, very patient.
FOR THE LOVE OF GOD DO NOT FOLLOW SYMLINKS IN A FILESYSTEM WALKER!!1!
This version actually halts eventually.