Solved

LibraryExport() for long script

Posted on 2003-12-09
10
359 Views
Last Modified: 2013-12-26
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?
0
Comment
Question by:xo123
  • 5
  • 5
10 Comments
 
LVL 15

Expert Comment

by:namasi_navaretnam
Comment Utility
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
 
LVL 15

Expert Comment

by:namasi_navaretnam
Comment Utility
Btw, this is not PB limitation, but OS limitation.
0
 

Author Comment

by:xo123
Comment Utility
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
 
LVL 15

Expert Comment

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

0
 

Author Comment

by:xo123
Comment Utility
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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

Author Comment

by:xo123
Comment Utility
I'm using Window 2000 Professional.
0
 

Author Comment

by:xo123
Comment Utility
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
 

Author Comment

by:xo123
Comment Utility
I'll try to partition the export script (ls_objsyn) and write each partition at a time.
0
 
LVL 15

Expert Comment

by:namasi_navaretnam
Comment Utility
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
 
LVL 15

Accepted Solution

by:
namasi_navaretnam earned 50 total points
Comment Utility
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

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now