Procedure for return string of a DLL [Resolved]

Just starting out? Need help? Post your questions and find answers here.
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Procedure for return string of a DLL [Resolved]

Post by Kwai chang caine »

Hello at all

I try to create a procedure for include the string DLL result.
I have create this, she works fine, but she not nice and she's more long :oops:

Have you a better code to remplace mine :

Code: Select all

Procedure.s FonctionString(IdDll, Fonction$, Parametre1.s = "", Type1.s = "", Parametre2.s = "", Type2.s = "", Parametre3.s = "", Type3.s = "", Parametre4.s = "", Type4.s = "", Parametre5.s = "", Type5.s = "") 
  
 zz.s = Space(1000) 
  
 If Not Parametre1 
  
  *zz = CallFunction(IdDll, Fonction$) 
  
 ElseIf Parametre1 
  
  Select Type1 
  
   Case "s", "" 
    *zz = CallFunction(IdDll, Fonction$, Parametre1)  
   Case "l" 
    *zz = CallFunction(IdDll, Fonction$, Val(Parametre1)) 
    
  EndSelect 
  
 ElseIf Parametre2 
  
  Select Type2 
  
   Case "s", "" 
    *zz = CallFunction(IdDll, Fonction$, Parametre2)  
   Case "l" 
    *zz = CallFunction(IdDll, Fonction$, Val(Parametre2)) 
    
  EndSelect 
  
 ElseIf Parametre3 
  
  Select Type3 
  
   Case "s", "" 
    *zz = CallFunction(IdDll, Fonction$, Parametre3)  
   Case "l" 
    *zz = CallFunction(IdDll, Fonction$, Val(Parametre3)) 
    
  EndSelect 
  
 ElseIf Parametre4 
  
  Select Type4 
  
   Case "s", "" 
    *zz = CallFunction(IdDll, Fonction$, Parametre4)  
   Case "l" 
    *zz = CallFunction(IdDll, Fonction$, Val(Parametre4)) 
    
  EndSelect 
  
 ElseIf Parametre5 
  
  Select Type5 
  
   Case "s", "" 
    *zz = CallFunction(IdDll, Fonction$, Parametre5)  
   Case "l" 
    *zz = CallFunction(IdDll, Fonction$, Val(Parametre5)) 
    
  EndSelect 
  
 EndIf 
  
 ProcedureReturn PeekS(*zz) 
  
EndProcedure 
Thanks for your help
Good day
Last edited by Kwai chang caine on Wed Jun 11, 2008 8:35 am, edited 1 time in total.
ImageThe happiness is a road...
Not a destination
User avatar
eddy
Addict
Addict
Posts: 1479
Joined: Mon May 26, 2003 3:07 pm
Location: Nantes

Post by eddy »

Code: Select all

Macro CallFunctionRegex(dllID, Fonction, Param, numericRegexID)
	If MatchRegularExpression(numericRegexID, Param)
		*zz=CallFunction(dllID, Fonction, Val(Param))
	Else
		*zz=CallFunction(dllID, Fonction, Param)
	EndIf
EndMacro

Procedure.s FonctionString(IdDll, Fonction$, Parametre1.s="", Parametre2.s="")
	
	zz.s=Space(1000)
	numericRegexID=CreateRegularExpression(#PB_Any, "^([-+]{0,1}[\d]*)([.]{0,1}[\d]*)$")
	
	If Not Parametre1		
		*zz=CallFunction(IdDll, Fonction$)		
	ElseIf Parametre1
		CallFunctionRegex(IdDll, Fonction$, Parametre1, numericRegexID)
	ElseIf Parametre2
		CallFunctionRegex(IdDll, Fonction$, Parametre2, numericRegexID)
	EndIf
	
	FreeRegularExpression(numericRegexID)
	ProcedureReturn PeekS(*zz)
	
EndProcedure
Imagewin10 x64 5.72 | IDE | PB plugin | Tools | Sprite | JSON | visual tool
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Post by Kwai chang caine »

Thanks EDDY 8)
Obviously, i can't imagine an also great code alone :oops:
I don't believe that is possible to make more short :D

I don't know this functions, i saw they are better code that mine, but i don't believed like this :shock:

I need three days for understand this master clock code :D
I put this jewel on the french forum, with your copyright, obviously :wink:

http://www.purebasic.fr/french/posting. ... ply&t=8189

Thanks a lot
I wish you a good day
ImageThe happiness is a road...
Not a destination
Post Reply