User Name
Password

Go Back   Planetarion Forums > Non Planetarion Discussions > Programming and Discussion
Register FAQ Members List Calendar Arcade Today's Posts

Reply
Thread Tools Display Modes
Unread 13 Jan 2005, 16:54   #1
derry
Registered User
 
Join Date: Jun 2003
Location: somewhere
Posts: 130
derry will become famous soon enoughderry will become famous soon enough
Delphi paradox database

I've got a question about storing something in a paradox db (need to use this cause school forces me)

i've got 4 integers (say 10-11-12-13) is it possible that i store those in 1 field instead of making 4 fields in that table?

if yes, how do i implent that with BDE (delhi's Database maker prog) and how do i do it with delphi code?

if you wouldn't know it in delphi, but know if its possible feel free to reply aswell hehe

thnx in advance,

derry
__________________
[18:45] <Helix> if two wrongs dont make a right its twice as wrong to do something wrong to right it

[00:22] <Doom> Where as in most cases it appears multing is an individual thing, LDK organises it and uses it. Making it an effective unit with a small number of players. It makes sense just not part of the rules. They just organised cheating =-)
derry is offline   Reply With Quote
Unread 13 Jan 2005, 18:10   #2
Epcylon
Registered User
 
Join Date: Apr 2000
Location: Oslo, Norway
Posts: 78
Epcylon is a glorious beacon of lightEpcylon is a glorious beacon of lightEpcylon is a glorious beacon of lightEpcylon is a glorious beacon of lightEpcylon is a glorious beacon of light
Re: Delphi paradox database

Without knowing either paradox or delphi, I'd say it depends on the integers..

4 integers of a limited range can (almost) always be encoded in 1 integer of a larger range.. just a matter of making it work..
__________________
Epcylon
[R1]: noob | [R2]: B8S/ICD | [R3-5]: ICD | [R6]: HR | [R7-9.5]: HR/NoS |
[R10]: HR RecOff | [R10.5]: HR RO -> HR HC -> HR pe0n | [R11]: HR pe0n -> Leave of Absence |
[R12]: HR free-pe0n | [R13-]: HR pe0n
Epcylon is offline   Reply With Quote
Unread 14 Jan 2005, 22:29   #3
Structural Integrity
Rawr rawr
 
Structural Integrity's Avatar
 
Join Date: Dec 2000
Location: Upside down
Posts: 5,300
Structural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriend
Re: Delphi paradox database

I don't know any Delphi, and have never heard of Paradox, but couldn't you with some trickage shift the bits of the integer a few places.
If the value of every unsigned integer does not go over 255 (1 byte) you will be able to fit four of those in one integer (4 bytes).
I'm a C++ person, but I'd do some binary trickage like this:
Code:
int a = 10;
int b = 11;
int c = 12;
int d = 13;

int result = 0;

result = a;
result = (result << 8) | b; // shift left 8 bits, add the second int. Use the OR operator to prevent numerical overflow.
result = (result << 8) | c; // same trick, shift a and b left a byte, and put c in the lowest byte
result = (result << 8) | d; // add d, now a is in the highest order byte, and d in the lowest order byte

// Recovering a, b c and d

d = result & 255; // filter out the lowest byte (& is logical AND operator)
c = (result >> 8) & 255; // move the number right a byte, c is now the lowest order byte, again AND with 255 to filter out the lowest order byte
b = (result >> 16) & 255; // b is the third byte, move the number right two bytes (pushing c and d away) and filter out b.
a = (result >> 24) & 255; // you should get this now
You should find out how to shift bits around in Delphi and how to do an AND and OR operation. You can also multiply or divide by 255 in order to achieve the bitshift (multiply with 255 is a left shift of one byte, divide by 255 is a right shift of one byte) , but note that some languages (Visual Basic) will cause problems with such large numbers. I don't know about Delphi, but I'll leave that up to you.
__________________
"Yay"
Structural Integrity is offline   Reply With Quote
Reply



Forum Jump


All times are GMT +1. The time now is 17:27.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2002 - 2018