Btrieve GetNextExtended Status 62 - vb6

I'm having trouble getting the GetNextExtended(36) operation working
in Btrieve. Here is the call which returns the status code 62 :
intStatus = BTRCALL(B_GETNEXTEXTENDED, _
m_byteFilePosBlk, _
m_byteRecordBuffer(0), _
lngDataBufferLen, _
ByVal strKeyBuffer, _
intKeyBufferLen, _
m_intKeyNum)
After doing a search for the code I found numerous site stating that the
code indicates an error in the databuffer, stored in m_byteRecordBuffer.
Here are the values stored in that variable :
m_byteRecordBuffer(0) 16 'These two bytes indicate the total size of'
m_byteRecordBuffer(1) 0 'data buffer'
m_byteRecordBuffer(2) 67 'These two bytes indicate the characters 'UC''
m_byteRecordBuffer(3) 85
m_byteRecordBuffer(4) 0 'These two bytes indicate the maximum reject'
m_byteRecordBuffer(5) 0 'count, which if set to 0 defaults to 4,095'
m_byteRecordBuffer(6) 0 'These two bytes indicate the number of terms'
m_byteRecordBuffer(7) 0 'which has been set to zero'
m_byteRecordBuffer(8) 1 'These two bytes indicate the number of'
m_byteRecordBuffer(9) 0 'records to return'
m_byteRecordBuffer(10) 1 'These two bytes indicate the number of fields'
m_byteRecordBuffer(11) 0 'to extract'
m_byteRecordBuffer(12) 2 'These two bytes indicate the length of the'
m_byteRecordBuffer(13) 0 'field to extract'
m_byteRecordBuffer(14) 1 'These two bytes indicate the field offset'
m_byteRecordBuffer(15) 0
I hope I am just missing something simple. Any help would be greatly appreciated.

In the record buffer, try swapping the position of the UC characters.
Put 'U' (85) in position 2 and 'C' (67) in position 3.

Related

Encapsulated poscript max line limit

