1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to? Incorporate tables from HELP into batch file

Discussion in 'Support' started by Steve Fabian, Jun 19, 2013.

  1. Steve Fabian

    Joined:
    May 20, 2008
    Messages:
    3,523
    Likes Received:
    4
    Many HELP pages contain tables where one column of the table shows a set of codes and another column shows the corresponding text. In some cases the codee is used as a parameter to a command or function, in others it is a return value. For example, @WININFO - input parameter value v. what information will be returned means; @DRIVETYPE - return value vs. description. @SERVER has two informal tables: one for the second parameter's value v. what will be returned, and for the case when the second parameter's value is Type lists what each bit of the returned value means.

    One often wants to display the text associated with the codes. Embedding them in a batch file (or for that matter in any other source code) permanently is not a good option, since a new version (or sometimes a new build) of TCC may change the table (hopefully only by additions). I am looking for a way to access the information dynamically from TCC. One possible method is by including it in one or more files included in the TCMD distribution.

    Charles Dye made a big step in this direction in the @SHFOLDER function of his uistuff.dll by permitting the use of the CSIDL names.
     
  2. samintz

    samintz Scott Mintz

    Joined:
    May 20, 2008
    Messages:
    1,188
    Likes Received:
    11
    I don't mean to be a smart-ass (sometimes it just happens), but isn't that what HELP is for?

    Pressing F1 brings up help.
     
  3. Steve Fabian

    Joined:
    May 20, 2008
    Messages:
    3,523
    Likes Received:
    4
    That's what I currently do - highlight the relevant HELP page section, copy and paste it into my .BTM, and go through major editing effort to convert it to code. When the next HELP version comes out, repeat it. The original effort I do not mind. It's the repeat effort that I wish to avoid. If each table became a text file, or - better yet - all the tables become a database directly accessible from TCC, new versions would not require new effort for old features. This is in the same sense as I did not like that the 4DOS variables _APMAC and _APMBATT were renamed to _ACSTATUS and _BATTERYPERCENT in 4NT without change in function simply because the information was obtained through a different mechanism. (I admit the new names are more descriptive, and in the long run better.)

    Maybe I should submit this as a feature request. Oops, I cannot without withdrawing my vote from some other request.
     
  4. samintz

    samintz Scott Mintz

    Joined:
    May 20, 2008
    Messages:
    1,188
    Likes Received:
    11
    Steve, what's wrong with hard coding the values? They really don't change that often and, if I had to guess, you don't use all the values anyway.
     
  5. Steve Fabian

    Joined:
    May 20, 2008
    Messages:
    3,523
    Likes Received:
    4
    Oh, and using F1 to interpret a compound value, e.g., %@SERVER[machine,Type] - each bit of which is an independent return code - is not exactly child's play.
     
  6. Steve Fabian

    Joined:
    May 20, 2008
    Messages:
    3,523
    Likes Received:
    4
    I do use hard coding now; my worry is that some table changed since I first embedded it and I did not update the code.

    I came across yet another table I am now interested in, and was looking how I could automate the code generation. The mechanical manipulation of the table was easy. Building a test for 26 bits as 26 separate "if ... echo ..." form is tedious. I thought of loading the code/string pairs into an array I can cycle through, which requires loading the array first. A separate file with @FILEARRAY would do it. Another method is using explicit SET for each array element. I was looking at HERE-document and TEXT command. If I am not using an external file which is part of the TCMD distribution, I prefer to have the code in a single file, without an external data file, for maintainability. I suppose I could put the data in a stream file of the batch file, but my backup USB devices are VFAT, I am worried about losing them.

    If this were a one-time deal, I'd have just done it, but it comes up every now and then, so I appreciate new ideas.
     
  7. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,883
    Likes Received:
    29
    Hmmm! With HH.EXE you could de-compile the help file. Then with little (?) scripts, extract the tables you want from the HTM files and save them as you wish. This (below) wasn't too hard and the result is almost in a usable format. I turned tags into newlines and then got rid of empty lines. Quite possibly, TPIPE could do that (and more).
    Code:
    v:\jphelp> grep "A LAN" f_server.htm | sed -e "s/<[^<>]*>/\n/g" | grep .
    1
    A LAN Manager workstation
    2
    A LAN Manager server
    4
    Any server running with Microsoft SQL Server
    8
    Primary domain controller
    0x10
    Backup domain controller
    0x20
    Server running the Timesource service
    0x40
    Apple File Protocol server
    0x80
    Novell server
    0x100
    LAN Manager 2.x domain member
    0x200
    Server sharing print queue
    0x400
    Server running dial-in service
    0x800
    Unix/Linux server
    0x1000
    Windows Server 2003, Windows XP, Windows 2000, or Windows NT
    0x2000
    Server running Windows for Workgroups
    0x4000
    Microsoft File and Print for NetWare
    0x8000
    Windows server that is not a domain controller
    0x10000
    Server that can run the browser service
    0x20000
    Server running a browser service as backup
    0x40000
    Server running the master browser service
    0x80000
    Server running the domain master browser
    0x400000
    Windows 95/98/Me
    0x1000000
    Server clusters available in the domain
    0x2000000
    Terminal Server
    0x4000000
    Cluster virtual servers available in the domain
    0x40000000
    Servers maintained by the browser
    0x80000000
    Primary domain
     
  8. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,883
    Likes Received:
    29
    P.S. That table was all on one line (11292 characters long).
     
  9. Joe Caverly

    Joined:
    Aug 28, 2009
    Messages:
    659
    Likes Received:
    8
  10. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,883
    Likes Received:
    29
    (Of course) my example works just as well with the online help page. And though TPIPE could probably to it, I'm not up to that struggle right now.
    Code:
    v:\> type "http://jpsoft.com/help/f_server.htm" | grep "A LAN" | sed -e "s/<[^<>]*>/\n/g" | grep ."
    1
    A LAN Manager workstation
    2
    A LAN Manager server
    (snip)
     
  11. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,883
    Likes Received:
    29
    It wasn't too much of a struggle. It's too bad TPIPE's /input can't be a URL.
    Code:
    v:\> type "http://jpsoft.com/help/f_server.htm" | tpipe /grep=3,0,0,0,0,0,0,0,"A LAN" /replace=4,0,0,0,0,0,0,0,0,"<.*>","\r\n" /simple=10
    1
    A LAN Manager workstation
    2
    A LAN Manager server
    (snip)
     
  12. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,883
    Likes Received:
    29
    After spending some time reading about Perl regex syntax, I formatted it more nicely.
    example.png
     
  13. Joe Caverly

    Joined:
    Aug 28, 2009
    Messages:
    659
    Likes Received:
    8
    I am adding this to my TPIPE tips and tricks notes. Great example.

    Joe
     
  14. Steve Fabian

    Joined:
    May 20, 2008
    Messages:
    3,523
    Likes Received:
    4
    Vince, it looks very nice, but I would have to hand copy character by character the command, since .png files are graphics, not text.

    Joe, is there a URL where I can find this?
    --
    Thanks, Steve
     
  15. Joe Caverly

    Joined:
    Aug 28, 2009
    Messages:
    659
    Likes Received:
    8
    My TPIPE tips and tricks notes is just a KeyNote file that I have on my local system, with information I have gleaned from forum messages about TPIPE. Each note contains sample code, with URL links to the forum message from which the sample code originated. If you do a Google search for

    Code:
    tpipe site:jpsoft.com
    and limit it to the past year, you will find most of the TPIPE tips and tricks that I have in my KeyNote file.

    Joe

    A couple of examples;
    http://jpsoft.com/forums/threads/tpipe-examples.4417/
    http://jpsoft.com/forums/threads/for-those-wanting-to-learn-tpipe.5008/
     
  16. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,883
    Likes Received:
    29
    Code:
    v:\> type "http://jpsoft.com/help/f_server.htm" | tpipe /grep=3,0,0,0,0,0,0,0,"A LAN" /replace=4,0,0,0,0,0,0,0,0,"<.*>","\r\n" /simple=10 /replace=4,0,0,0,0,0,0,0,0,"^([01248x]+)\r\n","$1\t" /replace=4,0,0,0,0,0,0,0,0,"^([01248x]{1,7}?\t)","$1\t"
     

Share This Page