Perhaps an idea for the fan of old and sick CALLFUNCTION

Share your advanced PureBasic knowledge/code with the community.
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Perhaps an idea for the fan of old and sick CALLFUNCTION

Post by Kwai chang caine »

Hello the silicon familly :D

Since several version FRED don't want we use callfunction, and say we must use PROTOTYPE :(
So PROTOTYPE is not really easy for use, and a little bit more long for write..at my advice :roll:

CALLFUNCTION was so simple for "hight level programmer" like me. :oops:
Then.... listen that his bravery....KCC take his keyboard, and try to extend the life of his love CALLFUNCTION :D

Kcc_CallFunction ==> For replace the old call, with use prototype (FRED perhaps happy :roll:)
Perhaps also FRED laugh a little bit, because i'm forced me too, for the moment, to send the String with her pointer "@String" :lol: (If FRED read that..he understand surelly what i say :oops: )

But pom-pom on the brownie....KCC create three other functions, for make again more simple, the call of function.
He have anticipate ten parameters, i think it's enough :roll:

Kcc_CallFunctionString ==> For manage and return directly String
Kcc_CallFunctionArrayString ==> For manage and return directly Array of string
Kcc_CallFunctionArray ==> For manage and return directly Array

Obviously...i go to learn to you something....Kcc don't works alone... :mrgreen:

He have an angel, with big wings, above his cradle 8)
And like nobody know him....i have the honor to say his name.... It's MASTER SROD....:mrgreen:
But i want to thanks also, MASTER NETMAESTRO who help me so much in this code 8)

I caution you, this code is writing with the feet....furthermore KCC feets :oops:
And surelly have one thowsand of bugs, and memory leaks, and other things, that i don't know the being.....you are surelly not surprising :oops:
If you want say to me the list..KCC have cut all his tree of his garden, to can writing it :mrgreen:

I want just present to you an idea... :D :idea:
And i hope, that someone, perhaps want to help me for ameliorate it, or again better, use my idea and write better code without junk :roll:
Or perhaps it's possible to mix several function for have again less of "KCC_CALFUNCTIONS" :D
Or at the minimum give his advice, or even a little slap behind KCC head, like leroy jethro gibbs, not too strong, because i have a headache after that :oops:

Attention !!! Not works in 4.50 (Bugs STATIC fixed in v4.51)

So like say my MASTER..enough talking.....this is the second tips of KCC.......

TaaaaaaaTaaaaaaaa !!!!!


The Exe

Code: Select all

#ERC_ArrayPB = 1
#ERC_ArrayVB = 2

Prototype Send0ParS(*address.STRING, Chars)
Prototype Send1ParS(*address.STRING, Chars, Par1)
Prototype Send2ParS(*address.STRING, Chars, Par1, Par2)
Prototype Send3ParS(*address.STRING, Chars, Par1, Par2, Par3)
Prototype Send4ParS(*address.STRING, Chars, Par1, Par2, Par3, Par4)
Prototype Send5ParS(*address.STRING, Chars, Par1, Par2, Par3, Par4, Par5)
Prototype Send6ParS(*address.STRING, Chars, Par1, Par2, Par3, Par4, Par5, Par6)
Prototype Send7ParS(*address.STRING, Chars, Par1, Par2, Par3, Par4, Par5, Par6, Par7)
Prototype Send8ParS(*address.STRING, Chars, Par1, Par2, Par3, Par4, Par5, Par6, Par7, Par8)
Prototype Send9ParS(*address.STRING, Chars, Par1, Par2, Par3, Par4, Par5, Par6, Par7, Par8, Par9)
Prototype Send10ParS(*address.STRING, Chars, Par1, Par2, Par3, Par4, Par5, Par6, Par7, Par8, Par9, Par10)


Prototype Send0Par(*address.STRING)
Prototype Send1Par(*address.STRING, Par1)
Prototype Send2Par(*address.STRING, Par1, Par2)
Prototype Send3Par(*address.STRING, Par1, Par2, Par3)
Prototype Send4Par(*address.STRING, Par1, Par2, Par3, Par4)
Prototype Send5Par(*address.STRING, Par1, Par2, Par3, Par4, Par5)
Prototype Send6Par(*address.STRING, Par1, Par2, Par3, Par4, Par5, Par6)
Prototype Send7Par(*address.STRING, Par1, Par2, Par3, Par4, Par5, Par6, Par7)
Prototype Send8Par(*address.STRING, Par1, Par2, Par3, Par4, Par5, Par6, Par7, Par8)
Prototype Send9Par(*address.STRING, Par1, Par2, Par3, Par4, Par5, Par6, Par7, Par8, Par9)
Prototype Send10Par(*address.STRING, Par1, Par2, Par3, Par4, Par5, Par6, Par7, Par8, Par9, Par10)

If Not OpenLibrary(0, "stringfunctions.dll")
Debug "No dll..."
End
EndIf

