I wrote a loop wrong, and my brain is too broken to fix it.

Just starting out? Need help? Post your questions and find answers here.
Longshot
User
User
Posts: 12
Joined: Sat Sep 08, 2012 2:32 pm

I wrote a loop wrong, and my brain is too broken to fix it.

Post by Longshot »

Hey guys, I've been banging my head against this one for two days now, and I am clearly doing something obvious (except to me) wrong. Here is the input I've got:

Code: Select all

1
21
19.6G	/vmfs/volumes/4c361ff9-f5ab5aa5-411a-003048c85ebe/Support2 MCP/UnideskLayers/OS/Win7 x86 SP1
25.3G	/vmfs/volumes/4c361ff9-f5ab5aa5-411a-003048c85ebe/Support2 MCP/UnideskLayers/OS/XP SP3
52.5G	/vmfs/volumes/4c361ff9-f5ab5aa5-411a-003048c85ebe/Support2 MCP/UnideskLayers/OS/Win7 x64
49.3G	/vmfs/volumes/4c361ff9-f5ab5aa5-411a-003048c85ebe/Support2 MCP/UnideskLayers/OS/Essen Win7
146.7G	/vmfs/volumes/4c361ff9-f5ab5aa5-411a-003048c85ebe/Support2 MCP/UnideskLayers/OS
680.1M	/vmfs/volumes/4c361ff9-f5ab5aa5-411a-003048c85ebe/Support2 MCP/UnideskLayers/App/W7x86 View Agent 5.0
770.1M	/vmfs/volumes/4c361ff9-f5ab5aa5-411a-003048c85ebe/Support2 MCP/UnideskLayers/App/W7x86 CYGWIN
1.2G	/vmfs/volumes/4c361ff9-f5ab5aa5-411a-003048c85ebe/Support2 MCP/UnideskLayers/App/W7x86 ActiveTCL 8.5
732.1M	/vmfs/volumes/4c361ff9-f5ab5aa5-411a-003048c85ebe/Support2 MCP/UnideskLayers/App/W7x86 View Agent 5.1
2.6G	/vmfs/volumes/4c361ff9-f5ab5aa5-411a-003048c85ebe/Support2 MCP/UnideskLayers/App/SEP test 2 for Daktronics
444.1M	/vmfs/volumes/4c361ff9-f5ab5aa5-411a-003048c85ebe/Support2 MCP/UnideskLayers/App/Due whatever
380.1M	/vmfs/volumes/4c361ff9-f5ab5aa5-411a-003048c85ebe/Support2 MCP/UnideskLayers/App/W7x86 Trend Notifier
6.7G	/vmfs/volumes/4c361ff9-f5ab5aa5-411a-003048c85ebe/Support2 MCP/UnideskLayers/App/movado pub
13.4G	/vmfs/volumes/4c361ff9-f5ab5aa5-411a-003048c85ebe/Support2 MCP/UnideskLayers/App
946.3M	/vmfs/volumes/4c361ff9-f5ab5aa5-411a-003048c85ebe/Support2 MCP/UnideskLayers/User/DataMiner
2.7G	/vmfs/volumes/4c361ff9-f5ab5aa5-411a-003048c85ebe/Support2 MCP/UnideskLayers/User/TW-Win64-test-2
782.3M	/vmfs/volumes/4c361ff9-f5ab5aa5-411a-003048c85ebe/Support2 MCP/UnideskLayers/User/TMDS-TestVM
744.2M	/vmfs/volumes/4c361ff9-f5ab5aa5-411a-003048c85ebe/Support2 MCP/UnideskLayers/User/TommyTester
2.2G	/vmfs/volumes/4c361ff9-f5ab5aa5-411a-003048c85ebe/Support2 MCP/UnideskLayers/User/KurschunFinch
7.4G	/vmfs/volumes/4c361ff9-f5ab5aa5-411a-003048c85ebe/Support2 MCP/UnideskLayers/User


I have code that knows how many machines to look for, and the first line of my input tells you how many lines of output to expect (in this case it's number of directories). My code works, but it doesn't handle more than one machine.

Code: Select all

    Count = CountString(*plink\Output, #CRLF$) 
    For x = 1 To Count
      
      If CachePointCount > 0
        Debug CachePointCount
        For y = 1 To CachePointCount
          DirectoryCount = Val(StringField(*plink\Output, y + DirectoryCount, Chr(10)))
          Debug DirectoryCount
          
          For z = 2 To DirectoryCount
            Debug StringField(*plink\Output, z, Chr(10))
          Next
          x + DirectoryCount + 1
        Next
        Host()\Uptime = StringField(*plink\Output, x, Chr(10))
        Host()\Version = StringField(*plink\Output, x + 1, Chr(10))
        Host()\IP_Address = StringField(*plink\Output, x + 2, Chr(10))
        x + 2
Oh, the last bit with the "Host" is actually the output AFTER it gets the directory listing. So basically it gets a directory count, all the directories, and then it outputs 3 other things that are useful (1 line a piece). I think I need to reset the for loop for "y" so that it starts over.. maybe? I need sleep.
Longshot
User
User
Posts: 12
Joined: Sat Sep 08, 2012 2:32 pm

Re: I wrote a loop wrong, and my brain is too broken to fix

Post by Longshot »

I think I fixed it, hopefully it isn't terrible.

Code: Select all

Count = CountString(*plink\Output, #CRLF$) 
    For x = 1 To Count
      DirectoryCount = 0
      CurrentLine = 0
      If CachePointCount > 0
        For y = 1 To CachePointCount
          DirectoryCount = Val(StringField(*plink\Output, y, Chr(10))) + CurrentLine + 1
          
          For z = 2 To DirectoryCount
            Debug StringField(*plink\Output, z + CurrentLine, Chr(10))
          Next
          CurrentLine + DirectoryCount
          x + DirectoryCount
        Next
        Host()\Uptime = StringField(*plink\Output, x, Chr(10))
        Host()\Version = StringField(*plink\Output, x + 1, Chr(10))
        Host()\IP_Address = StringField(*plink\Output, x + 2, Chr(10))
        x + 2
This returns the right info in the debug now, just the directory listing... now to dump it into an array/list/map/whatever.
Post Reply