Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I need help writing a simple program

Status
Not open for further replies.

Chris08

Programmer
Apr 25, 2001
1
0
0
US
I need to write a program to transfer 2 sentences into pig latin. for example: he left today. -- ehay eftlay odaytay.
Please help i can only get so much

(program -- (input, output);

(*------------*)
(*------------*)

uses
crt; please help

var


begin
 
Have a look at pages 313 to 315 of "Visual Basic 6 How to Program" by Deitel, Deitel and T.R. Neito (Prentice Hall)
 
Not sure if this is what you are looking for
because it is written for SQL SERVER 7.0,
but you might be able to modify it!?!

CREATE PROCEDURE spP_L
(@phrase varchar(1000))
AS
set nocount on
declare @array varchar(1000) /* sentance passed from Call of sp_*/
declare @separator char(1)
declare @separator_position int /*used to locate each separator charachter*/
declare @array_value varchar(1000) /*holds each array value as it is returned*/
declare @PigTranslator varchar(1000) /*holds return of each returned array to return one(1) sentance)*/

set @separator=' ' /*Setting separator to the 'space' between words*/
set @array = @phrase + @separator
set @PigTranslator=''
while patindex('%' + @separator + '%', @array)<>0
begin
select @separator_position = patindex('%' + @separator + '%', @array)
select @array_value = left(@array, @separator_position -1)
set @PigTranslator =@PigTranslator+' '+substring(@array_Value,2,(len(@array_VAlue)-1))+substring(@array_Value,1,1)+'ay'
select @array = stuff(@array, 1, @separator_position, '')
end
Select @PigTranslator

set nocount off

/* Original Parsing sp_ created by graz@sqlteam.com
'Pig Latin' modifications made by mGruodis@aol.com*/
hope this helps,
Michael
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top