Editing CSV file
Moderators: Dorian (MJT support), JRL
-
- Newbie
- Posts: 18
- Joined: Wed Aug 18, 2010 5:51 pm
Editing CSV file
Trying to multiply "cost" by 1.5 and input the result in the next row as "price"
Price always shows up as simply "price" rather than the numerical value
Let>k=1
Label>start
setfocus>Excel*
dderequest>Excel,C:\Program Files\screen-scraper basic edition\ItemsforVendio.txt,R%k%C9,cost,10
StringReplace>cell,SPACE,,cell
Let>a = 1.5
Let> price = %cost% * %a%
MessageModal>cost
MessageModal>%price%
Let>LineToWrite=,,,,,,,,,price
WriteLn>newtest.csv,result,LineToWrite
If>k>5,finish
Let>k=k+1
Goto>start
Label>finish
Price always shows up as simply "price" rather than the numerical value
Let>k=1
Label>start
setfocus>Excel*
dderequest>Excel,C:\Program Files\screen-scraper basic edition\ItemsforVendio.txt,R%k%C9,cost,10
StringReplace>cell,SPACE,,cell
Let>a = 1.5
Let> price = %cost% * %a%
MessageModal>cost
MessageModal>%price%
Let>LineToWrite=,,,,,,,,,price
WriteLn>newtest.csv,result,LineToWrite
If>k>5,finish
Let>k=k+1
Goto>start
Label>finish
-Ben
-
- Automation Wizard
- Posts: 1101
- Joined: Fri Jan 07, 2005 5:55 pm
- Location: Somewhere else on the planet
Assuming that what you posted is the actual code, you need to remove all those spaces in
Code: Select all
Let>a = 1.5
Let> price = %cost% * %a%
-
- Newbie
- Posts: 18
- Joined: Wed Aug 18, 2010 5:51 pm
Thanks
Thanks it looks a little better except now i'm getting:
5*1.5 as "price"
5*1.5 as "price"
Code: Select all
Let>k=1
Label>start
setfocus>Excel*
dderequest>Excel,C:\Program Files\screen-scraper basic edition\ItemsforVendio.txt,R%k%C9,cost,10
StringReplace>cell,SPACE,,cell
Let>a=1.5
Let>price=%cost%*%a%
MessageModal>cost
MessageModal>price
Let>LineToWrite=,,,,,,,,,price
WriteLn>newtest.csv,result,LineToWrite
If>k>10,finish
Let>k=k+1
Goto>start
Label>finish
-Ben
-
- Newbie
- Posts: 18
- Joined: Wed Aug 18, 2010 5:51 pm
-
- Automation Wizard
- Posts: 1101
- Joined: Fri Jan 07, 2005 5:55 pm
- Location: Somewhere else on the planet
Does this this code work? If so, and yours doesn't, then it would seem there is "something" wrong with cost as passed by dde.
Code: Select all
Let>cost=5
Let>a=1.5
Let>price=%cost%*%a%
MessageModal>cost
MessageModal>price
-
- Newbie
- Posts: 18
- Joined: Wed Aug 18, 2010 5:51 pm
-
- Automation Wizard
- Posts: 1101
- Joined: Fri Jan 07, 2005 5:55 pm
- Location: Somewhere else on the planet
Thanks JRL, I was thinking it might be a TAB
Code: Select all
To test replace MessageModal>cost with MDL>#%cost%# you should get
#5#
if there's a TAB or CRLF you may get
#5 # or
#5
#
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Just use Trim to get rid of tabs/spaces/line feeds.
Trim>cost,cost
Trim>cost,cost
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
Doh... Apparently some people read Help.Marcus wrote:Just use Trim.....
Help for trim says it removes spaces and control characters. I wrote the following to determine exactly what "control characters" means. What I found was that Trim> removes every ASCII character from decimal 0 (hex 00) to decimal 32 (hex 20). Or the first 33 ASCII characters. It leaves the rest alone.
Thanks Marcus.
Code: Select all
VBSTART
VBEND
Let>kk=-1
Repeat>kk
Add>kk,1
Let>vStr=string
VBEval>chr("%kk%"),vChar
Let>vStr=%vStr%%vChar%
Trim>vStr,vStr
Length>vStr,vLen
WriteLn>%temp_dir%Trim_Results.txt,wres,ASCII character %kk% - %vLen% - %vStr%
Until>kk=255
mdl>complete