Login | |
|
 |
RE: Combining Ubound with loop? >> If Ubound = 10... - 6/5/2008 8:19:30 PM
|
|
 |
|
| |
TKS
Posts: 187
Score: 0
Joined: 5/16/2008
Status: offline
|
Here's the explanation of this problem I sent off to TNO: _______________________________ Hey TNO, I've reached coders block, and need help. Here's what I've got so far: This code snippet keeps adding 1 onto a, making the type of File Progression I'm looking for: Option Explicit Const ForReading = 1, ForWriting = 2, ForAppending = 3 Dim FSO: Set FSO = CreateObject("Scripting.FileSystemObject") Dim a: a = 1 Dim post: post = post.value Do Until Not FSO.FileExists("IF" & a & ".html") a = a + 1 Loop Dim Obj: Set Obj = FSO.CreateTextFile("IF" & a & ".html", ForAppending, True) Obj.WriteLine("<!--asdf-->") Obj.WriteLine (post) Obj.Close While this code snippet counts how many times "<!--asdf-->" is inserted into IFa.html: Const ForReading = 1,ForWriting = 2, ForAppending = 8 Dim objFSO: Set objFSO = CreateObject("Scripting.FileSystemObject") Dim objFile: Set objFile = objFSO.OpenTextFile("IFa.html", ForReading) Dim strText: strText = objFile.ReadAll objFile.Close msgBox UBound(Split(strText, "<!--asdf-->")) What I'm trying to do, is combine the First and Second code snippets like this: If Ubound(Split(strText, "<!--asdf-->")) = 10 Then Create the next File in Progression (a+1) Else Append to the current File in Progression (Obj.WriteLine "<!--asdf-->" & (post)) __________________ So the idea is to Create the next Text File in Progression, when the Ubound of the current Text File is: Ubound(Split(strText, "<!--asdf-->")) = 10 ___________________ Hope this makes sense, -TKS
|
|
| |
|
|
|
 |
RE: Combining Ubound with loop? >> If Ubound = 10... - 6/6/2008 2:41:48 AM
|
|
 |
|
| |
TKS
Posts: 187
Score: 0
Joined: 5/16/2008
Status: offline
|
quote:
ORIGINAL: dm_4ever So basically you're trying to limit the number of "asdf" occurances per file? Hey dm_4ever, Yes, basically Thanks for taking an interest. -TKS
|
|
| |
|
|
|
 |
RE: Combining Ubound with loop? >> If Ubound = 10... - 6/7/2008 1:48:57 AM
|
|
 |
|
| |
TNO
Posts: 1284
Score: 12
Joined: 12/18/2004
From: thenewobjective.com
Status: offline
|
Try to think the problem through using pseudocode if you have to. If you get used to thinking in the language you work in, you could solve problems much easier. Don't worry about IF something can be done, think about the steps for doing it or the result you want. All programming languages are Turing Complete and can solve pretty much any problem there is (assuming enough time & space is available). Without knowing too much about your program, I still honestly think an XML file would be alot easier for you to mess with than flat file progression. (the code will be alot smaller and faster too)
< Message edited by TNO -- 6/7/2008 1:51:50 AM >
_____________________________
To iterate is human, to recurse divine. -- L. Peter Deutsch
|
|
| |
|
|
|
 |
RE: Combining Ubound with loop? >> If Ubound = 10... - 6/8/2008 10:37:38 AM
|
|
 |
|
| |
TKS
Posts: 187
Score: 0
Joined: 5/16/2008
Status: offline
|
quote:
ORIGINAL: TNO Try to think the problem through using pseudocode if you have to. If you get used to thinking in the language you work in, you could solve problems much easier. Don't worry about IF something can be done, think about the steps for doing it or the result you want. All programming languages are Turing Complete and can solve pretty much any problem there is (assuming enough time & space is available). Without knowing too much about your program, I still honestly think an XML file would be alot easier for you to mess with than flat file progression. (the code will be alot smaller and faster too) Hey TNO, Yes, it really is a matter of time & space, but I'll figure it out eventually. As for you not really knowing my program, I'm not happy with my current code format, so I'm just going through a bit of code refining. I'll send you a copy soon.
|
|
| |
|
|
|
| |
|
|
 |
|
 |
|
|