Forum > General

Can Absolute be used on string / packed record

(1/17) > >>

andresayang:
Hello,

I build a packet record of shot strings, can I use Absolute directive to split a short string in several parts of my packed record ?
Or is there any way to do something like:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---varsplitline: MyPackedRecord;line : String[100]; (100 is the size on my packed record) splitline:= line; ( to have direct acces to plitline.record without having to use copy function)  Cheers

Awkward:
You can use 'Absolute' for string (why not?)
but looks like you forgot one thing. string[100] is 101 bytes length coz first byte will be used to keep line length
so? code

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---var  splitline: MyPackedRecord;  line: string[100] absolute splitline; can be compiled but line[1] will be not first byte of record but second byte

andresayang:
Hi,

Well, the way I understood it (Absolute), it should be the other way:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---var  line: string[100];  splitline: MyPackedRecord absolute of line; 
This is the way I codded it, and it seems to do not work. Maybe due to each short string of splitline having one additional byte [0] ...

Bart:
I would say that practically it is not possible.
Let's say MyPackedRecord consists of 2 shortsstrings (SA and SB) with length A and B, such that A + B = 100-2.
Now your shortstring Line has the exact same memory layout as MyPackedRecord since you declared one to be absolute the other.

If you want to use Line to populate MyPackedRecord (which is what I understand from your posts), then Line[0] must be the length of the first shortstring in MyPackedRecord (SA), but Line[A+1] maps to the 0-th byte of the second shortstring (SB), which is the length indicator for that string, so it must be the length of the second string.
While in theory that is possible, it would be more difficult to make it so than just accessing the individual shortstrings of MyPackedRecord.
You certainly would not be able to read Line from a file (or console) and correctly map it to MyPackedRecord.

The same argument goes for the other way around.

Bart

andresayang:
@Bart:
Yep, this is what I realize when I was remind that short string have 1 byte more (byte 0) for length.

So do you have an optimized technique to do "column separated values" of text file or we absolutely need to use Copy(S, start, length) ?

Thanks

Navigation

[0] Message Index

[#] Next page

Go to full version