Click to See Complete Forum and Search --> : Enhanced mode test PHP + #


Angelus
November 1st, 2002, 05:47 AM
Ivor B Gun
Don Kiddick
Seymor Butts
Amanda Hugnkiss
I P Freely
Mike Hunt

Hrm so thats the colours then, right now for code:

' This function makes a string of a specified length containing the specified characters. This function avoides the need for loops
Public Function MakeStringOf(ByVal p_strChar As String, ByVal p_lngCount As Long) As String
Dim strReturn As String

' Check that the character is not blank and the length is greater than zero
If (p_strChar = "") Or (p_lngCount <= 0) Then
strReturn = ""
Else
' Make a string of spaces of the required length
strReturn = Space(p_lngCount)
If (p_strChar <> " ") Then
' Replace the spaces in the string with the specified character
strReturn = Replace(strReturn, " ", p_strChar)
End If
End If

MakeStringOf = strReturn
End Function



That was a lot of effort to do the coloring.' Make a string of spaces of the required length

Angelus
November 1st, 2002, 05:54 AM
What does # do? Well lets see:


' This function makes a string of a specified number of a specified character e.g.
' a string of five dots "....." etc.
Public Function MakeStringOf(ByVal p_strChar As String, ByVal p_lngCount As Long) As String
Dim strReturn As String

' Check that the input character is not a blank string
' and that the length is not less than 0
If (p_strChar = "") Or (p_lngCount <= 0) Then
strReturn = ""
Else
' Make a string of spaces of the specified size
strReturn = Space(p_lngCount)
If (p_strChar <> " ") Then
' Replace all of the spaces with the specified character.
strReturn = Replace(strReturn, " ", p_strChar)
End If
End If

' Return the new string.
MakeStringOf = strReturn
End Function


What does PHP do? Lets see:


' This function makes a string of a specified number of a specified character e.g.
' a string of five dots "....." etc.
Public Function MakeStringOf(ByVal p_strChar As String, ByVal p_lngCount As Long) As String
Dim strReturn As String

' Check that the input character is not a blank string
' and that the length is not less than 0
If (p_strChar = "") Or (p_lngCount <= 0) Then
strReturn = ""
Else
' Make a string of spaces of the specified size
strReturn = Space(p_lngCount)
If (p_strChar <> " ") Then
' Replace all of the spaces with the specified character.
strReturn = Replace(strReturn, " ", p_strChar)
End If
End If

' Return the new string.
MakeStringOf = strReturn
End Function

Angelus
November 1st, 2002, 05:56 AM
What does ENHANCED MODE do?


' This function makes a string of a specified number of a specified character e.g.
' a string of five dots "....." etc.
Public Function MakeStringOf(ByVal p_strChar As String, ByVal p_lngCount As Long) As String
Dim strReturn As String

' Check that the input character is not a blank string
' and that the length is not less than 0
If (p_strChar = "") Or (p_lngCount <= 0) Then
strReturn = ""
Else
' Make a string of spaces of the specified size
strReturn = Space(p_lngCount)
If (p_strChar <> " ") Then
' Replace all of the spaces with the specified character.
strReturn = Replace(strReturn, " ", p_strChar)
End If
End If

' Return the new string.
MakeStringOf = strReturn
End Function



Can anyone tell me how to get this to be VB colours rather than red comments?

Yves M
November 1st, 2002, 05:59 AM
The only thing that works are php colors, sorry

Yves M
November 1st, 2002, 07:47 AM
inside a code segment...

' This function makes a string of a specified length containing the specified characters.
This function avoides the need for loops
Public Function MakeStringOf(ByVal p_strChar As String, ByVal p_lngCount As Long) As String
Dim strReturn As String

' Check that the character is not blank and the length is greater than zero
If (p_strChar = "") Or (p_lngCount <= 0) Then
strReturn = ""
Else
' Make a string of spaces of the required length
strReturn = Space(p_lngCount)
If (p_strChar <> " ") Then
' Replace the spaces in the string with the specified character
strReturn = Replace(strReturn, " ", p_strChar)
End If
End If

