Re: Script to format file to character number locations?

From: Matthias Tacke (Matthias_at_Tacke.de)
Date: 01/18/05


Date: Tue, 18 Jan 2005 18:47:21 +0100

Sean M. Loftus wrote:
> I'm getting a syntax error on this snippet...
>
> UML_PSInputScript.VBS(111, 14) Microsoft VBScript compilation error: Syntax
> error
>
> Function FixLength(sText,iSize)
> FixLength = Left(sText & Space(iSize), iSize)
> End Function
>
Just checked again without errors:
==screen=copy=================================================================
C:\test\vbs>cscript Fixlength.vbs
          1 2 3 4 5 6 7
1234567890123456789012345678901234567890123456789012345678901234567890123456789
First name starts at char 1
               Last name starts at char 15
                         account starts at char 25
                                                  email starts at char 50
Matthias WalteTacke don't know what you have Matthias.Tacke@web.de
==screen=copy=================================================================

' FixLength.vbs
option explicit
dim First, Last, account, email, RetString

First = "Matthias Walter"
Last = "Tacke"
account = "don't know what you have here"
email = "Matthias.Tacke@web.de"

RetString = FixLength(First, 14) & _
             FixLength(Last, 10) & _
             FixLength(account, 25) & email

wscript.echo " 1 2 3 4 5 6 7"
wscript.echo "1234567890123456789012345678901234567890123456789012345678901234567890123456789"
wscript.echo "First name starts at char 1"
wscript.echo " Last name starts at char 15"
wscript.echo " account starts at char 25"
wscript.echo " email starts at char 50"

wscript.echo RetString

Function FixLength(sText,iSize)
   FixLength = Left(sText & Space(iSize), iSize)
End Function

==screen=copy=================================================================
C:\test\vbs>Fixlength.vbs
          1 2 3 4 5 6 7
1234567890123456789012345678901234567890123456789012345678901234567890123456789
First name starts at char 1
               Last name starts at char 15
                         account starts at char 25
                                                  email starts at char 50
Matthias WalteTacke don't know what you have Matthias.Tacke@web.de
==screen=copy=================================================================

HTH

-- 
Gruesse  Greetings Saludos   Saluti    Salutations
Matthias
---------+---------+---------+---------+---------+---------+---------+


Relevant Pages

  • Re: Script to format file to character number locations?
    ... I still get a syntax error at the line - Function FixLength ... > First name starts at char 1 ... > Matthias WalteTacke don't know what you have Matthias.Tacke@web.de ... > dim First, Last, account, email, RetString ...
    (microsoft.public.scripting.vbscript)
  • Re: Script to format file to character number locations?
    ... I'm actually doing this from a "Do While" loop, is there a limitation of the ... > First name starts at char 1 ... > Matthias WalteTacke don't know what you have Matthias.Tacke@web.de ... > dim First, Last, account, email, RetString ...
    (microsoft.public.scripting.vbscript)
  • Re: tolower conflict with iostream?
    ... a string will not contain EOF. ... Although the 'is*' and 'to*' account for EOF, ... for negative values of 'char' on platforms where 'char' is a signed ...
    (comp.lang.cpp)
  • what is the best way of passing floats into a string
    ... That's why i also account for the extra +1. ... Is it even correct as i do not quite understand this, because i reserved memory for sizeof+1 which should be 5 bytes on my machine, yet it can write -10.000000 chars into my char * string. ... Does sprintf terminate a supplied string "%f %d" as well by the way? ...
    (comp.unix.programmer)
  • Re: Moving a char between accounts... ?
    ... >> something (my girlfriend bought her Wow copy and wanted to move her char ... > Between servers I've heard of, but giving a character to another account I ... justifiable account cases and not for ebay sellers. ...
    (alt.games.warcraft)

Loading