Procedure.s Kcc_CallFunctionString(NameOfFunction.s, Par1 = 0, Par2 = 0, Par3 = 0, Par4 = 0, Par5 = 0, Par6 = 0, Par7 = 0, Par8 = 0, Par9 = 0, Par10 = 0)

Define Result.s = "Error"

If Par10
  Function.Send10ParS = GetFunction(0, NameOfFunction)
  If Function.Send10ParS
   Length = Function(@Result, 0, Par1, Par2, Par3, Par4, Par5, Par6, Par7, Par8, Par9, Par10)
   Result = Space(Length)
   Function(@Result, Length, Par1, Par2, Par3, Par4, Par5, Par6, Par7, Par8, Par9, Par10)
  EndIf
ElseIf Par9
  Function.Send9ParS = GetFunction(0, NameOfFunction)
  If Function.Send9ParS
   Length = Function(@Result, 0, Par1, Par2, Par3, Par4, Par5, Par6, Par7, Par8, Par9)
   Result = Space(Length)
   Function(@Result, Length, Par1, Par2, Par3, Par4, Par5, Par6, Par7, Par8, Par9)
  EndIf
ElseIf Par8
  Function.Send8ParS = GetFunction(0, NameOfFunction)
  If Function.Send8ParS
   Length = Function(@Result, 0, Par1, Par2, Par3, Par4, Par5, Par6, Par7, Par8)
   Result = Space(Length)
   Function(@Result, Length, Par1, Par2, Par3, Par4, Par5, Par6, Par7, Par8)
  EndIf
ElseIf Par7
  Function.Send7ParS = GetFunction(0, NameOfFunction)
  If Function.Send7ParS
   Length = Function(@Result, 0, Par1, Par2, Par3, Par4, Par5, Par6, Par7)
   Result = Space(Length)
   Function(@Result, Length, Par1, Par2, Par3, Par4, Par5, Par6, Par7)
  EndIf
ElseIf Par6
  Function.Send6ParS = GetFunction(0, NameOfFunction)
  If Function.Send6ParS
   Length = Function(@Result, 0, Par1, Par2, Par3, Par4, Par5, Par6)
   Result = Space(Length)
   Function(@Result, Length, Par1, Par2, Par3, Par4, Par5, Par6)
  EndIf
ElseIf Par5
  Function.Send5ParS = GetFunction(0, NameOfFunction)
  If Function.Send5ParS
   Length = Function(@Result, 0, Par1, Par2, Par3, Par4, Par5)
   Result = Space(Length)
   Function(@Result, Length, Par1, Par2, Par3, Par4, Par5)
  EndIf
ElseIf Par4
  Function.Send4ParS = GetFunction(0, NameOfFunction)
  If Function.Send4ParS
   Length = Function(@Result, 0, Par1, Par2, Par3, Par4)
   Result = Space(Length)
   Function(@Result, Length, Par1, Par2, Par3, Par4)
  EndIf
ElseIf Par3
  Function.Send3ParS = GetFunction(0, NameOfFunction)
  If Function.Send3ParS
   Length = Function(@Result, 0, Par1, Par2, Par3)
   Result = Space(Length)
   Function(@Result, Length, Par1, Par2, Par3)
  EndIf 
ElseIf Par2
  Function.Send2ParS = GetFunction(0, NameOfFunction)
  If Function.Send2ParS
   Length = Function(@Result, 0, Par1, Par2)
   Result = Space(Length)
   Function(@Result, Length, Par1, Par2)
  EndIf
ElseIf Par1
  Function.Send1ParS = GetFunction(0, NameOfFunction)
  If Function.Send1ParS
   Length = Function(@Result, 0, Par1)
   Result = Space(Length)
   Function(@Result, Length, Par1)
  EndIf
Else
  Function.Send0ParS = GetFunction(0, NameOfFunction)
  If Function.Send0ParS
   Length = Function(@Result, 0)
   Result = Space(Length)
   Length = Function(@Result, Length)
  EndIf
EndIf 

If Result = "Error"
  MessageRequester("ArrayFromDll", "The function ''" + NameOfFunction + "'' don't answer.")
EndIf

ProcedureReturn Result

EndProcedure 

Procedure Kcc_CallFunction(NameOfFunction.s, Par1 = 0, Par2 = 0, Par3 = 0, Par4 = 0, Par5 = 0, Par6 = 0, Par7 = 0, Par8 = 0, Par9 = 0, Par10 = 0)

Define Result.l = -1

If Par10
  Function.Send10Par = GetFunction(0, NameOfFunction)
  If Function.Send10Par 
   Function(@Result, Par1, Par2, Par3, Par4, Par5, Par6, Par7, Par8, Par9, Par10)
  EndIf
ElseIf Par9
  Function.Send9Par = GetFunction(0, NameOfFunction)
  If Function.Send9Par
   Function(@Result, Par1, Par2, Par3, Par4, Par5, Par6, Par7, Par8, Par9)
  EndIf
ElseIf Par8
  Function.Send8Par = GetFunction(0, NameOfFunction)
  If Function.Send8Par
   Function(@Result, Par1, Par2, Par3, Par4, Par5, Par6, Par7, Par8)
  EndIf