MakeStringOf = strReturn
End Function

Yves M
November 1st, 2002, 12:44 PM
C++ test...

class&nbsp;CFSM&nbsp;
{
public:
&nbsp;&nbsp;typedef&nbsp;map<char,&nbsp;CFSM&nbsp;*>&nbsp;MapType;

&nbsp;&nbsp;MapType&nbsp;&nbsp;&nbsp;&nbsp;m_map;
&nbsp;&nbsp;set<char>&nbsp;&nbsp;&nbsp;*m_separators;

&nbsp;&nbsp;CFSM()
&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;m_separators&nbsp;=&nbsp;0;
&nbsp;&nbsp;}

&nbsp;&nbsp;CFSM(long&nbsp;nStrings,&nbsp;char&nbsp;**pszStr,&nbsp;set<char>&nbsp;*separators)
&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;m_separators&nbsp;=&nbsp;separators;
&nbsp;&nbsp;&nbsp;&nbsp;AddStrings(nStrings,&nbsp;pszStr);
&nbsp;&nbsp;}

&nbsp;&nbsp;~CFSM()
&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;ClearMap();
&nbsp;&nbsp;}

private:
&nbsp;&nbsp;void&nbsp;ClearMap()
&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;MapType::iterator&nbsp;it;

&nbsp;&nbsp;&nbsp;&nbsp;it&nbsp;=&nbsp;m_map.begin();
&nbsp;&nbsp;&nbsp;&nbsp;while&nbsp;(it&nbsp;!=&nbsp;m_map.end())&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;delete&nbsp;(*it).second;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m_map.erase(it);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;it&nbsp;=&nbsp;m_map.begin();
&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;}
public:

&nbsp;&nbsp;void&nbsp;AddStrings(long&nbsp;nStrings,&nbsp;char&nbsp;**pszStr)
&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;int&nbsp;i,&nbsp;j,&nbsp;k;
&nbsp;&nbsp;&nbsp;&nbsp;char&nbsp;**pszRecStr;
&nbsp;&nbsp;&nbsp;&nbsp;CFSM&nbsp;*recFSM;
&nbsp;&nbsp;&nbsp;&nbsp;char&nbsp;curr;

&nbsp;&nbsp;&nbsp;&nbsp;i&nbsp;=&nbsp;0;
&nbsp;&nbsp;&nbsp;&nbsp;while&nbsp;(i&nbsp;<&nbsp;nStrings)&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;curr&nbsp;=&nbsp;pszStr[i][0];
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(curr&nbsp;!=&nbsp;0)&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&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nbsp;&nbsp;&nbsp;}&nbsp;else&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(m_map.find(curr)&nbsp;==&nbsp;m_map.end())&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m_map[curr]&nbsp;=&nbsp;new&nbsp;CFSM;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m_map[curr]->m_separators&nbsp;=&nbsp;m_separators;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;i++;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;}

&nbsp;&nbsp;void&nbsp;Traverse(int&nbsp;indent&nbsp;=&nbsp;0)
&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;MapType::iterator&nbsp;it;
&nbsp;&nbsp;&nbsp;&nbsp;int&nbsp;i;
&nbsp;&nbsp;&nbsp;&nbsp;bool&nbsp;bFirst&nbsp;=&nbsp;true;

&nbsp;&nbsp;&nbsp;&nbsp;it&nbsp;=&nbsp;m_map.begin();
&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(it&nbsp;==&nbsp;m_map.end())&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf("\n");
&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;else&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;while&nbsp;(it&nbsp;!=&nbsp;m_map.end())&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(!bFirst)&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for&nbsp;(i&nbsp;=&nbsp;0;&nbsp;i&nbsp;<&nbsp;indent;&nbsp;i++)&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf(" ");
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf("%c",&nbsp;(*it).first);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(*it).second->Traverse(indent&nbsp;+&nbsp;1);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;bFirst&nbsp;=&nbsp;false;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;it++;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;}