I think that I'm exceeding EPS max line limits:
I'm generating an eps programmatically that consists of a grid of pictures.
My EPS has this structure:
%!PS-Adobe-3.0 EPSF-3.0
.
.
%%BeginProlog
%%EndProlog
%%Page: 1 1
%%Begin Raster Image. Index: 0
save
449 2576 translate
0 rotate
-282 -304 translate
[1 0 0 1 0 0] concat
0 0 translate
[1 0 0 1 0 0] concat
0 0 translate
userdict begin
DisplayImage
0 0
564 608
12
564 608
0
0
FBDBB9FBDCBCFDDBBAFFD8B2FFD7A9FED4A1FCD29CFDD09EFED0A2FFD0A6FFCDA3FFCBA0FFCBA0...
EED79CEBD09CEDD19EEED2A1EFD3A3F0D4A5F0D4A6F0D4A7F1D4A4F3D4A0F3D49F
end
restore
%%End Raster Image
%%Begin Raster Image. Index: 1
.
.
end
restore
%%End Raster Image
%%Begin Raster Image. Index: 2
etc
So the thing is if I write up to 4 images to the EPS, everything works fine, but when I try to write a 5th, the eps won't open on any EPS viewer including Adobe Illustrator (the operation cannot complete because of an unknown error).
I tried using different images to make sure that the particular images were ok and I got the same result, as long as I'm writing 4 images (105825 lines file) everything works. But when I use 5 (132253 lines file) it fails.
Is it possible that I'm exceeding the maximum line limit for EPS?
This are the files in question if you'd like to analyze them:
the one that works - >https://files.fm/u/bfn2d32m and the one that doesn't ->
https://files.fm/u/4gbybr3y
There's no 'line limit' in PostScript or EPS, so you can't be hitting that.
When I run your file through Ghostscript it throws an error /undefined in yImage (I'd suggest you debug PostScript using a proper PostScript interpreter, not Adobe Illustrator).
This suggests to me that one of your images is using more data than you have supplied, so the interpreter runs off the end of the data, consuming parts of the program, until it has read sufficient bytes from currentfile to satisfy the request. At that point is starts processing the file as PostScript again, but the file pointer now points to the 'yImage' of the next 'DisplayImage'. Since you haven't defined a 'yImage' key, naturally this gives you an 'undefined' error.
From your description, this would seem likely to be the 4th image, since adding the 5th throws the error. Note that if your program terminates without supplying enough data (so the interpreter reaches EOF) then the data supplied will be drawn. So it might look like your 4th image is correct even when it isn't, provided it isn't followed by any further program code.
A style note; PostScript is a stack-based language, so normally one would proceed by pushing values onto the stack and reading them from there, instead of executing the 'token' operator.
So your input would be more like :
0 0
564 608
12
564 608
0
0
DisplayImage
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
...
And the DisplayImage code would be :
/DisplayImage
{
%
% Display a DirectClass or PseudoClass image.
%
% Parameters:
% x & y translation.
% x & y scale.
% label pointsize.
% image label.
% image columns & rows.
% class: 0-DirectClass or 1-PseudoClass.
% compression: 0-none or 1-RunlengthEncoded.
% hex color packets.
%
gsave
/buffer 512 string def
/byte 1 string def
/color_packet 3 string def
/pixels 768 string def
/compression exch def
/class exch def
/rows exch def
/columns exch def
/pointsize exch def
scale
translate
This avoids you having to use token at all for the scale and translate operations for instance.

Errors with inter-group communications

I have to implement a scenario where I have 2 groups. Group 1 contains only process 0 and 1. Group 2 contains all the processes. Now the processes in Group 2 read some data and send it to Group 1(process 0 or 1, equal division). It should look like this:
Grp1 Grp2
Rank
(grp)
0 0 0
1 1 1
2 2
3 3
4 4 and so on..
Now to implement this, I have used the following code (All the variables and other things are taken care)
program mpi
use mpi
integer ierr,new_rank1,new_grp1,new_rank2,new_grp2,new_comm1,new_comm2
integer numtasks,rank,orig_grp,tag,sendbuf,recvbuf
integer ranks1(2),ranks2(8),stat(MPI_STATUS_SIZE)
data ranks1 /0,1/,ranks2 /0,1,2,3,4,5,6,7/
call mpi_init(ierr)
call mpi_comm_rank(mpi_comm_world,rank,ierr)
call mpi_comm_size(mpi_comm_world,numtasks,ierr)
call MPI_COMM_GROUP(MPI_COMM_WORLD,orig_grp,ierr)
tag = 342
call MPI_GROUP_INCL(orig_grp,8,ranks2,new_grp2,ierr)
call mpi_comm_create_group(mpi_comm_world,new_grp2,112,new_comm2,ierr)
call mpi_comm_rank(new_comm2,new_rank2,ierr)
if(new_rank2 == 4) then
call mpi_send(123,1,MPI_INT,0,tag,new_comm2,ierr) !send a msg from rank 4 of group 2 to rank 0 of group 1
end if
if(rank <2) then
call MPI_GROUP_INCL(orig_grp,2,ranks1,new_grp1,ierr)
call mpi_comm_create_group(mpi_comm_world,new_grp1,111,new_comm1,ierr)
call mpi_comm_rank(new_comm1,new_rank1,ierr)
if(new_rank1 == 0) then
call mpi_recv(recvbuf,1,MPI_INT,4,tag,new_comm2,stat,ierr)
print*,recvbuf
end if
end if
call mpi_finalize(ierr)
end
Facing errors in sending and receiving data. The other things work fine. And also if the whole concept is wrong, I am open to suggestions.

High & Low Numbers From A String (Ruby)

Good evening,
I'm trying to solve a problem on Codewars:
In this little assignment you are given a string of space separated numbers, and have to return the highest and lowest number.
Example:
high_and_low("1 2 3 4 5") # return "5 1"
high_and_low("1 2 -3 4 5") # return "5 -3"
high_and_low("1 9 3 4 -5") # return "9 -5"
Notes:
All numbers are valid Int32, no need to validate them.
There will always be at least one number in the input string.
Output string must be two numbers separated by a single space, and highest number is first.
I came up with the following solution however I cannot figure out why the method is only returning "542" and not "-214 542". I also tried using #at, #shift and #pop, with the same result.
Is there something I am missing? I hope someone can point me in the right direction. I would like to understand why this is happening.
def high_and_low(numbers)
numberArray = numbers.split(/\s/).map(&:to_i).sort
numberArray[-1]
numberArray[0]
end
high_and_low("4 5 29 54 4 0 -214 542 -64 1 -3 6 -6")
EDIT
I also tried this and receive a failed test "Nil":
def high_and_low(numbers)
numberArray = numbers.split(/\s/).map(&:to_i).sort
puts "#{numberArray[-1]}" + " " + "#{numberArray[0]}"
end
When omitting the return statement, a function will only return the result of the last expression within its body. To return both as an Array write:
def high_and_low(numbers)
numberArray = numbers.split(/\s/).map(&:to_i).sort
return numberArray[0], numberArray[-1]
end
puts high_and_low("4 5 29 54 4 0 -214 542 -64 1 -3 6 -6")
# => [-214, 542]
Using sort would be inefficient for big arrays. Instead, use Enumerable#minmax:
numbers.split.map(&:to_i).minmax
# => [-214, 542]
Or use Enumerable#minmax_by if you like result to remain strings:
numbers.split.minmax_by(&:to_i)
# => ["-214", "542"]

Meaning of mxlc in Oracle Trace file

I am seeing the following in my trace file:
Bind#3 oacdty=01 mxl=128(35) mxlc=36 mal=00 scl=00 pre=00
oacflg=03 fl2=1000010 frm=01 csi=31 siz=0 off=168
kxsbbbfp=ffffffff79f139a8 bln=128 avl=35 flg=01 value="1234 W
1234 West, West Groves City"
I am wondering what the mxlc value is?
I quote
Bind #n
oacdty - Datatype code
mxl - Maximum length of the bind variable value (private maximum length in parentheses)
mxlc - Unknown :(
mal - array length
scl - Scale
pre - Precision
oacflg - Special flag indicating bind options
fl2 - second part of oacflg
frm - Unknown :(
csi - Unknown :(
siz - Amount of memory to be allocated for this chunk
off - Offset into this chunk for this bind buffer
kxsbbbfp- Bind address
bln - Bind buffer length
avl - actual value length
flg - bind status flag
value - Value of the bind variable
Source (& snippet of the book)
The book also quotes-
There is currently no information on three parameters.
Which are mxlc,frm, and csi.
Summary
mxlc appears to be the maximum number of characters for the bind variable, but only if the variable uses character length semantics.
Method
I searched My Oracle Support for mxlc. Almost every article has mxlc=00, the only exceptions involve an NVARCHAR or NCHAR. The code below is based on the code from Document ID 552262.1. I changed the variable sizes (99 and 123 char) around, and each time mxlc was set to the variable size if character length semantics was used.
Code
create table t1(ncol1 nvarchar2(100), col1 varchar2(100));
alter session set timed_statistics = true;
alter session set statistics_level=all;
alter session set max_dump_file_size = unlimited;
alter session set events '10046 trace name context forever,level 4';
VAR nvar1 NVARCHAR2(99)
VAR var1 VARCHAR2(123 char)
EXEC :nvar1 := 'nvarchar'
EXEC :var1 := 'varchar'
SELECT * FROM T1 WHERE ncol1 = :nvar1 and col1 = :var1;
ALTER SESSION SET EVENTS '10046 trace name context off';
Results:
Bind#0
oacdty=01 mxl=2000(198) mxlc=99 mal=00 scl=00 pre=00
oacflg=03 fl2=1000010 frm=02 csi=2000 siz=4000 off=0
kxsbbbfp=0e702edc bln=2000 avl=16 flg=05
value=0 6e 0 76 0 61 0 72 0 63 0 68 0 61 0 72
Bind#1
oacdty=01 mxl=2000(369) mxlc=123 mal=00 scl=00 pre=00
oacflg=03 fl2=1000010 frm=01 csi=873 siz=0 off=2000
kxsbbbfp=0e7036ac bln=2000 avl=07 flg=01
value="varchar"
More Questions
Normally the relationship between mxl and mxlc makes sense. For a NVARCHAR, UTF16 on my system, there will be 2 bytes per character, thus 198 and 99. My database is UTF8, a character could take up to 4 bytes. Maybe Oracle guesses the average size will be 3 bytes, thus 123 and 369. Obviously it could be more than 369, perhaps that's just the initial memory allocated, and it can grow later?
But your numbers, 36 and 35, don't make sense to me. Surely the number of bytes can never be LESS than the number of characters? Is Oracle making a bad guess, or is some client program sending in bad data?

Limiting the size of vbstring to 10240 bytes in VB6 [duplicate]

This question already has answers here:
Closed 13 years ago.
Possible Duplicates:
How to declare variable containing character limiting to 1000 bytes in vb6
“Object variable or With block variable not set” runtime error in VB6
Exact duplicate of askers own question How to declare variable containing character limiting to 1000 bytes in vb6
How to declarare the size of string variable as 10240 butes in VB6?
Try
Dim s As String * 5120
' Gives 10240 bytes, as pointed out by KristoferA
This will ensure the string is ALWAYS 5120 characters, if there are less in there, it will be padded with spaces. e.g.
Dim s As String * 10
s = "Hello"
Debug.Print "[" & s & "]"
gives
[Hello ]
10240 bytes* or characters*?
Dim strFoo As String * 5120 // 10240 bytes
Dim strFoo As String * 10240 // 10240 characters
(* = VB6 strings are unicode, so each character in a string takes 2 bytes)
This is the syntax for a fixed-length string of 5120 characters, which is 10240 bytes. The value will always have 5120 characters - trailing spaces will be added, or excess characters truncated. VB6 strings are Unicode (UTF-16) and therefore each character has 2 bytes.
Dim s As String * 5120 ' 5120 characters, 10240 bytes
It's not clear whether you are dealing with binary data rather than text. The Byte data type is better for binary data.
Dim byt(10240) as Byte ' an array of 10240 bytes

Resources