Hot Topic (More than 10 Replies) Wordmerge in Linux (Read 2738 times)
Kris
Member
*
Offline



Posts: 9
Joined: Apr 25th, 2007
Wordmerge in Linux
Apr 25th, 2007 at 9:02am
Print Post Print Post  
Hi,

While converting from Windows to Linux, I discovered a problem with the wordmerge button I had installed in a database.
It merges the result from a specific record with a ms word file that contains certain fields from the record.

I tried to change the script but I keep having an error. I suppose it has something to do with the path reference I use. For now I have:

var vDataPath as String = "/home/Krisla/Desktop/Sesame/Docs/customer.txt"
var vDocsPath as String = "/home/Krisla/Desktop/Docs
var vWordPath as String = "/home/Krisla/Desktop/word.sh"
var vListPath as String = "/home/Krisla/Desktop/Sesame/Docs/list.txt"

But I think it has to be something else. Does anyone know a way out?

Thanks!

Kris
  
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Wordmerge in Linux
Reply #1 - Apr 25th, 2007 at 12:03pm
Print Post Print Post  
Hi Kris,

What error do you get?

If the error occurs when you run Test Program in Sesame, it may be the missing quote mark at the end of the second line:
var vDocsPath as String = "/home/Krisla/Desktop/Docs"
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Kris
Member
*
Offline



Posts: 9
Joined: Apr 25th, 2007
Re: Wordmerge in Linux
Reply #2 - Apr 25th, 2007 at 12:16pm
Print Post Print Post  
OK, I feel a bit stupid I did not see that.

The error is gone, but now I have another problem. When I'm using Sesame and I try to merge a document, after I selct "This record only" nothing happens anymore. Any ideas why this could happen?
  
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Wordmerge in Linux
Reply #3 - Apr 25th, 2007 at 12:22pm
Print Post Print Post  
Don't feel stupid! I can't type three lines of code without making eight syntax errors. That's what Test Program is for.   Wink

Can you post the contents of word.sh?

Also, WordMerge has been through several versions. Could you post your code so we have a point of reference?
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Kris
Member
*
Offline



Posts: 9
Joined: Apr 25th, 2007
Re: Wordmerge in Linux
Reply #4 - Apr 25th, 2007 at 12:29pm
Print Post Print Post  
Thanks.

I got a bit further. In the preview application I get every step to merge a document, but when normally openoffice writer should open, nothing happens.

This is the content of my word.sh:

/usr/share/applications
oowriter
Exit

This is the code of the Wordmerge I use:

var vFileHandle as Int          // For writing data file
var vHeader as String           // Data file header line
var vData as String             // Data file data line
var n as Int = 1            // General purpose counter
var vSelectedDoc as String      // Document selected from menu
var vOneOrAll as String         // Include record(s) option
var F as array[81] of String    // Mergeable fields array
var vStartingRec = @ResultSetCurrentPosition()
var vGoPrint as String

/* This program differs slightly from the one in
   Appendix 2 of the Sesame Programming Guide.
   This one gets its list of available merge documents
   from an external text file (list.txt) instead of the
   document names being hard-coded into the program.
   One may then create any number of merge documents,
   and simply edit the list.txt file (with Notepad) to
   correspond to the available merge documents */

// Next 4 lines user modifiable
var vDataPath as String = "/home/Krisla/Desktop/Sesame/Docs/customer.txt"
var vDocsPath as String = "/home/Krisla/Desktop/Sesame/Docs/"
var vWordPath as String = "/home/Krisla/Desktop/Sesame/word.sh"
var vListPath as String = "/home/Krisla/Desktop/Sesame/Docs/list.txt"

SUBROUTINE PrintCurrentRecordOnly()

If @Askuser("Merge print the " + vSelectedDoc + " for "
+ vOneOrAll + "?","","") Then
{

vGoPrint = "Yes"

n = 1                  
While F[n] <> ""
{
     vHeader = vHeader + F[n]   + "^"
     vData   = vData   + @(F[n]) + "^"
     n = n + 1
}

vFileHandle = fileOpen(vDataPath)
fileSeek(vFileHandle, 0)
fileWriteLn(vFileHandle, vHeader + @NewLine() + vData)
fileClose(vFileHandle)

}

END SUBROUTINE

SUBROUTINE PrintAllRetrievedRecords()

var n as Int
var i as Int = 1

If @Askuser("Merge Print " + vSelectedDoc + " for these " + @ResultSetTotal() + " retrieved records?",
"( If not, cancel this task, press F7 for a new search,"," and retrieve the records DO you want to print. )")
Then
{

     vGoPrint = "Yes"

     n = 1                  
     While F[n] <> ""
           {
           vHeader = vHeader + F[n]   + "^"
           n = n + 1
           }

     vFileHandle = fileOpen(vDataPath)
     fileSeek(vFileHandle, 0)
     fileWriteLn(vFileHandle, vHeader)

     For n = 1 to @ResultSetTotal()

     ResultSetCurrentPosition(n)

     While F[i] <> ""
           {
           vData = vData + @(F[i]) + "^"
           i = i + 1
           }

     FileWriteLn(vFileHandle, vData)

     @Msg("Processed Record " + n + " of " + @ResultSetTotal())
     vData = ""
     i = 1

     Next

     fileClose(vFileHandle)

     // Rewind to record where it all started
     ResultSetCurrentPosition(vStartingRec)

     }

END SUBROUTINE


// BEGIN MAIN PROGRAM

// Build documents menu

vSelectedDoc = @PopupMenu(
@insert(vListPath), "SELECT MERGE DOCUMENT" )

// Build which record(s) menu

vOneOrAll = @PopupMenu(
"THIS Record Only;" +
"ALL Retrieved Records;" , "SELECT RECORD(S) TO MERGE PRINT" )

If vSelectedDoc <> "" and vOneOrAll <> "" Then
{      

     // Delete exsting data file. New one will be generated.
     If FileExists(vDocsPath + vSelectedDoc) Then
     {
     fileDelete(vDataPath)      

     // Fields available for merging
     F[1] = "Nummer";
       F[2] = "Numm.advokaat";
       F[3] = "zie notas";
     F[4] = "W.K.";
       F[5] = "Lid KVG";
       F[6] = "Mutualiteit";
     F[7] = "Naam";
       F[8] = "Voornaam";
       F[9] = "Voor";
     F[10]= "Verhoging door herziening";
       F[11]= "Adres";
       F[12]= "Nr";
     F[13]= "Postnummer";
       F[14]= "Gemeente";
       F[15]= "Tel.";
       F[16]= "70";
       F[17]= "2de rolnummer";
     F[18]= "naam vertegenwoordig(st)er";
     F[19]= "beroep t/attest";
     F[20]= "adm.beroep/adm.beroep";
     F[21]= "betreft";
     F[22]= "tegen beslissing";
     F[23]= "te verdedigen";
     F[24]= "medisch b. op besliss.min.";
     F[25]= "onderz.";
     F[26]= "rolnummer";
     F[27]= "advokaat";
     F[28]= "inleiding";
     F[29]= "verdaagd";
     F[30]= "bijzondere rol";
     F[31]= "doorhaling";
     F[32]= "voorkeuze begeleidende arts";
     F[33]= "aangestelde deskundige; - dr.1";
     F[34]= "- dr.2";
     F[35]= "- dr.3";
     F[36]= "andere discipline";
     F[37]= "discipline";
     F[38]= "datum deskundig onderzoek";
     F[39]= "inhoud voorlopig verslag";
     F[40]= "verslag aan client j/n";
     F[41]= "uitstel gevraagd";
     F[42]= "bemerkingen";
     F[43]= "datum bemerkingen";
     F[44]= "inhoud definitief verslag";
     F[45]= "110";
     F[46]= "tweede eis";
     F[47]= "eindzitting";
     F[48]= "datum eindvonnis";
     F[49]= "inhoud eindvonnis";
     F[50]= "advies advocaat h.beroep";
     F[51]= "start 2000";
     F[52]= "brief zaak afgehandeld";
     F[53]= "brief dossier op bureel";
     F[54]= "dossier meegenomen";
     F[55]= "auditoraat nr.";
     F[56]= "notas";
     F[57]= "huisdokter";
     F[58]= "ikvt";
     F[59]= "it";
     F[60]= "haanb";
     F[61]= "mw";
     F[62]= "numm.ministerie";
     F[63]= "numm.riziv";
     F[64]= "verblijf adres";
     F[65]= "naam contact adres";
     F[66]= "verzaking aanvraag";
     F[67]= "zaak beroepscommissie";
     F[68]= "gift j/n";
     F[69]= "b.numm.";
     F[70]= "ref. compensatiekas";
     F[71]= "lid numm. C.M.";
     F[72]= "verklaring client";
     F[73]= "1";
     F[74]= "150";
     F[75]= "2";
     F[76]= "geboortedatum";
     F[77]= "geboortepl.";
     F[78]= "3";
     F[79]= "rijksregister nr.";
     F[80]= "terug voorkomen";


     If vOneOrAll = "THIS Record Only" Then
           PrintCurrentRecordOnly()
     Else
           PrintAllRetrievedRecords()

     If vGoPrint = "Yes" Then
     {
           // Start Word via Word.bat and pass doc filename.            
           n = @Shell(vWordPath + " " + @Chr(34) + vDocsPath + vselectedDoc + @Chr(34))
           If n = 1 Then
           @MSgbox(vDocsPath + vSelectedDoc,"word.bat not found or something else wrong.","")
     }
     }
     Else
           @Msgbox(vDocsPath + vSelectedDoc + " doesn't exist.","","Aw shucks!")
}

  
Back to top
 
