Windows Scripting
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Iron Speed
Go Back   ASP Free ForumsSystem AdministrationWindows Scripting

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
  #1  
Old November 14th, 2007, 03:10 PM
kmtiburona kmtiburona is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2007
Posts: 2 kmtiburona User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 16 m 38 sec
Reputation Power: 0
Basic VBScript Class Loop determine biggest and smallest!

I am in a very basic VBScript class in college where we need to write a program using a loop, reading from a program. I have reading from the file and writing to a new one and all the calculations I have, but how can I work in an if statement to compare the number to the previous one. I know this is a lot of code, but I figure it will help, thanks in advance!
Code:
Option Explicit
Dim rts,rfso,wts,wfso,Nums,x,b,c,ct,totx,e,f,q

Call OpenFiletoRead(rts,rfso)
Call OpenFiletoWrite(wts,wfso)

Call Heading(wts)

Call GetNums(nums,rts)

Do until csng(nums) >= 9999
	
	Call count(ct)
	totx=csng(totx) + csng(nums)
	If csng(nums) > csng(tot
	b=fir(nums)
	c=sec(nums)
	Call Table(nums,wts)
	Call GetNums(nums,rts)
Loop




wts.write "--------------------------------------------------------"
wts.writeblanklines 2
wts.write "Average " & average(nums)
wts.writeblanklines 1
wts.write "Largest " & e
wts.writeblanklines 1
wts.write "Smallest " & f

Call closefile(rts,rfso,wts,wfso)



'-------------------SUBS------------------

Sub GetNums(nums, rts)
	nums = rts.read(7)
End Sub 

Sub count(ct)
	If nums < 9999 Then
	ct = csng(ct) + 1
	End If
End Sub


Sub Table(nums, wts)
	Call leftjustify(nums, 15)
	wts.write nums 
	Call rightjustify(b,15)
	wts.write b
	Call rightjustify(c,25)
	wts.write c
	wts.writeblanklines 2
End Sub

Sub Heading(wts)
	wts.write "x          Int(x)          Int(10x + .5)/10     "
	wts.writeblanklines 1
	wts.write "------------------------------------------------"
	wts.writeblanklines 2
End Sub

'------------------------------------------------

Sub OpenFiletoWrite(wts,wfso)
	Dim filename
	Set wfso=createobject("Scripting.Filesystemobject")
	Filename="ProjectNums.txt"
	Set wts=wfso.createtextfile(filename,True)
End Sub

Sub rightjustify(myNumber,n)
	Dim colwidth
	Do until cint(colwidth) > cint(n)
		myNumber=" " & cstr(myNumber)
		colwidth= len(cstr(myNumber))
		Loop
		colwidth=0
		n=0
End Sub

Sub Openfiletoread(rts,rfso)
	Dim filename
	Set rfso=createobject("Scripting.filesystemobject")
	filename="TheNumbers.txt"
	Set rts=rfso.opentextfile(filename,1,False)
End Sub

Sub closefile(rts,rfso,wts,wfso)
	rts.close
	wts.close
	Set wts=Nothing
	Set wfso=Nothing
	Set rts=Nothing
	Set rfso=Nothing
End Sub

Function fir(a)
	fir=int(a)
End Function

Function sec(a)
	Dim y
	y= (10*csng(a)) + .05
	sec=int(y)/10
End Function
	
	
Sub LeftJustify(myWord, n)
	Dim colwidth
	Do until cint(colWidth) > cint(n)
		myWord = cstr(myWord) & " "
		colwidth = cint(len(cstr(myword)))
	Loop
	colwidth = 0
	n = 0
End Sub

Function average(a)
	average= csng(totx)/csng(ct)
End Function

Last edited by Shadow Wizard : November 20th, 2007 at 01:46 AM. Reason: added [Code] and [/Code] tags around code please do that yourself next.

Reply With Quote
  #2  
Old November 20th, 2007, 01:48 AM
Shadow Wizard's Avatar
Shadow Wizard Shadow Wizard is online now
Moderator From Beyond
Click here for more information.
 
Join Date: Sep 2004
Location: Israel
Posts: 26,397 Shadow Wizard User rank is General 5th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 5th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 5th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 5th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 5th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 5th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 5th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 5th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 5th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 5th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 5th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 5th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 5th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 5th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 5th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 5th Grade (Above 100000 Reputation Level)  Folding Points: 313769 Folding Title: Super Ultimate Folder - Level 1Folding Points: 313769 Folding Title: Super Ultimate Folder - Level 1Folding Points: 313769 Folding Title: Super Ultimate Folder - Level 1Folding Points: 313769 Folding Title: Super Ultimate Folder - Level 1Folding Points: 313769 Folding Title: Super Ultimate Folder - Level 1Folding Points: 313769 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 3 Months 1 Week 3 Days 22 h 32 m 47 sec
Reputation Power: 1311
--moved to the Windows Scripting forum.
indeed, that's lot of code. please tell us what's the relevant part
meaning what lines/function you're having trouble with.

Reply With Quote
  #3  
Old November 20th, 2007, 08:35 AM
kmtiburona kmtiburona is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2007
Posts: 2 kmtiburona User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 16 m 38 sec
Reputation Power: 0
Quote:
Originally Posted by Shadow Wizard
--moved to the Windows Scripting forum.
indeed, that's lot of code. please tell us what's the relevant part
meaning what lines/function you're having trouble with.


Nevermind, we went over it in class and I can't figure out how to delete this. I did say in my original post I don't need help w/ functions, just how to compare a number going through the loop to the previous one.

Reply With Quote
  #4  
Old November 20th, 2007, 08:40 AM
jmurrayhead's Avatar
jmurrayhead jmurrayhead is offline
The Drunken Moderator
Click here for more information.
 
Join Date: Feb 2004
Location: Reston, VA, USA
Posts: 12,944 jmurrayhead User rank is General 7th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 7th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 7th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 7th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 7th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 7th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 7th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 7th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 7th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 7th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 7th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 7th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 7th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 7th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 7th Grade (Above 100000 Reputation Level)jmurrayhead User rank is General 7th Grade (Above 100000 Reputation Level)  Folding Points: 76972 Folding Title: Intermediate FolderFolding Points: 76972 Folding Title: Intermediate FolderFolding Points: 76972 Folding Title: Intermediate FolderFolding Points: 76972 Folding Title: Intermediate Folder
Time spent in forums: 3 Months 2 Days 21 h 31 m 12 sec
Reputation Power: 1456
Facebook
Members aren't allowed to delete posts for the sake of the knowledge base. However, if you would post your solution, it may help someone else with a similar problem.
__________________
jmurrayhead

Did I help you out? Make me popular by clicking the icon!

New Members:Proper way to post a question

Powered by ASP.Net

Reply With Quote
Reply

Viewing: ASP Free ForumsSystem AdministrationWindows Scripting > Basic VBScript Class Loop determine biggest and smallest!


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway