PDA

View Full Version : سوال: يك فانكشن كه يك Text بزرگ را بازميگرداند



mehdi_moosavi
چهارشنبه 05 مهر 1391, 10:36 صبح
سلام، وقت دوستان بخير
اگر بخواهيم يك فانكشن داشته باشيم كه يك متن بزرگ (Text) را بازگرداند و داخل اين متن هر كاراكتري ممكن است باشد (:/',.67v"bg) چطور بايد اين فانكشن راتعريف كنيم؟
لطفاً راهنمايي كنيد
با تشكر

Felony
چهارشنبه 05 مهر 1391, 13:19 عصر
متن بزرگ یعنی چی ؟ یعنی String پاسخگوی متن شما نیست ؟! به نوع داده string ( نه ShortString ) در دلفی به صورت Dynamic حافظه تخصیص داده میشه و تا 30^2 کارکتر میتونید داخلش درج کنید ( به عبارتی حدود 2 گیگابایت ) .

مشکل چی هست ؟!

mehdi_moosavi
شنبه 08 مهر 1391, 10:24 صبح
سلام ، باتشكر
فرض كنيد بخواهيم يك فانكشن بشكل زير داشته باشيم:


function A1:String ;
begin
A1:='
Range Search Conditions
A range search is one that returns all values between two specified values. Inclusive ranges return any values that match the two specified values. Exclusive ranges do not return any values that match the two specified values.

The BETWEEN keyword specifies an inclusive range to search. For example, this SELECT returns all products whose units in stock is between 15 and 25:

SELECT UnitsInStock, ProductID, ProductName
FROM Northwind.dbo.Products
WHERE UnitsInStock BETWEEN 15 AND 25
ORDER BY UnitsInStock

The results of this SELECT statement contains any products that have either 15 or 25 units in stock.

SELECT UnitsInStock, ProductID, ProductName
FROM Northwind.dbo.Products
WHERE UnitsInStock = 15 OR UnitsInStock = 25
ORDER BY UnitsInStock

To specify an exclusive range, use the greater-than and less-than operators (> and <). The following query using the greater-than and less-than operators returns different results than the last example because these operators do not include rows matching the values that limit the range.

SELECT UnitsInStock, ProductID, ProductName
FROM Northwind.dbo.Products
WHERE UnitsInStock > 15 AND UnitsInStock < 25
ORDER BY UnitsInStock

NOT BETWEEN finds all rows outside the range you specify. Use this query to find all products for which the number of units in stock are outside the 15 to 25 range:

SELECT UnitsInStock, ProductID, ProductName
FROM Northwind.dbo.Products
WHERE UnitsInStock NOT BETWEEN 15 AND 25
ORDER BY UnitsInStock

';

end;



ولي قبول نميكنه و error ميده:
Unterminated error

Ananas
شنبه 08 مهر 1391, 14:37 عصر
سلام.
function A1:String ;
begin
A1 :=
'Range Search Conditions'#13#10 +
'A range search is one that returns all values between two specified values. Inclusive ranges return any values that match the two specified values. Exclusive ranges do not return any values that match the two specified values.'#13#10 +
#13#10 +
'The BETWEEN keyword specifies an inclusive range to search. For example, this SELECT returns all products whose units in stock is between 15 and 25:'#13#10 +
#13#10 +
'SELECT UnitsInStock, ProductID, ProductName'#13#10 +
'FROM Northwind.dbo.Products'#13#10 +
'WHERE UnitsInStock BETWEEN 15 AND 25'#13#10 +
'ORDER BY UnitsInStock'#13#10 +
#13#10 +
'The results of this SELECT statement contains any products that have either 15 or 25 units in stock.'#13#10 +
#13#10 +
'SELECT UnitsInStock, ProductID, ProductName'#13#10 +
'FROM Northwind.dbo.Products'#13#10 +
'WHERE UnitsInStock = 15 OR UnitsInStock = 25'#13#10 +
'ORDER BY UnitsInStock'#13#10 +
#13#10 +
'To specify an exclusive range, use the greater-than and less-than operators (> and <).' +
' The following query using the greater-than and less-than operators returns different results than the last example because these operators do not include rows matching the values that limit the range.'#13#10 +
#13#10 +
'SELECT UnitsInStock, ProductID, ProductName'#13#10 +
'FROM Northwind.dbo.Products'#13#10 +
'WHERE UnitsInStock > 15 AND UnitsInStock < 25'#13#10 +
'ORDER BY UnitsInStock'#13#10 +
#13#10 +
'NOT BETWEEN finds all rows outside the range you specify. Use this query to find all products for which the number of units in stock are outside the 15 to 25 range:'#13#10 +
#13#10 +
'SELECT UnitsInStock, ProductID, ProductName'#13#10 +
'FROM Northwind.dbo.Products'#13#10 +
'WHERE UnitsInStock NOT BETWEEN 15 AND 25'#13#10 +
'ORDER BY UnitsInStock';

end;

majidbestgame
یک شنبه 09 مهر 1391, 02:34 صبح
سلام.....
دوستمون Ananas جواب شمارو دادن..و اگه به این شکل تابعتون رو بنویسد جواب میده
کلا خواستم بگم بعضی وقتا وقتی واسمون یک مشگلی پیش میاد چه تو برنامه نویسی و چه هر چیز دیگری. متاسفانه همیشه فکر میکنیم راه حل سخت است و دنبال یک راه پیچیده هستیم و حتی اگه جواب و راه حل پیش چشمامون باشه از بس فکرمون درگیر مشگل و پیدا کردن یک راه حل پیچیدست که انگار نمیتوینم چیزیو ببینیم.
اگه الان فکر کنی میبینی چقدر ساده بوده وشاید بارها هم اینکارو کردی ولی اینبار دنبال راه حل پیچیده بودی - موفق باشید-

mehdi_moosavi
دوشنبه 10 مهر 1391, 11:59 صبح
سلام
مثلا در دستور زير فانكشن A1 بايد يك دستور SQL را برگردانه كه شامل حدود 40 تا 50 خط هست:
ADOQuery1.SQL.Text:=A1;
ويا فانكشن A2 بايد يك دستور ديگر رو كه مثلا 100 خط هست برگردانه:
ADOQuery1.SQL.Text:=A2;
يعني sql مربوط به Adoquery در طول اجراي برنامه تغيير ميكنه و در يك جاي برنامه مقدار فانكشن A1 هست و در جاي ديگه مقدار فانكشن A2
حالا چطور فانكشن A1 رو بنويسيم كه يك متن مثلا 100 خطي رو برگردونه