In brief and as a reminder, I need a way to quickly assign values to variables 
received from a web page. The problem I have is that if a field submitted on a 
web page does not exist it produces a  runtime error messages in a compiled 
data base indicating a bad usage of a pointer. The process stops until continue 
or abort is selected. 

I want a way to just ignore any instances where the variable does not exist in 
the data base.  Lee's suggestion of putting my 25,000 variables in an object 
and using OB Is Defined looked like a fast easy solution. Unfortunately I was 
sloppy over the last 25 years it turns out and I have not consistently made use 
of case convention in my variable names. Since OB Is Defined is case sensitive 
I cannot use it unless I spend days cleaning up my code. I will put that on the 
list for the future, but, in the meantime, does anyone have any other quick 
solutions? 

Keisuke made a reference to using Not(Nil( $p))) and Type($p->) following Get 
pointer. I played with that but can't quite see how that would work. In essence 
I would just like to bypass or ignore any situations where the 
arr_Web_Field_Name is not actually a defined variable name so I don't get the 
runtime error messages related to bad usage of a pointer which in turn halts 
the process until I click the continue button.  

Any suggestions? Hopefully I'm just missing something obvious and simple here.

        WEB GET VARIABLES(arr_Web_Field_Name;arr_Web_Field_Value)
        For ($i;1;Size of array(arr_Web_Field_Name))
                $p:=Get pointer(arr_Web_Field_Name{$i})
                $p->:=arr_Web_Field_Value{$i}
        End for


Thanks again,
Mike McCall





ORIGINAL POST FROM NOVEMBER 9, 2016: 

Thanks in advance for any assistance,

This is probably something I should know and clearly something I could do 
differently but for now I'm hoping for an easy solution.

I believe 4D is moving away from the Automatic Variable Assignment option when 
using a browser to access a 4D enabled Web server. As they do that I believe 
the replacement approach is to use Web Get Variables. Because we have a silly 
number of variables (i.e., 20,000) which could be called from any given web 
page we'd like use something similar to the code below to assign the values 
received using Web Get Variables to their corresponding and existing variables 
using pointers. That would allow us to move away from the Automatic variable 
assignment without a major rewrite to our code.

In an uncompiled application the code works fine. 

In a compiled application it works fine as well unless someone were to 
maliciously or somehow inadvertently submit a web page with a field name which 
was not defined in our application. In brief if they modified an html form to 
submit to our application and added a non-existent field, then a -20010 error - 
Bad usage of pointer or pointer to an unknown variable message would be 
generated and the connection would hang until we clicked OK on the message on 
the server.

Is there any way we could avoid this from happening? We were hopeful that using 
"undefined" would help but that doesn't work in a compiled database. 

Aside from a major rewrite of how we handle the fields from a form statement 
does anyone know how we could just ignore unknown field names o handle them 
without the error message being generated in a compiled database?

Code used during On Web Authentication

C_TEXT($1;$2;$3;$4;$5;$6)
C_TEXT(vtSystem_Password;vtSystem_User;vtSystem_Server_IP;vtSystem_Client_IP;vtSystem_Hdr;vtSystem_URL)
$0:=True
vtSystem_URL:=$1
vtSystem_Hdr:=$2
vtSystem_Client_IP:=$3
vtSystem_Server_IP:=$4
vtSystem_User:=$5
vtSystem_Password:=$6

C_TEXT(Dummy;Web_TM_Accessed_By)  //variables which are not typed explicitly or 
by reference during compilation. They could be deleted
$vt_GetOrPost:=""
$vt_GetOrPost:=Substring(vtSystem_Hdr;1;4)
If ($vt_GetOrPost="Post")
        ARRAY TEXT(arr_Web_Field_Name;0)
        ARRAY TEXT(arr_Web_Field_Value;0)
        WEB GET VARIABLES(arr_Web_Field_Name;arr_Web_Field_Value)

        C_BOOLEAN($test)
          //  $start:=Milliseconds

        For ($i;1;Size of array(arr_Web_Field_Name))
                  //ALERT(string($i)+" - "+arr_Web_Field_Name{$i})
                Case of 
                        : (arr_Web_Field_Name{$i}="vbFileName")
                                
C_TEXT($vPartName;$vPartMimeType;$vPartFileName;$vDestinationFolder)
                                C_BLOB($vPartContentBlob)
                                C_BLOB(vbFileName)
                                C_LONGINT($i)
                                  //$vDestinationFolder:=Get 4D folder(HTML 
Root folder)+"photos"+Folder separator
                                For ($j;1;WEB Get body part count)  //for each 
part
                                        WEB GET BODY 
PART($i;$vPartContentBlob;$vPartName;$vPartMimeType;$vPartFileName)
                                        If ($vPartFileName#"")
                                                vbFileName:=$vPartContentBlob
                                                
vt_OrignalFileName:=$vPartFileName
                                                vt_cttype:=$vPartMimeType
                                                  //BLOB TO 
DOCUMENT($vDestinationFolder+$vPartFileName;$vPartContentBlob)
                                        End if 
                                End for 
                        Else 

                                  //  $test:=OB Is 
defined(<>Obj_Defined_Text_Variables;arr_Web_Field_Name{$i})
                                $test:=True
                                If ($test)
                                        $p:=Get pointer(arr_Web_Field_Name{$i})
                                        $p->:=arr_Web_Field_Value{$i}
                                Else 
                                          // Alert("The following field was not 
found: "+arr_Web_Field_Name{$i})
                                End if 
                End case 
        End for 

          // ALERT("01 - "+String(Milliseconds-$start))  // I get 0


End if 





Mike McCall 
Facilitate.com 
**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[email protected]
**********************************************************************

Reply via email to