ElseIf Par7
  Function.Send7Par = GetFunction(0, NameOfFunction)
  If Function.Send7Par
   Function(@Result, Par1, Par2, Par3, Par4, Par5, Par6, Par7)
  EndIf
ElseIf Par6
  Function.Send6Par = GetFunction(0, NameOfFunction)
  If Function.Send6Par
   Function(@Result, Par1, Par2, Par3, Par4, Par5, Par6)
  EndIf
ElseIf Par5
  Function.Send5Par = GetFunction(0, NameOfFunction)
  If Function.Send5Par
   Function(@Result, Par1, Par2, Par3, Par4, Par5)
  EndIf
ElseIf Par4
  Function.Send4Par = GetFunction(0, NameOfFunction)
  If Function.Send4Par
   Function(@Result, Par1, Par2, Par3, Par4)
  EndIf 
ElseIf Par3
  Function.Send3Par = GetFunction(0, NameOfFunction)
  If Function.Send3Par
   Function(@Result, Par1, Par2, Par3)
  EndIf
ElseIf Par2
  Function.Send2Par = GetFunction(0, NameOfFunction)
  If Function.Send2Par
   Function(@Result, Par1, Par2)
  EndIf 
ElseIf Par1
  Function.Send1Par = GetFunction(0, NameOfFunction)
  If Function.Send1Par
   Function(@Result, Par1)
  EndIf
Else
  Function.Send0Par = GetFunction(0, NameOfFunction)
  If Function.Send0Par
   Function(@Result)
  EndIf
EndIf 

If Result = - 1
  MessageRequester("ArrayFromDll", "The function ''" + NameOfFunction + "'' don't answer.")
EndIf 

ProcedureReturn Result
   
EndProcedure 

Procedure Kcc_CallFunctionArrayString(NameOfFunction.s, Array TabloARemplir.s(1), Par1 = 0, Par2 = 0, Par3 = 0, Par4 = 0, Par5 = 0, Par6 = 0, Par7 = 0, Par8 = 0, Par9 = 0, Par10 = 0)

Define Result.l = -1
Define *strPtr.INTEGER

If Par10
  Function.Send10Par = GetFunction(0, NameOfFunction)
  If Function.Send10Par 
   Function(@Result, Par1, Par2, Par3, Par4, Par5, Par6, Par7, Par8, Par9, Par10)
  EndIf
ElseIf Par9
  Function.Send9Par = GetFunction(0, NameOfFunction)
  If Function.Send9Par
   Function(@Result, Par1, Par2, Par3, Par4, Par5, Par6, Par7, Par8, Par9)
  EndIf
ElseIf Par8
  Function.Send8Par = GetFunction(0, NameOfFunction)
  If Function.Send8Par
   Function(@Result, Par1, Par2, Par3, Par4, Par5, Par6, Par7, Par8)
  EndIf
ElseIf Par7
  Function.Send7Par = GetFunction(0, NameOfFunction)
  If Function.Send7Par
   Function(@Result, Par1, Par2, Par3, Par4, Par5, Par6, Par7)
  EndIf
ElseIf Par6
  Function.Send6Par = GetFunction(0, NameOfFunction)
  If Function.Send6Par
   Function(@Result, Par1, Par2, Par3, Par4, Par5, Par6)
  EndIf
ElseIf Par5
  Function.Send5Par = GetFunction(0, NameOfFunction)
  If Function.Send5Par
   Function(@Result, Par1, Par2, Par3, Par4, Par5)
  EndIf
ElseIf Par4
  Function.Send4Par = GetFunction(0, NameOfFunction)
  If Function.Send4Par
   Function(@Result, Par1, Par2, Par3, Par4)
  EndIf 
ElseIf Par3
  Function.Send3Par = GetFunction(0, NameOfFunction)
  If Function.Send3Par
   Function(@Result, Par1, Par2, Par3)
  EndIf
ElseIf Par2
  Function.Send2Par = GetFunction(0, NameOfFunction)
  If Function.Send2Par
   Function(@Result, Par1, Par2)
  EndIf 
ElseIf Par1
  Function.Send1Par = GetFunction(0, NameOfFunction)
  If Function.Send1Par
   Function(@Result, Par1)
  EndIf
Else
  Function.Send0Par = GetFunction(0, NameOfFunction)
  If Function.Send0Par
   Function(@Result)
  EndIf
EndIf 

If Result = - 1
  MessageRequester("ArrayFromDll", "The function ''" + NameOfFunction + "'' don't answer.")
EndIf 

*strPtr.INTEGER = Result 

