• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

substring and error - why?

M

mrkramer

#1
Hello

I'm newbie on vbs programing. I'm trying use subsstring method, but I
get error "object required 'helo great world'" and code:800A01A08.

-------
dim str
str="helo great world"
wscript.echo str.substring(5,10)
---------------------


It is wierd for me because documentation says:

strVariable.substring(start, end)
"String Literal".substring(start, end)


It is possible that substring method is only in Jscript?
 

My Computer

R

Richard Mueller [MVP]

#2
"mrkramer" <hhfm@newsgroup> wrote in message
news:4bc9b4cc$0$19174$65785112@newsgroup

> Hello
>
> I'm newbie on vbs programing. I'm trying use subsstring method, but I get
> error "object required 'helo great world'" and code:800A01A08.
>
> -------
> dim str
> str="helo great world"
> wscript.echo str.substring(5,10)
> ---------------------
>
>
> It is wierd for me because documentation says:
>
> strVariable.substring(start, end)
> "String Literal".substring(start, end)
>
>
> It is possible that substring method is only in Jscript?
The expression "str.substr(5,10)" implies that substr is a method of a
object str. The variable str is not an object reference, but a string. All
object references in VBScript are established with "Set" statements, as in:

Set objShell = CreateObject("Wscript.Shell")

There is no substring function in VBScript (that I am aware of). Your
example looks more like .NET to me. I note that when I search for syntax
examples I frequently find .NET examples. I don't know what documentation
you found, but the example is definitely not VBScript. I believe the Mid
function does what you intend. For example:

str = "helo great world"
Wscript.Echo Mid(str, 5, 10)

This will echo the string "great worl". Or, since the third parameter of the
Mid function is optional, you could try:

Wscript.Echo Mid(str, 5)

which would result in "great world". For VBScript documentation, download
the help file script56.chm at this link:

http://www.microsoft.com/downloads/...48-207d-4be1-8a76-1c4099d7bbb9&DisplayLang=en

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--
 

My Computer

M

mrkramer

#3
Richard Mueller [MVP] napisal w dniu 2010-04-17 15:59:

> "mrkramer"<hhfm@newsgroup> wrote in message
> news:4bc9b4cc$0$19174$65785112@newsgroup

>> Hello
>>
>> I'm newbie on vbs programing. I'm trying use subsstring method, but I get
>> error "object required 'helo great world'" and code:800A01A08.
>>
>> -------
>> dim str
>> str="helo great world"
>> wscript.echo str.substring(5,10)
>> ---------------------
>>
>>
>> It is wierd for me because documentation says:
>>
>> strVariable.substring(start, end)
>> "String Literal".substring(start, end)
>>
>>
>> It is possible that substring method is only in Jscript?
>
> The expression "str.substr(5,10)" implies that substr is a method of a
> object str. The variable str is not an object reference, but a string. All
> object references in VBScript are established with "Set" statements, as in:
>
> Set objShell = CreateObject("Wscript.Shell")
>
> There is no substring function in VBScript (that I am aware of). Your
> example looks more like .NET to me. I note that when I search for syntax
> examples I frequently find .NET examples. I don't know what documentation
> you found, but the example is definitely not VBScript. I believe the Mid
> function does what you intend. For example:
>
> str = "helo great world"
> Wscript.Echo Mid(str, 5, 10)
>
> This will echo the string "great worl". Or, since the third parameter of the
> Mid function is optional, you could try:
>
> Wscript.Echo Mid(str, 5)
>
> which would result in "great world". For VBScript documentation, download
> the help file script56.chm at this link:
>
> http://www.microsoft.com/downloads/...48-207d-4be1-8a76-1c4099d7bbb9&DisplayLang=en
>
I'm using exactly the same help file. There is substring method, but as
I said previously, i'm afraid that is Jscript method only.
Mid function is good and is similar to substring. I'll use mid function.
Thanks for help
 

