June 24, 2024, 06:15:56 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Compile issue

Started by ckoehn, July 20, 2011, 07:04:08 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ckoehn

I can compile the following code in EBASIC but not IWBASIC.  I am trying to add TTS and this lists what voices are available. What am I not doing right?

DECLARE CDECL EXTERN _dhPutRef(pointer pDisp, WSTRING szMember, ...),int

WINDOW w1
INT run=0
CONST VoiceList=1

OPENWINDOW w1,100,100,400,340,@TOOLWINDOW|@TOPMOST,0,"TTS Test",&main
CONTROL w1,@LISTBOX,"",10,10,200,100,@TABSTOP|@CTLISTNOTIFY|@VSCROLL,VoiceList

SETFONT w1,"Times New Roman",10,500,0,VoiceList

GetVoices(w1,VoiceList)

WAITUNTIL run=1
CLOSEWINDOW w1
END

SUB main
SELECT @MESSAGE
CASE @IDCREATE
CENTERWINDOW w1

CASE @IDCLOSEWINDOW
run=1

CASE @IDCONTROL
SELECT @CONTROLID
CASE VoiceList
SELECT @NOTIFYCODE
CASE 0
ENDSELECT
ENDSELECT
ENDSELECT
RETURN 0
ENDSUB

SUB Speak (string a,INT VoiceID)
IDispatch speech
IDispatch spvoice
speech = createComObject("Sapi.SPVoice","")
IF speech+0 <> NULL
GetComProperty(speech,"%o",&spvoice,".GetVoices.Item(%d)",VoiceID)
IF (spvoice <> NULL)
_dhPutRef(speech,L".Voice = %o",spvoice)
ENDIF
callObjectMethod(speech,".Speak(%s,0)",a)
speech->release()
ENDIF
ENDSUB

SUB GetVoices(WINDOW win,INT vList)
'clear list
WHILE GETSTRINGCOUNT(win,vList)>0
DELETESTRING win,vList,0
ENDWHILE
IDispatch speech
IDispatch spvoice
string text
pointer pText
int count,x
speech = CreateComObject("Sapi.SpVoice","")
if speech+0 <> NULL
GetComProperty(speech,"%d",&count,".GetVoices.Count")
FOR x = 1 TO count
GetComProperty(speech,"%o",&spvoice,".GetVoices.Item(%d)",x-1)
GetComProperty(spvoice,"%s",&pText,".GetDescription")
text=#<STRING>pText
ADDSTRING win,vList,text
FreeCOMString(pText)
NEXT x
speech->release()
endif
ENDSUB


Later,
Clint

LarryMc

You said you can't compile in IWBasic.
What compile error are you getting?

LarryMc
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

LarryMc

The code below compiles for me.
Make sure disphelper.inc is in your iwbdev/include folder
and disphelper.lib is in your iwbdev/libs folder

$include "disphelper.inc"
WINDOW w1
INT run=0
CONST VoiceList=1

OPENWINDOW w1,100,100,400,340,@TOOLWINDOW|@TOPMOST,0,"TTS Test",&main
CONTROL w1,@LISTBOX,"",10,10,200,100,@TABSTOP|@CTLISTNOTIFY|@VSCROLL,VoiceList

SETFONT w1,"Times New Roman",10,500,0,VoiceList

GetVoices(w1,VoiceList)

WAITUNTIL run=1
CLOSEWINDOW w1
END

SUB main
SELECT @MESSAGE
CASE @IDCREATE
CENTERWINDOW w1

CASE @IDCLOSEWINDOW
run=1

CASE @IDCONTROL
SELECT @CONTROLID
CASE VoiceList
SELECT @NOTIFYCODE
CASE 0
ENDSELECT
ENDSELECT
ENDSELECT
RETURN 0
ENDSUB

SUB Speak (string a,INT VoiceID)
IDispatch speech
IDispatch spvoice
speech = createComObject("Sapi.SPVoice","")
IF speech+0 <> NULL
GetComProperty(speech,"%o",&spvoice,".GetVoices.Item(%d)",VoiceID)
IF (spvoice <> NULL)
dhPutRef(speech,L".Voice = %o",spvoice)
ENDIF
callObjectMethod(speech,".Speak(%s,0)",a)
speech->release()
ENDIF
ENDSUB

SUB GetVoices(WINDOW win,INT vList)
'clear list
WHILE GETSTRINGCOUNT(win,vList)>0
DELETESTRING win,vList,0
ENDWHILE
IDispatch speech
IDispatch spvoice
string text
pointer pText
int count,x
speech = CreateComObject("Sapi.SpVoice","")
if speech+0 <> NULL
GetComProperty(speech,"%d",&count,".GetVoices.Count")
FOR x = 1 TO count
GetComProperty(speech,"%o",&spvoice,".GetVoices.Item(%d)",x-1)
GetComProperty(spvoice,"%s",&pText,".GetDescription")
text=#<STRING>pText
ADDSTRING win,vList,text
FreeCOMString(pText)
NEXT x
speech->release()
endif
ENDSUB


LarryMc
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

whitenite1

It compiles fine on 'puter also, but the list box has nothing in it. Is there something else I need for the list to be populated with anything?

whitenite1

sapero

QuoteError: Unresolved extern _dhPutRef
The disphelper library has been un-decorated, remove the leading underscore.

My SPVoice returns Count=1, GetDescription=NULL

ckoehn

I did get it to compile, by removing the underscore and including disphelper.inc.  But it ended up with nothing in it like whitenite1.  With EBASIC it is populated with all the voices available on my system.

Thanks,
Clint

LarryMc

July 21, 2011, 09:57:06 AM #6 Last Edit: July 21, 2011, 10:07:29 AM by LarryMc
It didn't have anything in the list in IWB or EB for me.

One of the things I noticed is that even though speech has a non-zero value
after executing this line
speech = CreateComObject("Sapi.SpVoice","")
the following IF statement is acting as if speech=NULL.

This is in IWB on my win7 64 machine.

LarryMc
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

ckoehn

I am using a Win7 64 machine. The following line..

Quotespeech = CreateComObject("Sapi.SpVoice","")

doesn't look like it is creating the "Sapi.SpVoice".

Speech is returning 0.  Why does EBASIC work?

Later,
Clint

sapero

Just remove the empty string from CreateComObject. The default value for machine name is NULL.

ckoehn

Sapero,

I did that but the IDispatch "speech" still is 0 and it doesn't work.

Later,
Clint

ckoehn

My bad.  Once again I had some settings wrong in the compiler options.

Thanks for your help,
Clint