Author Topic: Update files to a program made in HN 4  (Read 12141 times)

minius

  • Newbie
  • *
  • Posts: 11
Update files to a program made in HN 4
« on: September 20, 2016, 07:10:47 PM »
Hi guys! I have a quick question. I made a program for a customer using HN 4 and I will most probably need to update the program with new features or bug fixes. Is it possible to send just some files containing the changes while keeping the generated data with the softer on the customer's PC? What files I need to send to my customer to have the new program (the upgrade) without losing existing information stored in variables and local files made by the program?
The program is working under Window.
Thanks!

Malkom

  • Administrator
  • Newbie
  • *****
  • Posts: 464
  • Here to help you
Re: Update files to a program made in HN 4
« Reply #1 on: September 21, 2016, 06:55:49 AM »
Hi Minius

Not sure I understand you fully. It looks like you could just send them the generated code file that contains your new scripts with bug fixes and new variables. It would replace their script file and its variables. However, if they have data that must not be overwritten then it would have to be in a  separate file.

An example using the Chart demo project.
After being built for Windows it would have the following files in its project folder:-

Chart
   Data (folder)
   Chart.exe
   Chart.prj       
   stand.app       ---- send this to customer

Note, the Data folder only needs sending if you specifically saved any Local data files in there with the CreateTWrite or other file commands.

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.

Malkom

  • Administrator
  • Newbie
  • *****
  • Posts: 464
  • Here to help you
Re: Update files to a program made in HN 4
« Reply #2 on: October 04, 2016, 07:22:24 AM »
Hi Minius

Thank you for the update on this and for reminding me that you have to send the .exe file if you want to let the customer know the version number etc has changed in the updated app's About Box or Splash Screen.

About the customer fields losing data by reverting to what is in the updated app you send them. Here are some scripts so that their field data is saved when their app quits and restored when it loads again.

Here are two scripts called FieldSave and FieldLoad. They assume the customer field data is stored in a local binary file called FieldData. The FieldData file are whatever you call it will be created once your customer runs and quits their app for the first time. A binary file is used in case the fields have multiple lines of text. In my example Card 1 has 3 fields and Card 2 has 2 fields.

Note there aren't yet any functions so you know the number of fields in advance - this will be in the next update to HN.


How To Use:-

(1) Place both the FieldSave and FieldLoad procedures in the MainCode section.

(2) Using the Menu Designer place the following call to FieldSave in the script of the File Quit option

(3) In the MainCode section - Startup - place a call to FieldLoad
 

FieldSave
Code: [Select]
Local fname,fvar,fdets,ftypes,fpaths,fnames,fextens
Local findex,txt

@+++ Open or Create Binary File +++
Put 'FieldData' into fname
FileGet(fname,fvar,fdets,ftypes,fpaths,fnames,fextens)
CreateBFile(fvar,findex)

@ ++ Card 1 ++
Put FieldCardFN(1,1) into txt
WriteBVariable(findex,txt)

Put FieldCardFN(1,2) into txt
WriteBVariable(findex,txt)

Put FieldCardFN(1,3) into txt
WriteBVariable(findex,txt)


@ ++ Card 2 ++
Put FieldCardFN(2,1) into txt
WriteBVariable(findex,txt)

Put FieldCardFN(2,2) into txt
WriteBVariable(findex,txt)


@ +++ Close file +++
CloseBFile(findex) 


FieldLoad
Code: [Select]
Local fname,fvar,fdets,ftypes,fpaths,fnames,fextens
Local findex,txt

@+++ Open or Create Binary File +++
Put 'FieldData' into fname
FileGet(fname,fvar,fdets,ftypes,fpaths,fnames,fextens)
OpenAsBFile(fvar,findex)


@ ++  Card 1 +++
ReadBVariable(findex,txt)
FieldCardSet(1,1,txt)

ReadBVariable(findex,txt)
FieldCardSet(1,2,txt)

ReadBVariable(findex,txt)
FieldCardSet(1,3,txt)


@ ++  Card 2 +++
ReadBVariable(findex,txt)
FieldCardSet(2,1,txt)

ReadBVariable(findex,txt)
FieldCardSet(2,2,txt)



@+++ Close File
CloseBFile(findex)


MenuDesigner - Field - Quit script
Code: [Select]
Call FieldSave
Quit


MainCode - Startup
Code: [Select]
Call FieldLoad
The binary files are explained in the Language Reference PDF and 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.

minius

  • Newbie
  • *
  • Posts: 11
Re: Update files to a program made in HN 4
« Reply #3 on: October 04, 2016, 08:25:04 AM »
Thank you Malkom for the solution. What can I do to fill in a listbox with saved information. Is there a simple way to read a file and use the ListboxFill command? I use listboxes to store information that I can look-up by address (raw and column) similar to a database (but I easier, i think).

Malkom

  • Administrator
  • Newbie
  • *****
  • Posts: 464
  • Here to help you
Re: Update files to a program made in HN 4
« Reply #4 on: October 04, 2016, 02:23:43 PM »
Sorry Minius but unfortunately there isn't a simple way to save all the Lists like we did with the fields. HyperNext doesn't have that global command for lists - it is still on the to-do-list :(

You could save each List's contents from a card to a file with something like the following code. However,  it would mean ensuring the saves are done after a card closes and before the next one opens plus have the SaveList routine called when the app Quits. Also must consider what to do if you add more listboxes to the app because the customers listbox data is on their machine.

Code: [Select]
@ --- for listbox 1 ---
Local nrows,ncols,r,c,txt

Put ListboxRowsFN(1) into nrows
Put ListboxColumnsFN(1) into ncols

for r=1 to nrows
   for c=1 to ncols
      Put ListboxCellValueFN(1,r,c) into txt
      WriteBVariable(findex,txt)
   endfor
endfor


Your idea of using a database would make saving/loading much easier as it could be done from the MainCode Startup section but the disadvantage is that each card with a listbox would have to read/write to the database.

If I had to implement this so customers could easily have their code updated then I would probably use HyperNext's SQLite database. You could also implement your own database using lists or arrays and save it in a binary file.

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.

 

anything