[Gambas-user] External C function usage error - IPC queue usage
Yahoo
olivier.cruilles at yahoo.fr
Tue Jan 23 21:28:13 CET 2018
Hello,
This is my workaround about the issue of how to convert to octal:
' Gambas module file
Library "libc:6"
' Library
Private Extern strtoul(mode As Pointer, dechet As Pointer, base As Integer) As Integer
Public Sub Main()
Print "Example, mode '0660' = " & convert_octal_mode("0660")
End
Private Function convert_octal_mode(mode As String) As Short
' Fonction to convert an Unix mode text to an integer
Dim ResultPerm As Short
Dim sMode As String
Dim sDechet As Pointer
If mode = "" Or Len(mode) <> 4 Then
Print "Unix string perms not valid ! [" & mode & "] Example: 0644"
Return IPC_ERROR
Endif
sMode = mode
ResultPerm = CShort(strtoul(VarPtr(sMode), sDechet, 8))
If ResultPerm = 0 Then
Print "Unix string perms not valid ! [" & sMode & "]"
Return IPC_ERROR
Endif
Return ResultPerm
End
Olivier
Le January 23, 2018 à 14:43:03, T Lee Davidson (t.lee.davidson at gmail.com) a écrit:
On 01/23/2018 11:40 AM, Fabien Bodard wrote:
> 2018-01-23 1:05 GMT+01:00 T Lee Davidson <t.lee.davidson at gmail.com <mailto:t.lee.davidson at gmail.com>>:
>
> On 01/22/2018 06:58 PM, Doug Hutcheson wrote:
> >>
> > Hi Lee. Would it not be "&0" (ampersand zero) not "&o" ?
> > Just a hunch.
> > Cheers,
> > Doug
>
> According to http://gambaswiki.org/wiki/cat/constants <http://gambaswiki.org/wiki/cat/constants>, "&0" would be a
> hexadecimal representation.
>
> I tried '&0600'. Result in decimal: 1536.
>
>
> Hexadecimal short signed integers.&H1F5, &HFFFF, &H0000FFFF, &FFFF
> Hexadecimal signed integers. &H10BF332E, &10BF332E
> Hexadecimal unsigned integers. &H8000&, &HFFFF&
> Binary integers. &X1010010101, %101001011
>
> Where did you read that, Lee ?
>
> http://gambaswiki.org/wiki/cat/constants
>
> There is a lack between doc and gb source code ...
>
> --
> Fabien Bodard
>
Where did I read, what, Fabien? That "&0" would be a hexadecimal representation?
From the first two lines you posted from the referenced doc page. Take a look at the last example on each of those lines.
"&FFFF": Ampersand followed by a hexadecimal number. "0" is a hexadecimal number.
"&10BF332E": Again, ampersand followed by a hexadecimal number.
Or, maybe that's not what you were referring to about what I read.
And yes, as Tobi pointed out, the doc doesn't quite reflect the state of the source code.
--
Lee
--------------------------------------------------
This is the Gambas Mailing List
https://lists.gambas-basic.org/listinfo/user
Hosted by https://www.hostsharing.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20180123/96c6b944/attachment-0001.html>
More information about the User
mailing list