• Vb6 type to python

    From luca72.bertolotti@gmail.com@21:1/5 to All on Wed Nov 30 03:56:43 2022
    Hello i have a byte file, that fill a vb6 type like:
    Type prog_real
    codice As String * 12 'hsg
    denom As String * 24 'oo
    codprof As String * 12 'ljio
    note As String * 100
    programmer As String * 11
    Out As Integer
    b_out As Byte 'TRUE = Sec FALSE= mm
    asse_w As Byte '3.zo Asse --> 0=Z 1=W
    numpassi As Integer 'put
    len As Long 'leng
    p(250) As passo_pg
    vd(9) As Byte 'vel.
    qUscita(9) As Integer 'quote
    l_arco As Long 'reserved
    AxDin As Byte 'dime
    End Type

    How i can convert to python

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From DFS@21:1/5 to luca72.b...@gmail.com on Wed Nov 30 13:07:17 2022
    On 11/30/2022 6:56 AM, luca72.b...@gmail.com wrote:

    Hello i have a byte file, that fill a vb6 type like:
    Type prog_real
    codice As String * 12 'hsg
    denom As String * 24 'oo
    codprof As String * 12 'ljio
    note As String * 100
    programmer As String * 11
    Out As Integer
    b_out As Byte 'TRUE = Sec FALSE= mm
    asse_w As Byte '3.zo Asse --> 0=Z 1=W
    numpassi As Integer 'put
    len As Long 'leng
    p(250) As passo_pg
    vd(9) As Byte 'vel.
    qUscita(9) As Integer 'quote
    l_arco As Long 'reserved
    AxDin As Byte 'dime
    End Type

    How i can convert to python


    You don't need to declare variable types in Python.

    I don't do Python OO so someone else can answer better, but a simple
    port of your VB type would be a python class definition:

    class prog_real:
    codice, denom, codprof, note, programmer
    AxDin, b_out, asse_w, vd, Out, numpassi, qUscita
    len, l_arco, p

    important: at some point you'll have trouble with a variable named
    'len', which is a Python built-in function.

    For a visual aid you could label the variables by type and assign an
    initial value, if that helps you keep track in your mind.

    class prog_real:
    # strings
    codice, denom, codprof, note, programmer = '', '', '', '', ''

    # bytes
    AxDin, b_out, asse_w, vd = 0, 0, 0, 0

    # ints
    Out, numpassi, qUscita = 0, 0, 0

    # longs
    len, l_arco = 0, 0

    # misc
    p = ''

    But it's not necessary.

    To restrict the range of values in the variables you would have to
    manually check them each time before or after they change, or otherwise
    force some kind of error/exception that occurs when the variable
    contains data you don't want.


    # assign values
    prog_real.codice = 'ABC'
    print('codice: ' + prog_real.codice)
    prog_real.codice = 'DEF'
    print('codice: ' + prog_real.codice)
    prog_real.codice = 123
    print('codice: ' + str(prog_real.codice))


    And as shown in the last 2 lines, a variable can accept any type of
    data, even after it's been initialized with a different type.

    b = 1
    print(type(b))
    <class 'int'>
    b = 'ABC'
    print(type(b))
    <class 'str'>


    Python data types: https://www.digitalocean.com/community/tutorials/python-data-types

    A VB to python program:
    https://vb2py.sourceforge.net

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From DFS@21:1/5 to DFS on Wed Nov 30 14:03:31 2022
    On 11/30/2022 1:07 PM, DFS wrote:
    On 11/30/2022 6:56 AM, luca72.b...@gmail.com wrote:



    I don't do Python OO so someone else can answer better, but a simple
    port of your VB type would be a python class definition:

    class prog_real:
        codice, denom, codprof, note, programmer
        AxDin, b_out, asse_w, vd, Out, numpassi, qUscita
        len, l_arco, p


    Sorry for bad advice - that won't work. The other class definition that initializes the variables does work:

    class prog_real:
    # strings
    codice, denom, codprof, note, programmer = '', '', '', '', ''

    # bytes
    AxDin, b_out, asse_w, vd = 0, 0, 0, 0

    # ints
    Out, numpassi, qUscita = 0, 0, 0

    # longs
    len, l_arco = 0, 0

    # misc
    p = ''

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Weatherby,Gerard@21:1/5 to All on Wed Nov 30 20:12:16 2022
    Look at struct package: https://docs.python.org/3/library/struct.html


    From: Python-list <python-list-bounces+gweatherby=uchc.edu@python.org> on behalf of luca72.b...@gmail.com <luca72.bertolotti@gmail.com>
    Date: Wednesday, November 30, 2022 at 11:48 AM
    To: python-list@python.org <python-list@python.org>
    Subject: Vb6 type to python
    *** Attention: This is an external email. Use caution responding, opening attachments or clicking on links. ***

    Hello i have a byte file, that fill a vb6 type like:
    Type prog_real
    codice As String * 12 'hsg
    denom As String * 24 'oo
    codprof As String * 12 'ljio
    note As String * 100
    programmer As String * 11
    Out As Integer
    b_out As Byte 'TRUE = Sec FALSE= mm
    asse_w As Byte '3.zo Asse --> 0=Z 1=W
    numpassi As Integer 'put
    len As Long 'leng
    p(250) As passo_pg
    vd(9) As Byte 'vel.
    qUscita(9) As Integer 'quote
    l_arco As Long 'reserved
    AxDin As Byte 'dime
    End Type

    How i can convert to python
    -- https://urldefense.com/v3/__https://mail.python.org/mailman/listinfo/python-list__;!!Cn_UX_p3!ky-bqK3l3Sbj0O_n3_x6Yo2wFaF5xABKKYgjbIPH49rdLZ2W_vQlW2gGbSQ7uRplRBZn_wS4h4evqcYQZaR1aSNJaTXnRQ$<https://urldefense.com/v3/__https:/mail.python.org/mailman/
    listinfo/python-list__;!!Cn_UX_p3!ky-bqK3l3Sbj0O_n3_x6Yo2wFaF5xABKKYgjbIPH49rdLZ2W_vQlW2gGbSQ7uRplRBZn_wS4h4evqcYQZaR1aSNJaTXnRQ$>

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)