Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Assigned for Awk in another Section  (Read 15220 times)

0 Members and 1 Guest are viewing this topic.

BillRichardson

    Topic Starter


    Intermediate

    Thanked: 15
    Re: Assigned for Awk in another Section
    « Reply #30 on: December 27, 2009, 07:29:28 PM »
    I see your code, but  wonder where are awkbat6.bat and awkbat8.bat ? I have also run your code, but I have another question, if I have more data, like 309, 310, 311 etc...do i have to create awkbat09.bat , awkbat10.bat, awkbat11.bat etc as well?


    I posted  awkbat8.bat  but you said you were not interested.

    Awkbat6.bat and awkbat8.bat is  generic code that will work for any line as it did for line 301.

    I saw no other input files from Eldorado,Topic Starter, other than what was used.

    If  Ghostdog 74  is really interested in a batch solution, please post the code you have written and we will work together. I see no need to continue if you don't offer to help.

    « Last Edit: December 27, 2009, 07:40:44 PM by BillRichardson »
    Bill Richardson

    Geek-9pm


      Mastermind
    • Geek After Dark
    • Thanked: 1026
      • Gekk9pm bnlog
    • Certifications: List
    • Computer: Specs
    • Experience: Expert
    • OS: Windows 10
    Re: Assigned for Awk in another Section
    « Reply #31 on: December 27, 2009, 07:33:17 PM »
    Quote
    Only one person in 1000 have access to Awk (gawk ) files

    HuH?   ???

    gawk for windows is available to everybody with internet.

    http://gnuwin32.sourceforge.net/packages/gawk.htm

    BillRichardson

      Topic Starter


      Intermediate

      Thanked: 15
      Re: Assigned for Awk in another Section
      « Reply #32 on: December 27, 2009, 07:46:06 PM »
      HuH?   ???

      "gawk for windows is available to everybody with internet."

      http://gnuwin32.sourceforge.net/packages/gawk.htm

      My mistake.  I should have written that only one in 1000 ever  download or use awk (gawk).

      Thanks for the download site.

      http://gnuwin32.sourceforge.net/packages/gawk.htm

      I will try again.
      Bill Richardson

      ghostdog74



        Specialist

        Thanked: 27
        Re: Assigned for Awk in another Section
        « Reply #33 on: December 27, 2009, 08:20:11 PM »
        My mistake.  I should have written that only one in 1000 ever  download or use awk (gawk).
        this is baseless and is fit for the rubbish bin.

        ghostdog74



          Specialist

          Thanked: 27
          Re: Assigned for Awk in another Section
          « Reply #34 on: December 27, 2009, 08:38:07 PM »
          I posted  awkbat8.bat  but you said you were not interested.
          Awkbat6.bat and awkbat8.bat is  generic code that will work for any line as it did for line 301.
          you keep saying there is awkbat8.bat, but where is it ??
          and if they are generic, then why are there 2 versions of it awk6 and awk8?? if its generic, you should make it such that it works for all scenarios, no matter whether there are 309, 310 or 411 etc... why is there a need to call that many .bat files??

          I am really a beginner in batch, and my gawk solution solves the problem for data like this
          Code: [Select]
          C:\test>more file
          301|AF_ACC_BDL|774;
          301|AF_WMG_BDL|6660;
          301|AF_REP_BDL|4735;
          303|AF_ACC_BDL|1360;
          304|AF_ACC_BDL|5092;
          305|AF_ACC_BDL|32384;
          306|AF_ACC_BDL|80859;
          306|AF_REP_BDL|80875;
          308|AF_ACC_BDL|1418;
          308|AF_WLH_BDL|78273;
          308|AF_WSL_BDL|9990;
          308|AF_WFL_BDL|9998;
          309|AF_BLA_DDD|9999;
          309|AF_BAL_DDE|99999;
          309|AF_AAA_DDW|99959;
          310|AF_XXX_AAA|1345;
          310|AF_YYY_AAA|1235;
          310|AF_ZZZ_BBB|1245;

          C:\test>gawk -F"|" "{a[$1]=a[$1] FS $2 FS $3}END{for(i in a){ print i,a[i] } }" file
          310 |AF_XXX_AAA|1345;|AF_YYY_AAA|1235;|AF_ZZZ_BBB|1245;
          301 |AF_ACC_BDL|774;|AF_WMG_BDL|6660;|AF_REP_BDL|4735;
          303 |AF_ACC_BDL|1360;
          304 |AF_ACC_BDL|5092;
          305 |AF_ACC_BDL|32384;
          306 |AF_ACC_BDL|80859;|AF_REP_BDL|80875;
          308 |AF_ACC_BDL|1418;|AF_WLH_BDL|78273;|AF_WSL_BDL|9990;|AF_WFL_BDL|9998;
          309 |AF_BLA_DDD|9999;|AF_BAL_DDE|99999;|AF_AAA_DDW|99959;

          notice the data now has 309, 310?? (and you can add more), but it will still solve it, without adding extra code. Now all i am asking you , since you started to do this in batch, is to do the same.  I do not want to create  extra batch files. I just want to do it in one batch file...is that ok ?? can you show me how please, in batch ?




          BillRichardson

            Topic Starter


            Intermediate

            Thanked: 15
            Re: Assigned for Awk in another Section
            « Reply #35 on: December 27, 2009, 10:10:34 PM »
            GH,

            I'm not an expert with batch.   I suspect someone by email has given you a better batch solution.  My solution works. It is not a good design nor good code.  You need someone with more skill than I can offer.  Good Luck.  We are getting nowhere.  You need a new start.  Send me your new batch program.

            p.s. I got the gawk to work but not with the "all one line"  problem.
            As good as you are:  start from scratch and write a new batch for this problem
            « Last Edit: December 29, 2009, 11:24:51 AM by BillRichardson »
            Bill Richardson

            BC_Programmer


              Mastermind
            • Typing is no substitute for thinking.
            • Thanked: 1140
              • Yes
              • Yes
              • BC-Programming.com
            • Certifications: List
            • Computer: Specs
            • Experience: Beginner
            • OS: Windows 11
            Re: Assigned for Awk in another Section
            « Reply #36 on: December 28, 2009, 07:47:04 AM »
            I nominate this thread for *censored* of the year award.

            In fact, I find it so *censored*-ey that I might even require it's URL as part of a shebang line for BCScript files, heh.

            As good as you are:  start from scratch and write a new batch for this problem

            Why? he has a working AWK solution.

            Additionally I might wonder aloud why it is that you prefer batch over VBScript and JScript? your reasoning for awk is that it needs t be downloaded; but VBScript and JScript COME with ALL installations of windows since windows 98SE; any windows install past windows 95 (in fact, windows 95 has an OS update that I believe installs ActiveX Scripting engines such as VBS and JS) can use VBScript files. There is no reason to write a batch file if a working VBS or JS solution is provided, and works better. your statements that they are "easier to understand" are merely expressions of your own opinion and not actually decided through any real experience with people using VBS and batch files. batch files ALWAYS open a command prompt window; this, in and of itself, is enough to scare new users sometimes. VBScript, on the other hand, can be written to use WScript.exe and therefore use dialogs and Inputboxes rather then scary text mode Command prompt UI, so anybody who wouldn't understand VBScript would likely prefer the VBScript solution anyway, which brings up the point that the idea isn't always to educate the person seeking help as to the intricacies if the language, but rather to simply provide a solution; sometimes a batch solution, sometimes VBScript, but there is absolutely, positively, no reason to lean towards batch unless the OP has expressed a EXPLICIT interest in only batch-based solutions, and even in those cases a VBScript can be adapted to run from within a batch script anyway so the point is moot. If the OP then becomes interested in learning VBScript, they can be referred to a number of fine resources. I might even conclude that VBScript is EASIER for a new user to understand; BASIC statements roughly translate into plain english:

            Code: [Select]
            For Each Value In Collection
                Print Value
            Next Value

            Is a *censored* of a lot easier to read then:

            Code: [Select]
            For /f %%P in (`type collection`) do echo %%P

            Sure, they both have similarities, but the batch version is not exactly plain english, there are far too many semantics that would need to be explained, such as why there are percent signs, and of course why it is that when the OP uses the command at the command prompt you need only a single % sign. Batch being "simple" is a huge misperception by a large number of users, even the base language as used in Pure DOS is relatively confusing.

            Only language I can think of being more "english-like" then BASIC  might be python; I don't have extensive experience but I will not argue the repeated point Ghostdog makes that it is easy t olearn for a beginner. It may not ALWAYS be the best choice (which I believe is where I and ghostdog disagree) but it certainly isn't a bad starting point for anybody.

            Batch Is. Trust me, I know from experience that learning batch programming first can become a hurdle later on when learning a less domain-restricted programming language. When I first started with QBASIC after using batch, it took some time to realize that I wasn't writing commands, I was writing statements; my previous experience with batch was certainly only a minor hurdle, but a hurdle nonetheless. It's not necessarily a bad thing to learn batch; it's a bad thing to try to learn another language from the perspective of batch semantics, which I believe would hold true for nearly any programming language; they have different "spirits" to steal the term from Bruce McKinney, Author of "HardCore Visual Basic"; for example, the C "spirit" pretty much says the programmer is in control of everything; memory allocations, deallocations, everything must be done by them, and it is this "total control" concept that lends itself to streamlined, low-level C code. Visual Basic tries to hide a good number of things about windows programming from the programmer, sparing them the troubles of creating and maintaining window handles, sending and recieving window messages, etc. There is of course some allocation to be done, such as dimensioning variables (optional, actually, defaulting to the Single data type in Version 1 and to Variant In versions after, unless a Deftype statement is found in the declarations section of a module, in which case the default type for that module is the specified type), but once a variable goes out of scope, it is automatically destroyed. To some extend, C will do this; for static variables declared within procedures. However, pointers will NOT be automatically deallocated in C and this must be dealt with properly. The "spirit" if batch is the very essence of a "glue" language, that is, calling of a number of programs that were compiled in other languages (things like format, find, etc) in predefined orders, and with very specific and basic Control flow that was pretty much a spaghetti of gotos. It has evolved past this stage but it is still a glue language at it's core, and a glue language is limited in far too many ways to count and at the same time its powerful by the sum of the parts that is happens to glue together.

            One of the things that batch can use as a glued piece is AWK, just as VBS code can be written to a file and executed from a batch, so to can AWK be executed from the command line, as an extension of batch.

            Consider for a moment that almost every batch program calls into another program to do it's work, and all batch programs rely on cmd.exe to perform at the very least basic interpretation of the file; ther eis no denying that it has limitations, and one of these limitations can be found in text processing. warranted, it CAN do text processing, but it takes experience and patience to get it working; on the other hand, scripting languages like VBS have a number of string functions at their disposal, and their Date/time manipulation is simply not matched by any feasible batch solution.

            I was trying to dereference Null Pointers before it was cool.

            BillRichardson

              Topic Starter


              Intermediate

              Thanked: 15
              Re: Assigned for Awk in another Section
              « Reply #37 on: December 28, 2009, 03:44:03 PM »
              I nominate this thread for *censored* of the year award.

              BC  writes many lines of nonsense  and says nothing and offers no code of any kind as a solution.  What happened to the Perl Solution from BC?   Where is there a solution of any kind offered by BC?

              Is Bc the dilettante of the Hope Board?

              dil·et·tante (dl-tänt, dl-tänt, -tänt, -tnt, -tnt)
              n. pl. dil·et·tantes also dil·et·tan·ti (-tänt, -tn-)
              1. A dabbler in  a field of knowledge. See Synonyms at amateur.

              Superficial; amateurish.
              Bill Richardson

              BC_Programmer


                Mastermind
              • Typing is no substitute for thinking.
              • Thanked: 1140
                • Yes
                • Yes
                • BC-Programming.com
              • Certifications: List
              • Computer: Specs
              • Experience: Beginner
              • OS: Windows 11
              Re: Assigned for Awk in another Section
              « Reply #38 on: December 28, 2009, 04:19:12 PM »
              Learn to read, troll.
              I was trying to dereference Null Pointers before it was cool.

              BillRichardson

                Topic Starter


                Intermediate

                Thanked: 15
                Re: Assigned for Awk in another Section
                « Reply #39 on: December 28, 2009, 05:17:53 PM »
                Bill Richardson

                BC_Programmer


                  Mastermind
                • Typing is no substitute for thinking.
                • Thanked: 1140
                  • Yes
                  • Yes
                  • BC-Programming.com
                • Certifications: List
                • Computer: Specs
                • Experience: Beginner
                • OS: Windows 11
                Re: Assigned for Awk in another Section
                « Reply #40 on: December 29, 2009, 07:47:45 AM »
                Where is BC's  code?

                What code? I never promised any code.
                I was trying to dereference Null Pointers before it was cool.

                Salmon Trout

                • Guest
                Re: Assigned for Awk in another Section
                « Reply #41 on: December 29, 2009, 08:56:34 AM »
                Let's boycott him.