My Computer

M

Mayayana

#4
| >
http://www.microsoft.com/downloads/...48-207d-4be1-8a76-1c4099d7bbb9&DisplayLang=en
| >
| I'm using exactly the same help file. There is substring method, but as
| I said previously, i'm afraid that is Jscript method only.

Yes. They used to provide separate help files, but now
it's all in the WSH help. (Apparently they were spending
too much on paper with multiple CHMs. :)

Now you have to check at the top of the topic page to
make sure you've got a VBScript topic.

There is a file called vbscrip5.chm. I have a copy. You might
do a search for that if you want to have a straight VBS reference.
 

My Computer

R

Richard Mueller [MVP]

#5
"mrkramer" <hhfm@newsgroup> wrote in message
news:4bc9c2fe$0$19175$65785112@newsgroup

> Richard Mueller [MVP] napisal w dniu 2010-04-17 15:59:

>> "mrkramer"<hhfm@newsgroup> wrote in message
>> news:4bc9b4cc$0$19174$65785112@newsgroup

>>> Hello
>>>
>>> I'm newbie on vbs programing. I'm trying use subsstring method, but I
>>> get
>>> error "object required 'helo great world'" and code:800A01A08.
>>>
>>> -------
>>> dim str
>>> str="helo great world"
>>> wscript.echo str.substring(5,10)
>>> ---------------------
>>>
>>>
>>> It is wierd for me because documentation says:
>>>
>>> strVariable.substring(start, end)
>>> "String Literal".substring(start, end)
>>>
>>>
>>> It is possible that substring method is only in Jscript?
>>
>> The expression "str.substr(5,10)" implies that substr is a method of a
>> object str. The variable str is not an object reference, but a string.
>> All
>> object references in VBScript are established with "Set" statements, as
>> in:
>>
>> Set objShell = CreateObject("Wscript.Shell")
>>
>> There is no substring function in VBScript (that I am aware of). Your
>> example looks more like .NET to me. I note that when I search for syntax
>> examples I frequently find .NET examples. I don't know what documentation
>> you found, but the example is definitely not VBScript. I believe the Mid
>> function does what you intend. For example:
>>
>> str = "helo great world"
>> Wscript.Echo Mid(str, 5, 10)
>>
>> This will echo the string "great worl". Or, since the third parameter of
>> the
>> Mid function is optional, you could try:
>>
>> Wscript.Echo Mid(str, 5)
>>
>> which would result in "great world". For VBScript documentation, download
>> the help file script56.chm at this link:
>>
>> http://www.microsoft.com/downloads/...48-207d-4be1-8a76-1c4099d7bbb9&DisplayLang=en
>>
> I'm using exactly the same help file. There is substring method, but as I
> said previously, i'm afraid that is Jscript method only.
> Mid function is good and is similar to substring. I'll use mid function.
> Thanks for help
Yes, now I see in script56.chm that substring is a jscript function. I find
the Mid function under VBScript functions (not methods) in the contents.

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--
 

My Computer

M

mrkramer

#6
Mayayana napisal w dniu 2010-04-17 16:41:

> |>
> http://www.microsoft.com/downloads/...48-207d-4be1-8a76-1c4099d7bbb9&DisplayLang=en
> |>
> | I'm using exactly the same help file. There is substring method, but as
> | I said previously, i'm afraid that is Jscript method only.
>
> Yes. They used to provide separate help files, but now
> it's all in the WSH help. (Apparently they were spending
> too much on paper with multiple CHMs. :)
>
> Now you have to check at the top of the topic page to
> make sure you've got a VBScript topic.
>
> There is a file called vbscrip5.chm. I have a copy. You might
> do a search for that if you want to have a straight VBS reference.
>
>
Ok. I downloaded vbscript5.chm. But i have one more question. Do you
know do somewhere is chm documentation regarding Internet explorer
object. Any available which i've found is in web version.
 

