IonicWind Software

IWBasic => General Questions => Topic started by: ckoehn on July 20, 2011, 07:04:08 PM

Title: Compile issue
Post by: ckoehn on July 20, 2011, 07:04:08 PM
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
Title: Re: Compile issue
Post by: LarryMc on July 20, 2011, 08:30:40 PM
You said you can't compile in IWBasic.
What compile error are you getting?

LarryMc
Title: Re: Compile issue
Post by: LarryMc on July 20, 2011, 08:52:22 PM
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
Title: Re: Compile issue
Post by: whitenite1 on July 20, 2011, 11:25:59 PM
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
Title: Re: Compile issue
Post by: sapero on July 21, 2011, 03:22:20 AM
QuoteError: Unresolved extern _dhPutRef
The disphelper library has been un-decorated, remove the leading underscore.

My SPVoice returns Count=1, GetDescription=NULL
Title: Re: Compile issue
Post by: ckoehn on July 21, 2011, 09:22:31 AM
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
Title: Re: Compile issue
Post by: LarryMc on July 21, 2011, 09:57:06 AM
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
Title: Re: Compile issue
Post by: ckoehn on July 22, 2011, 07:20:40 AM
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
Title: Re: Compile issue
Post by: sapero on July 22, 2011, 07:38:42 AM
Just remove the empty string from CreateComObject. The default value for machine name is NULL.
Title: Re: Compile issue
Post by: ckoehn on July 22, 2011, 08:43:30 AM
Sapero,

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

Later,
Clint
Title: Re: Compile issue
Post by: ckoehn on July 22, 2011, 08:48:38 AM
My bad.  Once again I had some settings wrong in the compiler options.

Thanks for your help,
Clint