Jump to content
Developer Wiki and Function Reference Links ×

Export Worksheet > TXT File (Append and WriteLn)


Recommended Posts

Hi Everyone,

 

I Have a worksheet in Vectorworks, with the CMYK values and, the code/nome of product.

I need to convert this in .xml, like this below:

<D>0.000000,0.117647,0.156863,0.419608</D>

<N>SW 0001&#160; - Mulberry Silk</N>

 

I trying made this with this Script below:

But I have problem with separation after 0 (.), My export script doesn't put dot (.), Decimal point, after 0.

 

MY EXPORT PLUG IN:

000000,3584070,6858410,113725
R129Abóbora

 

I WANT IT TO BE LIKE THIS:

0.000000,0.3584070,0.6858410,0.113725

R129Abóbora

 

PROCEDURE ExportTXTCMYK;

VAR
fileName : STRING;
hplan : HANDLE;
vcode, vnome, vcyan, vmangen, vyellow, vblack : STRING;
numRows, numColumns : INTEGER;
vlin : INTEGER;
vboo: BOOLEAN;

BEGIN

    fileName := 'Suvinil_CMYK.txt';
    Append(fileName);
    
    hplan := GetObject('Teste2l');
    IF (hplan <> NIL) THEN GetWSRowColumnCount(hplan, numRows, numColumns);

vlin := 2;

REPEAT
    
    vcode := GetCellStr(hplan, vlin, 1);
    vnome := GetCellStr(hplan, vlin, 2);
    vcyan := GetCellStr(hplan, vlin, 7);
    vmangen := GetCellStr(hplan, vlin, 8);
    vyellow := GetCellStr(hplan, vlin, 9);
    vblack := GetCellStr(hplan, vlin, 10);

    WriteLn(vcyan,vmangen,vyellow,vblack,vcode,vnome);
    WriteLn;

    {WriteLn('Teste Teste');}
    
    vlin := vlin+1;

UNTIL(vlin>numRows);
    
vboo := EOF('Teste_CMYK.txt');
Close('Teste_CMYK.txt');

END;
RUN (ExportTXTCMYK);

Sherwin-Williams Colors.xml

Captura de Tela 2018-08-14 às 12.04.21.png

Edited by Paulo Renan Ferrari
Link to comment

I think this is due to your system language settings using the comma as the decimal separator.

 

Probably the most straight forward way to solve this is to convert to strings using the format you want and then writing the strings to the file. That way you will have full control over the output.

 

Num2Str should get you a string value, but it will probably still have the comma as the decimal separator. Loop through using something like the following:

 

ChangePos:=Pos(',',MyStringVariable);

Delete(MyStringVariable,ChangePos,1);

Insert(MyStringVariable,Changepos,'.');

 

HTH.

  • Like 1
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...