Author Topic: write to a file  (Read 5549 times)

denhurk

  • Newbie
  • *
  • Posts: 5
write to a file
« on: January 05, 2013, 12:27:44 AM »
I tried to write some information to a textfile.
Like
Local n,fname,h1
Put 'testdata' into fname
OpenTWrite(fname,h1)
For n=1 to 10
WriteTLine(h1,n)
EndFor
CloseTWrite(h1)
but it does nothing.

who can help me?
I already created a testdata.txt file
Dave

Malkom

  • Administrator
  • Sr. Member
  • *****
  • Posts: 287
Re: write to a file
« Reply #1 on: January 05, 2013, 01:45:00 PM »
I tried to write some information to a textfile.
Like
Local n,fname,h1
Put 'testdata' into fname
OpenTWrite(fname,h1)
For n=1 to 10
WriteTLine(h1,n)
EndFor
CloseTWrite(h1)
but it does nothing.

who can help me?
I already created a testdata.txt file
Dave

Hi Dave

Here is some code for writing and reading text files - note that I changed your OpenTWrite command to OpenTWriteLoc which works with files in the apps local folder called Local. If you wanted full pathname (absolute) then use OpenTWrteAbs.

Code: [Select]
@ ---- Write to a file ---
Local n,fname,h1

Put 'testdata' into fname
OpenTWriteLoc(fname,h1)

For n=1 to 10
    WriteTLine(h1,n)
EndFor

CloseTWrite(h1)


Code: [Select]
@ --- read all lines from file - put if field 1 ---
Local n,fname,h1,done

Clear field 1

Put 'testdata' into fname
OpenTReadLoc(fname,h1)

Put EndTFileFN(h1) into done
while (done=0)
    ReadTLine(h1,n)
    Put n after field 1
    Put EndTFileFN(h1) into done
EndWhile

CloseTRead(h1)

With the file reading - not that the next line must be checked for using function EndTFileFN that returns 1 when end of file reached otherwise returns 0.

I hope this helps

Malkom



 
I am sorry but I do not have time to answer questions by PM or email.
If you post your questions in this forum then it might help others.

denhurk

  • Newbie
  • *
  • Posts: 5
Re: write to a file
« Reply #2 on: January 05, 2013, 03:15:17 PM »
Thanks  :)

denhurk

  • Newbie
  • *
  • Posts: 5
Re: write to a file
« Reply #3 on: January 07, 2013, 09:26:29 PM »
Is it also possible to use this to connect a file at a server (website)

Malkom

  • Administrator
  • Sr. Member
  • *****
  • Posts: 287
Re: write to a file
« Reply #4 on: January 07, 2013, 11:21:49 PM »
Is it also possible to use this to connect a file at a server (website)

To read a file from the web there is a UrlExistsFN function and an example project Stock Quote that reads a file (web page) and parses it.

This post gives some detail on fetching a web page

http://www.hypernextandroid.com/forum/index.php?topic=78.msg154#msg154

There is also some info on this in the Help pdf and HAC's built in help.

Malkom
I am sorry but I do not have time to answer questions by PM or email.
If you post your questions in this forum then it might help others.

denhurk

  • Newbie
  • *
  • Posts: 5
Re: write to a file
« Reply #5 on: January 08, 2013, 10:39:10 PM »

Hi Thanks,

I'm just trying and playing.
When try to build a *.apk  file I get an error in the log file (see partly this reply), Also when only a button is ceated.
Perhaps It's answer is already on the forum?

Dave





Hurk\AppData\Roaming\HAC_Data\data\HN_Runtime\bin\classes.dex"

Rebuild Data
THIS TOOL IS DEPRECATED. See --help for more information.



  DONE
PH_6 Android_SignAPK .....TYPE:---   debug.keystore
Debug Key
C:\Users\D vd Hurk\Documents\My Android  projects>cd ""
C:\Users\D vd Hurk\Documents\My Android  projects

C:\Users\D vd Hurk\Documents\My Android  projects>jarsigner -J-Duser.language=en -keystore "C:\Users\D vd Hurk\AppData\Roaming\HAC_Data\data\debug.keystore" "C:\Users\D vd Hurk\AppData\Roaming\HAC_Data\data\HN_Runtime\dist\Davetest.jfif.apk" androiddebugkey
jarsigner wordt niet herkend als een interne
of externe opdracht, programma of batchbestand.

Debug Data
 


 DONE
PH_7 Android_SignVerifyAPK .....-
C:\Users\D vd Hurk\Documents\My Android  projects>cd ""
C:\Users\D vd Hurk\Documents\My Android  projects

C:\Users\D vd Hurk\Documents\My Android  projects>jarsigner -J-Duser.language=en -verify  "C:\Users\D vd Hurk\AppData\Roaming\HAC_Data\data\HN_Runtime\dist\Davetest.jfif.apk"
jarsigner wordt niet herkend als een interne
of externe opdracht, programma of batchbestand.
-
shell jar verify failed

Malkom

  • Administrator
  • Sr. Member
  • *****
  • Posts: 287
Re: write to a file
« Reply #6 on: January 09, 2013, 08:37:54 AM »
Hi Dave

Thanks for the debug info.

It looks like there might be a problem with Java or the Android paths.
In this section of the debug info you posted the path to Java is empty:-

  DONE
PH_6 Android_SignAPK .....TYPE:---   debug.keystore
Debug Key
C:\Users\D vd Hurk\Documents\My Android  projects>cd ""
C:\Users\D vd Hurk\Documents\My Android  projects


We need to check that you have version 6.x of 32 bit Java installed and that your paths are correct.

The file paths can be examined from HAC using its Menu Android - Option Android Paths - and all the check boxes should be ticked green.

These posts might help:-

http://www.hypernextandroid.com/forum/index.php?topic=13.0

http://www.hypernextandroid.com/forum/index.php?topic=119.msg226#msg226


Malkom
I am sorry but I do not have time to answer questions by PM or email.
If you post your questions in this forum then it might help others.

denhurk

  • Newbie
  • *
  • Posts: 5
Re: write to a file
« Reply #7 on: January 14, 2013, 11:40:50 AM »
Hi Malkom,

I installed the program again full version and now it seemed to work.
I can create a apk file.

When trying to install it on a android phone or tablet I get the message programm not installed.
Is this because something is missed?

I did once a file from a member here and that was installed, but later I got a message again.

regards,
Dave

Malkom

  • Administrator
  • Sr. Member
  • *****
  • Posts: 287
Re: write to a file
« Reply #8 on: January 14, 2013, 03:06:10 PM »
Hi Malkom,

I installed the program again full version and now it seemed to work.
I can create a apk file.

When trying to install it on a android phone or tablet I get the message programm not installed.
Is this because something is missed?

I did once a file from a member here and that was installed, but later I got a message again.

regards,
Dave

Hi Dave

Thanks for the info on this.

Could you please post the full log of when you try to run it on your Android Device - clearing the log first will help.

Also - are you running the DDMS (debugger) ?  - this shows the response from the Android device.
If not, it can be run from the HAC's Go menu - option Debugger DDMS

Malkom
I am sorry but I do not have time to answer questions by PM or email.
If you post your questions in this forum then it might help others.