Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: using host_addr, hostip_toname, hostname_toip

  1. #1
    Member
    Join Date
    Jan 2018
    Location
    France
    Age
    71
    Posts
    69
    Rep Power
    13

    using host_addr, hostip_toname, hostname_toip

    Hi,

    I'm looking to use host_addr and I receive a run time error popup

    saying "HOST_ADDR" variable not defined or mispelled keyword

    I guess I have to
    uses "the good module"
    
    But the help pages does not indicate the name of the needed module

    I tried
    uses "inet"
    uses "lan"
    
    without success.

    Please . . . . .

    Regards,

    Dany
    Last edited by dco045; 28-01-2018 at 22:55.

  2. #2
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10
    Check \SampleScripts\INet\INet_GetIPs.tBasic
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  3. #3
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10
    Module is iNet
    Your computer can have multiple network cards and cards can be activate/deactivated on the fly. For example if you connect to WiFi networks or you activate a VPN over a network.

    Uses "inet"Uses "Console"
    
    
    Long lCount
    
    
    While %true
      PrintL "Number of interfaces present:", INET_GetInterfaces
      PrintL "------------------------------------------"
      
      PrintL "-##-[IP           ] [SubNet       ] [Type]"
      PrintL "------------------------------------------"
      For lCount = 1 To INET_GetInterfaces
        PrintL  Format$(lCount, " 00"), _
                Using$("\             \", INET_GetIp(lCount)), _
                Using$("\             \", INET_GetSubNet(lCount)), _
                Format$(INet_GetIpType(lCount), "0000")
      Next
      
      PrintL "------------------------------------------"
      PrintL
      PrintL " Press [ESC] to finish"
      PrintL " 4 seconds for the next auto refresh  "
      PrintL " any key to refresh "
      PrintL "------------------------------------------"
      If WaitKey(4) = "[ESC]" Then Exit While
      Cls
    Wend
    
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  4. #4
    Member
    Join Date
    Jan 2018
    Location
    France
    Age
    71
    Posts
    69
    Rep Power
    13
    Hi Eros,

    Your example works fine. But what about functions :

    n = HOST_ADDR [(nIndex)]
    
    s = HOSTIP_TONAME(nIP)
    
    n = HOSTNAME_TOIP(sHost)
    
    as they appear in online and offline Helpfiles ?

    Regards,

    Dany

  5. #5
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10
    If you press F1 while above a keyword you should get help about that keyword.
    Help should say which module that keyword is inside.
    The mentioned functions are inside TcpUdp module.
    TcpUdp module implements some functionalities to create a Tcp or Udt server or use Tcp or Udp protocol to connect to a server that exposes some functionality over network.
    There are some scripts inside \SampleScripts\TcpUdp\ directory that can show how to create a network communication using Tcp and Udp

    Example on your mentioned functions:
    uses "TcpUdp"uses "Console"
    
    
    string sHost = "www.google.com"
    Long nIp
    
    
    nIp = HOSTNAME_TOIP(sHost)                      '---How your DNS resolve a host name
    printl "HOSTNAME_TOIP of", sHost, "is", nIp
    printl "IP_ToString is", IP_ToString(nIp)       '---Translate Ip address into human one
    printl "HOSTIP_TONAME is", HOSTIP_TONAME(nIp)   '---How your DNS knows the ip
    WaitKey
    
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  6. #6
    Member
    Join Date
    Jan 2018
    Location
    France
    Age
    71
    Posts
    69
    Rep Power
    13
    Quote Originally Posted by ErosOlmi View Post
    If you press F1 while above a keyword you should get help about that keyword.
    Help should say which module that keyword is inside.
    The mentioned functions are inside TcpUdp module.
    TcpUdp module implements some functionalities to create a Tcp or Udt server or use Tcp or Udp protocol to connect to a server that exposes some functionality over network.
    There are some scripts inside \SampleScripts\TcpUdp\ directory that can show how to create a network communication using Tcp and Udp

    Example on your mentioned functions:
    uses "TcpUdp"uses "Console"
    
    
    string sHost = "www.google.com"
    Long nIp
    
    
    nIp = HOSTNAME_TOIP(sHost)                      '---How your DNS resolve a host name
    printl "HOSTNAME_TOIP of", sHost, "is", nIp
    printl "IP_ToString is", IP_ToString(nIp)       '---Translate Ip address into human one
    printl "HOSTIP_TONAME is", HOSTIP_TONAME(nIp)   '---How your DNS knows the ip
    WaitKey
    
    HI Eros,
    But the reason I posted on these function is that the relevant

    uses "tcpudp"
    
    doesn't appear in help files either online or offline.

    As I said in my PM of 21 january, I begin using ThinBasic and I make huge use of help files, and before disturbing TB developpers , be sure that, I try, try, press F1, read help, look in SamplesScripts. My F1 key is completely worn out.
    So for this precise case, help files may be completed.


    Regards,


    Dany
    Last edited by dco045; 31-01-2018 at 13:15.

  7. #7
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10
    Strange

    What thinBasic version are you using?
    You can check thinBasic verion inside thinAir/Help menu/About thinAIr/

    Please check here for online but you should also see in offline, both are generated from the same source:
    http://www.thinbasic.com/public/prod...tml?tcpudp.htm
    http://www.thinbasic.com/public/prod...?host_addr.htm
    http://www.thinbasic.com/public/prod...tname_toip.htm

    Yes, help is not so much exhaustive ... I admit, but should be there.

    Latest thinBasic version is 1.10.4.0: http://www.thinbasic.com/community/s...inBasic-1-10-x
    It is Beta but quite stable
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  8. #8
    Member
    Join Date
    Jan 2018
    Location
    France
    Age
    71
    Posts
    69
    Rep Power
    13
    Quote Originally Posted by ErosOlmi View Post
    Strange

    What thinBasic version are you using?
    You can check thinBasic verion inside thinAir/Help menu/About thinAIr/

    Please check here for online but you should also see in offline, both are generated from the same source:
    http://www.thinbasic.com/public/prod...tml?tcpudp.htm
    http://www.thinbasic.com/public/prod...?host_addr.htm
    http://www.thinbasic.com/public/prod...tname_toip.htm

    Yes, help is not so much exhaustive ... I admit, but should be there.

    Latest thinBasic version is 1.10.4.0: http://www.thinbasic.com/community/s...inBasic-1-10-x
    It is Beta but quite stable
    Hi Eros.

    Version 1.9.16.17 . I only downloaded 1.10 on a sandbox PC. I am prudent with versions labelled as Beta. But if you say 'quite stable ' ? I'll try it.

    The problem comes because I was looking for Hex$() syntax, using either online(web) or offline help.
    Using index view, I then saw host_addr, hostip_toname and hostname_toip functions, I remembered a tool I had on Unix. I wanted to try, but by this way, we do not know the necessary ' uses "module " '.
    That's why I asked that question. Maybe it's worth remembering the "uses" in the pages of these functions.


    As we say in France : "ça va sans dire, mais ça va mieux en le disant" , "It goes without saying, but it's better by saying it", "Inutile dire, ma è meglio dirlo"


    Best regards,


    Dany

  9. #9
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10
    As you well know writing documentation is one of the hardest part in a project.
    Also writing documentation is something you learn, sometimes from others having more experience.
    thinBasic Help material is my only experience in writing documentation and I missed suggestions from professionals.
    So I'm here to absorb indications and do better.

    The idea that I've followed is:


    I have to admit it is not so clear and immediate to understand.

    Now ... what to change in order to make module/keywords/features dependency without the need to change all thinBasic keywords?

    Modules_In_Help.JPG
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  10. #10
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732
    Hi Eros, Dany,

    my experience with documentation is that no matter how good it is, people prefer to not read it a all and jump to action first. That does not mean there is no point to do documentation, but that the guidance of the user can be approached differently for some cases.

    So what about the following hint for the programmer - when thinBASIC finds unknown keyword ( error 30 ) or Variable not defined or misspelled Keyword ( error 18 ), thinBasic could take the token found and try to find it in all installed modules, hinting the user.

    To give example:
    uses "Console"
    
    print strformat$("45 degress to radians is {1}", DegToRad(45))
    
    waitkey
    
    This now reports "Variable not defined or misspelled Keyword" for token "DegToRad".
    With my suggestion, thinBASIC would lookup tokens defined in all installed modules and as a result give hint:
    "Consider adding Uses "Math" to your script"

    I think it would be perfectly okay to have the module token list done statically (file generated during thinBASIC installation creation).


    Petr
    Last edited by Petr Schreiber; 07-02-2018 at 22:41.
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

Page 1 of 2 12 LastLast

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •