4 Replies - 433 Views - Last Post: 03 November 2015 - 04:41 PM Rate Topic: -----

#1 Ameri  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 43
  • Joined: 26-October 13

problem using "mkdir" in a for loop!

Posted 03 November 2015 - 03:12 PM

Hey there,

In Tcl/Tk language, I've written something like this:

for {set i 0} {$i<=60 } {incr i 1} { 

file mkdir Drifts/Scale_Factor=$i

}


my problem is that I want my built files to be named by $i/10 (not by $i), i.e., Scale_Factor=0.1 Scale_Factor=0.2 ... Scale_Factor=6.0! Does anyone know how to do that?! writing something like "file mkdir Drifts/Scale_Factor=$i/10" definitely doesn't work!

Thanks!

Is This A Good Question/Topic? 0
  • +

Replies To: problem using "mkdir" in a for loop!

#2 andrewsw  Icon User is offline

  • blow up my boots
  • member icon

Reputation: 6544
  • View blog
  • Posts: 26,526
  • Joined: 12-December 12

Re: problem using "mkdir" in a for loop!

Posted 03 November 2015 - 03:15 PM

A complete guess, but worth a try, is for line 2 to be $j = $i/10 and then use $j in line 3. Never used Tcl so don't know if $j needs to declared somewhere.

A second complete guess is that maybe {$i/10} would work, but I'm only basing this on a wild assumption based on those few lines ;)

Despite appearances I'm not encouraging guesses, but thought you might try these while awaiting someone who actually knows Tcl.

This post has been edited by andrewsw: 03 November 2015 - 03:18 PM

Was This Post Helpful? 1
  • +
  • -

#3 Ameri  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 43
  • Joined: 26-October 13

Re: problem using "mkdir" in a for loop!

Posted 03 November 2015 - 03:27 PM

View Postandrewsw, on 03 November 2015 - 03:15 PM, said:

A complete guess, but worth a try, is for line 2 to be $j = $i/10 and then use $j in line 3. Never used Tcl so don't know if $j needs to declared somewhere.

A second complete guess is that maybe {$i/10} would work, but I'm only basing this on a wild assumption based on those few lines ;)/>

Despite appearances I'm not encouraging guesses, but thought you might try these while awaiting someone who actually knows Tcl.


Thanks for your guesses Andrew, but non of them worked here. :)
Was This Post Helpful? 0
  • +
  • -

#4 andrewsw  Icon User is offline

  • blow up my boots
  • member icon

Reputation: 6544
  • View blog
  • Posts: 26,526
  • Joined: 12-December 12

Re: problem using "mkdir" in a for loop!

Posted 03 November 2015 - 03:58 PM

Tcl is a bit odd ;)

I'll have one more go:
file mkdir Drifts/Scale_Factor=[expr {$i/10}]
# or
file mkdir "Drifts/Scale_Factor=[expr {$i/10}]"

Was This Post Helpful? 1
  • +
  • -

#5 Ameri  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 43
  • Joined: 26-October 13

Re: problem using "mkdir" in a for loop!

Posted 03 November 2015 - 04:41 PM

View Postandrewsw, on 03 November 2015 - 03:58 PM, said:

Tcl is a bit odd ;)/>

I'll have one more go:
file mkdir Drifts/Scale_Factor=[expr {$i/10}]
# or
file mkdir "Drifts/Scale_Factor=[expr {$i/10}]"


Now it's better, thanks :) But the problem is that it only makes 6 files (1, 2, 3, 4, 5, 6) Actually it doesn't make file for 0.1 , 0.2, ... the numbers which are not integers!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1