If *strPtr

  If *strPtr\i
   
   LigneZero$ = PeekS(*strPtr\i, -1, #PB_Unicode)
   
   If Left(Trim(LigneZero$), 1) = "?"
    LigneZero$ = PeekS(*strPtr\i, -1, #PB_Ascii)
   EndIf 
   
   If Trim(LigneZero$) = ""
    MessageRequester("TabloDllEnLocal", "La ligne zéro du tableau est vide.")
    ProcedureReturn #False
   EndIf
   
   TailleTabloDLL = Val(LigneZero$)
         
   If TailleTabloDLL = #False
    ProcedureReturn #False
   ElseIf TailleTabloDLL < 0
    TailleTabloDLL = TailleTabloDLL * (-1)
    TypeArray = #ERC_ArrayVB 
   ElseIf TailleTabloDLL > 0 
    TypeArray = #ERC_ArrayPB
   EndIf
    
   TailleTotale = TailleTabloDLL
    
   If ArraySize(TabloARemplir())
    TailleTabloModifier = ArraySize(TabloARemplir())
    TailleTotale + TailleTabloModifier
   EndIf
    
   ReDim TabloARemplir.s(TailleTotale)
   TabloARemplir(0) = Str(TailleTotale)
    
   For i = TailleTabloModifier + 1 To TailleTotale
    
    *strPtr + SizeOf(INTEGER)
    
    If *strPtr\i <> 0
    
     Select TypeArray
      Case #ERC_ArrayVB
       TabloARemplir(i) = PeekS(*strPtr\i, -1, #PB_Unicode)
      Case #ERC_ArrayPB 
       TabloARemplir(i) = PeekS(*strPtr\i, -1, #PB_Ascii)
     EndSelect
     
    Else
    
      TabloARemplir(i) = ""
    
    EndIf
    
   Next
   
   ProcedureReturn TailleTotale
   
  Else
   
   MessageRequester("TabloDllEnLocal", "La valeur de la variable structurée est de zéro (La ligne zéro du tableau est peut etre vide)")
   ProcedureReturn #False
    
  EndIf 

Else

   ProcedureReturn #False
    
EndIf
   
EndProcedure 

Procedure Kcc_CallFunctionArray(NameOfFunction.s, Array TabloARemplir(1), Par1 = 0, Par2 = 0, Par3 = 0, Par4 = 0, Par5 = 0, Par6 = 0, Par7 = 0, Par8 = 0, Par9 = 0, Par10 = 0)

Define Result.l = -1
Define *strPtr.INTEGER

If Par10
  Function.Send10Par = GetFunction(0, NameOfFunction)
  If Function.Send10Par 
   Function(@Result, Par1, Par2, Par3, Par4, Par5, Par6, Par7, Par8, Par9, Par10)
  EndIf
ElseIf Par9
  Function.Send9Par = GetFunction(0, NameOfFunction)
  If Function.Send9Par
   Function(@Result, Par1, Par2, Par3, Par4, Par5, Par6, Par7, Par8, Par9)
  EndIf
ElseIf Par8
  Function.Send8Par = GetFunction(0, NameOfFunction)
  If Function.Send8Par
   Function(@Result, Par1, Par2, Par3, Par4, Par5, Par6, Par7, Par8)
  EndIf
ElseIf Par7
  Function.Send7Par = GetFunction(0, NameOfFunction)
  If Function.Send7Par
   Function(@Result, Par1, Par2, Par3, Par4, Par5, Par6, Par7)
  EndIf
ElseIf Par6
  Function.Send6Par = GetFunction(0, NameOfFunction)
  If Function.Send6Par
   Function(@Result, Par1, Par2, Par3, Par4, Par5, Par6)
  EndIf
ElseIf Par5
  Function.Send5Par = GetFunction(0, NameOfFunction)
  If Function.Send5Par
   Function(@Result, Par1, Par2, Par3, Par4, Par5)
  EndIf
ElseIf Par4
  Function.Send4Par = GetFunction(0, NameOfFunction)
  If Function.Send4Par
   Function(@Result, Par1, Par2, Par3, Par4)
  EndIf 
ElseIf Par3
  Function.Send3Par = GetFunction(0, NameOfFunction)
  If Function.Send3Par
   Function(@Result, Par1, Par2, Par3)
  EndIf
ElseIf Par2
  Function.Send2Par = GetFunction(0, NameOfFunction)
  If Function.Send2Par
   Function(@Result, Par1, Par2)
  EndIf 
ElseIf Par1
  Function.Send1Par = GetFunction(0, NameOfFunction)
  If Function.Send1Par
   Function(@Result, Par1)
  EndIf
Else
  Function.Send0Par = GetFunction(0, NameOfFunction)
  If Function.Send0Par
   Function(@Result)
  EndIf
EndIf 

If Result = - 1
  MessageRequester("ArrayFromDll", "The function ''" + NameOfFunction + "'' don't answer.")
EndIf

*strPtr.INTEGER = Result

If *strPtr

  If *strPtr\i
   
   SizeArray = PeekL(*strPtr)
   
   If SizeArray = 0
    MessageRequester("TabloParPointeur", "La ligne zéro du tableau est vide.")
    ProcedureReturn #False
   EndIf
   
   Dim TabloARemplir(SizeArray)
   CopyMemory(*strPtr, @TabloARemplir(), (SizeArray + 1) * SizeOf(INTEGER))
       
  Else
   
   MessageRequester("TabloDllEnLocal", "La valeur de la variable structurée est de zéro (La ligne zéro du tableau est peut etre vide)")
   ProcedureReturn #False
    
  EndIf 

Else

  ProcedureReturn #False
   
EndIf
    
EndProcedure 

; Function for numeric
Debug Kcc_CallFunction("AddNumbe", 1, 2, 3) ; Create an error, for a time anticipate :-)))
Debug "Function ''ADDNUMBER'' For adding numbers"
Debug Kcc_CallFunction("AddNumber", 1, 2, 3)
Debug ""

; Function for strings with parameter
Debug "Function ''ADDSTRING'' for strings with parameter"
A$ = "Kcc "
B$ = "Reinvent "
C$ = "the wheel"
Debug Kcc_CallFunctionString("AddString", @A$, @B$, @C$)
Debug ""
Debug "Function ''UCASESTRING'' for strings with parameter"
Debug Kcc_CallFunctionString("UcaseString", @"Kcc is the most happy little programmer at the word")
Debug ""
 
; Function for strings without parameter
Debug "Function ''APPPATH'' For strings without parameter"
Debug Kcc_CallFunctionString("AppPath")
Debug ""

;Function For Return StringArray with no sending array
Debug "Function ''FILLEDARRAY'' For Return StringArray with no sending array"
Dim NewArray1.s(0)
Kcc_CallFunctionArrayString("FilledArray", NewArray1())

For i = 0 To ArraySize(NewArray1())
Debug NewArray1(i)
Next

Debug ""

;Function For Return Array with sending array
Debug "Function ''COMPLEMENT ARRAY'' For Return Array with sending array"
Dim ArrayExe(5)
ArrayExe(0) = ArraySize(ArrayExe())
ArrayExe(1) = 1
ArrayExe(2) = 2
ArrayExe(3) = 3
ArrayExe(4) = 4
ArrayExe(5) = 5

Dim NewArray2(0)
Kcc_CallFunctionArray("ComplementArray", NewArray2(), @ArrayExe())

For i = 0 To ArraySize(NewArray2())
Debug NewArray2(i)
Next

Debug ""

;Function For Return StringArray with sending array
Debug "Function ''UCASEARRAY'' For Return StringArray with sending array"
Dim ArrayExeString.s(5)
ArrayExeString(0) = Str(ArraySize(ArrayExeString()))
ArrayExeString(1) = "I'm a line 1 from array EXE"
ArrayExeString(2) = "I'm a line 2 from array EXE"
ArrayExeString(3) = "I'm a line 3 from array EXE"
ArrayExeString(4) = "I'm a line 4 from array EXE"
ArrayExeString(5) = "I'm a line 5 from array EXE"

Dim NewArrayString.s(0)
Kcc_CallFunctionArrayString("UcaseArray", NewArrayString(), @ArrayExeString())

For i = 0 To ArraySize(NewArrayString())
Debug NewArrayString(i)
Next
The DLL

Code: Select all

#ERC_ArrayPB = 1
#ERC_ArrayVB = 2

Procedure TabloStringParPointeur(*strPtr.INTEGER, Array TabloARemplir.s(1)) ; Recupere un tableau de string provenant d'une procedure LOCALE ou DLL
  
If *strPtr

  If *strPtr\i
   
   LigneZero$ = PeekS(*strPtr\i, -1, #PB_Unicode)
   
   If Left(Trim(LigneZero$), 1) = "?"
    LigneZero$ = PeekS(*strPtr\i, -1, #PB_Ascii)
   EndIf 
   
   If Trim(LigneZero$) = ""
    MessageRequester("TabloDllEnLocal", "La ligne zéro du tableau est vide.")
    ProcedureReturn #False
   EndIf
   
   TailleTabloDLL = Val(LigneZero$)
         
   If TailleTabloDLL = #False
    ProcedureReturn #False
   ElseIf TailleTabloDLL < 0
    TailleTabloDLL = TailleTabloDLL * (-1)
    TypeArray = #ERC_ArrayVB 
   ElseIf TailleTabloDLL > 0 
    TypeArray = #ERC_ArrayPB
   EndIf
    
   TailleTotale = TailleTabloDLL
    
   If ArraySize(TabloARemplir())
    TailleTabloModifier = ArraySize(TabloARemplir())
    TailleTotale + TailleTabloModifier
   EndIf
    
   ReDim TabloARemplir.s(TailleTotale)
   TabloARemplir(0) = Str(TailleTotale)
    
   For i = TailleTabloModifier + 1 To TailleTotale
    
    *strPtr + SizeOf(INTEGER)
    
    If *strPtr\i <> 0
    
     Select TypeArray
      Case #ERC_ArrayVB
       TabloARemplir(i) = PeekS(*strPtr\i, -1, #PB_Unicode)
      Case #ERC_ArrayPB 
       TabloARemplir(i) = PeekS(*strPtr\i, -1, #PB_Ascii)
     EndSelect
     
    Else
    
      TabloARemplir(i) = ""
    
    EndIf
    
   Next
   
   ProcedureReturn TailleTotale
   
  Else
   
   MessageRequester("TabloDllEnLocal", "La valeur de la variable structurée est de zéro (La ligne zéro du tableau est peut etre vide)")
   ProcedureReturn #False
    
  EndIf 

Else

  ProcedureReturn #False
   
EndIf
    
EndProcedure

Procedure TabloParPointeur(*strPtr.INTEGER, Array TabloARemplir(1)) ; Recupere un tableau integer provenant d'une procedure LOCALE ou DLL

If *strPtr

  If *strPtr\i
   
   SizeArray = PeekL(*strPtr)
   
   If SizeArray = 0
    MessageRequester("TabloParPointeur", "La ligne zéro du tableau est vide.")
    ProcedureReturn #False
   EndIf
   
   Dim TabloARemplir(SizeArray)
   CopyMemory(*strPtr, @TabloARemplir(), (SizeArray + 1) * SizeOf(INTEGER))
       
  Else
   
   MessageRequester("TabloDllEnLocal", "La valeur de la variable structurée est de zéro (La ligne zéro du tableau est peut etre vide)")
   ProcedureReturn #False
    
  EndIf 

Else

  ProcedureReturn #False
   
EndIf
    
EndProcedure

ProcedureDLL AppPath(*address, chars)

Value$ = Space(500)
GetCurrentDirectory_(500, @Value$)
Value$ = Trim(Value$)
PathAddBackslash_(@Value$) 
    
If chars
  If Len(Value$) < chars
   PokeS(*address, Value$)
   ProcedureReturn 0
  Else
   PokeS(*address, Left(Value$, chars - 1))
   ProcedureReturn Len(Value$) + 1
  EndIf
Else
  ProcedureReturn Len(Value$) + 1
EndIf
   
EndProcedure

ProcedureDLL UcaseString(*address, chars, *A)

If *A
  Value$ = UCase(PeekS(*A))
EndIf 
    
If chars
  If Len(Value$) < chars
   PokeS(*address, Value$)
   ProcedureReturn 0
  Else
   PokeS(*address, Left(Value$, chars - 1))
   ProcedureReturn Len(Value$) + 1
  EndIf
Else
  ProcedureReturn Len(Value$) + 1
EndIf
   
EndProcedure

ProcedureDLL AddString(*address, chars, *A, *B, *C)

Value$ + PeekS(*A) + PeekS(*B) + PeekS(*C)

If chars
  If Len(Value$) < chars
   PokeS(*address, Value$)
   ProcedureReturn 0
  Else
   PokeS(*address, Left(Value$, chars - 1))
   ProcedureReturn Len(Value$) + 1
  EndIf
Else
  ProcedureReturn Len(Value$) + 1
EndIf
   
EndProcedure

ProcedureDLL AddNumber(*address, P1, P2, P3)

Define Value.l
Value + P1 + P2 + P3
PokeL(*address, Value)
    
EndProcedure

ProcedureDLL FilledArray(*address)

Static Dim Temp_Array.s(10) ; Because i don't want a global

For i = 0 To ArraySize(Temp_Array())
  Temp_Array(i) = "Hello i'm the line " + Str(i) + " of an Array filled by the DLL" 
Next 

Temp_Array(0) = Str(ArraySize(Temp_Array()))
PokeL(*address, @Temp_Array())

EndProcedure

ProcedureDLL UcaseArray(*AdresseReturn, *AddressArray)

Dim ArrayExe.s(0)
TabloStringParPointeur(*AddressArray, ArrayExe())

SizeTempArrayExe = ArraySize(ArrayExe())
Static Dim Temp_Array.s(0) ; Because i don't want a global
ReDim Temp_Array.s(SizeTempArrayExe)

For i = 1 To SizeTempArrayExe
  Temp_Array(i) = UCase(ArrayExe(i))
Next 

Temp_Array(0) = Str(SizeTempArrayExe)
PokeL(*AdresseReturn, @Temp_Array())
  
EndProcedure

ProcedureDLL ComplementArray(*AdresseReturn, *AddressArray)

Static Dim ArrayExe(0)
TabloParPointeur(*AddressArray, ArrayExe())

For i = 1 To ArraySize(ArrayExe())
  ArrayExe(i) = 10 - ArrayExe(i)
Next 

ArrayExe(0) = ArraySize(ArrayExe())
PokeL(*AdresseReturn, @ArrayExe())
  
EndProcedure
Kcc can now, postulate to PB TEAM .....no ???? :mrgreen:

Thank you for reading 8)
ImageThe happiness is a road...
Not a destination
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: Perhaps an idea for the fan of old and sick CALLFUNCTION

Post by netmaestro »

KCC on prototypes wrote:and a little bit more long for write..
And this is shorter? :mrgreen:
BERESHEIT
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: Perhaps an idea for the fan of old and sick CALLFUNCTION

Post by srod »

I think you'd have a problem with that code if you had to call a function whose last parameter(s) had to be zero. Your code would then select the wrong prototype!

Must admit that the code looks like over-kill really. All of that just to call a function? :shock:
I may look like a mule, but I'm not a complete ass.
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Perhaps an idea for the fan of old and sick CALLFUNCTION

Post by Kwai chang caine »

NETMAEST HERO wrote:And this is shorter?
:lol: :lol: I perceive a little bit of irony, in your answer ???? :roll:

The command is shorter...yes yes yes....
Just one line, and she return what i want :D

And no need to understand the PROTOTYPE, just try to understand one time ....and can forget it :mrgreen:

I hope i have persuade my first client :mrgreen:
Because KCC hope to sell BLACK of KCC_CallFunction :lol: :lol:
(Black in french = Numerous, enormous, too much)
ImageThe happiness is a road...
Not a destination
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Perhaps an idea for the fan of old and sick CALLFUNCTION

Post by Kwai chang caine »

Oooohh !!! a second client :shock: :shock:
Kcc need to search a shop and a commercial man now :roll:
MASTER of the sun wrote:I think you'd have a problem with that code if you had to call a function whose last parameter(s) had to be zero
Yes you are right...you are surprising but KCC thinking of this problem.
Before he want to put -1 to default value...but have the same problem if i call function whose last parameter had to be -1 :(
MASTER OF THE KEY wrote:All of that just to call a function
No no no...you have not read all the adventures of little KCC :mrgreen:
Not ONE function.....but 211 functions

And this example have all the type of call..it's the reason why it is so long .... :D
Just one line ....just one line for call..
ImageThe happiness is a road...
Not a destination
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: Perhaps an idea for the fan of old and sick CALLFUNCTION

Post by netmaestro »

Just one line ....just one line for call..
One line for the call sounds fine but when I use it and something doesn't work right I have to look through all that stuff for a bug? I'll stick with prototypes, thanks.
BERESHEIT
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: Perhaps an idea for the fan of old and sick CALLFUNCTION

Post by PB »

> Since several version FRED don't want we use callfunction, and say we must use PROTOTYPE

What is this all about, anyway? I use CallFunction all the time. Is it going to be removed?
Why? Prototype is so much harder to work with for a BASIC language. CallFunction just
makes sense. Is it really going away like KCC implies?
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: Perhaps an idea for the fan of old and sick CALLFUNCTION

Post by netmaestro »

I don't think it's going anywhere, it's just restricted to integer-only parameters and returns now is all. Limits its usefulness somewhat.
BERESHEIT
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Perhaps an idea for the fan of old and sick CALLFUNCTION

Post by Kwai chang caine »

NETMAESTRO wrote:One line for the call sounds fine but when I use it and something doesn't work right I have to look through all that stuff for a bug? I'll stick with prototypes, thanks.
It's a pity...I thought it was a good idea, and I was glad that someone like you are interested in it. :(
Good as they say in France ...." I think, I'll put it back in my pants " :lol:

The use and interest of this code is designed primarily for "backward bulb" like me, because it can manage easilly DLLs, and that's what attracted me, in the beginning of another PB. :roll:
It's sure that for someone like you ... there's no interest .. if it is one of life easier for beginners. :wink:

It's in the phylosophy of departure from PB to make available the more complicated commands of windows.
The power of C without the complexity. 8)
I think PB time after time, is more complicated, becoming increasingly powerful, and approaches little bit by little of C :(
For someone it's a good thing...and for other..it's a good thing too....but it's very very difficult to follow :oops:
PB wrote:What is this all about, anyway? I use CallFunction all the time. Is it going to be removed?
Why? Prototype is so much harder to work with for a BASIC language. CallFunction just
makes sense. Is it really going away like KCC implies?
> Since several version FRED don't want we use callfunction, and say we must use PROTOTYPE

What is this all about, anyway? I use CallFunction all the time. Is it going to be removed?
Why? Prototype is so much harder to work with for a BASIC language. CallFunction just
makes sense. Is it really going away like KCC implies?
Yes FRED say to me several time, of not use Callfunction because it's a deprecated function, this is the last time, but there are others and not found the link :(
http://www.purebasic.fr/english/viewtop ... 92#p329392
Me too i'm sad... :(
NETMAESTRO wrote:I don't think it's going anywhere, it's just restricted to integer-only parameters and returns now is all. Limits its usefulness somewhat.
Please and pity .....can you "throw an eyes" on my code Image
Because i have already say that before, but it's really important for KCC :cry:
He works hard for create this, and want to be sure, that i have not make some serious error for the memory or other.
And especially the modification of array string or numeric, because it's the most difficult :(

I'm forced to:
1/ Send pointer of array
2/ Copy in the DLL the array sending in an array DLL
3/ Do the modification
4/ Sending the pointer of array DLL
5/ Copy the array DLL in Local Array

Please please pleeeeaaaaaaaaaaase !!!...

Image

You have see...for the passing between EXE/DLL, i have do like you say to me, all in memory, with POKE, like the API windows :D

This code is certainly not efficient, normal it's KCC code.....
If someone does want to improve it, because it's surelly too much works for convert Kcc code to normal code :oops:, just tell me whether it is not dangerous, because i have not again all understand at the *Pointer, @String, *address.STRING, *address.INTEGER, etc ...
Because, I will use it later, hundreds of times in my code, this will be the heart of my programs


Thanks in advance at all 8)
ImageThe happiness is a road...
Not a destination
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: Perhaps an idea for the fan of old and sick CALLFUNCTION

Post by PB »

> I think PB time after time, is more complicated, becoming increasingly powerful,
> and approaches little bit by little of C

I must side with KCC on this subject. I just checked the docs for Prototype and
it even starts with: For advanced programmers. :( I then read the description,
which says: "Prototype allows to declare a type which will map a function." What
on earth does that mean? How is this Basic? It scares me as much as it does KCC.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Perhaps an idea for the fan of old and sick CALLFUNCTION

Post by Kwai chang caine »

For advanced programmers
I have say exactely the same thing at fred :D
Apparently, we are three now, to be affraid by the prototype :roll:

FRED must understand that we are not against the progress....no no no :oops:

But When the gods piss on their ground, they forget sometime that some people, live under the clouds :oops:

That sentence mean, it's very difficult, when we have the level of FRED, FREAK, NETMAESTRO, SROD, SPARKIE...etc to imagine, the difficulty that we have for follow.
Obviously all this new fonctions is already using in another langage....and numerous members are happy to see it come....
But, for certains members, the come of PROTOTYPE, REGULAR EXPRESSION, LIST, etc ....are the same surprising that "marylin monroe come a night in our bed" :shock:

Again a time, i don't want that FRED believe, i'm a "nuts breaker" and always have the open mouth, just useful for eat mosquito :oops:
I don't want create a revolution, i love too much FRED his team, and all of you, for do that :?
It's just to me a cry of pain, a call using :oops: :cry:

I really want do understand at the MASTERS, that for certain members, the progress and the programming is very difficult, but it's not because it's difficult, that they not love programming. :oops:

Then the "low level programmers" search a langage, like PB, to play in the big league, with MASTER..., and can do their passion too :oops:

It's very difficult to give at a langage all the power...and stay in the maximum of simplicity :?
I'm sure the creator of the ASM and the C, have the same goal.....but we must say now, that for their era, the ASM and C are a revolution of simplicity against BINARY code 8) ....now ....they are the most difficult langage :lol:
ImageThe happiness is a road...
Not a destination
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: Perhaps an idea for the fan of old and sick CALLFUNCTION

Post by srod »

It's like anything, you just need to expend some time and a little effort.

The first time I saw prototypes I did sit scratching my butt for a while... until I realised that I'd seen them before... VB delegates and the like!

Prototypes are far easier to use, imo, than call function etc. and they are far more readable and flexible as well. Take the advice and ditch CallFunctionFast() and you will not be sorry. Better still, swat up on psuedo-types as well and you will soon wonder how you did without them?

As for advanced programmers only... tish and tash... any monkey could use 'em! :)
I may look like a mule, but I'm not a complete ass.
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Perhaps an idea for the fan of old and sick CALLFUNCTION

Post by Kwai chang caine »

My MASTER wrote:The first time I saw prototypes I did sit scratching my butt for a while
Oooohh it's funny because, me too, i do the same thing :shock:
But not for the same reason... :mrgreen:
It's just because like i'm 24/24 before the PC...i have not the time to take shower :oops:
My teacher wrote:It's like anything, you just need to expend some time and a little effort.
You have right MASTER...
The proof is that Kcc have do a big big effort to understand "PROTOTHING"
Yes yes ... you surelly not believe me, but in the middle of the three page of code of KCC...there are some PROTOTYPE :shock:

Then for comeback to my question.....can you say to me, please, if i have do a serious error in my code ??? :roll:
Because how do you want that KCC is progressing, if he has no teacher to correct his duty ??? :(
ImageThe happiness is a road...
Not a destination
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: Perhaps an idea for the fan of old and sick CALLFUNCTION

Post by srod »

Sorry, but I haven't the time to read through all of your code KCC... I have enough code of my own to sit staring at whilst scratching my butt.
I may look like a mule, but I'm not a complete ass.
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Perhaps an idea for the fan of old and sick CALLFUNCTION

Post by Kwai chang caine »

It's a pity :( , don't worry, it's already cool you answer at all my numerous questions 8)
In fact the code is not really big, because it's always the same code reapeated, with different declaration :roll:

You say, you and NETMAESTRO the code is big for only one function, but i'm nearly sure that, behind PB function, sometime, there are the same length of code in C :wink:

Perhaps i have the chance that MASTER NETMAESTRO or another MASTER member have a little bit more time, just for see, if there are a thing who shock him :roll:
ImageThe happiness is a road...
Not a destination
Post Reply