Forcing a variable to be a string

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
DWEd
Newbie
Posts: 12
Joined: Fri Jul 15, 2016 2:54 pm

Forcing a variable to be a string

Post by DWEd » Wed Oct 18, 2017 12:56 pm

Hi, I can't work out how to ensure that a variable isn't interpreted as an integer.
I'm pulling in data from an excel spreadsheet with a car make and model in different cells then combining them.
so for example I have a spreadsheet with:
A1:Ford
B1:Mondeo
C1:2000-20005

I am then loading the spreadsheet in with DBConnect and DBQuery

however if I try and create a variable containing all three imported cells I end up with
"Ford Mondeo -5"
rather than
Ford Mondeo 2000-2005
as it's calculating the 2000-2005 rather than treating it as a string.

User avatar
Marcus Tettmar
Site Admin
Posts: 7378
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: Forcing a variable to be a string

Post by Marcus Tettmar » Wed Oct 18, 2017 3:00 pm

I think we'd need to see the Excel file and script example. Are you able to share?
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

DWEd
Newbie
Posts: 12
Joined: Fri Jul 15, 2016 2:54 pm

Re: Forcing a variable to be a string

Post by DWEd » Wed Oct 18, 2017 4:02 pm

I've worked out what was happening, and learned something new in macro scheduler at the same time ;)
I worked out how to set a numerical calculation as a string:
let>test={"123-123"}
makes test=123-123 rather than
let>test=123-123
which is 0
however my actual issue was with DBQuery, the data was actually "- 1990-2005" with a - at the start. If you opened this csv in excel it shows the cell as "=- 1990-2005" despite no = being in the csv, this then returns the value -15 which macro scheduler accepts. so the data "corruption" was happening before it was imported, and macro scheduler seems happy to hold the variable as a string rather than calculating it.

Cheers

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts