Jump to content

سسؤال بخصوص local


Recommended Posts

هذا يعتبر تعريف محلي و محدود

car فـ مثلاً انا عندي كلمة

وابي اسوي تعريف في فنكشن محدد

1-

function test1 ( ) 
    local car 
    if car then 
        print ( "true" ) 
    else 
        print ( "false" ) 
    end 
end 
  
function test2 ( ) 
    if car then 
        print ( "true" ) 
    else 
        print ( "false" ) 
    end 
end 

true راح تكون النتيجة test1 في فنكشن

test2 بعكس الفنكشن

داخل فنكشن local لأني استخدمت التعريف المحلي

2-

فـ لو خلينا التعريف المحلي برا الفنكشن

مثل كذا

local car 
  
function test ( ) 
    if car then 
        print ( "true" ) 
    else 
        print ( "false" ) 
    end 
end 
  
function test2 ( ) 
    if car then 
        print ( "true" ) 
    else 
        print ( "false" ) 
    end 
end 

true راح تلاحظ في جميع الفنكشنز بيقول

3-

local واذا ما استخدمت امر

داخل فنكشن car وحطيت تعريف

مثل كذا

function test ( ) 
    car = true 
    if car then 
        print ( "true" ) 
    else 
        print ( "false" ) 
    end 
end 
  
function test2 ( ) 
    if car then 
        print ( "true" ) 
    else 
        print ( "false" ) 
    end 
end 

في جميع الحالات true بيقول

مثل نقطة رقم 2

4-

local برا الفنكشن وبدون car واذا حطيت التعريف

مثل كذا

car = true 
  
function test ( ) 
    if car then 
        print ( "true" ) 
    else 
        print ( "false" ) 
    end 
end 
  
function test2 ( ) 
    if car then 
        print ( "true" ) 
    else 
        print ( "false" ) 
    end 
end 

راح تلاحظ ان التعريف بيوصل حتى في الملفات الثانية

اللي موجودة بنفس المود و نفس جانب الملف

يعني سيرفر يتعرف مع سيرفر الكل

و كلنت راح يتعرف مع ملفات الكلنت كلها

Link to comment
هذا يعتبر تعريف محلي و محدود

car فـ مثلاً انا عندي كلمة

وابي اسوي تعريف في فنكشن محدد

1-

function test1 ( ) 
    local car 
    if car then 
        print ( "true" ) 
    else 
        print ( "false" ) 
    end 
end 
  
function test2 ( ) 
    if car then 
        print ( "true" ) 
    else 
        print ( "false" ) 
    end 
end 

true راح تكون النتيجة test1 في فنكشن

test2 بعكس الفنكشن

داخل فنكشن local لأني استخدمت التعريف المحلي

2-

فـ لو خلينا التعريف المحلي برا الفنكشن

مثل كذا

local car 
  
function test ( ) 
    if car then 
        print ( "true" ) 
    else 
        print ( "false" ) 
    end 
end 
  
function test2 ( ) 
    if car then 
        print ( "true" ) 
    else 
        print ( "false" ) 
    end 
end 

true راح تلاحظ في جميع الفنكشنز بيقول

3-

local واذا ما استخدمت امر

داخل فنكشن car وحطيت تعريف

مثل كذا

function test ( ) 
    car = true 
    if car then 
        print ( "true" ) 
    else 
        print ( "false" ) 
    end 
end 
  
function test2 ( ) 
    if car then 
        print ( "true" ) 
    else 
        print ( "false" ) 
    end 
end 

في جميع الحالات true بيقول

مثل نقطة رقم 2

4-

local برا الفنكشن وبدون car واذا حطيت التعريف

مثل كذا

car = true 
  
function test ( ) 
    if car then 
        print ( "true" ) 
    else 
        print ( "false" ) 
    end 
end 
  
function test2 ( ) 
    if car then 
        print ( "true" ) 
    else 
        print ( "false" ) 
    end 
end 

راح تلاحظ ان التعريف بيوصل حتى في الملفات الثانية

اللي موجودة بنفس المود و نفس جانب الملف

يعني سيرفر يتعرف مع سيرفر الكل

و كلنت راح يتعرف مع ملفات الكلنت كلها

كوداتك فيها خربطة ولا كيف ؟ وش if و else

من وين جآيبهم

Link to comment

if : جملة شرطية

else : ifتابع لـ

else راح ينتقل ل if يعني ان لم يتحقق

----

والاكواد الخربطة هذي

true راح يقولك car تقلك لمن يتوفر تعريف

if ولو قرأناها بالجملة الشرطية

راح تكون كذا

فـ أفعل الآتي car إن وجد التعريف  
      true اخرج نص بـ كلمة  
وإن لم يتحقق فـ أفعل الآتي 
    false اخرج النص  
إنهي الشرط 

عسى وضحت معك

* إذا ماتعرف انجليزي ريح بالك من البرمجة

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...