Computing.Net > Forums > Programming > IVO, Mechanix , Can this be done!

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

IVO, Mechanix , Can this be done!

Reply to Message Icon

Name: dtech10
Date: November 20, 2005 at 09:31:21 Pacific
OS: Win XP Pro
CPU/Ram: PIII 1Gb/1Gb
Comment:

Hi
I'm trying to figure out if I can insert varables into of a set command.
No luck so far.

ie..
set Days=SunMonTueWedThuFriSat
set Pos=3
set WDay=%Days:~%Pos%,3%
echo %WDay%
rem should echo Mon




Sponsored Link
Ads by Google

Response Number 1
Name: pr3d
Date: November 20, 2005 at 11:27:49 Pacific
Reply:

Like this?

@ECHO OFF
SET DAYS=ECHO. | DATE | FIND /I "Current"
ECHO %DAYS%


Quoth the raven, `Nevermore.'rp$D


0

Response Number 2
Name: IVO
Date: November 20, 2005 at 12:44:50 Pacific
Reply:

Yes, you can do it just enabling the delayed expansion of variables. That way you can "index" an array type environment variable like the one you posted.
Pay attention to mark with ! the outer variable to be indexed as in your rearranged code

@Echo Off
SetLocal EnableDelayedExpansion

Set Days=SunMonTueWedThuFriSat
Set Pos=3
Set WDay=!Days:~%Pos%,3!
Echo %WDay%

EndLocal
Rem should echo Mon

The sample should be self explanatory, but I'm at your side if you need any support.

Good scripting
IVO


0

Response Number 3
Name: dtech10
Date: November 20, 2005 at 14:47:30 Pacific
Reply:

Hi
Works great thanks IVO for your time and knowledge.
I Tryed Delayed Expansion and put the ! symbols
arount the !Pos! variabled, never throught about putting them around the whole statememt.
Much Appreciated.
Harry



0

Response Number 4
Name: Mechanix2Go
Date: November 20, 2005 at 23:12:08 Pacific
Reply:

Hi IVO,

Thanks; that helps with something else I'm working on.

d10,

I guess I should be flattered to be mentioned in the same breath with IVO.

:0)


If at first you don't succeed, you're about average.

M2


0

Response Number 5
Name: dtech10
Date: November 21, 2005 at 07:55:34 Pacific
Reply:

Hi
I've learned alot from both of yours and IVO coding.
Programmers can learn alot from studying other people's coding.
It's not easy, but there no right or wrong way to write a program, maybe that's why they call it a art.
Give 3 programmers some code to write and there all do if differently.
Many Thanks to you both and Others.


0

Related Posts

See More



Response Number 6
Name: IVO
Date: November 22, 2005 at 03:23:17 Pacific
Reply:

Hi dtech10,

I agree, programming is "science art" (much like Sci-Fi), a discipline where heart and mind get togheter as Pascal could say.

There are strong coding principles that have to be taken in account as structured and object oriented programming, but if you don't feel the underlying flavour you miss the right solution.

Thanks again for your (M2's too) kind words.
IVO from Milano, Italy


0

Response Number 7
Name: Mechanix2Go
Date: November 22, 2005 at 03:29:47 Pacific
Reply:

d10,

I saw a book on programming called "Nailing Jelly to a Tree".

That pretty much sums it up.


If at first you don't succeed, you're about average.

M2


0

Sponsored Link
Ads by Google
Reply to Message Icon

C++ How to save calculate... Launch secure process



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: IVO, Mechanix , Can this be done!

htaccess - can this be done? www.computing.net/answers/programming/htaccess-can-this-be-done/801.html

Can this be done? www.computing.net/answers/programming/can-this-be-done/871.html

Can booting be stopped? www.computing.net/answers/programming/can-booting-be-stopped/810.html