'OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
' SECTION "OOOO" IS A PLACE WHERE
' ASP RESERVED NAMES OF FUNCTIONS, OBJECTS, PROPERTIES, METHODS CAN BE ADDED FOR CONVERTION.
'
' Currently, not all of them added.
.
' There are three methods to add:
' REPLACEMENT(easy), WRAPPING(less easy), and EXPLICIT(more complex):
' REPLACEMENT. Exact match exist between ASP and PHP constructs. Usually, section 'rrr...'
' WRAPPING Writing new wrap-function replacing ASP-function. Usually, section 'www...'
' EXPLICIT means that convertion part is written in schema. Usually, section 'eee...'
' SAME NAME this is a fourth case when no name replacement
' between ASP and PHP required at all.
' Programmer can declare incoming name as a keyword (.k) or as a separator (.s),
' and this should not make difference. Identificator (.id) cannot be used because it is caught above.
' More details are provided in sections.
' Useful Built-in ASP Objects Reference: http://localhost/iishelp/iis/htm/asp/iiapwelc.htm
' PHP : http://www.php.net/manual/en/reserved.variables.php
'eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
' EXPLICIT.
' Functions (which return value) or other terms should be declared in state "we",
' handled in states "above we in schema for .id", and transform initial state "we" into "e".
' Examples: "mid" and "left" functions.
' Or, handler should produce a queue which applies to a state "we" according generic syntax.
' (day --> date conversion)
' Methods and subroutines can happen only in ws state, so this does not matter how programmer
' writes explicit handler "as it results with" completed statement.
' If schema-variables are used, programmer should be sure that they will not be recursively
' used in child-constructs.
' Note: It is important that section 'OOO...' is placed before event ".".s in schema.
' For example, "Response.ContentType" will be caught before event "."
' Examples:
'===============================================================================================================
'----------------------------------------------------------------------------------------------------------------------------
' FUNCTION LEFT
we left.k substr >left
left ( ( >we
left,e , ,0, <left2,we
left2,e ) ) <2,e
'----------------------------------------------------------------------------------------------------------------------------
'----------------------------------------------------------------------------------------------------------------------------
' MID FUNCTION:
we mid.k substr >mid '! see notes in replacers.inc;
mid ( ( >we 'make top of nest = mid,we and print (;
mid,e , , <mid2,we 'wait for the second mid-parameter;
mid2,e , -1, <mid3,we 'SUBSCRIBE FROM THE SECOND MID PARAMETER 1 BECAUSE
'POINTER IN PHP STARTS FROM 0, BUT IN VB FROM 1;
) -1) <2,e 'expression mid(string,start_position) has been
'handled and resulted into state "e";
mid3,e ) ) <2,e '-------"-------
'----------------------------------------------------------------------------------------------------------------------------
'----------------------------------------------------------------------------------------------------------------------------
' Conversion day(date)-->date("d") or day(arg) --> date("d",arg); month, hour, second, ...
'!Edit six lines below for your preferred format:
we day.k "d".=t >d,d1
month.k "m".=t >d,d1
year.k "Y".=t >d,d1
hour.k "H".=t >t,d1
minute.k "i".=t >t,d1
second.k "s".=t >t,d1
d1 ( =d2
d,d2 date.k =d3
t,d2 time.k =d3
d2 now.k =d3
d2 . <2 +date.idf +( +"""$t """.str +, + 'result=date("d",second_argument ...
'! the second_argument must be time stamp of integer type in PHP.
d3 ) <2 +"date(""$t "")".idv
'----------------------------------------------------------------------------------------------------------------------------
'============================================================================================================================
' RESPONSE OBJECT
'----------------------------------------------------------------------------------------------------------------------------
' TO MATCH .id-events, token-pattern must be in low case because Tokenizer submits them in low case.
' When converting RESPONSE OBJECT, all three methods are used. For example:
' response.write --> echo (REPLACEMENT)
' response.buffer --> set_buffer_c_ (WRAPPING)
' ContentType --> ... (EXPLICIT)
'----------------------------------------------------------------------------------------------------------------------------
- response.id >response
response "." =response.
ws,response " "..l < +response!!_c_.idf 'unknown use of object "response";
"\009"..l +" "
. +" " +
response . < +response!!_c_c.idf + 'unknown use of object "response";
'assume that it will be used as a function;
'----------------------------------------------------------------------------------------------------------------------------
' C o l l e c t i o n s
'- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
response. cookies.id < +"err_$ !!_c_".idv 'attribute property is ignored
'in ASP: Cookies(cookie)[(key)|.attribute] = value
'setcookie() should be used
'----------------------------------------------------------------------------------------------------------------------------
' P r o p e r t i e s
'- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
' Properties can be wrapped when they are to be read or returned.
' Properties can behave as variables which must be set. This may need parsing event "=".
'- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
'to be set:
ws,response. buffer.id >Buffer
cachecontrol.id >CacheControl
contenttype.id >ContentType 'Response.ContentType [=ContentType]
expires.id >Expires
expiresabsolute.id >ExpiresAbsolute
status.id >Status 'Response.Status = StatusDescription
'to be read:
response. buffer.id < +ret_buffer!!_c_.idf 'Response.Buffer [=flag] False is default.
cachecontrol.id < +ret_cache_control!!_c_.idf 'CacheControl [=Cache Control Header ]
contenttype.id < +ret_content_type!!_c_.idf
expires.id < +ret_expires!!_c_.idf 'Response.Expires [=number]
expiresabsolute.id < +ret_expires_absolute!!_c_.idf
status.id < +ret_response_status!!_c_.idf
isclientconnected.id < +ret_is_client_connected!!_c_.idf 'Response.IsClientConnected ()
'to be read or set:
response. charset.id < +set_ret_charset!!_c_.idf 'Response.Charset(CharsetName)
pics.id < +set_ret_pics!!_c_.idf 'Response.PICS(PICSLabel)
'----------------------------------------------------------------------------------------------------------------------------
' M e t h o d s
'- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
' Methods are assumed to happen only in ws-state and can be wrapped or replaced with functions.
'- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
response. addheader.id .*a >AddHeader,we 'Response.AddHeader name, value
appendtolong.id < +set_response_append_to_long!!_c_.idf 'Response.AppendToLong string
binarywrite.id < +set_response_binarywrite!!_c_.idf 'Response.BinaryWrite data
clear.id < +set_response_clear!!_c_.idf 'Response.Clear
'token must be .k because declared as end.k in other parts of schema:
end.k < +exit.idf 'Response.End
flush.id < +"!After processing ob_end_flush, buffering will be off.".r :
+ob_end_flush.idf 'Response.Flush
write.id < +echo.idf 'Response.Write variant
redirect.id .*a >Redirect,we 'Response.Redirect URL
'----------------------------------------------------------------------------------------------------------------------------
'----------------------------------------------------------------------------------------------------------------------------
' A u x i l a i r y H a n d l e r s f o r R e s p o n s e O b j e c t
'- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
AppendToLong = <f,we set_append_to_long!!_c_(
. += +
Status = <f,we set_status!!_c_(
. <2 +"Syntax: missed ""=""".r +
Expires = <f,we set_expires!!_c_(
. += +
Buffer = <f,we set_buffer_c_(
. <e ob_end_flush(); +
CacheControl = <f,we cache_control!!_c_(
. += +
'hot fix: put \l here temporarily
'until the cause of sticking to comment will be
'clear:
Redirect,e .t .-a "\lheader(""Location: "" . $a );" <4 +.tfull
AddHeader,e , .-a <AddHeader2,we .*b
AddHeader2,e .t .-b "header($a . "": "" . $b );" <4 +.tfull
ContentType = >we .*a
.t += +"""text/HTML""".str + 'default
ContentType,e .t .-a "header(""Content-type: "". $a );" <4 +.tfull
'- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
' this is a little bit odd because of #-use
ExpiresAbsolute = >wait# 'Response.ExpiresAbsolute [= #[date] [time]#]
. >e "".=a +
ExpiresAbsolute,wait# #..l .*a =#
. .*a =we +
# #..l .-a =e """$a """.=a
" "..l .&
"\009"..l .&
. .& 'collect
ExpiresAbsolute,e .t .-a <4 "set_expires_absolute!!_c_($a );" +.tfull
'----------------------------------------------------------------------------------------------------------------------------
'============================================================================================================================
' ERROR OBJECT
'----------------------------------------------------------------------------------------------------------------------------
- err.id >err
err "." >ob 'err. is met: "ob" denotes this fact.
" "..l <1 +"err_number_c_".idf 'err as default is err.number:
"\009"..l +" " 'x = err is assumed as x =err.number;
. +" "
err,ob clear.id <2 +"err_$ _c_".idf
raise.id <2 +"err_$ _c_".idf
.id <2 +"\$err_$ _c_".idv
'----------------------------------------------------------------------------------------------------------------------------
' on error resume next
ws on.k >on
on error.k =on2
on2 resume.k =on3
on3 next.k =e on_error_resume_next_c_()
'----------------------------------------------------------------------------------------------------------------------------
'eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
'rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
' REPLACEMENT
' For function which maps to PHP-function exactly, programmer needs only replace
' ASP-function-name-event with corresponding PHP-function-name-event,
' and change event-type from .s or .k to .idf
' (.s can be omitted)
' Examples:
'============================================================================================================================
- ucase.k +strtoupper.idf
lcase.k +strtolower.idf
len.k +strlen.idf
asc.k +ord.idf
int.k +(int)floor.idf '!M good may only for non-negative; may need wrapper;
- CStr.k +(string).idf '! converts string casting to PHP style
CInt.k +(int).idf '! cast to int
CLng.k +(int).idf '! cast to int
CDbl.k +(double).idf '! cast to float
CSng.k +(double).idf '!
- vbtab.k +"""\\t""".str
vbcrlf.k +"""\\r\\n""".str
vbcr.k +"""\\r""".str
vblf.k +"""\\n""".str
'rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
'wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
' WRAPPING.
' If ASP-PHP match is not exact, programmer needs write own wrap function,
' add it to php/wrap/replacers.inc file, and put
' wrap function name here as shown below:
' Be sure that new function name does not conflict with existng functions.
' For example, "request_form_c_" is a wrap function to be written in replacers.inc:
- "request.form" +request_form_c_.idf
"Request.QueryString" +request_query_string_c_.idf
"Request.ServerVariables" +request_server_var_c_.idf
'----------------------------------------------------------------------------------------------------------------------------
' this section for request is EXPLICIT: it must be below "request.form".
- "request" >request
we,request ( ${ ={,we 'links to "(,we" chain.
request "." <1 +request!!.idf + 'unknown use
we,{,e ) } <2,e 'chain completed
'----------------------------------------------------------------------------------------------------------------------------
- rnd.k +rand_c_.idf '!M
randomize.k +srand_c_.idf '!M
instr.k +instr_c_.idf '!
instrrev.k +instrrev_c_.idf '!
space.k +space_c_.idf '!
replace.k +replace_c_.idf '!
right.k +right_c_.idf '!
ubound.k +ubound_c_.idf '! notes in replacers.inc
split.k +split_c_.idf '! notes in replacers.inc
'-----------------------------------------------------------------------------------------------------------------------------
' Conversion functions now, date, time.
' -------------------------------------
now.k +time.idf ' This should be exact conversion.
' This is conversion to strings. String may be not a type that expression which
' accepts "date" or "time" expects. If PHP cast works correctly, string type will be converted to
' appropriate format at run-time
- date.k +"date(""m-d-Y"")".idv '! edit this line for you preferred format;
time.k +"date(""H:i:s"")".idv '! edit this line for you preferred format;
' However, conversion to correct PHP variable: time() ADDS date information to VB time variable and
' time information to date VB variable. If programmer still wish to do this, following two instructions
' can be used:
' date.k +time.idf '! ASP date is a subtype Date, in PHP, time is an integer.
' time.k +time.idf '! ASP time is a subtype Date, in PHP, time is an integer.
'wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
'ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss
' SAME NAME
'============================================================================================================================
'chr
'trim
'ltrim
'rtrim
'abs
'ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss
'============================================================================================================================
' TEMPLATE FOR SERVER OBJECT
'----------------------------------------------------------------------------------------------------------------------------
- server.id >server
server "." =server.
'spell-check some cases:
ws,server " "..l < +server!!_c_.idf
"\009"..l +" "
. +" " +
server . < +server!!_c_.idf + 'unknown use of name "server";
'release this state as event "function";
'case to be set by syntax: "ws object.memeber [=x]"
ws,server. scripttimeout.id >scripttimeout
scripttimeout = <f,we set_time_limit(
. <2 +server!!_c_.idf +
'other memebers are not implemented yet: release them as functions:
server. .id < +"ret_server_$ !!_c_".idf
. < +"ret_server_!!_c_".idf +
'============================================================================================================================
NOTE: there may be some other wrappers, replacements, explicits in the schema: for example: const.k.
'OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO