473,396 Members | 1,966 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

If...Else and variables and counts

I am trying to incorporate a count into a variable within an if...else
statement. Here is the code. I cant get it to work. perhaps someone
can assist me.

folder = window.prompt('starting folder','default');
picnumber = window.prompt('pictures taken?','default');
f2 = parseFloat(folder);
p2 = parseFloat(picnumber);
varAdd = f2+p2-1;
varImg = p2;
var9 = '000';
var99 = '00';
var999 = '0';
var9999 = '0000';

for (count1=f2;count1<=varAdd;count1++)
if (count1 <=9)
varFc = var9999 + count1 +;
else if (count1 <=99)
varFc = var9 + count1 +;
else if (count1 <=999)
varFc = var99 + count1 +;
else if (count1 <=9999)
varFc = var999 + count1 +;
else
varFc = + count +;
document.write('mkdir',varFc,'<br>');
Jul 20 '05 #1
2 1262

Tank <is*******@yahoo.com> wrote in message
news:99**************************@posting.google.c om...
I am trying to incorporate a count into a variable within an if...else
statement. Here is the code. I cant get it to work. perhaps someone
can assist me.

folder = window.prompt('starting folder','default');
picnumber = window.prompt('pictures taken?','default');
f2 = parseFloat(folder);
p2 = parseFloat(picnumber);
varAdd = f2+p2-1;
varImg = p2;
var9 = '000';
var99 = '00';
var999 = '0';
var9999 = '0000';

for (count1=f2;count1<=varAdd;count1++)
if (count1 <=9)
varFc = var9999 + count1 +;
else if (count1 <=99)
varFc = var9 + count1 +;
else if (count1 <=999)
varFc = var99 + count1 +;
else if (count1 <=9999)
varFc = var999 + count1 +;
else
varFc = + count +;
document.write('mkdir',varFc,'<br>');


Hi,
not best, but most similar to what you've got...

var folder = window.prompt('starting folder','default');
var picnumber = window.prompt('pictures taken?','default');
// SHOULD check the input for correctness, though

var f2 = parseFloat(folder);
var p2 = parseFloat(picnumber);

var varAdd = f2+p2-1;
var varImg = p2;
var var9 = '000';
var var99 = '00';
var var999 = '0';
var var9999 = '0000';
var varFc;

// for test purposes, display the init values before getting into the loop
document.write( 'start=' + f2 + '<br>');
document.write( 'pic=' + p2 + '<br>');
for (var count1=f2; count1<=varAdd; count1++)
{
if (count1 <=9)
varFc = var9999 + count1;
else if (count1 <=99)
varFc = var9 + count1;
else if (count1 <=999)
varFc = var99 + count1;
else if (count1 <=9999)
varFc = var999 + count1;
else
varFc = count1;
document.write('mkdir' + varFc + '<br>');
}
Jul 20 '05 #2
JRS: In article <99**************************@posting.google.com >, seen
in news:comp.lang.javascript, Tank <is*******@yahoo.com> posted at Tue,
10 Feb 2004 17:05:22 :-
I am trying to incorporate a count into a variable within an if...else
statement. Here is the code. I cant get it to work. perhaps someone
can assist me.


You appear to be trying to count with leading zeroes.

To do that most readily, increase the count by, say, one billion; and
after converting to a string use substring() to remove unwanted leading
digits. If the count K is 7,

document.write('mkdir', String(1e12+K).substr(9), '<br>')

will write mkdir0007 .

But evidently you need to study javascript syntax, as well as
algorithms.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: J-P | last post by:
Hi, I have a Python script interacting with a specialized C numerical library. The whole program does quite a lot of number crunching as should be running for a couple of hours. However, it...
6
by: Bart Nessux | last post by:
Should an if statement have a corresponding else statement? Or, is it OK to have an if statement by itself. For completeness, it seems the two should be together, but from experience I know that a...
5
by: Steven Bethard | last post by:
I have a list of dictionaries. Each dictionary holds counts of various 'words', e.g.: py> countdicts = I need to select dicts with the constraint that the number of each 'word' totalled...
28
by: Alf P. Steinbach | last post by:
A few days ago I posted an "Hello, world!" tutorial, discussed in <url: http://groups.google.no/groups?threadm=41ba4c0a.76869078@news.individual.net>. As I wrote then: <quote> because there...
5
by: WertmanTheMad | last post by:
Ive been playing with this for a few days and thought I might thow it out for seggestions. I have Several Queries that need counts returned The Queries are Mutually Exclusive meaning whatever...
4
by: mccoyn | last post by:
I have a class exported in a dll that has member variables I wish to access. When I do it I get an error C2039: 'myVar' : is not a member of myClass Here is an example of what my code looks like...
8
by: Paddy | last post by:
Proposal: Named RE variables ====================== The problem I have is that I am writing a 'good-enough' verilog tag extractor as a long regular expression (with the 'x' flag for...
2
by: requeth | last post by:
I have 12 possible error codes that can be placed in an attribute, and multiple attributes with this in an XML file. I am attempting to use an XSLT (which makes the data viewable to non technical...
28
by: sowmiyakc18 | last post by:
Please clear my doubt. When do we declare a variable to be a register variable? What is its significance? What are the conditions to be adhered to when register variables are passed between...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.