LibraryExport() for long script

I used LibraryExport() to export a Window object in PB5.
But the object is too large that it can only export partially.

How can I fix the problem if I want to use  script instead of the Export Painter
to export objects?
xo123Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

namasi_navaretnamCommented:
Are you using PB 5.0 16 bit? Migrate to 32bit PB 5.0 then LibraryExport will work for string length greater than 64K.

16 bit string datatype can only hold 64K.
0
namasi_navaretnamCommented:
Btw, this is not PB limitation, but OS limitation.
0
xo123Author Commented:
I think I'm using 32bit.
This is the info from 'About'
    PowerBuilder Enterprise/32
           by Powersoft
       Version 5.0.04
  Copyright c 1991 - 1997 Sybase, Inc.
       and its subsidiaries.
.....
0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

namasi_navaretnamCommented:
Does the string gets truncated when you run the app thru development environment as well? What operating system you are using?

0
xo123Author Commented:
For any objects longer than 32 KB,
the libaryexport() can only export them to 32 KB long.
But if I used the Library painter's Export option, it can export successfully without loss.

Here's my coding:
   ....
   String  ls_objsyn
   ls_objsyn = LibraryExport( lib_path,  obj_name, DirWindow! )
   ....

0
xo123Author Commented:
I'm using Window 2000 Professional.
0
xo123Author Commented:
Oh.... I just discover one thing:
  FileWrite can write only 32,766 bytes at a time, which includes the string   terminator character. If the length of variable exceeds 32,765, FileWrite writes the first 32,765 characters and returns 32,765.

I'm using FileWrite() for writing the export script.

What can I do?
0
xo123Author Commented:
I'll try to partition the export script (ls_objsyn) and write each partition at a time.
0
namasi_navaretnamCommented:
OK. Using filewrite you can only write 32k at a time. Try PFCs of_FileWrite. I think of_filewrite can handle more than 32K.
0
namasi_navaretnamCommented:
Here is the PFCs FileWrite

//////////////////////////////////////////////////////////////////////////////
//
//      Function:  of_FileWrite
//
//      Access:  public
//
//      Arguments:
//      as_FileName                        The name of the file to write to.
//      as_Text                                    The text to be written to the file.
//      ab_Append                        True - append to the end of the file,
//                                                      False - overwrite the existing file.
//
//      Returns:            Integer
//                              1 if successful, -1 if an error occurrs.
//
//      Description:      Open, write to, and close a file.  Handles strings > 32,765 bytes.
//
//////////////////////////////////////////////////////////////////////////////
//
//      Revision History
//
//      Version
//      5.0   Initial version
//      6.0.01      Rewrite to handle strings > 60k making more than 2 passes (for 32 bit platforms)
//
//////////////////////////////////////////////////////////////////////////////
//
//      Copyright © 1996-1997 Sybase, Inc. and its subsidiaries.  All rights reserved.
//      Any distribution of the PowerBuilder Foundation Classes (PFC)
//      source code by other than Sybase, Inc. and its subsidiaries is prohibited.
//
//////////////////////////////////////////////////////////////////////////////

Integer            li_FileNo, li_writes, li_cnt
Long                  ll_StrLen, ll_currentpos
String            ls_Text
Writemode      lwm_Mode

If ab_Append Then
      lwm_Mode = Append!
Else
      lwm_Mode = Replace!
End if

li_FileNo = FileOpen(as_FileName, StreamMode!, Write!, LockReadWrite!, lwm_Mode)
If li_FileNo < 0 Then Return -1

ll_StrLen = Len(as_Text)

// If the string is longer than 32765 bytes then it will require multiple writes to write it
If ll_StrLen > 32765 Then
      If Mod(ll_StrLen, 32765) = 0 Then
            li_Writes = ll_StrLen / 32765
      Else
            li_Writes = (ll_StrLen / 32765) + 1
      End if
Else
      li_Writes = 1
End if

ll_CurrentPos = 1

For li_Cnt = 1 To li_Writes
      ls_Text = Mid(as_Text, ll_CurrentPos, 32765)
      ll_CurrentPos += 32765
      If FileWrite(li_FileNo, ls_Text) = -1 Then
            Return -1
      End if
Next

FileClose(li_FileNo)

Return 1
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Editors IDEs

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.