Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disappearing commas...

Status
Not open for further replies.

AndiChoin

Programmer
May 7, 2003
6
US
I am working on a script that writes the contents of a field in Access to a text file and then parses the text and translates it from the drawing command line instructions it was in into AutoCAD command line. However, I have run into a problem. In the command line it is in, the directions are in the following format:

r30 d16 l30 u16

This would mean go right 30, down 16, left 30, and up 16. Translating this isn't a problem, but when the command line has a diagonal line it would say:

rd3,3

This would mean draw a line from your starting point to a coordinate which is three right and three down from where you were. Translating this also would not be a problem except for some reason the comma disappears.

The script I have converts the input command line to all lowercase letters using the LCase() function and then when I go to get the string of interest instead of it reading

u19 ul3,3 l3 dl3,3 d19 r9

it reads

u19 ul33 l3 dl33 d19 r9

This disappearance of commas makes it impossible to translate the command. Does anyone know why the commas would disappear?

-Andi
 
I don't use these specific programs, but it looks like you've got commas in strings causing you problems. You might try to express them differently.

Try the following string:
"u19 ul3','3 l3 dl3','3 d19 r9"
or possibly:
"u19 ul3" & "," & "3 l3 dl3" & "," & "3 d19 r9"

You may just have to play with this a bit. Since commas are used to delimit strings, they are sometimes more difficult to carry in strings. You may also want to use the Chr(44) command instead.
 
You may very well be right, but the problem is that I am not writing the string, I am just taking it out of a memo field in Access. There are some two or three thousand records in the Access table which have commas in the string. How can I recognize the comma in the original string to know that it is there? I dont' really think it would be practical to change all of the commas to another character inorder to avoid the problem... unless I could maybe run a replace on all of the records in Access to change the commas to say semi-colons which are readable...

Do you have any other ideas?

-Andi
 
So, your code reads from a field in Access. Try stepping through the code and see if it reads it correctly. My guess is that it's generating the error when you use the string. What are you doing with the string?

 
Some background: I work for a local government and our land management software has building drawings in it. These building drawings are in a special format with both a picture and a command line, however the format they are currently in can't not be brought directly into ESRI GIS software. Inorder to get the drawing into the GIS system, it was determined that the best way would be to take the command line format that the land management software uses and translate this into AutoCAD and create drawings from the command line which could be brought into GIS.

I am reading the field from Access and writing the contents to a text file. (The text in the text file is correct.) I then read the text file and parse the text to translate the command format the text is in to AutoCAD command. The AutoCAD command is then written to another text file to later be run through AutoCAD and grenerate a drawing. Somewhere between when I read the text from the text file and work with it, the commas disappear. A relatively simple example:

Text in Access field (same as text in text file):
1wd=b (r67 d36 l25 u12 l14 d12 l28 u36)

What the script which parses the text sees:
r67 d36 l25 u12 l14 d12 l28 u36

End AutoCAD command line:
pline 0,0 @67,0 @0,-36 @-25,0 @0,12 @-14,0 @0,-12 @-28,0 @0,36

This works great and wonderful and produces a perfect picture in AutoCAD. Even the more updated command lines which can use the syntax ru6;8 instead of r6 u8 work perfect. The problem only appears with the commas. Example:

Text in Access field (same as text in text file):
1WD=B(U19 UL3,3 L3 DL3,3 D19 R9)

What the script which parses the text sees:
u19 ul33 l3 dl33 d19 r9

End AutoCAD command line:
pline 0,0 @0,19 @0, @-33,0 @-3,0 @0,- @-33,0 @0,-19 @9,0

When it should read:
pline 0,0 @0,19 @-3,3 @-3,0 @-3,-3 @0,-19 @9,0

I know why the AutoCAD code is getting all messed up and that is because to parse the text the script is looking for the commas to tell it where the number ends and the next number starts.
-Andi
 
If anyone is interested, I solved my problem by replacing the commas with semi-colons in a new field and then parsed out the text. This worked just fine.

-Andi
 
Hi - I am looking for links to VBA for ARCGIS (ESRI) forums or programming sites. I have got some good VB6 background but there is some problems when I port my code to VBA for ARCGIS and any help would be appreciated.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top