My Computer

M

Mayayana

#7
| Ok. I downloaded vbscript5.chm. But i have one more question. Do you
| know do somewhere is chm documentation regarding Internet explorer
| object. Any available which i've found is in web version.

That's a tough one. I've never seen Microsoft offer a download.
It's a very extensive set of docs, if you include the DOM. Generally
you have to get MSDN to get the whole thing. But there is another
possibility:

http://download.cnet.com/Windows-Server-2003-R2-Platform-SDK-ISO-Download/3000-10248_4-10731094.html

That link is for the Server 2003 SDK. There are similar links
around for other SDKs. Microsoft has been gradually moving
almost all docs into the main platform SDK and putting the
help files in HXS format ("HTML Help 2") rather than CHM.
So for a lot of docs you have to download the whole thing, and
you have to install a Help2 reader. (There's no standalone
version.) Help2 is especially aimed at use with VS.Net.

I know all of this because I happen to be looking into docs
myself lately. I have an older copy of the MSDN docs and
reader. I have no interest in .Net. But I'd like to have more
recent docs on hand that cover XP. The upshot of that is that
I've just written a script to convert HXS to CHM and have made
a CHM copy of the entire SDK help. The file with IE and the
DOM is inet.hxs (or inet.chm) which is vast. It's about 35 MB.

There may be better sources of docs than the server 2003
SDK. I picked that myself because 1) the later SDKs seem to
be more .Net-centric 2) I don't care about .Net and 3) I don't care
about any APIs in Vista/7 that are not supported by XP.

You might try looking aound for inet.chm. If you find it (and
other SDK CHMs) I'd be interested to know where they turned
up. I just looked myself and found dead links to inet.chm on
the Microsoft server. Which doesn't surprise me. Lastely it's "the
..Net way or the highway" as far as Microsoft is concerned.
If you want to start downloading SDKs and converting HXS files,
see here:

http://www.jsware.net/jsware/scripts.php5#tochm

The current download is a set of files for converting 1 HXS to
CHM in several steps. With my updated version you just drop a
folder onto a single script and it converts all HXSs in the folder.
But I've literally been working on that over the past few days.
I don't quite have the updated version online yet.
 

My Computer

P

Paul Randall

#9
"Mayayana" <mayayana@newsgroup> wrote in message
news:ORUIHQp3KHA.1452@newsgroup

> Update:
>
> The HXStoCHM converter is now online. A simple
> drag-drop script that will auto-convert any number
> of HXS files to CHM:
>
> http://www.jsware.net/jsware/scripts.php5#tochm
So what process do you use to get the HSX files you are interested in? I
suppose you could have a test computer with an OS that can easily be
reimaged, and install a SDK, search for the HSXs of interest, convert those
to CHMs, and then save them for later use. Or do you use MSI to extract the
files of interest from the SDK installation package?

-Paul Randall
 

My Computer

M

Mayayana

#10
| So what process do you use to get the HSX files you are interested in? I
| suppose you could have a test computer with an OS that can easily be
| reimaged, and install a SDK, search for the HSXs of interest, convert
those
| to CHMs, and then save them for later use. Or do you use MSI to extract
the
| files of interest from the SDK installation package?
|

I try to never install anything I don't have to,
in order to avoid system changes. And there's
really no reason to "install" docs.

If necessary I unpack an MSI. With the link I
provided to the Server 2003 SDK there are 2
options. The download is an ISO that ends up
being 3 MSIs (32- and 64-bit options) plus a
pile of CABs. The CABs have clear names. One
can just extract the CABs with "DOC" in the name.

The second, easier option is to use an unpacker:
http://www.jsware.net/jsware/msicode.php5

Copy the appropriate MSI and CABs from the CD
to a folder on disk. Drop the MSI onto the unpacker
script. The script will unpack the whole thing to a
folder hierarchy that mimics what would happen if
it were actually installed. The HXS and HXI files are
then easy to find. They're all extracted to the path:

