en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en de en nl en en en en en en en pt en en en en de fr en en en en nl en en en en en en en en en en en en en en en nl en en en en en en en en en en en en en nl en en en en en en en en fr en en en en nl en en en en en en en fr en en fr pt en en de en nl en en en en en te en nl en en en en pt en en en en en en en en en de en en en fr en en en en en en en en en pt en en en en en en
By logging into your account, you agree to our Privacy Policy, personal data processing and storage practices as described therein.
Forgot password or user name?
Search in titles only Search in PowerBASIC for Windows only
You are not logged in. You can browse in the PowerBASIC Community, but you must click Login (top right) before you can post. If this is your first visit, check out the FAQ or Sign Up.
All Time Today Last Week Last Month
All Discussions only Photos only Videos only Links only Polls only Events only
Can sombody explain this to me. How come SIZEOF returns 80 inside
PBMAIN but returns 0 in the test function. This really has me boggled!
I was under the impression that SIZEOF would always return the size
#compile exe function Test(Buffer as asciiz) as long msgbox format$(sizeof(Buffer)) end function function pbmain as long local mark as asciiz * 80 mark = "mark" msgbox format$(sizeof(mark)) test mark end function
Join Date: Sep 1999
25 Nov 2000, 11:21 AM
Asciiz strings haven't the descriptors.
That's why it possible to understand SizeOf from declaration only.
If to use Function Test(Buffer as asciiz * x) SizeOf(Buffer) will return x, not depends of real value.
Len is another question. Because Asciiz is 0 terninated, PB is able to calculate.
Join Date: Jun 1999
27 Nov 2000, 09:48 AM
The variable MARK is an ASCIIZ * 80, which is a buffer of 80 characters. The variable BUFFER is an ASCIIZ, which is a pointer to a nul-terminated buffer. So, I'd probably expect SIZEOF to return four (the size of a pointer), not zero. I'll have to take that up with Development.
Join Date: Jun 1999
28 Nov 2000, 11:02 AM
The word on this is, as a BASIC type, ASCIIZ without a length specification is considered as an ASCIIZ string of undefined length. So, SIZEOF is not actually meaningful here, and returns zero as an arbitrary result.
Join Date: Aug 1998
28 Nov 2000, 08:20 PM
One "solution" is to pass just a pointer to the ASCIIZ data and manipulate it thus:
(Note this is PB/DOS code as I don't have PB/DLL installed on the PC I'm using today, so you'll need to adapt the technique as you find necessary)
%AZsize = 80 function Test(byval buffer as dword) as long dim x as asciiz ptr * %AZsize x = buffer print sizeof(@x), len(@x) end function dim mark as asciiz * %AZsize mark = "mark" print sizeof(mark), len(mark) test varptr32(mark) end [b]Results:[/b] 80 4 80 4
29 Nov 2000, 05:06 AM
The original idea was that I was going to make some "macros" so
that I could get and put any powerbasic type to and from an edit
GetItemByte GetItemWord GetItemDword GetItemInteger GetItemLong GetItemQuad GetItemSingle GetItemDouble GetItemString GetItemAsciiz PutItemByte PutItemWord PutItemDword PutItemInteger PutItemLong PutItemQuad PutItemSingle PutItemDouble PutItemString PutItemAsciiz
For the string versions of these wrappers I needed to know the
full allocated length of the string. That way I could make sure
that I dont retrieve more string data then there is string space.
I solved the problem by just adding another variable to the string
function GetItemAsciiz(byval hDlg as long, byval ID as long, Buffer as asciiz, byval Length as long) as long function = SendMessage(GetDlgItem(hDlg,ID), %WM_GETTEXT, Length, varptr(Buffer)) end function function PutItemAsciiz(byval hDlg as long, byval ID as long, Buffer as asciiz) function = SendMessage(GetDlgItem(hDlg,ID), %WM_SETTEXT, 0, varptr(Buffer)) end function
[This message has been edited by mark smit (edited November 29, 2000).]
Copyright © 1998-2022 PowerBASIC Tools, LLC - All Rights Reserved.
Powered by vBulletin® Version 5.7.0
Copyright © 2022 vBulletin Solutions, Inc. All rights reserved.
All times are GMT-5. This page was generated at 10:44 PM.
We process personal data about users of our site, through the use of cookies and other technologies, to deliver our services, and to analyze site activity. For additional details, refer to our Privacy Policy.
By clicking "I AGREE" below, you agree to our Privacy Policy and our personal data processing and cookie practices as described therein. You also acknowledge that this forum may be hosted outside your country and you consent to the collection, storage, and processing of your data in the country where this forum is hosted.