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 CFSM
{
public:
typedef map<char, CFSM *> MapType;
MapType m_map;
set<char> *m_separators;
CFSM()
{
m_separators = 0;
}
CFSM(long nStrings, char **pszStr, set<char> *separators)
{
m_separators = separators;
AddStrings(nStrings, pszStr);
}
~CFSM()
{
ClearMap();
}
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, 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;
}
}
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.