ProgramFilesFolder\Microsoft Platform SDK for Windows Server 2003 R2\Help\

That folder can then just be dropped onto the
converter script to get CHMs.

I've been looking into writing another script to
create a "help collection". People who have MSDN 2001
or earlier installed can read the whole MSDN set
of SDK docs with a single index. That's a collection,
comprising a large number of "merged" CHMs.

Theoretically one can have multiple collections
by using a .COL file for each collection and registering
each collection in a file called hhcolreg.dat.
Unfortunately, there seems to be no official
documentation for this at all. I can only find snippets
of info. and I don't seem to be finding the whole story.
I *think* I should be able to create a .COL file that,
when clicked, would open the entire Server 2003 SDK
(or any other selected collection of CHMs) in the MSDN
library viewer, with a single, merged index. That would
mean that people using VS 5/6 with the CHM help system
could update their docs past 2001. (2001 was the last
MSDN version that was CHM.) But so far my experiments
just result in MSDN not working at all. :)

If anyone has thorough info. about how all of that
works I'd be interested to know. I have details about
how to write the two files. It's just not working so far.
 

My Computer

P

Paul Randall

#11
"Mayayana" <mayayana@newsgroup> wrote in message
news:OW4l5N93KHA.5084@newsgroup

>
> | So what process do you use to get the HSX files you are interested in?
> I
> | suppose you could have a test computer with an OS that can easily be
> | reimaged, and install a SDK, search for the HSXs of interest, convert
> those
> | to CHMs, and then save them for later use. Or do you use MSI to extract
> the
> | files of interest from the SDK installation package?
> |
>
> I try to never install anything I don't have to,
> in order to avoid system changes. And there's
> really no reason to "install" docs.
>
> If necessary I unpack an MSI. With the link I
> provided to the Server 2003 SDK there are 2
> options. The download is an ISO that ends up
> being 3 MSIs (32- and 64-bit options) plus a
> pile of CABs. The CABs have clear names. One
> can just extract the CABs with "DOC" in the name.
>
> The second, easier option is to use an unpacker:
> http://www.jsware.net/jsware/msicode.php5
>
> Copy the appropriate MSI and CABs from the CD
> to a folder on disk. Drop the MSI onto the unpacker
> script. The script will unpack the whole thing to a
> folder hierarchy that mimics what would happen if
> it were actually installed. The HXS and HXI files are
> then easy to find. They're all extracted to the path:
>
> ProgramFilesFolder\Microsoft Platform SDK for Windows Server 2003 R2\Help\
>
> That folder can then just be dropped onto the
> converter script to get CHMs.
>
> I've been looking into writing another script to
> create a "help collection". People who have MSDN 2001
> or earlier installed can read the whole MSDN set
> of SDK docs with a single index. That's a collection,
> comprising a large number of "merged" CHMs.
>
> Theoretically one can have multiple collections
> by using a .COL file for each collection and registering
> each collection in a file called hhcolreg.dat.
> Unfortunately, there seems to be no official
> documentation for this at all. I can only find snippets
> of info. and I don't seem to be finding the whole story.
> I *think* I should be able to create a .COL file that,
> when clicked, would open the entire Server 2003 SDK
> (or any other selected collection of CHMs) in the MSDN
> library viewer, with a single, merged index. That would
> mean that people using VS 5/6 with the CHM help system
> could update their docs past 2001. (2001 was the last
> MSDN version that was CHM.) But so far my experiments
> just result in MSDN not working at all. :)
>
> If anyone has thorough info. about how all of that
> works I'd be interested to know. I have details about
> how to write the two files. It's just not working so far.
Thanks for all that info. I will try to remember to run through the process
when I get home in a few weeks.

-Paul Randall
 

My Computer

Users Who Are Viewing This Thread (Users: 1, Guests: 0)