&nbsp;&nbsp;long&nbsp;IsInFSM(const&nbsp;char&nbsp;*sz)
&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;MapType::iterator&nbsp;it;

&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(m_separators->find(sz[0])&nbsp;!=&nbsp;m_separators->end())&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;((m_map.size()&nbsp;==&nbsp;1)&nbsp;&&&nbsp;(m_map.find(0)&nbsp;!=&nbsp;m_map.end()))&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;0;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;else&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;-1;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;else&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;((it&nbsp;=&nbsp;m_map.find(sz[0]))&nbsp;!=&nbsp;m_map.end())&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;long&nbsp;l;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;l&nbsp;=&nbsp;(*it).second->IsInFSM(sz&nbsp;+&nbsp;1);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(l&nbsp;==&nbsp;-1)&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;-1;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;else&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;l&nbsp;+&nbsp;1;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;else&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;-1;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;}

};

Yves M
November 1st, 2002, 01:08 PM
inside a code

class CFSM
{
public:
typedef map<char, CFSM *> MapType;

set<char> *m_separators;

CFSM(long nStrings, char **pszStr, set<char> *separators)
{
m_separators = separators;
AddStrings(nStrings, pszStr);
}

private:
void ClearMap()
{
MapType::iterator it;

it = m_map.begin();
while (it != m_map.end()) {
delete (*it).second;
m_map.erase(it);
it = m_map.begin();
}
}
public:

void AddStrings(long nStrings, char **pszStr)
{
int i, j, k;
char **pszRecStr;
CFSM *recFSM;
char curr;

i = 0;
while (i < nStrings) {
curr = pszStr[i][0];
if (curr != 0) {
j = i + 1;
while ((j < nStrings) && (pszStr[j][0] == curr)) {
j++;
}
pszRecStr = (char **) malloc((j - i) * sizeof(char *));
for (k = i; k < j; k++) {
pszRecStr[k - i] = pszStr[k] + 1;
}
recFSM = new CFSM(j - i, pszRecStr, m_separators);
m_map[curr] = recFSM;
free(pszRecStr);
i = j;
} else {
if (m_map.find(curr) == m_map.end()) {
m_map[curr] = new CFSM;
m_map[curr]->m_separators = m_separators;
}
i++;
}
}
}

void Traverse(int indent = 0)
{
MapType::iterator it;
int i;
bool bFirst = true;

it = m_map.begin();
if (it == m_map.end()) {
printf("\n");
} else {
while (it != m_map.end()) {
if (!bFirst) {
for (i = 0; i < indent; i++)
printf(" ");
}
printf("%c", (*it).first);
(*it).second->Traverse(indent + 1);
bFirst = false;
it++;
}
}
}

long IsInFSM(const char *sz)
{
MapType::iterator it;

if (m_separators->find(sz[0]) != m_separators->end()) {
if ((m_map.size() == 1) && (m_map.find(0) != m_map.end())) {
return 0;
} else {
return -1;
}
} else {
if ((it = m_map.find(sz[0])) != m_map.end()) {
long l;
l = (*it).second->IsInFSM(sz + 1);
if (l == -1) {
return -1;
} else {
return l + 1;
}
} else {
return -1;
}
}
}

};

Yves M
November 1st, 2002, 09:30 PM
char *GetClipData()
{
char *szRes = NULL;

if (OpenClipboard(hWnd)) {
HANDLE h;

h = GetClipboardData(CF_TEXT);
if (h) {
char *szTmp;

szTmp = (char *) GlobalLock(h);
szRes = new char[strlen(szTmp) + 1];
strcpy(szRes, szTmp);
GlobalUnlock(h);
}
CloseClipboard();
}
return szRes;
}

Yves M
November 2nd, 2002, 10:15 AM
Great, seems to work now :)

Yves M
November 2nd, 2002, 07:56 PM
void f(float x, char *s)
// checks something
{
if (x > 0) {
printf("%s\n",s);
} else if (x == 0) {
printf("string's \"single [COLOR=blue]blue[/COLOR]quotes");
} else if (x == -1) {
/* This is not
valid anymore */ x = 1;
}
}