I'm surprised your client has not upgraded to QBX 7.1 which is
much more capable, arrays to limits of available (DOS) memory,
more flexible Types, less bugs, etc.
------------------
Announcement
Collapse
No announcement yet.
Variables - Revisited!
Collapse
X
-
Problem is, QB is wretched at memory manipulation... this isn't going to be fast
or elegant. I'll take on faith that the controller is expecting IEEE floating
point numbers. The array needs to be under 32k (i.e., under 4096 elements), or
it gets more complicated.
Code:sub PutMailBox(TransferArray#(),DestSeg%,DestOff%,Length%) for i% = 0 to Length% SrcSeg% = varseg(TransferArray#(i%)) SrcOff% = varptr(TransferArray#(i%)) for j% = 0 to 7 ' double-precision = 8 bytes def seg = SrcSeg% v% = peek(SrcOff% + j%) def seg = DestSeg% poke DestOff% + i% * 8 + j%, v% next j% next i% end sub
------------------
Tom Hanlin
PowerBASIC Staff
Leave a comment:
-
Well, why didn't you say QuickBASIC?
And, after further review...
Why can't you just use an array of LONG integers to store your data- that will handle the whole number range +- 2.1E0
DIM Foo(100) AS LONG
INPUT X&
> 40000
Foo(0) = X&
INPUT X&
> -12345
Foo(1) = X&
Location of first var IN QB CODE is VARSEG(Foo(0))* 65536 + VARTPR(Foo(0)), length = 4
(This is ms-dos segffset format)
Why bleep around reordering bytes when you can do it the easy way?
That, or I am missing something else you need to do.
MCM
Leave a comment:
-
We are on the right track here except that this is going to have
to be done in QB45 and not PB. At this time, my client only has
QB45 and has not yet switched to PB. I am trying to convert him
though.
------------------
Noble D. Bell - Owner
Noble Software Publishing
http://www.noblesoftware.com
Leave a comment:
-
Well, if you "really" need specific memory locations...
Code:DIM MyArray ((numlements -1) * elementsize) AT desiredmemoryaddress AS DOUBLE or DWORD or whatever
Code:DIM Myarray (elements) AS DWORD (or DOUBLE, or WHATEVER) AddressWhereDataStarts??? = VARPTR32(MyArray(0))
Note: you said "double precision" numbers but you are using integer-class variables in your array. Not too sure which it is you need/want.
MCM
Leave a comment:
-
Variables - Revisited!
Hello,
Yesterday I started a post about variables and memory locations.
Me, being of quick wit, deleted it!
Tom Hanlin was saying: (before I rudely killed the message)
PutMailBox(TransferArray(),DestSeg,DestOff,Length)
def seg = varseg(DestSeg)
for i=0 to Length
poke DestOff+i*2,TransferArray(i) and 255
poke DestOff+i*2+1,TransferArray(i)\256 and 255
next i
end sub
GetToArrayI(TransferArray(),Source,Length)
def seg = varseg(Source)
v=varptr(Source)
for i=0 to Length
TransferArray(i)=peek(v+i*2)+peek(v+i*2+1) *256
next i
end sub
This was for unsigned integers and Intel byte ordering.
1. The user will key in a value, say 40000
2. The data entered needs to be stored in a specific memory location.
3. When the data is pulled from memory location it needs to be 40000.
I need to be able to both signed/unsigned double percission values.
Is there something that I can do to the above code to allow
me to use what I need?
I am not sure the client is asking for a specific memory segment
or not. I do know that he is asking for specific offsets to
store the data in.
If this does not work for him he is going to check with his
motor controller manufacturer's and see if he is limited to Qb
or if he can yes PB (Yeah!).
Thanks for your support.
Noble
------------------
Noble D. Bell - Owner
Noble Software Publishing
http://www.noblesoftware.comTags: None
Leave a comment: