| View previous topic :: View next topic |
| Author |
Message |
cmosentine General User

Joined: 11 Sep 2003 Posts: 35
|
Posted: Tue Aug 29, 2006 11:34 am Post subject: inadmissible value or data type error |
|
|
Hello all: I am updating an older OOo 1.1x macro for use in OOo 2.0.3 The macro basic is going to be used to convert about 45,000 OOo 1.x documents (.sxw) to OOo 2.x (.odt) file format.
The macro is designed to transverse thru a series of directories, numbers 1,2,3 ...) and open the files within which are numbered 0 thru 999.
The macro works fine on a limited number of files but when I try to run it on an entire directory of files (999 files) it fails with "inadmissible value or data type". The line of code which gets flagged is a simple interger multipication and addition formula.
Since the macro ran fine for the first 508 files I am thinking the problem may be a file handle issue of some kind.
Has anyone alse seen this problem and solved it?? How??
All help greatly appreciated, Chris. |
|
| Back to top |
|
 |
hol.sten Super User


Joined: 14 Nov 2004 Posts: 3532 Location: Hamburg, Germany
|
Posted: Tue Aug 29, 2006 1:33 pm Post subject: Re: inadmissible value or data type error |
|
|
| cmosentine wrote: | | Since the macro ran fine for the first 508 files I am thinking the problem may be a file handle issue of some kind. |
Regarding huge batch (conversion) jobs OOo stumbles from time to time. This has been reported manifold in this forum. Isn't it possible for you to continue with 509th document? I cannot image that you can convert 45,000 documents without restarting OOo.
With kind regards
hol.sten |
|
| Back to top |
|
 |
cmosentine General User

Joined: 11 Sep 2003 Posts: 35
|
Posted: Wed Aug 30, 2006 4:52 am Post subject: |
|
|
Yes I can certainly do that, but that is a bastardized way of working. I have used similar techniques when we converted from word perfect to staroffice format and twice since to replace built-in letterhead in the header and footer. In these cases SO and OOo did stumble but only after about 2000 + files, and then it was a lack of memory/resources.
But now the error is different in my opinion. The failure takes place during an integer operation. Surely OOo can handle 1000's of simple integer calcs. Or is this a result of memory/resource depletion, but in manifesting itself in a different form??
Chris |
|
| Back to top |
|
 |
B Marcelly Super User

Joined: 12 May 2004 Posts: 1414 Location: France
|
Posted: Wed Aug 30, 2006 7:08 am Post subject: Re: inadmissible value or data type error |
|
|
| cmosentine wrote: | | when I try to run it on an entire directory of files (999 files) it fails with "inadmissible value or data type". The line of code which gets flagged is a simple interger multipication and addition formula. |
Without a significant part of your code we can't help you.
It seems you create an overflow on a variable. Remember integer variables are 16 bits wide  |
|
| Back to top |
|
 |
cmosentine General User

Joined: 11 Sep 2003 Posts: 35
|
Posted: Wed Aug 30, 2006 7:16 am Post subject: |
|
|
Below is a snippet of my macro code. I was able to fix the issue by using type double rather than integer.
Given an integer is 16 bits wide, it should not fail until an integer variable passes 65535. Now it's been a long time since school, but the code should work with type integer too!
Sub ConvertFileType
dim mNoArgs()
dim oDesktop, oDocument, oText, oTextCursor as Object
dim oStyleFamilies, oStyle, oPageStyles as Object
dim sTemplateURI, sPageStyleName as String
dim sURL, sPath, sExtension as String
dim dURL, dPath, dExtension as String
dim iCounter, jCounter, fileNumber as double
sTemplateURL = "file:///j:/oo/templates/vra/letterhead_vra.ott"
sPath = "file:///d:/so/pts/"
sExtension = "sxw"
dPath = "file:///d:/oo/pts/"
dExtension = "odt"
fileNumber = 0
' Create a desktop to work in
oDesktop = createUnoService("com.sun.star.frame.Desktop")
for iCounter = 32 to 32
for jCounter = 0 to 999
fileNumber = iCounter*1000+jCounter
' Generate the source file URL
sURL = sPath & iCounter & "/" & fileNumber & "." & sExtension
if FileExists(sURL) then
' File exists so open it up
oDocument = oDesktop.loadComponentFromURL(sURL, "_blank", 0, mNoArgs()) |
|
| Back to top |
|
 |
B Marcelly Super User

Joined: 12 May 2004 Posts: 1414 Location: France
|
Posted: Wed Aug 30, 2006 11:52 am Post subject: |
|
|
Basic Integer is 16bits signed. Range is from -32768 to +32767.
The code should work with Long variables (32 bits signed). |
|
| Back to top |
|
 |
cmosentine General User

Joined: 11 Sep 2003 Posts: 35
|
Posted: Thu Aug 31, 2006 3:26 am Post subject: |
|
|
I am so stupid. YOU ARE EXACTLY RIGHT. Thanks for pointing out how much I have forgotten since CS101.
Thank you very much, Chris. |
|
| Back to top |
|
 |
|