IP Logged
 
Kris
Member
*
Offline



Posts: 9
Joined: Apr 25th, 2007
Re: Wordmerge in Linux
Reply #5 - Apr 25th, 2007 at 12:32pm
Print Post Print Post  
I keep making progress: after merging a record, openoffice writer opens, but with a blank page instead of the document I wanted to merge the record with. I guess it has something to do with the syntax in word.sh
  
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Wordmerge in Linux
Reply #6 - Apr 25th, 2007 at 12:43pm
Print Post Print Post  
Kris,

If oowriter is in your path, you shouldn't need anything in word.sh except:

oowriter $1

If it isn't in your path, then you need the full path to it. For example:

/usr/bin/oowriter $1

The $1 picks up the name of the document you want to open so Open Office knows what doc you want.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Kris
Member
*
Offline



Posts: 9
Joined: Apr 25th, 2007
Re: Wordmerge in Linux
Reply #7 - Apr 25th, 2007 at 12:53pm
Print Post Print Post  
Thank you so much. At this point I get the openoffice document I want. Now I only have to try to set up the merge fields in openoffice
  
Back to top
 
IP Logged
 
Kris
Member
*
Offline



Posts: 9
Joined: Apr 25th, 2007
Re: Wordmerge in Linux
Reply #8 - Apr 25th, 2007 at 1:06pm
Print Post Print Post  
And here is my next problem. Is there a way to connect fields in openoffice to a text document (in this case customer.txt) where the fields are separated by a "^"?
  
Back to top
 
IP Logged
 
Ben
Lantica Support
*****
Offline



Posts: 218
Joined: Apr 7th, 2005
Re: Wordmerge in Linux
Reply #9 - Apr 25th, 2007 at 1:42pm
Print Post Print Post  
Kris wrote on Apr 25th, 2007 at 1:06pm:
And here is my next problem. Is there a way to connect fields in openoffice to a text document (in this case customer.txt) where the fields are separated by a "^"?


Hello Kris,
In Open Office Writer it is possible to specify how your text file is formatted. You should receive an email shortly that contains step by step instructions for setting up a merge document in Open Office.

-Ben
  
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Wordmerge in Linux
Reply #10 - Apr 25th, 2007 at 2:13pm
Print Post Print Post  
Quote:
You should receive an email shortly that contains step by step instructions for setting up a merge document in Open Office.


I'll also add these instructions to the Sesame Library when I get a minute.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Kris
Member
*
Offline



Posts: 9
Joined: Apr 25th, 2007
Re: Wordmerge in Linux
Reply #11 - Apr 25th, 2007 at 6:09pm
Print Post Print Post  
Thank you! Your excellent guide brought me a huge step closer, although I still have a (minor) question.

I can use the .txt file as a data source and I can insert fields from it in the writer document. Then I save it, with the fields in it, and I close it. When I try to merge another record I notice the fields are no longer active and I have to insert them again manually. Is there a way to save my document so that I only have to make it up once (I hope you understand what I mean, because english is not my mother language)?

Thanks in advance!
  
Back to top
 
IP Logged
 
Ben
Lantica Support
*****
Offline



Posts: 218
Joined: Apr 7th, 2005
Re: Wordmerge in Linux
Reply #12 - Apr 25th, 2007 at 6:29pm
Print Post Print Post  
Kris wrote on Apr 25th, 2007 at 6:09pm:
I can use the .txt file as a data source and I can insert fields from it in the writer document. Then I save it, with the fields in it, and I close it. When I try to merge another record I notice the fields are no longer active and I have to insert them again manually?

Thanks in advance!


Kris,
When you saved the writer document that you added the fields to, did you save over the existing file or did you save it as a new document. If you saved the changed document as a new file, you will need to point Sesame at that version of the document.
-Ben


  
Back to top
IP Logged
 
Kris
Member
*
Offline



Posts: 9
Joined: Apr 25th, 2007
Re: Wordmerge in Linux
Reply #13 - Apr 25th, 2007 at 6:33pm
Print Post Print Post  
No, I saved it over the existing file.
  
Back to top
 
IP Logged
 
Kris
Member
*
Offline



Posts: 9
Joined: Apr 25th, 2007
Re: Wordmerge in Linux
Reply #14 - Apr 25th, 2007 at 6:38pm
Print Post Print Post  
Problem solved!

If you save the document as a MS Word document, the fields disappear. If you save the file as an .odt they stay where they should stay.

I'm gonnan test it some more, but I think for the moment I have what I want: merging records from Sesame with Openoffice.

Hammer and Ben, thank you very much for your invaluable help !!
  
Back to top
 
IP Logged